Hi,
I have a game (Last Chaos USA by AeriaGames) which does not start up the main game due to a bug in its toolhelp snaphot handling.
It does: h = CreateToolhelp32Snapshot(); Process32First(h, &x); while (Process32Next(h,&x)) { /* check x */ }
So it discards the very first entry we return from the snapshot. However it is looking for itself here and in current Wine it is in the first entry, ... so failure.
So I reorder the list to be backwards and it works better then.
BUT I would like to test run it on windows first, so can someone please run following patch against a real Windows?
Thanks & Ciao, Marcus
diff --git a/dlls/kernel32/tests/toolhelp.c b/dlls/kernel32/tests/toolhelp.c index ca9c06c..f135abb 100644 --- a/dlls/kernel32/tests/toolhelp.c +++ b/dlls/kernel32/tests/toolhelp.c @@ -108,6 +108,7 @@ static void test_process(DWORD curr_pid, MODULEENTRY32 me; unsigned found = 0; int num = 0; + int pos1 = -1 , pos2 = -1;
hSnapshot = pCreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); ok(hSnapshot != NULL, "Cannot create snapshot\n"); @@ -118,8 +119,8 @@ static void test_process(DWORD curr_pid, { do { - if (pe.th32ProcessID == curr_pid) found++; - if (pe.th32ProcessID == sub_pcs_pid) found++; + if (pe.th32ProcessID == curr_pid) { pos1 = num; found++; } + if (pe.th32ProcessID == sub_pcs_pid) { pos2 = num; found++; } trace("PID=%x %s\n", pe.th32ProcessID, pe.szExeFile); num++; } while (pProcess32Next( hSnapshot, &pe )); @@ -141,6 +142,9 @@ static void test_process(DWORD curr_pid, ok(found == 2, "couldn't find self and/or sub-process in process list\n"); ok(!num, "mismatch in counting\n");
+ ok (pos2 == 1, "new process at position %d in snapshot, expected 1.\n", pos2); + ok (pos1 == 0, "this process at position %d in snapshot, expected 0.\n", pos1); + te.dwSize = sizeof(te); ok(!pThread32First( hSnapshot, &te ), "shouldn't return a thread\n");
On Monday 08 October 2007 23:25:06 Marcus Meissner wrote:
BUT I would like to test run it on windows first, so can someone please run following patch against a real Windows?
toolhelp.c:145: Test failed: new process at position 26 in snapshot, expected 1. toolhelp.c:146: Test failed: this process at position 25 in snapshot, expected 0.
-Hans
On Tue, Oct 09, 2007 at 11:20:49AM +0200, Hans Leidekker wrote:
On Monday 08 October 2007 23:25:06 Marcus Meissner wrote:
BUT I would like to test run it on windows first, so can someone please run following patch against a real Windows?
toolhelp.c:145: Test failed: new process at position 26 in snapshot, expected 1. toolhelp.c:146: Test failed: this process at position 25 in snapshot, expected 0.
Hmm, windows has more processes running of course.
Can you revert the above and use this simpler check? (and try running it some times to see randomness, if any.)
Ciao, Marcus
diff --git a/dlls/kernel32/tests/toolhelp.c b/dlls/kernel32/tests/toolhelp.c index ca9c06c..b9e17c6 100644 --- a/dlls/kernel32/tests/toolhelp.c +++ b/dlls/kernel32/tests/toolhelp.c @@ -108,6 +108,7 @@ static void test_process(DWORD curr_pid, MODULEENTRY32 me; unsigned found = 0; int num = 0; + int pos1 = -1 , pos2 = -1;
hSnapshot = pCreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); ok(hSnapshot != NULL, "Cannot create snapshot\n"); @@ -118,8 +119,8 @@ static void test_process(DWORD curr_pid, { do { - if (pe.th32ProcessID == curr_pid) found++; - if (pe.th32ProcessID == sub_pcs_pid) found++; + if (pe.th32ProcessID == curr_pid) { pos1 = num; found++; } + if (pe.th32ProcessID == sub_pcs_pid) { pos2 = num; found++; } trace("PID=%x %s\n", pe.th32ProcessID, pe.szExeFile); num++; } while (pProcess32Next( hSnapshot, &pe )); @@ -141,6 +142,8 @@ static void test_process(DWORD curr_pid, ok(found == 2, "couldn't find self and/or sub-process in process list\n"); ok(!num, "mismatch in counting\n");
+ ok (pos2 > pos1, "father at pos %d, son at pos %d, expect son after father.\n", pos2, pos1); + te.dwSize = sizeof(te); ok(!pThread32First( hSnapshot, &te ), "shouldn't return a thread\n");
On Thursday 11 October 2007 08:45:40 Marcus Meissner wrote:
Hmm, windows has more processes running of course.
Can you revert the above and use this simpler check? (and try running it some times to see randomness, if any.)
This version succeeds repeatedly, while starting several new processes in between runs.
-Hans
On Do, 2007-10-11 at 08:45 +0200, Marcus Meissner wrote:
int num = 0;
- int pos1 = -1 , pos2 = -1;
You mix SPACE and TAB. Thanks
(The updated test works in w2k here)