The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Mark Jones on February 27, 2006, 05:59:40 AM

Title: Pushing too many params?
Post by: Mark Jones on February 27, 2006, 05:59:40 AM
Q: Is it necessarily bad if you push a few too many values to the stack? i.e.


.code
    invoke GetHandle,STD_OUTPUT_HANDLE
    mov hConsole,eax

    push eax
    push ecx
    push MyVar
    push GeorgeW.Bush

    invoke ExitProcess,0


What happens to those values, does ExitProcess clean up all the stack space used or simply increment past it? Thanks.
Title: Re: Pushing too many params?
Post by: Maeser on February 27, 2006, 08:17:43 AM
Well...if memory serves...the stack wouldn't be balanced. But since you're exiting I would assume it would be ignored
Title: Re: Pushing too many params?
Post by: zooba on February 27, 2006, 08:31:07 AM
Presumably it loads the appropriate stack pointer from a fixed memory location (relative to FS probably) or changes context and simply frees all of the memory. If it doesn't crash on exit, it's probably all right.
Title: Re: Pushing too many params?
Post by: Tedd on February 27, 2006, 11:59:56 AM
It seems you can mess up the stack all you want - pushing or popping (as long as you don't get an exception as a result of those actions.)
ExitProcess destroys 'your' stack and ignores.