Not being lazy yourself, jj2007, u don't understand lazy programmers! *This* is the version for us:
.data
lazyMsg db "Stack was off but don't worry, I took care of it. Go back to sleep.",0
.code
UseCheckEsp=1 ; 0=don't generate code
CheckEsp MACRO mode
if UseCheckEsp
ife mode
ifndef EspGlobal
.data?
EspGlobal dd ?
.code
endif
mov EspGlobal, esp
else
sub EspGlobal, esp
.if !Zero?
add esp, EspGlobal
pushad
invoke MessageBox, 0, str$(EspGlobal), addr lazyMsg, MB_OK
popad
.endif
endif
endif
ENDM
Even better, comment out the MessageBox invocation - lazy proggers hate to be forced to click "OK".
Of course if you have to write the CheckEsp macro yourself, this is the preferred version:
;No Code at all
Then when your stack is off, a helpful message will automatically pop up (assuming you're too lazy to have a debugger):
"lazy.exe has stopped working"
Simply click on this choice:
"Check online for a solution and close the program"
and all your data will be sent to Microsoft. Let them figure out what's wrong 8)