Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Winapi 如何获取窗口进程参数?_Winapi_Assembly_Nasm - Fatal编程技术网

Winapi 如何获取窗口进程参数?

Winapi 如何获取窗口进程参数?,winapi,assembly,nasm,Winapi,Assembly,Nasm,我尝试使用assembly NASM创建最简单的WinAPI窗口。 我对windowproc有问题。查看注释行: %macro API 2 import %1 %2 extern %1 %endmacro API GetModuleHandleA, kernel32.dll API LoadIconA,user32.dll API LoadCursorA,user32.dll API RegisterClassExA, user32.dll API CreateWindowE

我尝试使用assembly NASM创建最简单的WinAPI窗口。 我对windowproc有问题。查看注释行:

%macro API 2 import %1 %2 extern %1 %endmacro API GetModuleHandleA, kernel32.dll API LoadIconA,user32.dll API LoadCursorA,user32.dll API RegisterClassExA, user32.dll API CreateWindowExA, user32.dll API MessageBoxA, user32.dll API SendMessageA, user32.dll API DefWindowProcA, user32.dll API ExitProcess, kernel32.dll API GetMessageA, user32.dll API DispatchMessageA, user32.dll API TranslateMessage,user32.dll API ShowWindow,user32.dll API UpdateWindow,user32.dll API GetCommandLineA,kernel32.dll API PostQuitMessage,user32.dll segment .data USE32 windowName db "Hello world!", 0 cmdLine dd 0 hWnd dd 0 hInst dd 0 hCursor dd 0 className db "moje_okno",0 blad db "Blad!!!",0 segment .bss struc WNDCLASSEX .sSize resb 4 .style resb 4 .wndProc resb 4 .clsExtra resb 4 .wndExtra resb 4 .hInstance resb 4 .hIcon resb 4 .hCursor resb 4 .background resb 4 .sMenuName resb 4 .sClassName resb 4 .hIconSm resb 4 endstruc wndClass istruc WNDCLASSEX iend global ..start segment .text USE32 ..start: push 0 call [GetModuleHandleA] mov dword [hInst], eax ; application handle push dword 0x00007f00 ; MAKEINTRESOURCE(32512) push dword 0 call [LoadCursorA] mov dword [hCursor], eax ; cursor handle mov dword [wndClass + WNDCLASSEX.sSize], dword 48 ; struct size mov dword [wndClass + WNDCLASSEX.style], dword 0 ; style mov dword [wndClass + WNDCLASSEX.wndProc], wndproc ; window proc mov dword [wndClass + WNDCLASSEX.clsExtra], dword 0 mov dword [wndClass + WNDCLASSEX.wndExtra], dword 0 mov eax, dword [hInst] mov dword [wndClass + WNDCLASSEX.hInstance], eax ; handle mov dword [wndClass + WNDCLASSEX.hIcon], dword 0 mov eax, dword [hCursor] mov dword [wndClass + WNDCLASSEX.hCursor], eax mov dword [wndClass + WNDCLASSEX.background], dword 0 mov dword [wndClass + WNDCLASSEX.sMenuName], dword 0 mov dword [wndClass + WNDCLASSEX.sClassName], className ; class name mov dword [wndClass + WNDCLASSEX.hIconSm], dword 0 push wndClass call [RegisterClassExA] call near sprawdz_blad ; check return value of RegisterClassExA push 0 ; param push dword [hInst] ; handle push 0 ;hMenu push 0 ;parent push 200 ;height push 200 ;width push 200 ;y push 200 ;x push 0 ;style push className ;window name push className ;window class push 0 ;extended style call [CreateWindowExA] push eax call near sprawdz_blad ;check return value of CreateWindowExA. RETURNS 0 push 0 call [ExitProcess] wndproc: ; HERE I NEED ACCESS TO WINDOW PROC PARAMETERS: HWND, MSG, WPARAM, LPARAM ; I TRIED: pop eax pop ebx pop ecx pop edx ; BUT IT DOESN'T WORK ; THERE ARE NOT RIGHT VALUES IN THESE REGISTRIES ret box: push 0 push blad push blad push 0 call [MessageBoxA] ret sprawdz_blad: pop eax cmp eax, 0 jne ok ; if function returns 0 everything is allright push 0 push blad push blad push 0 call [MessageBoxA] push 1 call [ExitProcess] ok: ret %宏API 2 导入%1%2 外部%1 %endmacro API GetModuleHandleA,内核32.dll API LoadIconA,user32.dll API LoadCursorA,user32.dll API注册表类XA,user32.dll API CreateWindowExA,user32.dll API MessageBoxA,user32.dll API SendMessageA,user32.dll API DefWindowProcA,user32.dll API ExitProcess,kernel32.dll API GetMessageA,user32.dll API DispatchMessageA,user32.dll API TranslateMessage,user32.dll API显示窗口,user32.dll API更新窗口,user32.dll API GetCommandLineA,kernel32.dll API PostQuitMessage,user32.dll 段.数据使用32 windowName数据库“你好,世界!”,0 cmdLine dd 0 hWnd dd 0 hInst dd 0 hCursor dd 0 类名db“moje_okno”,0 blad db“blad!!!”,0 第2部分:bss struc WNDCLASSEX .sSize resb 4 .style resb 4 .wndProc resb 4 .clsExtra resb 4 .wndExtra resb 4 .HINB 4 .hIcon resb 4 .hCursor resb 4 .背景resb 4 .Smenuame resb 4 .sClassName resb 4 .hIconSm resb 4 端部结构 wndClass istruc wndClass X 伊恩德 全球..开始 段.文本使用32 …开始: 推0 调用[GetModuleHandleA] 莫夫·德沃德[hInst],eax;应用程序句柄 推送dword 0x00007f00;MAKEINTRESOURCE(32512) 推送dword 0 呼叫[LoadCursorA] 莫夫·德沃德[hCursor],eax;光标手柄 mov-dword[wndClass+WNDCLASSEX.sSize],dword 48;结构大小 mov-dword[wndClass+WNDCLASSEX.style],dword 0;风格 mov dword[wndClass+WNDCLASSEX.wndProc],wndProc;窗口程序 mov dword[wndClass+wndClass.clsExtra],dword 0 mov dword[wndClass+WNDCLASSEX.wndExtra],dword 0 mov eax,德沃德[hInst] mov-dword[wndClass+WNDCLASSEX.hInstance],eax;手柄 mov dword[wndClass+wndClass.hIcon],dword 0 mov eax,德沃德[hCursor] mov dword[wndClass+wndClass.hCursor],eax mov-dword[wndClass+WNDCLASSEX.background],dword 0 mov dword[wndClass+wndClass.sMenuName],dword 0 mov dword[wndClass+WNDCLASSEX.sClassName],类名;类名 mov dword[wndClass+wndClass.hIconSm],dword 0 推送wndClass 调用[RegisterClassExA] 在sprawdz_blad附近呼叫;检查寄存器CLASSEXA的返回值 推0;param 推德沃德[hInst];手柄 推0;花木 推0;父母亲 推200;高度 推200;宽度 推200;Y 推200;x 推0;风格 推送类名;窗口名 推送类名;窗口类 推0;扩展样式 调用[CreateWindowExA] 推送eax 在sprawdz_blad附近呼叫;检查CreateWindowExA的返回值。返回0 推0 呼叫[出口流程] wndproc: ; 这里我需要访问windowproc参数:HWND、MSG、WPARAM、LPARAM ; 我试过: 波普eax 流行电子束 波普ecx 波普edx ; 但它不起作用 ; 这些注册表中没有正确的值 ret 方框: 推0 推叶 推叶 推0 致电[MessageBoxA] ret 斯普拉德兹布拉德: 波普eax cmp-eax,0 jne ok;如果函数返回0,则一切正常 推0 推叶 推叶 推0 致电[MessageBoxA] 推1 呼叫[出口流程] 好 啊: ret 我试着让它工作几个小时,但我没有主意。 请帮忙。
您好,Michal。

一个被调用的子例程,无论您自己调用还是由Windows(如wndproc)调用,其返回地址都是堆栈上的第一项。你不想把这个给爆了!要访问这些参数,您需要进一步查看堆栈。试试像

wndproc:
    mov eax, [esp + 4]
    mov ebx, [esp + 8]
 ; etc...

看看这是否有帮助

最好的,
弗兰克

什么不起作用?发生了什么,没有发生什么?wndproc是在我调用CreateWindow之后由系统调用的。在没有返回DefWindowProc之前,CreateWindow将返回0。但要调用DefWindowProc,我需要访问wndproc参数。