ReactOS  0.4.14-dev-614-gbfd8a84
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 
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 }
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 }
#define TRUE
Definition: types.h:120
#define RegQueryInfoKey
Definition: winreg.h:521
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define TestKeyAccess(da, er, es)
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:56
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
long LONG
Definition: pedump.c:60
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
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
#define _In_
Definition: no_sal2.h:204
#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
_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
ACCESS_MASK REGSAM
Definition: winreg.h:69
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:51
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