From a10e9ba092994936a08e53c206ddb695a7ff53f6 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 28 May 2010 11:20:28 +0200 Subject: [PATCH] kernel32: Unalign the stack on process startup to work around Doom3 bug. --- dlls/kernel32/process.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index af06392bace..da99ab952b7 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 ); } -- 2.11.4.GIT