函数调用参数问题
.386.model flat, stdcall
option casemap:none
;==========================================================
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
include gdi32.inc
includelib gdi32.lib
;==========================================================
.data?
hInstance dd ?
g_hWnd dd ?
BALL struct
ball_x dw ?
ball_y dw ?
ball_cx dw ?
ball_cy dw ?
BALL ends
ball BALL <>
.const
szClassName db 'DrawBall', 0
szWindowTitle db 'DrawBall-Demo', 0
szRegClassErr db 'RegisterClassEx Error', 0
szCreateWndErr db 'CreateWindowEx Error', 0
szCaptionErr db 'Error!', 0
;==========================================================
.code
_WndProc proc uses ebx edi esi hWnd, wMsg, wParam, lParam
LOCAL @hDc
LOCAL @stPaint:PAINTSTRUCT
mov eax, wMsg
.if eax == WM_PAINT
invoke BeginPaint, hWnd, addr @stPaint
mov @hDc, eax
push 50
push 50
push 10
push 10
push @hDc
call Ellipse
;invoke Ellipse, @hDc, 10, 10, 50, 50
invoke EndPaint, hWnd, addr @stPaint
.elseif eax == WM_CREATE
mov ball.ball_x, 10
mov ball.ball_y, 10
mov ball.ball_cx, 50
mov ball.ball_cy, 50
.elseif eax == WM_CLOSE
invoke PostQuitMessage, 0
invoke DestroyWindow, hWnd
.else
invoke DefWindowProc, hWnd, wMsg, wParam, lParam
ret
.endif
mov eax, 0
ret
_WndProc endp
_WinMain proc
LOCAL @stWc:WNDCLASSEX
LOCAL @stMsg:MSG
invoke RtlZeroMemory, addr @stWc, sizeof WNDCLASSEX
mov @stWc.cbSize, sizeof WNDCLASSEX
mov @stWc.style, CS_HREDRAW or CS_VREDRAW
mov @stWc.lpfnWndProc, _WndProc
push hInstance
pop @stWc.hInstance
invoke LoadIcon, hInstance, IDI_APPLICATION
mov @stWc.hIcon, eax
mov @stWc.hIconSm, eax
invoke LoadCursor, hInstance, IDC_ARROW
mov @stWc.hCursor, eax
invoke GetStockObject, BLACK_BRUSH
mov @stWc.hbrBackground, eax
mov @stWc.lpszClassName, offset szClassName
invoke RegisterClassEx, addr @stWc
.if eax == 0
invoke MessageBox, NULL, offset szRegClassErr, offset szCaptionErr, MB_OK or MB_ICONINFORMATION
ret
.endif
invoke CreateWindowEx, NULL, offset szClassName, offset szWindowTitle, WS_OVERLAPPEDWINDOW, 100, 100, 600, 400, NULL, NULL, hInstance, NULL
mov g_hWnd, eax
.if eax == NULL
invoke MessageBox, NULL, offset szCreateWndErr, offset szCaptionErr, MB_OK or MB_ICONINFORMATION
ret
.endif
invoke ShowWindow, g_hWnd, SW_SHOW
invoke UpdateWindow, g_hWnd
.while TRUE
invoke GetMessage, addr @stMsg, NULL, NULL, NULL
.break .if eax == 0
invoke TranslateMessage, addr @stMsg
invoke DispatchMessage, addr @stMsg
.endw
ret
_WinMain endp
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke _WinMain
invoke ExitProcess, NULL
end start