WndProc (stack clean up?)

This is a discussion on WndProc (stack clean up?) within the ASM x86 ASM 370 forums in Programming Languages category; 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...

Go Back   Application Development Forum > Programming Languages > ASM x86 ASM 370

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 07-30-2008, 09:02 PM
bwaichu@yahoo.com
Guest
 
Default WndProc (stack clean up?)

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

Reply With Quote
  #2  
Old 07-31-2008, 02:04 AM
Tim Roberts
Guest
 
Default Re: WndProc (stack clean up?)

"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.

Reply With Quote
  #3  
Old 07-31-2008, 07:41 AM
Bob Masta
Guest
 
Default Re: WndProc (stack clean up?)

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!

Reply With Quote
  #4  
Old 08-04-2008, 10:22 PM
comrade
Guest
 
Default Re: WndProc (stack clean up?)

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!
>


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 06:53 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.