News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

I am new and Can anybody explain some part of the TD's code

Started by chiqui.paula, May 11, 2015, 04:35:48 PM

Previous topic - Next topic

chiqui.paula

Quote from: jj2007 on May 12, 2015, 04:01:31 AM
To understand what's going on, place an int 3 directly after WP1 and watch in Olly what happens:

mov     lpfnWndProc,OFFSET WP1          ;address of user lpfnWndProc function
(#### here you tell Windows where your application's message loop starts)
...

WP1:
int 3
push    ebp                             ;create stack frame
mov     ebp,esp                         ;
pushad                                  ;push all register to the stack

mov     eax,WP1_uMsg           ; [ebp+12] move the message number in eax
(#### Windows places the message on the stack, it ends up in [ebp+12])


jj2007,

I am guessing I am missing something, and please forgive me asking again :(
How do we get the message number inside the "WP1_uMsg"? When we call "GetMessage" function it returns the message number into "eax" and computer doesnt know the message number is inside the "WP1_uMsg". How do we guarantee that the message number is somehow returned into the "WP1_uMsg"? If we would have written "mov WP1_uMsg, eax" then I would understand it because the return value is in "eax".

Thanks,

PC,



dedndave

when the operating system dispatches the message to a window, it does so by calling the WndProc for that window class
the code probably looks something like this...

    push    _lParam
    push    _wParam
    push    _uMsg
    push    _hWnd
    call dword ptr _WNDCLASSEX.lpfnWndProc


now, when your WndProc executes, the passed arguments are in fixed locations on the stack
when RET is executed (actually, it's a RET 16), the passed arguments are discarded

chiqui.paula