21,453
社区成员
发帖
与我相关
我的任务
分享
.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 ?
hWinMain dd ?
.data
a db 1,2,3
@szBuffer db 1024 dup(0)
;szTextLen dd $-szText
.const
szClassName db 'text',0
szFormat db '%d %d %d',0
szString db '%s\n',0
.code
_ProcWinMain proc uses ebx edi esi hWnd,uMsg,wParam,lParam
local @stPs:PAINTSTRUCT
local @hDc
local @stRect:RECT
;local @szBuffer[1024]:byte
mov eax,uMsg
.if eax ==WM_PAINT
invoke wsprintf,addr @szBuffer,addr szFormat,a,a[1],a[2]
invoke BeginPaint,hWnd,addr @stPs
mov @hDc,eax
invoke GetClientRect,hWnd,addr @stRect
invoke DrawText,@hDc,addr @szBuffer,-1,addr @stRect,\
DT_SINGLELINE OR DT_VCENTER
invoke EndPaint,hWnd,addr @stPs
.elseif eax ==WM_CLOSE
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
_ProcWinMain endp
_WinMain proc
local @stWndClass:WNDCLASSEX
local @stMsg:MSG
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke RtlZeroMemory,addr @stWndClass,sizeof @stWndClass
push hInstance
pop @stWndClass.hInstance
mov @stWndClass.cbSize,sizeof WNDCLASSEX
mov @stWndClass.style,CS_HREDRAW or CS_VREDRAW
mov @stWndClass.lpfnWndProc,offset _ProcWinMain
mov @stWndClass.hbrBackground,COLOR_WINDOW + 1
mov @stWndClass.lpszClassName,offset szClassName
invoke RegisterClassEx,addr @stWndClass
invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset szClassName,offset szClassName,\
WS_OVERLAPPEDWINDOW,\
100,100,650,900,\
NULL,NULL,hInstance,NULL
mov hWinMain,eax
invoke ShowWindow,hWinMain,SW_SHOWNORMAL
invoke UpdateWindow,hWinMain
.while TRUE
invoke GetMessage,addr @stMsg,NULL,0,0
.break .if eax ==0
invoke TranslateMessage,addr @stMsg
invoke DispatchMessage,addr @stMsg
.endw
ret
_WinMain endp
start:
call _WinMain
invoke ExitProcess,NULL
end start
.386p
.model flat, stdcall
option casemap: none
include d:\masm32\include\windows.inc
include d:\masm32\include\kernel32.inc
include d:\masm32\include\user32.inc
includelib d:\masm32\lib\kernel32.lib
includelib d:\masm32\lib\user32.lib
.data
a db 1, 2, 3
szFormat db '%d %d %d', 0
szString db '%s\n', 0
szBuffer db 1024 dup(0)
hHandle dd 0
nSize dd 0
.code
start:
invoke wsprintf, offset szBuffer, offset szFormat, a, a[1], a[2]
invoke GetStdHandle, -11
mov hHandle,eax
invoke WriteFile, hHandle, offset szBuffer, 1024, offset nSize, 0
invoke ExitProcess, 0
ret
end start