ReactOS  0.4.14-dev-614-gbfd8a84
RegQueryInfoKey.c File Reference
#include "precomp.h"
Include dependency graph for RegQueryInfoKey.c:

Go to the source code of this file.

Macros

#define TestKeyAccess(da, er, es)   TestKeyAccess_(__FILE__, __LINE__, da, er, es)
 

Functions

static VOID TestKeyAccess_ (_In_ PCSTR File, _In_ INT Line, _In_ REGSAM DesiredAccess, _In_ LONG ExpectedReturn, _In_ BOOLEAN ExpectSd)
 
 START_TEST (RegQueryInfoKey)
 

Macro Definition Documentation

◆ TestKeyAccess

#define TestKeyAccess (   da,
  er,
  es 
)    TestKeyAccess_(__FILE__, __LINE__, da, er, es)

Definition at line 10 of file RegQueryInfoKey.c.

Function Documentation

◆ START_TEST()

START_TEST ( RegQueryInfoKey  )

Definition at line 52 of file RegQueryInfoKey.c.

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 }
#define TRUE
Definition: types.h:120
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define TestKeyAccess(da, er, es)
#define WRITE_OWNER
Definition: nt_native.h:60
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
#define WRITE_DAC
Definition: nt_native.h:59
#define READ_CONTROL
Definition: nt_native.h:58
#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
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define DELETE
Definition: nt_native.h:57
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019

◆ TestKeyAccess_()

static VOID TestKeyAccess_ ( _In_ PCSTR  File,
_In_ INT  Line,
_In_ REGSAM  DesiredAccess,
_In_ LONG  ExpectedReturn,
_In_ BOOLEAN  ExpectSd 
)
static

Definition at line 13 of file RegQueryInfoKey.c.

19 {
20  DWORD cbSd;
21  HKEY hKey;
22  LONG ret;
23 
24  ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software", 0, DesiredAccess, &hKey);
25  ok_(File, Line)(ret == NO_ERROR, "RegOpenKeyEx returned %ld\n", ret);
26  if (ret == NO_ERROR)
27  {
28  cbSd = 0x55555555;
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);
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;
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);
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 }
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 NO_ERROR
Definition: dderror.h:5
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
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
Definition: ncftp.h:79
int ret
static const WCHAR L[]
Definition: oid.c:1250
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
Definition: File.h:15
#define skip_(test, file, line,...)
Definition: kmt_test.h:222
#define ok_(x1, x2)
Definition: atltest.h:61
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12