Alexandre Julliard : ntdll: Move the calling of the process entry point back to kernel32.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jul 31 15:01:22 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 6f7b1f646389f850bc48abf79271037455fc91c6
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=6f7b1f646389f850bc48abf79271037455fc91c6

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Jul 31 21:25:29 2006 +0200

ntdll: Move the calling of the process entry point back to kernel32.

Apparently some copy protection stuff relies on that.
This reverts commit 50fca716fddf5af03b4c91ae5e950daff5fbdf2a.

---

 dlls/kernel/process.c |   17 +++++++++++++++++
 dlls/ntdll/loader.c   |   15 ++-------------
 include/winternl.h    |    2 +-
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/dlls/kernel/process.c b/dlls/kernel/process.c
index a2ab351..7092d2c 100644
--- a/dlls/kernel/process.c
+++ b/dlls/kernel/process.c
@@ -60,6 +60,7 @@ #endif
 
 WINE_DEFAULT_DEBUG_CHANNEL(process);
 WINE_DECLARE_DEBUG_CHANNEL(file);
+WINE_DECLARE_DEBUG_CHANNEL(relay);
 
 typedef struct
 {
@@ -802,7 +803,23 @@ static void start_process( void *arg )
 {
     __TRY
     {
+        PEB *peb = NtCurrentTeb()->Peb;
+        IMAGE_NT_HEADERS *nt;
+        LPTHREAD_START_ROUTINE entry;
+
         LdrInitializeThunk( 0, 0, 0, 0 );
+
+        nt = RtlImageNtHeader( peb->ImageBaseAddress );
+        entry = (LPTHREAD_START_ROUTINE)((char *)peb->ImageBaseAddress +
+                                         nt->OptionalHeader.AddressOfEntryPoint);
+
+        if (TRACE_ON(relay))
+            DPRINTF( "%04lx:Starting process %s (entryproc=%p)\n", GetCurrentThreadId(),
+                     debugstr_w(peb->ProcessParameters->ImagePathName.Buffer), entry );
+
+        SetLastError( 0 );  /* clear error code */
+        if (peb->BeingDebugged) DbgBreakPoint();
+        ExitProcess( entry( peb ) );
     }
     __EXCEPT(UnhandledExceptionFilter)
     {
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index d3a3d78..184f64f 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -2094,8 +2094,6 @@ void WINAPI LdrInitializeThunk( ULONG un
     LPCWSTR load_path;
     PEB *peb = NtCurrentTeb()->Peb;
     IMAGE_NT_HEADERS *nt = RtlImageNtHeader( peb->ImageBaseAddress );
-    LPTHREAD_START_ROUTINE entry = (LPTHREAD_START_ROUTINE)((char *)peb->ImageBaseAddress +
-                                                            nt->OptionalHeader.AddressOfEntryPoint);
 
     if (main_exe_file) NtClose( main_exe_file );  /* at this point the main module is created */
 
@@ -2128,7 +2126,7 @@ void WINAPI LdrInitializeThunk( ULONG un
     SERVER_START_REQ( init_process_done )
     {
         req->module = peb->ImageBaseAddress;
-        req->entry  = entry;
+        req->entry  = (char *)peb->ImageBaseAddress + nt->OptionalHeader.AddressOfEntryPoint;
         req->gui    = (nt->OptionalHeader.Subsystem != IMAGE_SUBSYSTEM_WINDOWS_CUI);
         status = wine_server_call( req );
     }
@@ -2153,16 +2151,7 @@ void WINAPI LdrInitializeThunk( ULONG un
     RtlLeaveCriticalSection( &loader_section );
 
     if (nt->FileHeader.Characteristics & IMAGE_FILE_LARGE_ADDRESS_AWARE) VIRTUAL_UseLargeAddressSpace();
-
-    if (TRACE_ON(relay))
-        DPRINTF( "%04lx:Starting process %s (entryproc=%p)\n", GetCurrentThreadId(),
-                 debugstr_w(peb->ProcessParameters->ImagePathName.Buffer), entry );
-
-    RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_SUCCESS );  /* clear error code */
-    if (peb->BeingDebugged) DbgBreakPoint();
-    status = entry( peb );
-    LdrShutdownProcess();
-    NtTerminateProcess( GetCurrentProcess(), status );
+    return;
 
 error:
     ERR( "Main exe initialization for %s failed, status %lx\n",
diff --git a/include/winternl.h b/include/winternl.h
index c8aa3ed..5177348 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -1726,7 +1726,7 @@ NTSTATUS  WINAPI LdrFindResourceDirector
 NTSTATUS  WINAPI LdrFindResource_U(HMODULE,const LDR_RESOURCE_INFO*,ULONG,const IMAGE_RESOURCE_DATA_ENTRY**);
 NTSTATUS  WINAPI LdrGetDllHandle(ULONG, ULONG, const UNICODE_STRING*, HMODULE*);
 NTSTATUS  WINAPI LdrGetProcedureAddress(HMODULE, const ANSI_STRING*, ULONG, void**);
-void DECLSPEC_NORETURN WINAPI LdrInitializeThunk(ULONG,ULONG,ULONG,ULONG);
+void      WINAPI LdrInitializeThunk(ULONG,ULONG,ULONG,ULONG);
 NTSTATUS  WINAPI LdrLoadDll(LPCWSTR, DWORD, const UNICODE_STRING*, HMODULE*);
 void      WINAPI LdrShutdownProcess(void);
 void      WINAPI LdrShutdownThread(void);




More information about the wine-cvs mailing list