ReactOS  0.4.15-dev-2985-g54406bf
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)
11 static
12 VOID
14  _In_ PCSTR File,
15  _In_ INT Line,
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);
43  ret = RegCloseKey(hKey);
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 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
#define RegQueryInfoKey
Definition: winreg.h:521
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define TestKeyAccess(da, er, es)
#define TRUE
Definition: types.h:120
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:3607
#define WRITE_OWNER
Definition: nt_native.h:60
#define NO_ERROR
Definition: dderror.h:5
int32_t INT
Definition: typedefs.h:58
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
long LONG
Definition: pedump.c:60
unsigned char BOOLEAN
#define _In_
Definition: ms_sal.h:308
START_TEST(RegQueryInfoKey)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WRITE_DAC
Definition: nt_native.h:59
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:3686
#define READ_CONTROL
Definition: nt_native.h:58
Definition: ncftp.h:79
int ret
static const WCHAR L[]
Definition: oid.c:1250
FxAutoRegKey hKey
#define KEY_CREATE_LINK
Definition: nt_native.h:1021
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define KEY_NOTIFY
Definition: nt_native.h:1020
ACCESS_MASK REGSAM
Definition: winreg.h:69
#define NULL
Definition: types.h:112
static VOID TestKeyAccess_(_In_ PCSTR File, _In_ INT Line, _In_ REGSAM DesiredAccess, _In_ LONG ExpectedReturn, _In_ BOOLEAN ExpectSd)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
const char * PCSTR
Definition: typedefs.h:52
Definition: File.h:15
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define skip_(test, file, line,...)
Definition: kmt_test.h:222
#define DELETE
Definition: nt_native.h:57
#define ok_(x1, x2)
Definition: atltest.h:61
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019