A couple of questions about the stack and win32.

Question 1

If i use the following asm blip:

Mov eax,25h
Push eax
Push ecx
Push edi
Call Proc

Proc {

Ret 2

Pop ebx

Does ebx now contain 25h? (I'm trying to see if i understand the stack frame correctly.

Question 2

If i am Invoking an win32 api call with 3 parameters does Masm always clean up the stack by returning 3.

Just trying to get the jist of how masm and the stack work together.

Thanx in advance.

Posted on 2002-07-18 20:27:37 by IwasTitan
"RET 2" is not correct. You need to give the number of parameters to clear from the stack (which is 2), times their size (which is 4, as we are dealing with DWORDs). So it should be one of

; RET 2 ; crashes
RET 2 * 4 ; works
RET 2 * SIZEOF DWORD ; works
RET 8 ; works

Apart from that, your assumption is right: EBX contains 25h after the procedure call.
Posted on 2002-07-18 21:24:39 by Frank
thanx Frank..i knew i was screwing up
Posted on 2002-07-18 22:24:14 by IwasTitan
functions that are STDCALL will always remove the paramters from the stack. C calling conversion functions rely on the caller to remove them from the stack but if your using invoke then masm will take care of this for you.
Posted on 2002-07-19 00:20:15 by Kudos