Module: wine Branch: master Commit: c9d85dd5760fb082c19577338632a05837eccdce URL: http://source.winehq.org/git/wine.git/?a=commit;h=c9d85dd5760fb082c195773386...
Author: Alexandre Julliard julliard@winehq.org Date: Sat Aug 29 11:07:17 2009 +0200
ntdll: Route the process startup through the platform-specific thread startup code.
---
dlls/kernel32/process.c | 50 +++++++++++++++++----------------------------- dlls/ntdll/loader.c | 13 ++++++++++- include/winternl.h | 2 +- 3 files changed, 31 insertions(+), 34 deletions(-)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index ddc93f2..bf9bab4 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -47,7 +47,6 @@ #include "wine/winuser16.h" #include "winternl.h" #include "kernel_private.h" -#include "wine/exception.h" #include "wine/server.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -930,38 +929,29 @@ static void start_wineboot( HANDLE handles[2] ) * * Startup routine of a new process. Runs on the new process stack. */ -static void start_process( void *arg ) +static DWORD WINAPI start_process( PEB *peb ) { - __TRY - { - PEB *peb = NtCurrentTeb()->Peb; - IMAGE_NT_HEADERS *nt; - LPTHREAD_START_ROUTINE entry; - - nt = RtlImageNtHeader( peb->ImageBaseAddress ); - entry = (LPTHREAD_START_ROUTINE)((char *)peb->ImageBaseAddress + - nt->OptionalHeader.AddressOfEntryPoint); - - if (!nt->OptionalHeader.AddressOfEntryPoint) - { - ERR( "%s doesn't have an entry point, it cannot be executed\n", - debugstr_w(peb->ProcessParameters->ImagePathName.Buffer) ); - ExitThread( 1 ); - } + IMAGE_NT_HEADERS *nt; + LPTHREAD_START_ROUTINE entry;
- if (TRACE_ON(relay)) - DPRINTF( "%04x:Starting process %s (entryproc=%p)\n", GetCurrentThreadId(), - debugstr_w(peb->ProcessParameters->ImagePathName.Buffer), entry ); + nt = RtlImageNtHeader( peb->ImageBaseAddress ); + entry = (LPTHREAD_START_ROUTINE)((char *)peb->ImageBaseAddress + + nt->OptionalHeader.AddressOfEntryPoint);
- SetLastError( 0 ); /* clear error code */ - if (peb->BeingDebugged) DbgBreakPoint(); - ExitThread( entry( peb ) ); - } - __EXCEPT(UnhandledExceptionFilter) + if (!nt->OptionalHeader.AddressOfEntryPoint) { - TerminateThread( GetCurrentThread(), GetExceptionCode() ); + ERR( "%s doesn't have an entry point, it cannot be executed\n", + debugstr_w(peb->ProcessParameters->ImagePathName.Buffer) ); + ExitThread( 1 ); } - __ENDTRY + + if (TRACE_ON(relay)) + DPRINTF( "%04x:Starting process %s (entryproc=%p)\n", GetCurrentThreadId(), + debugstr_w(peb->ProcessParameters->ImagePathName.Buffer), entry ); + + SetLastError( 0 ); /* clear error code */ + if (peb->BeingDebugged) DbgBreakPoint(); + return entry( peb ); }
@@ -1125,9 +1115,7 @@ void CDECL __wine_kernel_init(void) ExitProcess( error ); }
- LdrInitializeThunk( 0, 0, 0, 0 ); - /* switch to the new stack */ - wine_switch_to_stack( start_process, NULL, NtCurrentTeb()->Tib.StackBase ); + LdrInitializeThunk( start_process, 0, 0, 0 );
error: ExitProcess( GetLastError() ); diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index a3db3b2..df4bb01 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -2444,11 +2444,20 @@ static NTSTATUS attach_process_dlls( void *wm ) }
+/*********************************************************************** + * start_process + */ +static void start_process( void *kernel_start ) +{ + call_thread_entry_point( kernel_start, NtCurrentTeb()->Peb ); +} + /****************************************************************** * LdrInitializeThunk (NTDLL.@) * */ -void WINAPI LdrInitializeThunk( ULONG unknown1, ULONG unknown2, ULONG unknown3, ULONG unknown4 ) +void WINAPI LdrInitializeThunk( void *kernel_start, ULONG_PTR unknown2, + ULONG_PTR unknown3, ULONG_PTR unknown4 ) { NTSTATUS status; WINE_MODREF *wm; @@ -2489,7 +2498,7 @@ void WINAPI LdrInitializeThunk( ULONG unknown1, ULONG unknown2, ULONG unknown3,
virtual_release_address_space( nt->FileHeader.Characteristics & IMAGE_FILE_LARGE_ADDRESS_AWARE ); virtual_clear_thread_stack(); - return; + wine_switch_to_stack( start_process, kernel_start, NtCurrentTeb()->Tib.StackBase );
error: ERR( "Main exe initialization for %s failed, status %x\n", diff --git a/include/winternl.h b/include/winternl.h index aca74e5..07c778c 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -1980,7 +1980,7 @@ NTSYSAPI NTSTATUS WINAPI LdrDisableThreadCalloutsForDll(HMODULE); NTSYSAPI NTSTATUS WINAPI LdrFindEntryForAddress(const void*, PLDR_MODULE*); NTSYSAPI NTSTATUS WINAPI LdrGetDllHandle(LPCWSTR, ULONG, const UNICODE_STRING*, HMODULE*); NTSYSAPI NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE, const ANSI_STRING*, ULONG, void**); -NTSYSAPI void WINAPI LdrInitializeThunk(ULONG,ULONG,ULONG,ULONG); +NTSYSAPI void WINAPI LdrInitializeThunk(void*,ULONG_PTR,ULONG_PTR,ULONG_PTR); NTSYSAPI NTSTATUS WINAPI LdrLoadDll(LPCWSTR, DWORD, const UNICODE_STRING*, HMODULE*); NTSYSAPI NTSTATUS WINAPI LdrLockLoaderLock(ULONG,ULONG*,ULONG*); IMAGE_BASE_RELOCATION * WINAPI LdrProcessRelocationBlock(void*,UINT,USHORT*,INT_PTR);