[PATCH V3 2/2] kernel32: Adjust toolhelp thread return order.

Changping Yu dead.ash at hotmail.com
Fri Jun 19 02:05:11 CDT 2020


-------------- next part --------------
>From 311f5186acea7b81c3b636a56fe0c63f9b1a0e6b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BD=99=E6=98=8C=E5=B9=B3?= <yuchangping at deepin.com>
Date: Fri, 19 Jun 2020 15:00:45 +0800
Subject: [PATCH V3 2/2] kernel32: Adjust toolhelp thread return order.

v3: delete todo_wine

Some software incorrectly uses the way to get the main thread id. 
Coincidentally, the threads of wine and windows return differently.
The list of threads returned by flipping can be consistent with windows.

Signed-off-by: Changping Yu <dead.ash at hotmail.com>
---
 dlls/kernel32/tests/toolhelp.c | 2 --
 dlls/kernel32/toolhelp.c       | 6 +++---
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/dlls/kernel32/tests/toolhelp.c b/dlls/kernel32/tests/toolhelp.c
index e054f13c2a..2f694b24cd 100644
--- a/dlls/kernel32/tests/toolhelp.c
+++ b/dlls/kernel32/tests/toolhelp.c
@@ -208,7 +208,6 @@ static void test_main_thread(DWORD curr_pid, DWORD main_tid)
 
     /* check that the main thread id is first one in this thread. */
     first_tid = get_id_thread((void *)curr_pid);
-    todo_wine
     ok(first_tid == main_tid, "check main thread is error, main is %d, %d\n", main_tid, first_tid);
 
     /* check that the main thread id is first one in other thread. */
@@ -217,7 +216,6 @@ static void test_main_thread(DWORD curr_pid, DWORD main_tid)
     ok(error == WAIT_OBJECT_0, "Thread did not complete within timelimit\n");
 
     ok(GetExitCodeThread(thread, &first_tid), "Could not retrieve ext code\n");
-    todo_wine
     ok(first_tid == main_tid, "check main thread is error, main is %d, %d\n", main_tid, first_tid);
 }
 
diff --git a/dlls/kernel32/toolhelp.c b/dlls/kernel32/toolhelp.c
index d55e8185f2..26a8258e0a 100644
--- a/dlls/kernel32/toolhelp.c
+++ b/dlls/kernel32/toolhelp.c
@@ -359,11 +359,11 @@ static BOOL next_thread( HANDLE hSnapShot, LPTHREADENTRY32 lpte, BOOL first )
     }
     if ((snap = MapViewOfFile( hSnapShot, FILE_MAP_ALL_ACCESS, 0, 0, 0 )))
     {
-        if (first) snap->thread_pos = 0;
-        if (snap->thread_pos < snap->thread_count)
+        if (first) snap->thread_pos = snap->thread_count - 1;
+        if (snap->thread_pos >= 0)
         {
             LPTHREADENTRY32 te = (THREADENTRY32*)&snap->data[snap->thread_offset];
-            *lpte = te[snap->thread_pos++];
+            *lpte = te[snap->thread_pos--];
             ret = TRUE;
         }
         else SetLastError( ERROR_NO_MORE_FILES );
-- 
2.26.1.windows.1



More information about the wine-devel mailing list