看上去,好像抄书的!!!!!
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\gdi32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\gdi32.lib
return MACRO arg
mov eax, arg
ret
ENDM
m2m MACRO m1, m2
push m2
pop m1
ENDM
WinMain PROTO :DWORD, :DWORD, :DWORD, :DWORD
WndProc PROTO :DWORD, :DWORD, :DWORD, :DWORD
.data
szClsName db "mycls", 0
szWndName db "My window", 0
szFormat db "= %0X =", 0
.data?
hInstance HINSTANCE ?
.code
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke WinMain, hInstance, NULL, NULL, SW_SHOWDEFAULT
invoke ExitProcess, eax
WinMain proc hInst:DWORD, hPrevInst:DWORD, CmdLine:DWORD, CmdShow:DWORD
LOCAL wc :WNDCLASSEX
LOCAL hWnd :HWND
LOCAL msg :MSG
mov wc.cbSize, SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW OR CS_VREDRAW
mov wc.cbWndExtra, 0
mov wc.cbClsExtra, 0
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.lpszMenuName, NULL
mov wc.lpszClassName, OFFSET szClsName
invoke LoadIcon, hInst, IDI_APPLICATION
mov wc.hIcon, eax
mov wc.hIconSm, eax
invoke LoadCursor, NULL, IDC_ARROW
mov wc.hCursor, eax
m2m wc.hInstance, hInst
mov wc.hbrBackground, COLOR_WINDOW
invoke RegisterClassEx, ADDR wc
invoke CreateWindowEx, WS_EX_OVERLAPPEDWINDOW,
ADDR szClsName,
ADDR szWndName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0,
CW_USEDEFAULT, 0,
NULL, NULL, hInst, NULL
mov hWnd, eax
invoke ShowWindow, hWnd, CmdShow
invoke UpdateWindow, hWnd
StartLoop:
invoke GetMessage, ADDR msg, NULL, 0, 0
cmp eax, 0
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
ExitLoop:
mov eax, msg.wParam
ret
WinMain endp
WndProc proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
LOCAL hDC :HDC
LOCAL ps :PAINTSTRUCT
LOCAL szBuf[128]:BYTE
.if uMsg == WM_DESTROY
invoke PostQuitMessage, 0
.elseif uMsg == WM_PAINT
invoke wsprintf, ADDR szBuf, ADDR szFormat, 0ffffh
invoke BeginPaint, hWnd, ADDR ps
mov hDC, eax
invoke lstrlen, ADDR szBuf
invoke TextOut, hDC, 10, 10, ADDR szBuf, eax
invoke EndPaint, hWnd, ADDR ps
.elseif uMsg == WM_CREATE
ret
.endif
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
WndProc endp
end start