[PATCH 1/2] ntdll/tests: Add more HideFromDebugger tests.

Rémi Bernon rbernon at codeweavers.com
Fri Jun 26 04:27:28 CDT 2020


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---

537bb7a8aee278d285cb77669fd9258dfaa3222f was potentially involved in a
Diablo III regression, where NtSetInformationThread previously returned
success for any thread, where it then only succeeded with the current
thread.

This series should implement the HideFromDebugger request correctly,
checking handles and access rights on the server side. The hiding part
is still not implemented, but it could then use the dbg_hidden field on
the thread structure if we want to implement the debugger side.

According to the kernel32 thread test, HideFromDebugger can only be
queried with QUERY_INFORMATION rights, and not QUERY_LIMITED_INFORMATION
thus the additional field in the get_thread_info request.

 dlls/ntdll/tests/info.c | 46 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index eaf2f1a45b7..b91d54375ce 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -2346,7 +2346,6 @@ static void test_affinity(void)
     DWORD_PTR proc_affinity, thread_affinity;
     THREAD_BASIC_INFORMATION tbi;
     SYSTEM_INFO si;
-    ULONG dummy;
 
     GetSystemInfo(&si);
     status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL );
@@ -2451,6 +2450,20 @@ static void test_affinity(void)
     ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
     ok( tbi.AffinityMask == (1 << si.dwNumberOfProcessors) - 1,
         "Unexpected thread affinity\n" );
+}
+
+static DWORD WINAPI hide_from_debugger_thread(void *arg)
+{
+    HANDLE stop_event = arg;
+    WaitForSingleObject( stop_event, INFINITE );
+    return 0;
+}
+
+static void test_HideFromDebugger(void)
+{
+    NTSTATUS status;
+    HANDLE thread, stop_event;
+    ULONG dummy;
 
     dummy = 0;
     status = pNtSetInformationThread( GetCurrentThread(), ThreadHideFromDebugger, &dummy, sizeof(ULONG) );
@@ -2477,6 +2490,34 @@ static void test_affinity(void)
         ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status );
         if (status == STATUS_SUCCESS) ok( dummy == 1, "Expected dummy == 1, got %08x\n", dummy );
     }
+
+    stop_event = CreateEventA( NULL, FALSE, FALSE, NULL );
+    ok( stop_event != NULL, "CreateEvent failed\n" );
+    thread = CreateThread( NULL, 0, hide_from_debugger_thread, stop_event, 0, NULL );
+    ok( thread != INVALID_HANDLE_VALUE, "CreateThread failed with %d\n", GetLastError() );
+
+    dummy = 0;
+    status = NtQueryInformationThread( thread, ThreadHideFromDebugger, &dummy, 1, NULL );
+    todo_wine
+    ok( status == STATUS_SUCCESS || status == STATUS_INVALID_INFO_CLASS,
+        "Expected STATUS_SUCCESS, got %08x\n", status );
+    if (status == STATUS_SUCCESS) ok( dummy == 0, "Expected dummy == 0, got %08x\n", dummy );
+
+    status = pNtSetInformationThread( thread, ThreadHideFromDebugger, NULL, 0 );
+    todo_wine
+    ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status );
+
+    dummy = 0;
+    status = NtQueryInformationThread( thread, ThreadHideFromDebugger, &dummy, 1, NULL );
+    todo_wine
+    ok( status == STATUS_SUCCESS || status == STATUS_INVALID_INFO_CLASS,
+        "Expected STATUS_SUCCESS, got %08x\n", status );
+    if (status == STATUS_SUCCESS) ok( dummy == 1, "Expected dummy == 1, got %08x\n", dummy );
+
+    SetEvent( stop_event );
+    WaitForSingleObject( thread, INFINITE );
+    CloseHandle( thread );
+    CloseHandle( stop_event );
 }
 
 static void test_NtGetCurrentProcessorNumber(void)
@@ -2817,6 +2858,9 @@ START_TEST(info)
     trace("Starting test_affinity()\n");
     test_affinity();
 
+    trace("Starting test_HideFromDebugger()\n");
+    test_HideFromDebugger();
+
     trace("Starting test_NtGetCurrentProcessorNumber()\n");
     test_NtGetCurrentProcessorNumber();
 
-- 
2.27.0




More information about the wine-devel mailing list