.386
.model flat,stdcall
option casemap:none
include sysInfomy.inc
.code
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke GetCommandLine
invoke InitCommonControls
mov CommandLine,eax
invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL @Client:RECT
LOCAL @Qu:POINT
LOCAL @Buffer[256]:byte
mov wc.cbSize,sizeof WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc,offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,DLGWINDOWEXTRA
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName,IDM_MENU
mov wc.lpszClassName,offset ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx,addr wc
invoke CreateDialogParam,hInstance,IDD_DIALOG,NULL,addr WndProc,NULL
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
invoke GetClientRect,hWnd,addr @Client ;将光标限制在客户区
mov eax,@Client.left
push eax
pop @Qu.x
mov eax,@Client.top
push eax
pop @Qu.y
invoke ClientToScreen,hWnd,addr @Qu
invoke OffsetRect,addr @Client,@Qu.x,@Qu.y
invoke ClipCursor,addr @Client
invoke SetWindowPos,hWnd,HWND_TOP,0,0,0,0,SWP_NOSIZE or SWP_NOMOVE
.while TRUE
invoke GetMessage,addr msg,NULL,0,0
.BREAK .if !eax
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endw
mov eax,msg.wParam
ret
WinMain endp
WndProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL @Buffer[256]:byte
LOCAL @VersionInfo:OSVERSIONINFO
LOCAL @String[256]:byte
LOCAL @nSize:dWord
LOCAL @MemoInfo:MEMORYSTATUS
LOCAL @Pt:POINT
LOCAL @Ptt:POINT
LOCAL @hWnd:HWND
mov eax,uMsg
.if eax==WM_INITDIALOG
push hWin
pop hWnd
invoke RtlZeroMemory,addr @VersionInfo,sizeof @VersionInfo ;初始化结构变量
mov @VersionInfo.dwOSVersionInfoSize,sizeof @VersionInfo
invoke GetVersionEx,addr @VersionInfo ;得到版本信息
.if @VersionInfo.dwPlatformId==1 ;判别操作系统
invoke SetDlgItemText,hWnd,IDC_Version,addr lpVersion1
.elseif @VersionInfo.dwPlatformId==2
invoke SetDlgItemText,hWnd,IDC_Version,addr lpVersion2
.endif
mov eax,@VersionInfo.dwMajorVersion;得到主版本号
invoke wsprintf,addr @Buffer,addr lpMajorVersion,eax
invoke SetDlgItemText,hWnd,IDC_MajorVersion,addr @Buffer
mov eax,@VersionInfo.dwMinorVersion ;得到次版本号
invoke wsprintf,addr @Buffer,addr lpMinorVersion,eax
invoke SetDlgItemText,hWnd,IDC_MinorVersion,addr @Buffer
mov eax,@VersionInfo.dwBuildNumber ;得到内部版本号
invoke wsprintf,addr @Buffer,addr lpBuildNumber,eax
invoke SetDlgItemText,hWnd,IDC_BuildNumber,addr @Buffer
invoke GetWindowsDirectory,addr @String,sizeof @String ;得到操作系统目录
invoke wsprintf,addr @Buffer,addr lpWinDirectory,addr @String
invoke SetDlgItemText,hWnd,IDC_WinDirectory,addr @Buffer
invoke GetSystemDirectory,addr @String,sizeof @String ;得到系统文件目录
invoke wsprintf,addr @Buffer,addr lpSysDirectory,addr @String
invoke SetDlgItemText,hWnd,IDC_SysDirectory,addr @Buffer
mov @nSize,sizeof @String
invoke GetComputerName,addr @String,addr @nSize ;得到计算机名
invoke wsprintf,addr @Buffer,addr lpComputerName,addr @String
invoke SetDlgItemText,hWnd,IDC_ComputerName,addr @Buffer
mov @nSize,sizeof @String
invoke GetUserName,addr @String,addr @nSize ;得到用户名
invoke wsprintf,addr @Buffer,addr lpUserName,addr @String
invoke SetDlgItemText,hWnd,IDC_UserName,addr @Buffer
invoke RtlZeroMemory,addr @MemoInfo,sizeof @MemoInfo;初始化结构体
mov @MemoInfo.dwLength,sizeof @MemoInfo
invoke GlobalMemoryStatus,addr @MemoInfo ;得到结构体信息
mov eax,@MemoInfo.dwTotalPhys;进行信息处理
mov ecx,1024
div ecx
div ecx
invoke wsprintf,addr @Buffer,addr lpMemTotalPhys,eax
invoke SetDlgItemText,hWnd,IDC_MemTotalPhys,addr @Buffer
;invoke SetWindowPos,hWnd,HWND_TOP,0,0,0,0,SWP_NOSIZE or SWP_NOMOVE
;invoke SetTimer,hWnd,hTimer1,2000,NULL;申请一个计数器
.elseif eax==WM_COMMAND
mov eax,wParam
and eax,0FFFFh
.if eax==IDM_FILE_EXIT
invoke SendMessage,hWin,WM_CLOSE,0,0
.elseif eax==IDC_EXIT
invoke SendMessage,hWin,WM_CLOSE,0,0
.elseif eax==IDC_SHOW
invoke FindWindow,addr lpClassName,NULL
invoke ShowWindow,eax,SW_SHOW
.elseif eax==IDC_HIDE
invoke FindWindow,addr lpClassName,NULL
invoke ShowWindow,eax,SW_HIDE
.elseif eax==IDM_HELP_ABOUT
invoke ShellAbout,hWin,addr AppName,addr AboutMsg,NULL
.endif
; .elseif eax==WM_SIZE
;.elseif eax==WM_TIMER ;光标每两秒钟隐藏一次,且持续1秒
; mov eax,wParam
; and eax,0FFFFh
; .if eax==hTimer1
; invoke ShowCursor,FALSE
; invoke KillTimer,hWnd,hTimer1
; invoke SetTimer,hWnd,hTimer2,2000,NULL
; .elseif eax==hTimer2
; invoke ShowCursor,TRUE
; invoke KillTimer,hWnd,hTimer2
; invoke SetTimer,hWnd,hTimer1,1000,NULL
; .endif
.elseif eax==WM_MOUSEMOVE
invoke GetCursorPos,addr @Pt ;获得光标的位置并且显示
invoke wsprintf,addr @Buffer,addr lpCurPosition,@Pt.x,@Pt.y
invoke SetDlgItemText,hWnd,IDC_CurPosition,addr @Buffer
.elseif eax==WM_LBUTTONDOWN ;鼠标在客户区左键单击后的消息处理过程
invoke GetCursorPos,addr @Ptt
.if @Ptt.x>400 && @Ptt.x<420 && @Ptt.y>300 && @Ptt.y<320 ;光标的坐标为 x>400且x<420 y>300 且y<320时处理下列消息
invoke MessageBox,hWnd,addr lpMessage,addr AppName,MB_OK
invoke MessageBeep,MB_ICONASTERISK
.elseif @Ptt.x>500 && @Ptt.x<520 && @Ptt.y>400 && @Ptt.y<420
invoke MessageBox,hWnd,addr lpMessage,addr AppName,MB_OK
invoke MessageBeep,MB_ICONASTERISK
.else
invoke MessageBox,hWnd,addr lpMessageNone,addr AppName,MB_OK
.endif
.elseif eax==WM_CLOSE
invoke DestroyWindow,hWin
.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
end start
以上代码虽然有点乱,但希望能给初学者带来帮助!!!附件是源程序!!!用RADASM编辑.
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
上传的附件: