- Assembly code
.386 .model flat, stdcall option casemap:noneinclude windows.incinclude user32.incincludelib user32.libinclude kernel32.incincludelib kernel32.libinclude gdi32.incincludelib gdi32.lib;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; 数据段;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> .constszClassName db 'MyClass', 0szWindowName db 'Window', 0szHello db 'Hello Windows!', 0;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; 代码段;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> .code;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; 窗体过程函数;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>_ProcWinMain proc _hWnd, _uMsg, _wParam, _lParam local @stPs:PAINTSTRUCT local @stRect:RECT local @hDc mov eax, _uMsg .if eax == WM_PAINT invoke BeginPaint, \ _hWnd, \ addr @stPs mov @hDc, eax invoke GetClientRect, \ _hWnd, \ addr @stRect invoke DrawText, \ @hDc, \ offset szHello, \ -1, \ addr @stRect, \ DT_CENTER or DT_SINGLELINE or DT_VCENTER invoke EndPaint, _hWnd, addr @stPs .elseif eax == WM_DESTROY invoke PostQuitMessage, \ 0 .else invoke DefWindowProc, \ _hWnd, \ _uMsg, \ _wParam, \ _lParam ret .endif xor eax, eax ret_ProcWinMain endp;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; 主函数;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>_WinMain proc local @hInstance local @stWndClass:WNDCLASSEX local @hWnd local @stMsg:MSG; 得到实例句柄 invoke GetModuleHandle, \ NULL mov @hInstance, eax; 初始化窗口类 mov @stWndClass.cbSize, sizeof WNDCLASSEX mov @stWndClass.style, CS_HREDRAW or CS_VREDRAW mov @stWndClass.lpfnWndProc, _ProcWinMain mov @stWndClass.cbClsExtra, 0 mov @stWndClass.cbWndExtra, 0 push @hInstance pop @stWndClass.hInstance invoke LoadIcon, \ NULL, \ IDI_WINLOGO mov @stWndClass.hIcon, eax invoke LoadCursor, \ NULL, \ IDC_ARROW mov @stWndClass.hCursor, eax invoke GetStockObject, \ WHITE_BRUSH mov @stWndClass.hbrBackground, eax mov @stWndClass.lpszMenuName, NULL mov @stWndClass.lpszClassName, offset szClassName mov @stWndClass.hIconSm, NULL invoke RegisterClassEx, \ addr @stWndClass invoke CreateWindowEx, \ WS_EX_OVERLAPPEDWINDOW, \ offset szClassName, \ offset szWindowName, \ WS_OVERLAPPEDWINDOW, \ 0, \ 0, \ 800, \ 600, \ NULL, \ NULL, \ @hInstance, \ NULL invoke ShowWindow, \ @hWnd, \ SW_SHOWNORMAL invoke UpdateWindow, \ @hWnd .while TRUE invoke GetMessage, \ addr @stMsg, \ @hWnd, \ 0, \ 0, .break .if eax == FALSE invoke TranslateMessage, \ addr @stMsg invoke DispatchMessage, \ addr @stMsg .endw xor eax, eax ret_WinMain endp;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; 程序入口;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>start: invoke _WinMain invoke ExitProcess, \ 0 end start