Zebediah Figura : advapi32/tests: Add some tests for querying the security of pseudo-handles.

Alexandre Julliard julliard at winehq.org
Fri Feb 5 16:50:48 CST 2021


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

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Thu Feb  4 21:24:10 2021 -0600

advapi32/tests: Add some tests for querying the security of pseudo-handles.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/advapi32/tests/security.c | 50 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index 020e69277e0..91b358543d5 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -7878,6 +7878,55 @@ static void test_create_process_token_child(void)
     }
 }
 
+static void test_pseudo_handle_security(void)
+{
+    char buffer[200];
+    PSECURITY_DESCRIPTOR sd = buffer, sd_ptr;
+    unsigned int i;
+    DWORD size;
+    BOOL ret;
+
+    static const HKEY keys[] =
+    {
+        HKEY_CLASSES_ROOT,
+        HKEY_CURRENT_USER,
+        HKEY_LOCAL_MACHINE,
+        HKEY_USERS,
+        HKEY_PERFORMANCE_DATA,
+        HKEY_CURRENT_CONFIG,
+        HKEY_DYN_DATA,
+    };
+
+    ret = GetKernelObjectSecurity(GetCurrentProcess(), OWNER_SECURITY_INFORMATION, &sd, sizeof(buffer), &size);
+    ok(ret, "got error %u\n", GetLastError());
+
+    ret = GetKernelObjectSecurity(GetCurrentThread(), OWNER_SECURITY_INFORMATION, &sd, sizeof(buffer), &size);
+    ok(ret, "got error %u\n", GetLastError());
+
+    for (i = 0; i < ARRAY_SIZE(keys); ++i)
+    {
+        SetLastError(0xdeadbeef);
+        ret = GetKernelObjectSecurity(keys[i], OWNER_SECURITY_INFORMATION, &sd, sizeof(buffer), &size);
+        ok(!ret, "key %p: expected failure\n", keys[i]);
+        ok(GetLastError() == ERROR_INVALID_HANDLE, "key %p: got error %u\n", keys[i], GetLastError());
+
+        ret = GetSecurityInfo(keys[i], SE_REGISTRY_KEY,
+                DACL_SECURITY_INFORMATION, NULL, NULL, NULL, NULL, &sd_ptr);
+        if (keys[i] == HKEY_PERFORMANCE_DATA)
+            ok(ret == ERROR_INVALID_HANDLE, "key %p: got error %u\n", keys[i], ret);
+        else if (keys[i] == HKEY_DYN_DATA)
+            todo_wine ok(ret == ERROR_CALL_NOT_IMPLEMENTED || broken(ret == ERROR_INVALID_HANDLE) /* <7 */,
+                    "key %p: got error %u\n", keys[i], ret);
+        else
+            todo_wine ok(!ret, "key %p: got error %u\n", keys[i], ret);
+        LocalFree(sd_ptr);
+
+        ret = GetSecurityInfo(keys[i], SE_KERNEL_OBJECT,
+                DACL_SECURITY_INFORMATION, NULL, NULL, NULL, NULL, &sd_ptr);
+        ok(ret == ERROR_INVALID_HANDLE, "key %p: got error %u\n", keys[i], ret);
+    }
+}
+
 START_TEST(security)
 {
     init();
@@ -7940,6 +7989,7 @@ START_TEST(security)
     test_BuildSecurityDescriptorW();
     test_duplicate_handle_access();
     test_create_process_token();
+    test_pseudo_handle_security();
 
     /* Must be the last test, modifies process token */
     test_token_security_descriptor();




More information about the wine-cvs mailing list