Alexandre Julliard : kernel32: Unalign the stack on process startup to work around Doom3 bug.

Alexandre Julliard julliard at winehq.org
Fri May 28 09:43:10 CDT 2010


Module: wine
Branch: master
Commit: a10e9ba092994936a08e53c206ddb695a7ff53f6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a10e9ba092994936a08e53c206ddb695a7ff53f6

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri May 28 11:20:28 2010 +0200

kernel32: Unalign the stack on process startup to work around Doom3 bug.

---

 dlls/kernel32/process.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index af06392..da99ab9 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -944,6 +944,28 @@ static void start_wineboot( HANDLE handles[2] )
 }
 
 
+#ifdef __i386__
+extern DWORD call_process_entry( PEB *peb, LPTHREAD_START_ROUTINE entry );
+__ASM_GLOBAL_FUNC( call_process_entry,
+                    "pushl %ebp\n\t"
+                    __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
+                    __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
+                    "movl %esp,%ebp\n\t"
+                    __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
+                    "subl $12,%esp\n\t"  /* deliberately mis-align the stack by 8, Doom 3 needs this */
+                    "pushl 8(%ebp)\n\t"
+                    "call *12(%ebp)\n\t"
+                    "leave\n\t"
+                    __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
+                    __ASM_CFI(".cfi_same_value %ebp\n\t")
+                    "ret" )
+#else
+static inline DWORD call_process_entry( PEB *peb, LPTHREAD_START_ROUTINE entry )
+{
+    return entry( peb );
+}
+#endif
+
 /***********************************************************************
  *           start_process
  *
@@ -971,7 +993,7 @@ static DWORD WINAPI start_process( PEB *peb )
 
     SetLastError( 0 );  /* clear error code */
     if (peb->BeingDebugged) DbgBreakPoint();
-    return entry( peb );
+    return call_process_entry( peb, entry );
 }
 
 




More information about the wine-cvs mailing list