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.
:confused:
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.
:confused:
"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
Apart from that, your assumption is right: EBX contains 25h after the procedure call.
; 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.
thanx Frank..i knew i was screwing up
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.