我是ASM32新手,今天看着教程编了一个程序,在单位的win2000机子上一切OK没问题,可是回到家在XP机子上却出问题了,运行程序没有显示任何窗口,但是进程却存在。,实在找不到原因,请高手帮忙,到底在win2000和XP上运行为什么会不同。以下是源代码
.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
RGB macro red,green,blue
xor eax,eax
mov ah,blue
shl eax,8
mov ah,green
mov al,red
endm
_WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
.DATA
ClassName db "simplewinclass",0
AppName db "our first window",0
szText db "this is my first game!",0
szFontName db "shit font",0
szChar WPARAM 20h
.DATA?
hInstance dd ?
CommandLine dd ?
.CODE
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke GetCommandLine
mov CommandLine,eax
invoke _WinMain, hInstance, NULL, CommandLine,SW_SHOWDEFAULT
invoke ExitProcess,eax
_WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL @wc:WNDCLASSEX
LOCAL @msg:MSG
LOCAL @hwnd:HWND
mov @wc.cbSize,SIZEOF WNDCLASSEX
mov @wc.style,CS_HREDRAW or CS_VREDRAW
mov @wc.lpfnWndProc,offset _WndProc
push hInstance
pop @wc.hInstance
mov @wc.hbrBackground,COLOR_WINDOW + 1
mov @wc.lpszClassName,offset ClassName
invoke LoadCursor,0,IDC_ARROW
mov @wc.hCursor,eax
invoke LoadIcon,NULL,IDI_APPLICATION
mov @wc.hIcon,eax
mov @wc.hIconSm,eax
invoke RegisterClassEx,addr @wc
invoke CreateWindowEx,WS_EX_CLIENTEDGE,\
offset ClassName,offset AppName,\
WS_OVERLAPPEDWINDOW,\
100,100,600,400,\
NULL,NULL,hInst,NULL
mov @hwnd,eax
invoke ShowWindow, @hwnd,CmdShow
invoke UpdateWindow, @hwnd
.while TRUE
invoke GetMessage,addr @msg,NULL,0,0
.break .if eax == 0
invoke TranslateMessage,addr @msg
invoke DispatchMessage,addr @msg
.endw
mov eax,@msg.wParam
ret
_WinMain endp
_WndProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL @hdc:HDC
LOCAL @ps:PAINTSTRUCT
LOCAL @rect:RECT
LOCAL @hFont:HFONT
.IF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSEIF uMsg==WM_CHAR
push wParam
pop szChar
invoke InvalidateRect,hWnd,NULL,TRUE
.ELSEIF uMsg==WM_PAINT
invoke BeginPaint,hWnd,ADDR @ps
mov @hdc,eax
invoke CreateFont,24,16,0,0,400,0,0,0,OEM_CHARSET,\
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,\
DEFAULT_QUALITY,DEFAULT_PITCH or FF_SCRIPT,\
ADDR szFontName
invoke SelectObject,@hdc,eax
mov @hFont,eax
RGB 200,200,50
invoke SetTextColor,@hdc,eax
RGB 0,0,255
invoke SetBkColor,@hdc,eax
invoke TextOut,@hdc,0,0,ADDR szChar,SIZEOF szChar
invoke GetClientRect,hWnd,ADDR @rect
invoke DrawText,@hdc,ADDR szText,-1,ADDR @rect,\
DT_SINGLELINE or DT_CENTER or DT_VCENTER
invoke SelectObject,@hdc,@hFont
invoke EndPaint,hWnd,ADDR @ps
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
_WndProc endp
end start
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)