Commit c9d85dd5 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Route the process startup through the platform-specific thread startup code.

parent 8824deb6
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#include "wine/winuser16.h" #include "wine/winuser16.h"
#include "winternl.h" #include "winternl.h"
#include "kernel_private.h" #include "kernel_private.h"
#include "wine/exception.h"
#include "wine/server.h" #include "wine/server.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
...@@ -930,11 +929,8 @@ static void start_wineboot( HANDLE handles[2] ) ...@@ -930,11 +929,8 @@ static void start_wineboot( HANDLE handles[2] )
* *
* Startup routine of a new process. Runs on the new process stack. * 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; IMAGE_NT_HEADERS *nt;
LPTHREAD_START_ROUTINE entry; LPTHREAD_START_ROUTINE entry;
...@@ -955,13 +951,7 @@ static void start_process( void *arg ) ...@@ -955,13 +951,7 @@ static void start_process( void *arg )
SetLastError( 0 ); /* clear error code */ SetLastError( 0 ); /* clear error code */
if (peb->BeingDebugged) DbgBreakPoint(); if (peb->BeingDebugged) DbgBreakPoint();
ExitThread( entry( peb ) ); return entry( peb );
}
__EXCEPT(UnhandledExceptionFilter)
{
TerminateThread( GetCurrentThread(), GetExceptionCode() );
}
__ENDTRY
} }
...@@ -1125,9 +1115,7 @@ void CDECL __wine_kernel_init(void) ...@@ -1125,9 +1115,7 @@ void CDECL __wine_kernel_init(void)
ExitProcess( error ); ExitProcess( error );
} }
LdrInitializeThunk( 0, 0, 0, 0 ); LdrInitializeThunk( start_process, 0, 0, 0 );
/* switch to the new stack */
wine_switch_to_stack( start_process, NULL, NtCurrentTeb()->Tib.StackBase );
error: error:
ExitProcess( GetLastError() ); ExitProcess( GetLastError() );
......
...@@ -2444,11 +2444,20 @@ static NTSTATUS attach_process_dlls( void *wm ) ...@@ -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.@) * 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; NTSTATUS status;
WINE_MODREF *wm; WINE_MODREF *wm;
...@@ -2489,7 +2498,7 @@ void WINAPI LdrInitializeThunk( ULONG unknown1, ULONG unknown2, ULONG unknown3, ...@@ -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_release_address_space( nt->FileHeader.Characteristics & IMAGE_FILE_LARGE_ADDRESS_AWARE );
virtual_clear_thread_stack(); virtual_clear_thread_stack();
return; wine_switch_to_stack( start_process, kernel_start, NtCurrentTeb()->Tib.StackBase );
error: error:
ERR( "Main exe initialization for %s failed, status %x\n", ERR( "Main exe initialization for %s failed, status %x\n",
......
...@@ -1980,7 +1980,7 @@ NTSYSAPI NTSTATUS WINAPI LdrDisableThreadCalloutsForDll(HMODULE); ...@@ -1980,7 +1980,7 @@ NTSYSAPI NTSTATUS WINAPI LdrDisableThreadCalloutsForDll(HMODULE);
NTSYSAPI NTSTATUS WINAPI LdrFindEntryForAddress(const void*, PLDR_MODULE*); NTSYSAPI NTSTATUS WINAPI LdrFindEntryForAddress(const void*, PLDR_MODULE*);
NTSYSAPI NTSTATUS WINAPI LdrGetDllHandle(LPCWSTR, ULONG, const UNICODE_STRING*, HMODULE*); NTSYSAPI NTSTATUS WINAPI LdrGetDllHandle(LPCWSTR, ULONG, const UNICODE_STRING*, HMODULE*);
NTSYSAPI NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE, const ANSI_STRING*, ULONG, void**); 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 LdrLoadDll(LPCWSTR, DWORD, const UNICODE_STRING*, HMODULE*);
NTSYSAPI NTSTATUS WINAPI LdrLockLoaderLock(ULONG,ULONG*,ULONG*); NTSYSAPI NTSTATUS WINAPI LdrLockLoaderLock(ULONG,ULONG*,ULONG*);
IMAGE_BASE_RELOCATION * WINAPI LdrProcessRelocationBlock(void*,UINT,USHORT*,INT_PTR); IMAGE_BASE_RELOCATION * WINAPI LdrProcessRelocationBlock(void*,UINT,USHORT*,INT_PTR);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment