Did you ever want to make a function that can take a variable amount of arguments? Example wsprintf - but it doesn't clean the stack for you. This code puts ESP back where it belongs.
Start:
push 1
push 1
push 1
push 1
push 1
push 1
push 7 ;# of arguments
call dynamicreturn
push 0
call [ExitProcess]
dynamicreturn:
push ebp
mov ebp,esp
mov esp,ebp
pop ebp ;dynamic return starts
shl dword[esp+4],2 ;#of args to #of dwords
mov ecx,[esp] ;save return addr
mov edx,[esp+4] ;adjust esp to
lea esp,[esp+edx+4];preCall position
jmp ecx ;jmp return addr
You don't even need an arg for the number of arguments IF one of your args is say a format string you can have your function store how many args in a local from the stack frame.
I hope you all enjoy this as much as I enjoyed coding it.