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 WIN32_NO_STATUS
13 #define TestKeyAccess(da, er, es) TestKeyAccess_(__FILE__, __LINE__, da, er, es)
19 _In_ REGSAM DesiredAccess
,
20 _In_ LONG ExpectedReturn
,
21 _In_ BOOLEAN ExpectSd
)
27 ret
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, L
"Software", 0, DesiredAccess
, &hKey
);
28 ok_(File
, Line
)(ret
== NO_ERROR
, "RegOpenKeyEx returned %ld\n", ret
);
32 ret
= RegQueryInfoKeyW(hKey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &cbSd
, NULL
);
33 ok_(File
, Line
)(ret
== ExpectedReturn
, "RegQueryInfoKeyW returned %ld\n", ret
);
35 ok_(File
, Line
)(cbSd
!= 0 && cbSd
!= 0x55555555, "RegQueryInfoKeyW - cbSd = %lu\n", cbSd
);
37 ok_(File
, Line
)(cbSd
== 0, "RegQueryInfoKeyW - cbSd = %lu\n", cbSd
);
40 ret
= RegQueryInfoKeyA(hKey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &cbSd
, NULL
);
41 ok_(File
, Line
)(ret
== ExpectedReturn
, "RegQueryInfoKeyA returned %ld\n", ret
);
43 ok_(File
, Line
)(cbSd
!= 0 && cbSd
!= 0x55555555, "RegQueryInfoKeyA - cbSd = %lu\n", cbSd
);
45 ok_(File
, Line
)(cbSd
== 0, "RegQueryInfoKeyA - cbSd = %lu\n", cbSd
);
46 ret
= RegCloseKey(hKey
);
47 ok_(File
, Line
)(ret
== NO_ERROR
, "RegCloseKey returned %ld\n", ret
);
51 skip_(File
, Line
)("No key handle\n");
55 START_TEST(RegQueryInfoKey
)
57 /* 0 access just fails the open */
59 TestKeyAccess(0, ERROR_ACCESS_DENIED
, FALSE
);
60 /* Without KEY_QUERY_VALUE we can't query anything */
61 TestKeyAccess(READ_CONTROL
, ERROR_ACCESS_DENIED
, FALSE
);
62 /* Without READ_CONTROL we'll get success but SD size will yield 0 */
63 TestKeyAccess(KEY_QUERY_VALUE
, NO_ERROR
, FALSE
);
64 /* With the two combined we get everything */
65 TestKeyAccess(KEY_QUERY_VALUE
| READ_CONTROL
, NO_ERROR
, TRUE
);
66 /* Write rights return nothing on 2003 (but succeed and return SD size on Win7) */
67 TestKeyAccess(KEY_SET_VALUE
, ERROR_ACCESS_DENIED
, FALSE
);
68 TestKeyAccess(KEY_CREATE_SUB_KEY
, ERROR_ACCESS_DENIED
, FALSE
);
69 TestKeyAccess(KEY_CREATE_LINK
, ERROR_ACCESS_DENIED
, FALSE
);
70 TestKeyAccess(DELETE
, ERROR_ACCESS_DENIED
, FALSE
);
71 TestKeyAccess(WRITE_DAC
, ERROR_ACCESS_DENIED
, FALSE
);
72 TestKeyAccess(WRITE_OWNER
, ERROR_ACCESS_DENIED
, FALSE
);
73 /* But these return nothing */
74 TestKeyAccess(KEY_ENUMERATE_SUB_KEYS
, ERROR_ACCESS_DENIED
, FALSE
);
75 TestKeyAccess(KEY_NOTIFY
, ERROR_ACCESS_DENIED
, FALSE
);