Rémi Bernon : ntdll/tests: Test that ptids are multiples of four.

Alexandre Julliard julliard at winehq.org
Mon Apr 27 15:19:29 CDT 2020


Module: wine
Branch: master
Commit: 8bb684c63e02cabde0908b9b22d0bad3f044b214
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=8bb684c63e02cabde0908b9b22d0bad3f044b214

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Sat Apr 25 10:05:08 2020 +0200

ntdll/tests: Test that ptids are multiples of four.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/tests/info.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index 8dc8bad645..1576f5ca97 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -319,6 +319,11 @@ static void test_query_process(void)
     int i = 0, k = 0;
     BOOL is_nt = FALSE;
     SYSTEM_BASIC_INFORMATION sbi;
+    PROCESS_BASIC_INFORMATION pbi;
+    THREAD_BASIC_INFORMATION tbi;
+    OBJECT_ATTRIBUTES attr;
+    CLIENT_ID cid;
+    HANDLE handle;
 
     /* Copy of our winternl.h structure turned into a private one */
     typedef struct _SYSTEM_PROCESS_INFORMATION_PRIVATE {
@@ -401,13 +406,21 @@ static void test_query_process(void)
         
         if (!is_nt)
         {
+            DWORD_PTR tid;
             DWORD j;
+
+            todo_wine_if(last_pid & 3)
+            ok(!(last_pid & 3), "Unexpected PID low bits: %p\n", spi->UniqueProcessId);
             for ( j = 0; j < spi->dwThreadCount; j++) 
             {
                 k++;
                 ok ( spi->ti[j].ClientId.UniqueProcess == spi->UniqueProcessId,
                      "The owning pid of the thread (%p) doesn't equal the pid (%p) of the process\n",
                      spi->ti[j].ClientId.UniqueProcess, spi->UniqueProcessId);
+
+                tid = (DWORD_PTR)spi->ti[j].ClientId.UniqueThread;
+                todo_wine_if(tid & 3)
+                ok(!(tid & 3), "Unexpected TID low bits: %p\n", spi->ti[j].ClientId.UniqueThread);
             }
         }
 
@@ -423,6 +436,52 @@ static void test_query_process(void)
     if (one_before_last_pid == 0) one_before_last_pid = last_pid;
 
     HeapFree( GetProcessHeap(), 0, spi_buf);
+
+    if (is_nt)
+    {
+        win_skip("skipping ptids low bits tests\n");
+        return;
+    }
+
+    for (i = 1; i < 4; ++i)
+    {
+        InitializeObjectAttributes( &attr, NULL, 0, NULL, NULL );
+        cid.UniqueProcess = ULongToHandle(GetCurrentProcessId() + i);
+        cid.UniqueThread = 0;
+
+        status = NtOpenProcess( &handle, PROCESS_QUERY_LIMITED_INFORMATION, &attr, &cid );
+        todo_wine_if( status != STATUS_SUCCESS )
+        ok( status == STATUS_SUCCESS || broken( status == STATUS_ACCESS_DENIED ) /* wxppro */,
+            "NtOpenProcess returned:%x\n", status );
+        if (status != STATUS_SUCCESS) continue;
+
+        status = pNtQueryInformationProcess( handle, ProcessBasicInformation, &pbi, sizeof(pbi), NULL );
+        ok( status == STATUS_SUCCESS, "NtQueryInformationProcess returned:%x\n", status );
+        ok( pbi.UniqueProcessId == GetCurrentProcessId(),
+            "Expected pid %p, got %p\n", ULongToHandle(GetCurrentProcessId()), ULongToHandle(pbi.UniqueProcessId) );
+
+        NtClose( handle );
+    }
+
+    for (i = 1; i < 4; ++i)
+    {
+        InitializeObjectAttributes( &attr, NULL, 0, NULL, NULL );
+        cid.UniqueProcess = 0;
+        cid.UniqueThread = ULongToHandle(GetCurrentThreadId() + i);
+
+        status = NtOpenThread( &handle, THREAD_QUERY_LIMITED_INFORMATION, &attr, &cid );
+        todo_wine_if( status != STATUS_SUCCESS )
+        ok( status == STATUS_SUCCESS || broken( status == STATUS_ACCESS_DENIED ) /* wxppro */,
+            "NtOpenThread returned:%x\n", status );
+        if (status != STATUS_SUCCESS) continue;
+
+        status = pNtQueryInformationThread( handle, ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
+        ok( status == STATUS_SUCCESS, "NtQueryInformationThread returned:%x\n", status );
+        ok( tbi.ClientId.UniqueThread == ULongToHandle(GetCurrentThreadId()),
+            "Expected tid %p, got %p\n", ULongToHandle(GetCurrentThreadId()), tbi.ClientId.UniqueThread );
+
+        NtClose( handle );
+    }
 }
 
 static void test_query_procperf(void)




More information about the wine-cvs mailing list