2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPLv2.1+ - See COPYING.Lib in the top level directory
4 * PURPOSE: Test for RegQueryInfoKey
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
10 #define TestKeyAccess(da, er, es) TestKeyAccess_(__FILE__, __LINE__, da, er, es)
16 _In_ REGSAM DesiredAccess
,
17 _In_ LONG ExpectedReturn
,
18 _In_ BOOLEAN ExpectSd
)
24 ret
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, L
"Software", 0, DesiredAccess
, &hKey
);
25 ok_(File
, Line
)(ret
== NO_ERROR
, "RegOpenKeyEx returned %ld\n", ret
);
29 ret
= RegQueryInfoKeyW(hKey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &cbSd
, NULL
);
30 ok_(File
, Line
)(ret
== ExpectedReturn
, "RegQueryInfoKeyW returned %ld\n", ret
);
32 ok_(File
, Line
)(cbSd
!= 0 && cbSd
!= 0x55555555, "RegQueryInfoKeyW - cbSd = %lu\n", cbSd
);
34 ok_(File
, Line
)(cbSd
== 0, "RegQueryInfoKeyW - cbSd = %lu\n", cbSd
);
37 ret
= RegQueryInfoKeyA(hKey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &cbSd
, NULL
);
38 ok_(File
, Line
)(ret
== ExpectedReturn
, "RegQueryInfoKeyA returned %ld\n", ret
);
40 ok_(File
, Line
)(cbSd
!= 0 && cbSd
!= 0x55555555, "RegQueryInfoKeyA - cbSd = %lu\n", cbSd
);
42 ok_(File
, Line
)(cbSd
== 0, "RegQueryInfoKeyA - cbSd = %lu\n", cbSd
);
43 ret
= RegCloseKey(hKey
);
44 ok_(File
, Line
)(ret
== NO_ERROR
, "RegCloseKey returned %ld\n", ret
);
48 skip_(File
, Line
)("No key handle\n");
52 START_TEST(RegQueryInfoKey
)
54 /* 0 access just fails the open */
56 TestKeyAccess(0, ERROR_ACCESS_DENIED
, FALSE
);
57 /* Without KEY_QUERY_VALUE we can't query anything */
58 TestKeyAccess(READ_CONTROL
, ERROR_ACCESS_DENIED
, FALSE
);
59 /* Without READ_CONTROL we'll get success but SD size will yield 0 */
60 TestKeyAccess(KEY_QUERY_VALUE
, NO_ERROR
, FALSE
);
61 /* With the two combined we get everything */
62 TestKeyAccess(KEY_QUERY_VALUE
| READ_CONTROL
, NO_ERROR
, TRUE
);
63 /* Write rights return nothing on 2003 (but succeed and return SD size on Win7) */
64 TestKeyAccess(KEY_SET_VALUE
, ERROR_ACCESS_DENIED
, FALSE
);
65 TestKeyAccess(KEY_CREATE_SUB_KEY
, ERROR_ACCESS_DENIED
, FALSE
);
66 TestKeyAccess(KEY_CREATE_LINK
, ERROR_ACCESS_DENIED
, FALSE
);
67 TestKeyAccess(DELETE
, ERROR_ACCESS_DENIED
, FALSE
);
68 TestKeyAccess(WRITE_DAC
, ERROR_ACCESS_DENIED
, FALSE
);
69 TestKeyAccess(WRITE_OWNER
, ERROR_ACCESS_DENIED
, FALSE
);
70 /* But these return nothing */
71 TestKeyAccess(KEY_ENUMERATE_SUB_KEYS
, ERROR_ACCESS_DENIED
, FALSE
);
72 TestKeyAccess(KEY_NOTIFY
, ERROR_ACCESS_DENIED
, FALSE
);