开始看罗云彬的《win32汇编》,照着敲了一段,发现可以编译通过,进程也创建了,就是没有窗体现实,求各位先仁给盏明灯,贴代码:
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
include gdi32.inc
includelib user32.lib
includelib kernel32.lib
includelib gdi32.lib
----------------------------------------------------------------------------------------------------------------------------------------------
.const
szWndClass db 'Win32 Window',0
szCaptionText db 'Made by lilin',0
szText db 'Hello world!',0
.data?
hInstance dd ?
hWinMain dd ?
-----------------------------------------------------------------------------------------------------------------------------------------------
.code
_WinMainProc proc uses ebx esi edi,hWnd,uMsg,wParam,lParam
local @sthDc
local @stPs:PAINTSTRUCT
local @stRect:RECT
local @stCaptionText:DWORD
local @stText:DWORD
mov eax,uMsg
.if eax==WM_CLOSE
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,NULL
;.elseif eax==WM_CHAR
.elseif eax==WM_LBUTTONDOWN
invoke MessageBox,hWinMain,addr @stText,addr @stCaptionText,MB_OK
.elseif eax==WM_PAINT
invoke BeginPaint,hWnd,addr @stPs
mov @sthDc,eax
invoke GetClientRect,hWnd,addr @stRect
invoke DrawText,@sthDc,addr szText,-1,addr @stRect,DT_SINGLELINE or DT_CENTER or DT_VCENTER
invoke EndPaint,hWnd,addr @stPs
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
_WinMainProc endp
------------------------------------------------------------------------------------------------------------------------------------------
_WinMain proc
local @stWndClass:WNDCLASSEX
local @stMsg:MSG
invoke GetModuleHandle,0
mov hInstance,eax
invoke RtlZeroMemory,addr @stWndClass,sizeof @stWndClass
push hInstance
pop @stWndClass.hInstance
invoke LoadCursor,0,IDC_ARROW
mov @stWndClass.hCursor,eax
invoke LoadIcon,0,IDI_APPLICATION
mov @stWndClass.hIcon,eax
mov @stWndClass.cbSize,sizeof WNDCLASSEX
mov @stWndClass.style,CS_HREDRAW or CS_VREDRAW
mov @stWndClass.hbrBackground,COLOR_WINDOW+1
mov @stWndClass.lpszClassName,offset szWndClass
mov @stWndClass.lpfnWndProc,offset _WinMainProc
invoke RegisterClass,addr @stWndClass
invoke CreateWindowEx,WS_EX_CLIENTEDGE,\
offset szWndClass,\
offset szCaptionText,\
WS_OVERLAPPEDWINDOW,\
100,100,400,600,\
0,0,hInstance,0
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:
invoke _WinMain
invoke ExitProcess,0
end start
阿里云助力开发者!2核2G 3M带宽不限流量!6.18限时价,开
发者可享99元/年,续费同价!