http://bugs.winehq.org/show_bug.cgi?id=23772
Summary: The bug in NtQueryInformationProcess with ProcessInformationClass = ProcessDebugObjectHandle Product: Wine Version: unspecified Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: ntdll AssignedTo: wine-bugs@winehq.org ReportedBy: info@vmpsoft.com
The file http://source.winehq.org/source/dlls/ntdll/process.c has a bug in NtQueryInformationProcess with ProcessInformationClass = ProcessDebugObjectHandle
112 NTSTATUS ret = STATUS_SUCCESS; 113 ULONG len = 0; ... 319 case ProcessDebugObjectHandle: 320 /* "These are not the debuggers you are looking for." * 321 * set it to 0 aka "no debugger" to satisfy copy protections */ 322 len = sizeof(HANDLE); 323 if (ProcessInformationLength == len) 324 { 325 if (!ProcessInformation) 326 ret = STATUS_ACCESS_VIOLATION; 327 else if (!ProcessHandle) 328 ret = STATUS_INVALID_HANDLE; 329 else 330 memset(ProcessInformation, 0, ProcessInformationLength); 331 } 332 else 333 ret = STATUS_INFO_LENGTH_MISMATCH; 334 break;
In the real Windows system without active debugger the result (the variable "res") of that API is C0000353 but in WINE the result is 00000000.
http://bugs.winehq.org/show_bug.cgi?id=23772
Dmitry Timoshkov dmitry@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |1.2
--- Comment #1 from Dmitry Timoshkov dmitry@codeweavers.com 2010-07-24 00:45:20 --- What application is affected by this? Do you have a test case?
http://bugs.winehq.org/show_bug.cgi?id=23772
--- Comment #2 from Ivan Permyakov info@vmpsoft.com 2010-07-24 08:23:56 --- We are vendors of VMProtect - software protection system (http://www.vmpsoft.com). Protected applications can not start under wine if the debug protection is enabled. We investigated this and found that the problem is in this function. You may test this protected application: http://www.vmpsoft.com/downloads/wine_sample.rar
http://bugs.winehq.org/show_bug.cgi?id=23772
--- Comment #3 from Dmitry Timoshkov dmitry@codeweavers.com 2010-07-25 00:52:48 --- Please create a simple test case which replicates this problem. Ideally as a part of existing ntdll Wine tests.
http://bugs.winehq.org/show_bug.cgi?id=23772
--- Comment #4 from Ivan Permyakov info@vmpsoft.com 2010-07-25 06:31:09 --- ------------ first diff ------------
diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c index 6fdceae..fb8bc3b 100644 --- a/dlls/ntdll/process.c +++ b/dlls/ntdll/process.c @@ -327,7 +327,7 @@ NTSTATUS WINAPI NtQueryInformationProcess( else if (!ProcessHandle) ret = STATUS_INVALID_HANDLE; else - memset(ProcessInformation, 0, ProcessInformationLength); + ret = STATUS_PORT_NOT_SET; /* Windows doesn't clean the ProcessInformation field here */ } else ret = STATUS_INFO_LENGTH_MISMATCH;
------------ second diff ------------
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index 13c29f8..8b77419 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -837,6 +837,18 @@ static void test_query_process_debug_port(int argc, char **argv) ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError()); }
+static void test_query_process_debug_object_handle(int argc, char **argv) +{ + HANDLE debug_handle = 0xdeadbeef; + NTSTATUS status; + + status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessDebugObjectHandle, + &debug_handle, sizeof(debug_handle), NULL); + + ok(status == STATUS_PORT_NOT_SET, "NtQueryInformationProcess failed, status %#x.\n", status); + ok(debug_handle == 0xdeadbeef, "Expected handle 0xdeadbeef, got %#lx.\n", debug_handle); +} + static void test_query_process_handlecount(void) { NTSTATUS status; @@ -1198,6 +1210,10 @@ START_TEST(info) trace("Starting test_process_debug_port()\n"); test_query_process_debug_port(argc, argv);
+ /* 0x1E ProcessDebugObjectHandle */ + trace("Starting test_query_process_debug_object_handle()\n"); + test_query_process_debug_object_handle(argc, argv) + /* 0x14 ProcessHandleCount */ trace("Starting test_query_process_handlecount()\n"); test_query_process_handlecount();
http://bugs.winehq.org/show_bug.cgi?id=23772
Louis Lenders xerox_xerox2000@yahoo.co.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW CC| |xerox_xerox2000@yahoo.co.uk Ever Confirmed|0 |1
--- Comment #5 from Louis Lenders xerox_xerox2000@yahoo.co.uk 2010-07-25 13:32:26 --- Hi Ivan, thanks for adding the test. I ran your test on WinXP (bit modified as it didn't compile for me) but the second test fails for me:
ok(debug_handle == 0xdeadbeef, "Expected handle 0xdeadbeef, got %#lx.\n", debug_handle);
On WinXP I get: Test failed: Expected handle 0xdeadbeef, got 0"
Looks like windows sets the debughandle to 0. On what system did you run the test?
http://bugs.winehq.org/show_bug.cgi?id=23772
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, testcase
http://bugs.winehq.org/show_bug.cgi?id=23772
--- Comment #6 from Ivan Permyakov info@vmpsoft.com 2010-07-25 21:16:19 --- On Windows 7 I have 0xdeadbeef in debughandle.
http://bugs.winehq.org/show_bug.cgi?id=23772
--- Comment #7 from Austin English austinenglish@gmail.com 2010-07-25 23:58:51 --- (In reply to comment #6)
On Windows 7 I have 0xdeadbeef in debughandle.
I tried it on WineTestBot: https://testbot.winehq.org/JobDetails.pl?Key=3894
seems to vary between windows versions.
http://bugs.winehq.org/show_bug.cgi?id=23772
--- Comment #8 from Ivan Permyakov info@vmpsoft.com 2010-07-26 05:53:44 --- Regardless of parameter's zeroing, the returned status is essential. You may leave memset() if you wish, just return the correct status instead of 0.
http://bugs.winehq.org/show_bug.cgi?id=23772
Andrew Nguyen arethusa26@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED
--- Comment #9 from Andrew Nguyen arethusa26@gmail.com 2010-07-28 11:15:00 --- A patch that fixes the return value was committed:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=d7956bab541fde38f4b3f5...
http://bugs.winehq.org/show_bug.cgi?id=23772
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #10 from Alexandre Julliard julliard@winehq.org 2010-07-30 12:59:49 --- Closing bugs fixed in 1.3.0.
http://bugs.winehq.org/show_bug.cgi?id=23772
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |1.2.x
http://bugs.winehq.org/show_bug.cgi?id=23772
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|1.2.x |---
--- Comment #11 from Alexandre Julliard julliard@winehq.org 2010-10-08 10:40:25 CDT --- Removing 1.2.x milestone from bugs fixed in 1.2.1.
https://bugs.winehq.org/show_bug.cgi?id=23772
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |d7956bab541fde38f4b3f5011b2 | |09fa7d9989c30 CC| |focht@gmx.net