| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| When using a window procedure, do I need to clean up the stack or will windows clean up the stack for me? Do I need the RET 16 or can I just RET? For example: WndProc: push ebp mov ebp, esp cmp [ebp+12], dword WM_CREATE ; window message jz wm_create jmp default wm_create: jmp default default: push dword [ebp+20] push dword [ebp+16] push dword [ebp+12] push dword [ebp+8] call [DefWindowProcA] leave ret 16 |
|
#2
| |||
| |||
| "bwaichu@yahoo.com" <spamtrap@crayne.org> wrote: > >When using a window procedure, do I need to clean up the stack or will >windows clean up the stack for me? Do I need the RET 16 or can I just >RET? You need the "RET 16". The standard calling sequence in Win32 uses "callee cleanup". -- Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. |
|
#3
| |||
| |||
| On Wed, 30 Jul 2008 18:02:04 -0700 (PDT), "bwaichu@yahoo.com" <spamtrap@crayne.org> wrote: >When using a window procedure, do I need to clean up the stack or will >windows clean up the stack for me? Do I need the RET 16 or can I just >RET? > >For example: > >WndProc: > > push ebp > mov ebp, esp > > cmp [ebp+12], dword WM_CREATE ; window message > jz wm_create > jmp default > >wm_create: > > jmp default > >default: > > push dword [ebp+20] > push dword [ebp+16] > push dword [ebp+12] > push dword [ebp+8] > call [DefWindowProcA] > > leave > ret 16 > I don't know about other assemblers, but in MASM you can use a PROTO to take care of all this automatically. Best regards, Bob Masta DAQARTA v4.00 Data AcQuisition And Real-Time Analysis www.daqarta.com Scope, Spectrum, Spectrogram, Sound Level Meter FREE Signal Generator Science with your sound card! |
|
#4
| |||
| |||
| Yes, PROTO works if you don't forget to tell MASM to ".model flat, stdcall" in the beginning of the source file. It’s the 'stdcall' that does the trick here. "Bob Masta" <NoSpam@daqarta.com> wrote in message news:4891a453.746852@news.sysmatrix.net... > On Wed, 30 Jul 2008 18:02:04 -0700 (PDT), "bwaichu@yahoo.com" > <spamtrap@crayne.org> wrote: > >>When using a window procedure, do I need to clean up the stack or will >>windows clean up the stack for me? Do I need the RET 16 or can I just >>RET? >> >>For example: >> >>WndProc: >> >> push ebp >> mov ebp, esp >> >> cmp [ebp+12], dword WM_CREATE ; window message >> jz wm_create >> jmp default >> >>wm_create: >> >> jmp default >> >>default: >> >> push dword [ebp+20] >> push dword [ebp+16] >> push dword [ebp+12] >> push dword [ebp+8] >> call [DefWindowProcA] >> >> leave >> ret 16 >> > > I don't know about other assemblers, but in MASM you can use a PROTO > to take care of all this automatically. > > Best regards, > > > Bob Masta > > DAQARTA v4.00 > Data AcQuisition And Real-Time Analysis > www.daqarta.com > Scope, Spectrum, Spectrogram, Sound Level Meter > FREE Signal Generator > Science with your sound card! > |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.