实在是不好意思啊,最近联系汇编语言,被一个小小的函数卡主了,现在放出源代码:
.586
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
.data
ClassName db "MainWinClass",0
AppName db "Main Window",0
fileaddr db "D:\Program Files (x86)\TianCity\EVE\launcher\launcher - 03.exe",0
optype db "open",0
sw db "SW_SHOWNORMAL",0
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
filehandle DWORD ?
.code
; ---------------------------------------------------------------------------
;ip指令寄存器,sp堆栈栈顶,ret:(ip)<-((SP)+1,(SP)) (SP)←(SP)+2
start:
invoke GetModuleHandle, NULL ;取得当前模块句柄
mov hInstance,eax
invoke GetCommandLine ;得到命令性参数
mov CommandLine,eax
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke OpenExe,offset optype,offset fileaddr
invoke shmess,filehandle
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
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInstance
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION ;装入指定图标
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW ;装入光标资源
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc ;注册窗口
INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\
hInst,NULL ;创建窗口
mov hwnd,eax ;返回窗口句柄
invoke ShowWindow, hwnd,SW_SHOWNORMAL ;显示窗口
invoke UpdateWindow, hwnd ;更新窗口
.WHILE TRUE
invoke GetMessage, ADDR msg,NULL,0,0 ;取得消息
.BREAK .IF (!eax)
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 ;消息处理函数,必须保留
.IF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSEIF uMsg==WM_CREATE
;
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp
OpenExe proc faddr:LPSTR,otype:LPSTR
invoke ShellExecute,hWnd, otype, faddr,NULL,NULL,offset sw ;open file
if eax!
mov filehandle,eax ;保存打开进程句柄
ret
OpenExe endp
shmess proc messaddr:LPSTR
invoke MessageBox,NULL,messaddr,messaddr,MB_OK
shmess endp
end start
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课