ReactOS 0.4.16-dev-306-g647d351
RegQueryInfoKey.c
Go to the documentation of this file.
1/*
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>
6 */
7
8#include "precomp.h"
9
10#define TestKeyAccess(da, er, es) TestKeyAccess_(__FILE__, __LINE__, da, er, es)
11static
12VOID
17 _In_ LONG ExpectedReturn,
18 _In_ BOOLEAN ExpectSd)
19{
20 DWORD cbSd;
21 HKEY hKey;
22 LONG ret;
23
25 ok_(File, Line)(ret == NO_ERROR, "RegOpenKeyEx returned %ld\n", ret);
26 if (ret == NO_ERROR)
27 {
28 cbSd = 0x55555555;
30 ok_(File, Line)(ret == ExpectedReturn, "RegQueryInfoKeyW returned %ld\n", ret);
31 if (ExpectSd)
32 ok_(File, Line)(cbSd != 0 && cbSd != 0x55555555, "RegQueryInfoKeyW - cbSd = %lu\n", cbSd);
33 else
34 ok_(File, Line)(cbSd == 0, "RegQueryInfoKeyW - cbSd = %lu\n", cbSd);
35
36 cbSd = 0x55555555;
38 ok_(File, Line)(ret == ExpectedReturn, "RegQueryInfoKeyA returned %ld\n", ret);
39 if (ExpectSd)
40 ok_(File, Line)(cbSd != 0 && cbSd != 0x55555555, "RegQueryInfoKeyA - cbSd = %lu\n", cbSd);
41 else
42 ok_(File, Line)(cbSd == 0, "RegQueryInfoKeyA - cbSd = %lu\n", cbSd);
44 ok_(File, Line)(ret == NO_ERROR, "RegCloseKey returned %ld\n", ret);
45 }
46 else
47 {
48 skip_(File, Line)("No key handle\n");
49 }
50}
51
53{
54 /* 0 access just fails the open */
55 if (0)
57 /* Without KEY_QUERY_VALUE we can't query anything */
59 /* Without READ_CONTROL we'll get success but SD size will yield 0 */
61 /* With the two combined we get everything */
63 /* Write rights return nothing on 2003 (but succeed and return SD size on Win7) */
70 /* But these return nothing */
73}
unsigned char BOOLEAN
#define TestKeyAccess(da, er, es)
static VOID TestKeyAccess_(_In_ PCSTR File, _In_ INT Line, _In_ REGSAM DesiredAccess, _In_ LONG ExpectedReturn, _In_ BOOLEAN ExpectSd)
#define START_TEST(x)
Definition: atltest.h:75
#define ok_(x1, x2)
Definition: atltest.h:61
#define RegCloseKey(hKey)
Definition: registry.h:49
Definition: File.h:16
#define NO_ERROR
Definition: dderror.h:5
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryInfoKeyA(HKEY hKey, LPSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3583
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3662
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define skip_(test, file, line,...)
Definition: kmt_test.h:224
#define _In_
Definition: no_sal2.h:158
#define WRITE_DAC
Definition: nt_native.h:59
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define DELETE
Definition: nt_native.h:57
#define READ_CONTROL
Definition: nt_native.h:58
#define WRITE_OWNER
Definition: nt_native.h:60
#define KEY_CREATE_LINK
Definition: nt_native.h:1021
#define KEY_NOTIFY
Definition: nt_native.h:1020
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
Definition: ncftp.h:79
int32_t INT
Definition: typedefs.h:58
const char * PCSTR
Definition: typedefs.h:52
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
ACCESS_MASK REGSAM
Definition: winreg.h:69
#define RegQueryInfoKey
Definition: winreg.h:521