当前位置: 代码迷 >> 汇编语言 >> 读老罗WIN32有关问题
  详细解决方案

读老罗WIN32有关问题

热度:410   发布时间:2013-02-26 00:00:00.0
读老罗WIN32问题
我想要建一个窗口,然后按下BUTTON弹出一个消息窗口,显示mov ebp,1,lea,eax, [ebp + 12345678h] EAX的值
但按下BUTTON总是显示应用程序停止工作,环境是WIN7.
还有我看到一个大牛写的一个帖子里面,说这里说eax等于123456789h,我想不是等于12345679h吗?
下面是代码
Assembly code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;数据段;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        .data?hInstance    dd    ?hWinMain    dd    ?        .constszMessage    db    'EAX= %x',0szClassName    db    'WinTest',0szCaption    db    'WinTest',0szButton    db    'Button',0;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;代码段;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        .code;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>_ProcWinMain    proc    hWnd,uMsg,wParam,lParam        LOCAL    @szBuffer[256]:byte                pushad        mov    eax,uMsg        .if    eax ==    WM_CREATE            invoke    CreateWindowEx,NULL,\                offset szButton,offset szCaption,\                WS_CHILD or WS_VISIBLE,\                10,10,65,22,\                hWnd,1,hInstance,NULL;******************************************************************        .elseif    eax ==     WM_COMMAND            mov    ebp,1            lea    eax, [ebp + 12345678h]            invoke    wsprintf,addr @szBuffer,offset szMessage,eax            invoke    MessageBox,hWnd,addr @szBuffer,offset szCaption,MB_OK                        ;[color=#FF0000]就是在这里弹出消息啊。但总是显示程序已停止工作[/color]。;******************************************************************        .elseif    eax == WM_CLOSE                        invoke    DestroyWindow,hWinMain            invoke    PostQuitMessage,NULL;******************************************************************        .else            invoke    DefWindowProc,hWnd,uMsg,wParam,lParam            ret        .endif        ;xor    eax,eax        popad        ret_ProcWinMain endp;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>_WinMain    proc            LOCAL    @stWndClass:WNDCLASSEX        LOCAL    @stMsg:MSG                invoke    GetModuleHandle,NULL        mov    hInstance,eax        invoke    RtlZeroMemory,addr @stWndClass,sizeof @stWndClass;*******************************************************************;注册窗口类;*******************************************************************        invoke    LoadCursor,0,IDC_ARROW        mov    @stWndClass.hCursor,eax        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 szCaption,WS_OVERLAPPEDWINDOW,\            100,100,600,400,\            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
  相关解决方案