Rémi Bernon : ntdll/tests: Add tests for NtOpenProcess return status.

Alexandre Julliard julliard at winehq.org
Thu Nov 26 16:30:59 CST 2020


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

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Thu Nov 26 10:11:34 2020 +0100

ntdll/tests: Add tests for NtOpenProcess return status.

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

---

 dlls/ntdll/tests/om.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c
index d3b932bec1d..6687b8b6767 100644
--- a/dlls/ntdll/tests/om.c
+++ b/dlls/ntdll/tests/om.c
@@ -73,6 +73,7 @@ static NTSTATUS (WINAPI *pNtQuerySystemTime)( LARGE_INTEGER * );
 static NTSTATUS (WINAPI *pRtlWaitOnAddress)( const void *, const void *, SIZE_T, const LARGE_INTEGER * );
 static void     (WINAPI *pRtlWakeAddressAll)( const void * );
 static void     (WINAPI *pRtlWakeAddressSingle)( const void * );
+static NTSTATUS (WINAPI *pNtOpenProcess)( HANDLE *, ACCESS_MASK, const OBJECT_ATTRIBUTES *, const CLIENT_ID * );
 
 #define KEYEDEVENT_WAIT       0x0001
 #define KEYEDEVENT_WAKE       0x0002
@@ -2034,6 +2035,56 @@ static void test_wait_on_address(void)
     ok(address == 0, "got %s\n", wine_dbgstr_longlong(address));
 }
 
+static void test_process(void)
+{
+    OBJECT_ATTRIBUTES attr;
+    CLIENT_ID cid;
+    NTSTATUS status;
+    HANDLE process;
+
+    if (!pNtOpenProcess)
+    {
+        win_skip( "NtOpenProcess not supported, skipping test\n" );
+        return;
+    }
+
+    InitializeObjectAttributes( &attr, NULL, 0, 0, NULL );
+
+    cid.UniqueProcess = 0;
+    cid.UniqueThread = 0;
+    status = pNtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, NULL, &cid );
+    todo_wine ok( status == STATUS_ACCESS_VIOLATION, "NtOpenProcess returned %x\n", status );
+    status = pNtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, &attr, NULL );
+    todo_wine ok( status == STATUS_INVALID_PARAMETER_MIX, "NtOpenProcess returned %x\n", status );
+
+    cid.UniqueProcess = 0;
+    cid.UniqueThread = 0;
+    status = pNtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, &attr, &cid );
+    todo_wine ok( status == STATUS_INVALID_CID, "NtOpenProcess returned %x\n", status );
+
+    cid.UniqueProcess = ULongToHandle( 0xdeadbeef );
+    cid.UniqueThread = ULongToHandle( 0xdeadbeef );
+    status = pNtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, &attr, &cid );
+    todo_wine ok( status == STATUS_INVALID_CID, "NtOpenProcess returned %x\n", status );
+
+    cid.UniqueProcess = ULongToHandle( GetCurrentThreadId() );
+    cid.UniqueThread = 0;
+    status = pNtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, &attr, &cid );
+    todo_wine ok( status == STATUS_INVALID_CID, "NtOpenProcess returned %x\n", status );
+
+    cid.UniqueProcess = ULongToHandle( GetCurrentProcessId() );
+    cid.UniqueThread = 0;
+    status = pNtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, &attr, &cid );
+    ok( !status, "NtOpenProcess returned %x\n", status );
+    pNtClose( process );
+
+    cid.UniqueProcess = ULongToHandle( GetCurrentProcessId() );
+    cid.UniqueThread = ULongToHandle( GetCurrentThreadId() );
+    status = pNtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, &attr, &cid );
+    ok( !status, "NtOpenProcess returned %x\n", status );
+    pNtClose( process );
+}
+
 START_TEST(om)
 {
     HMODULE hntdll = GetModuleHandleA("ntdll.dll");
@@ -2082,6 +2133,7 @@ START_TEST(om)
     pRtlWaitOnAddress       =  (void *)GetProcAddress(hntdll, "RtlWaitOnAddress");
     pRtlWakeAddressAll      =  (void *)GetProcAddress(hntdll, "RtlWakeAddressAll");
     pRtlWakeAddressSingle   =  (void *)GetProcAddress(hntdll, "RtlWakeAddressSingle");
+    pNtOpenProcess          =  (void *)GetProcAddress(hntdll, "NtOpenProcess");
 
     test_case_sensitive();
     test_namespace_pipe();
@@ -2096,4 +2148,5 @@ START_TEST(om)
     test_keyed_events();
     test_null_device();
     test_wait_on_address();
+    test_process();
 }




More information about the wine-cvs mailing list