flat assembler
Message board for the users of flat assembler.
Index
> Windows > WindowProcedure: why push and pop registers? |
Author |
|
revolution 27 Dec 2009, 16:43
For all Windows stdcall functions ebp, ebx, esi and edi are preserved. And 'WindowProc' must comply with that standard or you will be sorry.
BTW: ebp is preserved by the 'proc' macro so you don't need to do it manually. You can also do this: Code: proc WindowProc uses ebx esi edi, hwnd, msg, wparam, lparam ; ... ret endp |
|||
27 Dec 2009, 16:43 |
|
Teehee 27 Dec 2009, 16:50
What reason they are preserved?
|
|||
27 Dec 2009, 16:50 |
|
revolution 27 Dec 2009, 16:57
Because the caller uses those registers to hold some state information. If you overwrite the information then you will be sorry. Windows has this code
Code: ... mov esi,someVeryImportantValue mov edi,anotherVeryImportantValue mov ebx,VVVVImportantValue ... call [WindowProc] ;Windows calls your proc cmp esi,someVeryImportantValue jnz CrashProgramAndDie cmp edi,anotherVeryImportantValue jnz CrashProgramAndDie cmp ebx,VVVVImportantValue jnz CrashProgramAndDie ... |
|||
27 Dec 2009, 16:57 |
|
Teehee 27 Dec 2009, 17:03
Hmmm... I see. *thumbs up*
|
|||
27 Dec 2009, 17:03 |
|
bitshifter 27 Dec 2009, 20:14
It's called an ABI standard.
Just Google it, Wiki it, MSDN it... |
|||
27 Dec 2009, 20:14 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.