Commit e9ea4360 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

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

parent a4199fa2
...@@ -7878,6 +7878,55 @@ static void test_create_process_token_child(void) ...@@ -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) START_TEST(security)
{ {
init(); init();
...@@ -7940,6 +7989,7 @@ START_TEST(security) ...@@ -7940,6 +7989,7 @@ START_TEST(security)
test_BuildSecurityDescriptorW(); test_BuildSecurityDescriptorW();
test_duplicate_handle_access(); test_duplicate_handle_access();
test_create_process_token(); test_create_process_token();
test_pseudo_handle_security();
/* Must be the last test, modifies process token */ /* Must be the last test, modifies process token */
test_token_security_descriptor(); test_token_security_descriptor();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment