Author Topic: I am new and Can anybody explain some part of the TD's code  (Read 8600 times)

chiqui.paula

  • Regular Member
  • *
  • Posts: 6
Re: I am new and Can anybody explain some part of the TD's code
« Reply #15 on: May 12, 2015, 04:15:02 AM »
To understand what's going on, place an int 3 directly after WP1 and watch in Olly what happens:

Code: [Select]
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

  • Member
  • *****
  • Posts: 8829
  • Still using Abacus 2.0
    • DednDave
Re: I am new and Can anybody explain some part of the TD's code
« Reply #16 on: May 12, 2015, 04:24:31 AM »
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...

Code: [Select]
    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

  • Regular Member
  • *
  • Posts: 6
Re: I am new and Can anybody explain some part of the TD's code
« Reply #17 on: May 12, 2015, 06:19:18 AM »
Thanks guys, I appreciate all your help.

Bests,

PC