WINPROC_wrapper: some window procedures modify the ebp register

Rein Klazes wijn at wanadoo.nl
Fri Mar 10 08:12:00 CST 2006


Hi,

Fix for bug #4768 where a buggy program thrashes the saved ebp register
in the windowproc. If it is considered worth fixing, here is a try.

Changelog:
dlls/user	: winproc.c
Some window procedures modify the ebp register, so do not depend on it.

Rein.
-------------- next part --------------
--- wine/dlls/user/winproc.c	2006-02-03 11:24:11.000000000 +0100
+++ mywine/dlls/user/winproc.c	2006-03-10 13:33:52.000000000 +0100
@@ -270,19 +270,27 @@ __ASM_GLOBAL_FUNC( WINPROC_wrapper,
                    "pushl %edi\n\t"
                    "pushl %esi\n\t"
                    "pushl %ebx\n\t"
-                   "subl $12,%esp\n\t"
+                   "pushl $0xdefabcde\n\t"
+                   "subl $8,%esp\n\t"
                    "pushl 24(%ebp)\n\t"
                    "pushl 20(%ebp)\n\t"
                    "pushl 16(%ebp)\n\t"
                    "pushl 12(%ebp)\n\t"
                    "movl 8(%ebp),%eax\n\t"
                    "call *%eax\n\t"
-                   "leal -12(%ebp),%esp\n\t"
+                   "cmpl $0xdefabcde, 8(%esp)\n\t"
+                   "jne 2f\n\t"
+                   "addl  $12,%esp\n\t"
+                   "1:\n\t"
                    "popl %ebx\n\t"
                    "popl %esi\n\t"
                    "popl %edi\n\t"
-                   "leave\n\t"
-                   "ret" );
+                   "popl %ebp\n\t"
+                   "ret\n\t" 
+                   "2:\n\t"
+                   "addl $28,%esp\n\t"
+                   "jmp 1b\n\t"
+                   );
 #else
 static inline LRESULT WINPROC_wrapper( WNDPROC proc, HWND hwnd, UINT msg,
                                        WPARAM wParam, LPARAM lParam )


More information about the wine-patches mailing list