News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Lingo's Message Loop ?

Started by ic2, February 15, 2007, 04:38:55 AM

Previous topic - Next topic

ic2

What a sling-shot.. hutch

I just want to make sure I got most of this right.

[esp+2*4] This is where all Window Messages Begin

[esp+3*4] I add 4 for any ChildWindow or new function or API call i want to start with.


mov   eax, [esp+1*4]                 ; same as [esp+4]       

add   esp, -5*4                      ; What is negative 5 x 4
                                     ; Is it going backward if so
                                     ; Where and how do you figure.
                                     ; wild guest = TranslateMessage

mov   [esp], offset @ret_1           ; Ok set up a return address

mov   dword ptr [esp+1*4], eax       ; same as [esp+4]

mov   [esp+2*4], offset buttonText_1 ; same as [esp+8]

mov   [esp+3*4], offset buttonText_1 ; same as [esp+12]

mov   dword ptr [esp+4*4], MB_OK     ; Call any API as long
                                     ; as i push (mov) the
                                     ; right amount of parameters
                                     ; the API need... in this
                                     ; case it is [esp+16] 4
jmp   MessageBox            ; parametersaction


wParam = [esp+12]  where do these come in at. 
lParam = [esp+16]  Just want to be sure


I this right?  I know I got a few wrong but im getting a good idea only because of the way it was explained. I don't want to ware out the word but I'll say thanks now because i'm going to be back tracking the forum to catch up on stuff i never an effort to understand...You guys know how much i appreciate it but don't let this be the end, make it an option.

.....................................

Seb,   you were not sure of what i was taking about and hutch explained fully, i'm sure.  Thanks for giving me the benefit of an douth of having a brain.  It's a big difference when all you know is

Push 0
Call. Call. Call

knowing nothing about  ... 
movq    [esp+4*8*1999 sub 2 infinity ],  MM7

or

INVOKE ReadFile,EBX,[S1$.pBuffer+3*DWORD],[S1$.iFileLength+2*DWORD],EAX,EBP

other than it look interesting.  I hate math i thought it was trigonometry or that i had to move up to something like that so i simply turned the pages ....  Now i see.

Hutch has some kind of special since of people and *usually* know how to break things down to nearly anyone with-out making them feel to bad or offensive provided he didn't have a bad day. :) don't know if im kidding or not .  Anyway, that's a lot of people power.  Most of us do wish you well :)

Yeah, Seb... Above all we're at  D  LINGOS_COMMAND: Center.

Doom Doomm 


Seb

Quote from: ic2 on February 18, 2007, 03:01:54 AM
[esp+2*4] This is where all Window Messages Begin

Yes, this is the "uMsg" parameter of WndProc (esp+8).

Quote from: ic2 on February 18, 2007, 03:01:54 AM
[esp+3*4] I add 4 for any ChildWindow or new function or API call i want to start with.

Not sure what you mean... the x*4 is, atleast by me, used for readability reasons to show the Xth DWORD of the call-stack... It'll be assembled to [esp+X] (where X is an even number) anyway. The [esp+3*4] in this case points to wParam.

Quote from: ic2 on February 18, 2007, 03:01:54 AM
mov   eax, [esp+1*4]                 ; same as [esp+4]       

Yes, EAX now holds to the hWnd (the first call-stack parameter of WndProc).

Quote from: ic2 on February 18, 2007, 03:01:54 AM
add   esp, -5*4                      ; What is negative 5 x 4
                                     ; Is it going backward if so
                                     ; Where and how do you figure.
                                     ; wild guest = TranslateMessage

Here lingo's allocating space on the stack for 5 DWORDs... The first DWORD is used to save the return address, which is an offset to a label that'll return 1 and bail out (@ret_1 or DefEnd_1 or whatever) and the last 4 DWORDs to save the parameters for the MessageBox-API...makes 5 DWORDs. :wink

In this case, you could also do...


sub esp, 5*4 ; allocate space for 5 DWORDs


...to achieve the same result as...


add esp, -5*4 ; allocate space for 5 DWORDs


AFAIK, the latter is the Microsoft-way of doing it, maybe lingo want to stick to their standard? :P

Quote from: ic2 on February 18, 2007, 03:01:54 AM
wParam = [esp+12]  where do these come in at. 
lParam = [esp+16]  Just want to be sure

These are two of the parameters pushed onto the stack by either GetMeessage or TranslateMessage (I reckon the latter though), because they're the functions notifying your own WndProc when a message arrives... So basically, they belong to the stack of your WndProc function.

Quote from: ic2 on February 18, 2007, 03:01:54 AM
Seb,   you were not sure of what i was taking about and hutch explained fully, i'm sure.

Yes, I didn't fully understand you, I thought you were only interested in the wParam and WndProc-stuff.