server: Store correct entry point for first thread.

Sebastian Lackner sebastian at fds-team.de
Thu Jul 30 00:16:36 CDT 2015


---
 dlls/ntdll/tests/info.c |   12 ++++++++++--
 server/process.c        |    1 +
 server/thread.c         |    2 +-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index 83e8757..4111be4 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -1713,18 +1713,26 @@ static DWORD WINAPI start_address_thread(void *arg)
 
 static void test_thread_start_address(void)
 {
-    PRTL_THREAD_START_ROUTINE entry;
+    PRTL_THREAD_START_ROUTINE entry, expected_entry;
+    IMAGE_NT_HEADERS *nt;
     NTSTATUS status;
     HANDLE thread;
+    void *module;
     DWORD ret;
 
+    module = GetModuleHandleA(0);
+    ok(module != NULL, "expected non-NULL address for module\n");
+    nt = RtlImageNtHeader(module);
+    ok(nt != NULL, "expected non-NULL address for NT header\n");
+
     entry = NULL;
     ret = 0xdeadbeef;
     status = pNtQueryInformationThread(GetCurrentThread(), ThreadQuerySetWin32StartAddress,
                                        &entry, sizeof(entry), &ret);
     ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
     ok(ret == sizeof(entry), "NtQueryInformationThread returned %u bytes\n", ret);
-    ok(entry != NULL, "expected non-NULL entry point\n");
+    expected_entry = (void *)((char *)module + nt->OptionalHeader.AddressOfEntryPoint);
+    ok(entry == expected_entry, "expected %p, got %p\n", expected_entry, entry);
 
     entry = (void *)0xdeadbeef;
     status = pNtSetInformationThread(GetCurrentThread(), ThreadQuerySetWin32StartAddress,
diff --git a/server/process.c b/server/process.c
index 0bf7194..7252497 100644
--- a/server/process.c
+++ b/server/process.c
@@ -1295,6 +1295,7 @@ DECL_HANDLER(init_process_done)
 
     process->ldt_copy = req->ldt_copy;
     process->start_time = current_time;
+    current->entry_point = req->entry;
 
     generate_startup_debug_events( process, req->entry );
     set_process_startup_state( process, STARTUP_DONE );
diff --git a/server/thread.c b/server/thread.c
index 981bcc1..e1696ba 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -1287,7 +1287,7 @@ DECL_HANDLER(init_thread)
     current->unix_pid = req->unix_pid;
     current->unix_tid = req->unix_tid;
     current->teb      = req->teb;
-    current->entry_point = req->entry;
+    current->entry_point = process->peb ? req->entry : 0;
 
     if (!process->peb)  /* first thread, initialize the process too */
     {
-- 
2.4.5



More information about the wine-patches mailing list