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

Changping Yu dead.ash at hotmail.com
Fri Jun 19 01:40:24 CDT 2020


-------------- next part --------------
>From 1a425b1605957e1a7aaa8fb50b97a4f3129f86c7 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 14:29:04 +0800
Subject: [PATCH V3 2/2] kernel32: Adjust toolhelp thread return order.

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/toolhelp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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