ReactOS  0.4.13-dev-464-g6b95727
registry.c File Reference
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "winreg.h"
#include "winperf.h"
#include "winsvc.h"
#include "winerror.h"
#include "aclapi.h"
Include dependency graph for registry.c:

Go to the source code of this file.

Macros

#define IS_HKCR(hk)   ((UINT_PTR)hk > 0 && ((UINT_PTR)hk & 3) == 2)
 
#define ADVAPI32_GET_PROC(func)   p ## func = (void*)GetProcAddress(hadvapi32, #func)
 
#define lok   ok_(__FILE__, line)
 
#define test_hkey_main_Value_A(name, string, full_byte_len)   _test_hkey_main_Value_A(__LINE__, name, string, full_byte_len)
 
#define test_hkey_main_Value_W(name, string, full_byte_len)   _test_hkey_main_Value_W(__LINE__, name, string, full_byte_len)
 
#define check_key_value(root, name, flags, expect)   _check_key_value( __LINE__, root, name, flags, expect )
 
#define cmp_li(a, b, c)   cmp_li_real(a, b, c, __LINE__)
 

Functions

static DWORD (WINAPI *pRegGetValueA)(HKEY
 
static LONG (WINAPI *pRegCopyTreeA)(HKEY
 
static BOOL (WINAPI *pIsWow64Process)(HANDLE
 
static NTSTATUS (WINAPI *pNtDeleteKey)(HANDLE)
 
static charget_temp_buffer (int size)
 
static const charwine_debugstr_an (const char *str, int n)
 
static void InitFunctionPtrs (void)
 
static DWORD delete_key (HKEY hkey)
 
static void setup_main_key (void)
 
static void check_user_privs (void)
 
static void _test_hkey_main_Value_A (int line, LPCSTR name, LPCSTR string, DWORD full_byte_len)
 
static void _test_hkey_main_Value_W (int line, LPCWSTR name, LPCWSTR string, DWORD full_byte_len)
 
static void test_set_value (void)
 
static void create_test_entries (void)
 
static void test_enum_value (void)
 
static void test_query_value_ex (void)
 
static void test_get_value (void)
 
static void test_reg_open_key (void)
 
static void test_reg_create_key (void)
 
static void test_reg_close_key (void)
 
static void test_reg_delete_key (void)
 
static BOOL set_privileges (LPCSTR privilege, BOOL set)
 
static void test_reg_save_key (void)
 
static void test_reg_load_key (void)
 
static void test_reg_unload_key (void)
 
static void test_regconnectregistry (void)
 
static void test_reg_query_value (void)
 
static void test_reg_query_info (void)
 
static void test_string_termination (void)
 
static void test_reg_copy_tree (void)
 
static void test_reg_delete_tree (void)
 
static void test_rw_order (void)
 
static void test_symlinks (void)
 
static DWORD get_key_value (HKEY root, const char *name, DWORD flags)
 
static void _check_key_value (int line, HANDLE root, const char *name, DWORD flags, DWORD expect)
 
static void test_redirection (void)
 
static void test_classesroot (void)
 
static void test_classesroot_enum (void)
 
static void test_classesroot_mask (void)
 
static void test_perflib_key (void)
 
static void test_deleted_key (void)
 
static void test_delete_value (void)
 
static void test_delete_key_value (void)
 
static void test_RegOpenCurrentUser (void)
 
static void test_RegNotifyChangeKeyValue (void)
 
static const chardbgstr_longlong (ULONGLONG ll)
 
static void cmp_li_real (LARGE_INTEGER *l1, LARGE_INTEGER *l2, LONGLONG slack, int line)
 
static void test_RegQueryValueExPerformanceData (void)
 
 START_TEST (registry)
 

Variables

static HKEY hkey_main
 
static DWORD GLE
 
static const charsTestpath1 = "%LONGSYSTEMVAR%\\subdir1"
 
static const charsTestpath2 = "%FOO%\\subdir1"
 
static const DWORD ptr_size = 8 * sizeof(void*)
 
static LPCSTR
 
static DWORD
 
static LPDWORD
 
static PVOID
 
static const char HKEY
 
static const char *static REGSAM
 
static PBOOL
 
static LPCWSTR
 
static BOOL limited_user
 

Macro Definition Documentation

◆ ADVAPI32_GET_PROC

#define ADVAPI32_GET_PROC (   func)    p ## func = (void*)GetProcAddress(hadvapi32, #func)

Definition at line 129 of file registry.c.

◆ check_key_value

#define check_key_value (   root,
  name,
  flags,
  expect 
)    _check_key_value( __LINE__, root, name, flags, expect )

Definition at line 2498 of file registry.c.

◆ cmp_li

#define cmp_li (   a,
  b,
  c 
)    cmp_li_real(a, b, c, __LINE__)

Definition at line 3544 of file registry.c.

◆ IS_HKCR

#define IS_HKCR (   hk)    ((UINT_PTR)hk > 0 && ((UINT_PTR)hk & 3) == 2)

Definition at line 35 of file registry.c.

◆ lok

#define lok   ok_(__FILE__, line)

Definition at line 202 of file registry.c.

◆ test_hkey_main_Value_A

#define test_hkey_main_Value_A (   name,
  string,
  full_byte_len 
)    _test_hkey_main_Value_A(__LINE__, name, string, full_byte_len)

Definition at line 203 of file registry.c.

◆ test_hkey_main_Value_W

#define test_hkey_main_Value_W (   name,
  string,
  full_byte_len 
)    _test_hkey_main_Value_W(__LINE__, name, string, full_byte_len)

Definition at line 249 of file registry.c.

Function Documentation

◆ _check_key_value()

static void _check_key_value ( int  line,
HANDLE  root,
const char name,
DWORD  flags,
DWORD  expect 
)
static

Definition at line 2493 of file registry.c.

2494 {
2496  ok_(__FILE__,line)( dw == expect, "%08x: wrong value %u/%u\n", flags, dw, expect );
2497 }
#define ok_(x1, x2)
static DWORD get_key_value(HKEY root, const char *name, DWORD flags)
Definition: registry.c:2475
Definition: parser.c:48
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID LPVOID DWORD dw
Definition: atlbase.h:40
GLbitfield flags
Definition: glext.h:7161
#define expect(expected, got)
Definition: combo.c:36
Definition: name.c:36

◆ _test_hkey_main_Value_A()

static void _test_hkey_main_Value_A ( int  line,
LPCSTR  name,
LPCSTR  string,
DWORD  full_byte_len 
)
static

Definition at line 204 of file registry.c.

206 {
207  DWORD ret, type, cbData;
208  DWORD str_byte_len;
209  BYTE* value;
210 
211  type=0xdeadbeef;
212  cbData=0xdeadbeef;
213  /* When successful RegQueryValueExA() leaves GLE as is,
214  * so we must reset it to detect unimplemented functions.
215  */
216  SetLastError(0xdeadbeef);
217  ret = RegQueryValueExA(hkey_main, name, NULL, &type, NULL, &cbData);
218  GLE = GetLastError();
219  lok(ret == ERROR_SUCCESS, "RegQueryValueExA/1 failed: %d, GLE=%d\n", ret, GLE);
220  /* It is wrong for the Ansi version to not be implemented */
221  ok(GLE == 0xdeadbeef, "RegQueryValueExA set GLE = %u\n", GLE);
222  if(GLE == ERROR_CALL_NOT_IMPLEMENTED) return;
223 
224  str_byte_len = (string ? lstrlenA(string) : 0) + 1;
225  lok(type == REG_SZ, "RegQueryValueExA/1 returned type %d\n", type);
226  lok(cbData == full_byte_len, "cbData=%d instead of %d or %d\n", cbData, full_byte_len, str_byte_len);
227 
228  value = HeapAlloc(GetProcessHeap(), 0, cbData+1);
229  memset(value, 0xbd, cbData+1);
230  type=0xdeadbeef;
231  ret = RegQueryValueExA(hkey_main, name, NULL, &type, value, &cbData);
232  GLE = GetLastError();
233  lok(ret == ERROR_SUCCESS, "RegQueryValueExA/2 failed: %d, GLE=%d\n", ret, GLE);
234  if (!string)
235  {
236  /* When cbData == 0, RegQueryValueExA() should not modify the buffer */
237  lok(*value == 0xbd, "RegQueryValueExA overflowed: cbData=%u *value=%02x\n", cbData, *value);
238  }
239  else
240  {
241  lok(memcmp(value, string, cbData) == 0, "RegQueryValueExA/2 failed: %s/%d != %s/%d\n",
242  wine_debugstr_an((char*)value, cbData), cbData,
243  wine_debugstr_an(string, full_byte_len), full_byte_len);
244  lok(*(value+cbData) == 0xbd, "RegQueryValueExA/2 overflowed at offset %u: %02x != bd\n", cbData, *(value+cbData));
245  }
247 }
#define lok
Definition: registry.c:202
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ERROR_SUCCESS
Definition: deptool.c:10
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static HKEY hkey_main
Definition: registry.c:37
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
unsigned char BYTE
Definition: mem.h:68
GLsizei const GLfloat * value
Definition: glext.h:6069
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
Definition: name.c:36
static const char * wine_debugstr_an(const char *str, int n)
Definition: registry.c:78
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define memset(x, y, z)
Definition: compat.h:39
#define HeapFree(x, y, z)
Definition: compat.h:394
static DWORD GLE
Definition: registry.c:38
#define REG_SZ
Definition: layer.c:22

◆ _test_hkey_main_Value_W()

static void _test_hkey_main_Value_W ( int  line,
LPCWSTR  name,
LPCWSTR  string,
DWORD  full_byte_len 
)
static

Definition at line 250 of file registry.c.

252 {
253  DWORD ret, type, cbData;
254  BYTE* value;
255 
256  type=0xdeadbeef;
257  cbData=0xdeadbeef;
258  /* When successful RegQueryValueExW() leaves GLE as is,
259  * so we must reset it to detect unimplemented functions.
260  */
261  SetLastError(0xdeadbeef);
262  ret = RegQueryValueExW(hkey_main, name, NULL, &type, NULL, &cbData);
263  GLE = GetLastError();
264  lok(ret == ERROR_SUCCESS, "RegQueryValueExW/1 failed: %d, GLE=%d\n", ret, GLE);
266  {
267  win_skip("RegQueryValueExW() is not implemented\n");
268  return;
269  }
270 
271  lok(type == REG_SZ, "RegQueryValueExW/1 returned type %d\n", type);
272  lok(cbData == full_byte_len,
273  "cbData=%d instead of %d\n", cbData, full_byte_len);
274 
275  /* Give enough space to overflow by one WCHAR */
276  value = HeapAlloc(GetProcessHeap(), 0, cbData+2);
277  memset(value, 0xbd, cbData+2);
278  type=0xdeadbeef;
279  ret = RegQueryValueExW(hkey_main, name, NULL, &type, value, &cbData);
280  GLE = GetLastError();
281  lok(ret == ERROR_SUCCESS, "RegQueryValueExW/2 failed: %d, GLE=%d\n", ret, GLE);
282  if (string)
283  {
284  lok(memcmp(value, string, cbData) == 0, "RegQueryValueExW failed: %s/%d != %s/%d\n",
285  wine_dbgstr_wn((WCHAR*)value, cbData / sizeof(WCHAR)), cbData,
286  wine_dbgstr_wn(string, full_byte_len / sizeof(WCHAR)), full_byte_len);
287  }
288  /* This implies that when cbData == 0, RegQueryValueExW() should not modify the buffer */
289  lok(*(value+cbData) == 0xbd, "RegQueryValueExW/2 overflowed at %u: %02x != bd\n", cbData, *(value+cbData));
290  lok(*(value+cbData+1) == 0xbd, "RegQueryValueExW/2 overflowed at %u+1: %02x != bd\n", cbData, *(value+cbData+1));
292 }
#define lok
Definition: registry.c:202
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ERROR_SUCCESS
Definition: deptool.c:10
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static HKEY hkey_main
Definition: registry.c:37
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
unsigned char BYTE
Definition: mem.h:68
const char * wine_dbgstr_wn(const WCHAR *str, int n)
Definition: compat.c:342
GLsizei const GLfloat * value
Definition: glext.h:6069
LONG WINAPI RegQueryValueExW(IN HKEY hKey, IN LPCWSTR lpValueName, IN PULONG lpReserved, OUT PULONG lpType OPTIONAL, OUT PUCHAR lpData OPTIONAL, IN OUT PULONG lpcbData OPTIONAL)
Definition: registry.c:862
Definition: name.c:36
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141
#define HeapFree(x, y, z)
Definition: compat.h:394
static DWORD GLE
Definition: registry.c:38
#define REG_SZ
Definition: layer.c:22

◆ BOOL()

static BOOL ( WINAPI pIsWow64Process)
static

◆ check_user_privs()

static void check_user_privs ( void  )
static

Definition at line 182 of file registry.c.

183 {
184  DWORD ret;
185  HKEY hkey = (HKEY)0xdeadbeef;
186 
187  ret = RegOpenKeyExA( HKEY_LOCAL_MACHINE, "Software", 0, KEY_READ|KEY_WRITE, &hkey);
188  ok(ret == ERROR_SUCCESS || ret == ERROR_ACCESS_DENIED, "expected success or access denied, got %i\n", ret);
189  if (ret == ERROR_SUCCESS)
190  {
191  ok(hkey != NULL, "RegOpenKeyExA succeeded but returned NULL hkey\n");
192  RegCloseKey(hkey);
193  }
194  else
195  {
196  ok(hkey == NULL, "RegOpenKeyExA failed but returned hkey %p\n", hkey);
197  limited_user = TRUE;
198  trace("running as limited user\n");
199  }
200 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
#define trace(...)
Definition: kmt_test.h:217
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
static BOOL limited_user
Definition: registry.c:55
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3331
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define KEY_WRITE
Definition: nt_native.h:1031
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static const char HKEY
Definition: registry.c:45
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by START_TEST().

◆ cmp_li_real()

static void cmp_li_real ( LARGE_INTEGER l1,
LARGE_INTEGER l2,
LONGLONG  slack,
int  line 
)
static

Definition at line 3545 of file registry.c.

3546 {
3547  LONGLONG diff = l2->QuadPart - l1->QuadPart;
3548  if (diff < 0) diff = -diff;
3549  ok_(__FILE__, line)(diff <= slack, "values don't match: %s/%s\n",
3551 }
#define ok_(x1, x2)
static const char * dbgstr_longlong(ULONGLONG ll)
Definition: registry.c:3529
Definition: parser.c:48
int64_t LONGLONG
Definition: typedefs.h:66
LONGLONG QuadPart
Definition: typedefs.h:112

◆ create_test_entries()

static void create_test_entries ( void  )
static

Definition at line 495 of file registry.c.

496 {
497  static const DWORD qw[2] = { 0x12345678, 0x87654321 };
498 
499  SetEnvironmentVariableA("LONGSYSTEMVAR", "bar");
500  SetEnvironmentVariableA("FOO", "ImARatherLongButIndeedNeededString");
501 
502  ok(!RegSetValueExA(hkey_main,"TP1_EXP_SZ",0,REG_EXPAND_SZ, (const BYTE *)sTestpath1, strlen(sTestpath1)+1),
503  "RegSetValueExA failed\n");
504  ok(!RegSetValueExA(hkey_main,"TP1_SZ",0,REG_SZ, (const BYTE *)sTestpath1, strlen(sTestpath1)+1),
505  "RegSetValueExA failed\n");
506  ok(!RegSetValueExA(hkey_main,"TP1_ZB_SZ",0,REG_SZ, (const BYTE *)"", 0),
507  "RegSetValueExA failed\n");
508  ok(!RegSetValueExA(hkey_main,"TP2_EXP_SZ",0,REG_EXPAND_SZ, (const BYTE *)sTestpath2, strlen(sTestpath2)+1),
509  "RegSetValueExA failed\n");
510  ok(!RegSetValueExA(hkey_main,"DWORD",0,REG_DWORD, (const BYTE *)qw, 4),
511  "RegSetValueExA failed\n");
512  ok(!RegSetValueExA(hkey_main,"BIN32",0,REG_BINARY, (const BYTE *)qw, 4),
513  "RegSetValueExA failed\n");
514  ok(!RegSetValueExA(hkey_main,"BIN64",0,REG_BINARY, (const BYTE *)qw, 8),
515  "RegSetValueExA failed\n");
516 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define REG_BINARY
Definition: nt_native.h:1496
static HKEY hkey_main
Definition: registry.c:37
static const char * sTestpath1
Definition: registry.c:40
#define ok(value,...)
static const char * sTestpath2
Definition: registry.c:41
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableA(IN LPCSTR lpName, IN LPCSTR lpValue)
Definition: environ.c:218
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: mem.h:68
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
#define REG_DWORD
Definition: sdbapi.c:596
#define REG_SZ
Definition: layer.c:22

Referenced by START_TEST().

◆ dbgstr_longlong()

static const char* dbgstr_longlong ( ULONGLONG  ll)
static

Definition at line 3529 of file registry.c.

3530 {
3531  static char buf[16][64];
3532  static int idx;
3533 
3534  idx &= 0x0f;
3535 
3536  if (sizeof(ll) > sizeof(unsigned long) && ll >> 32)
3537  sprintf(buf[idx], "0x%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll);
3538  else
3539  sprintf(buf[idx], "0x%08lx", (unsigned long)ll);
3540 
3541  return buf[idx++];
3542 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned int idx
Definition: utils.c:41
w ll
Definition: byte_order.h:166

Referenced by cmp_li_real().

◆ delete_key()

static DWORD delete_key ( HKEY  hkey)
static

Definition at line 153 of file registry.c.

154 {
155  char name[MAX_PATH];
156  DWORD ret;
157 
158  if ((ret = RegOpenKeyExA( hkey, "", 0, KEY_ENUMERATE_SUB_KEYS, &hkey ))) return ret;
159  while (!(ret = RegEnumKeyA(hkey, 0, name, sizeof(name))))
160  {
161  HKEY tmp;
162  if (!(ret = RegOpenKeyExA( hkey, name, 0, KEY_ENUMERATE_SUB_KEYS, &tmp )))
163  {
164  ret = delete_key( tmp );
165  RegCloseKey( tmp );
166  }
167  if (ret) break;
168  }
169  if (ret != ERROR_NO_MORE_ITEMS) return ret;
170  RegDeleteKeyA( hkey, "" );
171  RegCloseKey(hkey);
172  return 0;
173 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3331
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
LONG WINAPI RegEnumKeyA(HKEY hKey, DWORD dwIndex, LPSTR lpName, DWORD cbName)
Definition: reg.c:2391
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1222
static DWORD delete_key(HKEY hkey)
Definition: registry.c:153
Definition: name.c:36
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019

Referenced by setup_main_key(), START_TEST(), test_classesroot(), test_classesroot_enum(), test_deleted_key(), and test_reg_copy_tree().

◆ DWORD()

static DWORD ( WINAPI pRegGetValueA)
static

◆ get_key_value()

static DWORD get_key_value ( HKEY  root,
const char name,
DWORD  flags 
)
static

Definition at line 2475 of file registry.c.

2476 {
2477  HKEY key;
2478  DWORD err, type, dw, len = sizeof(dw);
2479 
2481  if (err == ERROR_FILE_NOT_FOUND) return 0;
2482  ok( err == ERROR_SUCCESS, "%08x: RegCreateKeyEx failed: %u\n", flags, err );
2483 
2484  err = RegQueryValueExA( key, "value", NULL, &type, (BYTE *)&dw, &len );
2485  if (err == ERROR_FILE_NOT_FOUND)
2486  dw = 0;
2487  else
2488  ok( err == ERROR_SUCCESS, "%08x: RegQueryValueEx failed: %u\n", flags, err );
2489  RegCloseKey( key );
2490  return dw;
2491 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
#define ERROR_SUCCESS
Definition: deptool.c:10
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID LPVOID DWORD dw
Definition: atlbase.h:40
GLbitfield flags
Definition: glext.h:7161
HKEY key
Definition: reg.c:42
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
#define err(...)
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
Definition: name.c:36
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1029
Definition: path.c:42

Referenced by _check_key_value(), and test_redirection().

◆ get_temp_buffer()

static char* get_temp_buffer ( int  size)
static

Definition at line 62 of file registry.c.

63 {
64  static char *list[32];
65  static UINT pos;
66  char *ret;
67  UINT idx;
68 
69  idx = ++pos % (sizeof(list)/sizeof(list[0]));
70  if (list[idx])
72  else
73  ret = HeapAlloc( GetProcessHeap(), 0, size );
74  if (ret) list[idx] = ret;
75  return ret;
76 }
unsigned int idx
Definition: utils.c:41
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
int ret
Definition: _list.h:228
#define HeapReAlloc
Definition: compat.h:393
#define list
Definition: rosglue.h:35
unsigned int UINT
Definition: ndis.h:50

Referenced by wine_debugstr_an().

◆ InitFunctionPtrs()

static void InitFunctionPtrs ( void  )
static

Definition at line 132 of file registry.c.

133 {
134  HMODULE hntdll = GetModuleHandleA("ntdll.dll");
135  HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
136  HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
137 
138  /* This function was introduced with Windows 2003 SP1 */
145 
146  pIsWow64Process = (void *)GetProcAddress( hkernel32, "IsWow64Process" );
147  pRtlFormatCurrentUserKeyPath = (void *)GetProcAddress( hntdll, "RtlFormatCurrentUserKeyPath" );
148  pRtlFreeUnicodeString = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString");
149  pNtDeleteKey = (void *)GetProcAddress( hntdll, "NtDeleteKey" );
150 }
LONG WINAPI RegDeleteKeyValueA(IN HKEY hKey, IN LPCSTR lpSubKey OPTIONAL, IN LPCSTR lpValueName OPTIONAL)
Definition: reg.c:1428
LONG WINAPI RegDeleteKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ REGSAM samDesired, _In_ DWORD Reserved)
Definition: reg.c:1252
LONG WINAPI RegSetKeyValueW(IN HKEY hKey, IN LPCWSTR lpSubKey OPTIONAL, IN LPCWSTR lpValueName OPTIONAL, IN DWORD dwType, IN LPCVOID lpData OPTIONAL, IN DWORD cbData)
Definition: reg.c:2172
static HINSTANCE hkernel32
Definition: process.c:66
LONG WINAPI RegDeleteTreeA(IN HKEY hKey, IN LPCSTR lpSubKey OPTIONAL)
Definition: reg.c:1840
#define ADVAPI32_GET_PROC(func)
Definition: registry.c:129
LONG WINAPI RegCopyTreeA(IN HKEY hKeySrc, IN LPCSTR lpSubKey OPTIONAL, IN HKEY hKeyDest)
Definition: reg.c:811
LSTATUS WINAPI RegGetValueA(HKEY hKey, LPCSTR pszSubKey, LPCSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:2071
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
static HINSTANCE hntdll
Definition: process.c:66
#define GetProcAddress(x, y)
Definition: compat.h:410

Referenced by START_TEST().

◆ LONG()

static LONG ( WINAPI pRegCopyTreeA)
static

Referenced by RtlpQueryRegistryDirect().

◆ NTSTATUS()

static NTSTATUS ( WINAPI pNtDeleteKey)
static

◆ set_privileges()

static BOOL set_privileges ( LPCSTR  privilege,
BOOL  set 
)
static

Definition at line 1525 of file registry.c.

1526 {
1528  HANDLE hToken;
1529  LUID luid;
1530 
1532  return FALSE;
1533 
1534  if(!LookupPrivilegeValueA(NULL, privilege, &luid))
1535  {
1536  CloseHandle(hToken);
1537  return FALSE;
1538  }
1539 
1540  tp.PrivilegeCount = 1;
1541  tp.Privileges[0].Luid = luid;
1542 
1543  if (set)
1544  tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
1545  else
1546  tp.Privileges[0].Attributes = 0;
1547 
1548  AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL);
1549  if (GetLastError() != ERROR_SUCCESS)
1550  {
1551  CloseHandle(hToken);
1552  return FALSE;
1553  }
1554 
1555  CloseHandle(hToken);
1556  return TRUE;
1557 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
_In_ UINT64 _In_ UINT64 _In_ UINT64 _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2694
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
smooth NULL
Definition: ftsmooth.c:416
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:376
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
Definition: _set.h:46
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:876
BOOL WINAPI LookupPrivilegeValueA(LPCSTR lpSystemName, LPCSTR lpName, PLUID lpLuid)
Definition: misc.c:732

Referenced by test_reg_load_key(), test_reg_save_key(), and test_reg_unload_key().

◆ setup_main_key()

static void setup_main_key ( void  )
static

Definition at line 175 of file registry.c.

176 {
177  if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Test", &hkey_main )) delete_key( hkey_main );
178 
179  assert (!RegCreateKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Test", &hkey_main ));
180 }
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define assert(x)
Definition: debug.h:53
static HKEY hkey_main
Definition: registry.c:37
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1177
static DWORD delete_key(HKEY hkey)
Definition: registry.c:153

Referenced by START_TEST(), test_deleted_key(), and test_reg_delete_key().

◆ START_TEST()

START_TEST ( registry  )

Definition at line 3760 of file registry.c.

3761 {
3762  /* Load pointers for functions that are not available in all Windows versions */
3763  InitFunctionPtrs();
3764 
3765  setup_main_key();
3766  check_user_privs();
3767  test_set_value();
3769  test_enum_value();
3771  test_get_value();
3779  test_symlinks();
3780  test_redirection();
3781  test_classesroot();
3784  test_perflib_key();
3790  test_rw_order();
3791  test_deleted_key();
3797 
3798  /* cleanup */
3799  delete_key( hkey_main );
3800 
3802 }
static void InitFunctionPtrs(void)
Definition: registry.c:132
static void test_reg_close_key(void)
Definition: registry.c:1458
static void test_reg_load_key(void)
Definition: registry.c:1576
static void test_reg_create_key(void)
Definition: registry.c:1283
static void test_reg_query_value(void)
Definition: registry.c:1672
static HKEY hkey_main
Definition: registry.c:37
static void test_query_value_ex(void)
Definition: registry.c:773
static void test_classesroot_mask(void)
Definition: registry.c:3277
static void test_rw_order(void)
Definition: registry.c:2300
static void setup_main_key(void)
Definition: registry.c:175
static void test_string_termination(void)
Definition: registry.c:2038
static void create_test_entries(void)
Definition: registry.c:495
static void test_reg_copy_tree(void)
Definition: registry.c:2115
static void test_RegQueryValueExPerformanceData(void)
Definition: registry.c:3553
static void test_reg_query_info(void)
Definition: registry.c:1795
static void test_regconnectregistry(void)
Definition: registry.c:1622
static void test_classesroot_enum(void)
Definition: registry.c:3100
static void test_classesroot(void)
Definition: registry.c:2801
static void test_RegOpenCurrentUser(void)
Definition: registry.c:3490
static void test_set_value(void)
Definition: registry.c:294
static void test_reg_delete_key(void)
Definition: registry.c:1492
static void test_deleted_key(void)
Definition: registry.c:3341
static void test_RegNotifyChangeKeyValue(void)
Definition: registry.c:3502
static void test_get_value(void)
Definition: registry.c:800
static void test_enum_value(void)
Definition: registry.c:518
static void test_reg_unload_key(void)
Definition: registry.c:1599
static void test_reg_save_key(void)
Definition: registry.c:1559
static void test_symlinks(void)
Definition: registry.c:2346
static void test_perflib_key(void)
Definition: registry.c:3309
static void test_delete_value(void)
Definition: registry.c:3387
static void test_redirection(void)
Definition: registry.c:2500
static DWORD delete_key(HKEY hkey)
Definition: registry.c:153
static void test_reg_open_key(void)
Definition: registry.c:1004
static void check_user_privs(void)
Definition: registry.c:182
static void test_reg_delete_tree(void)
Definition: registry.c:2210
static void test_delete_key_value(void)
Definition: registry.c:3427

◆ test_classesroot()

static void test_classesroot ( void  )
static

Definition at line 2801 of file registry.c.

2802 {
2803  HKEY hkey, hklm, hkcr, hkeysub1, hklmsub1, hkcrsub1, hklmsub2, hkcrsub2;
2804  DWORD size = 8;
2805  DWORD type = REG_SZ;
2806  static CHAR buffer[8];
2807  LONG res;
2808 
2809  /* create a key in the user's classes */
2810  if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Classes\\WineTestCls", &hkey ))
2811  {
2812  delete_key( hkey );
2813  RegCloseKey( hkey );
2814  }
2815  res = RegCreateKeyExA( HKEY_CURRENT_USER, "Software\\Classes\\WineTestCls", 0, NULL, 0,
2817  if (res == ERROR_ACCESS_DENIED)
2818  {
2819  skip("not enough privileges to add a user class\n");
2820  return;
2821  }
2822  ok(!IS_HKCR(hkey), "hkcr mask set in %p\n", hkey);
2823 
2824  /* try to open that key in hkcr */
2825  res = RegOpenKeyExA( HKEY_CLASSES_ROOT, "WineTestCls", 0,
2826  KEY_QUERY_VALUE|KEY_SET_VALUE, &hkcr );
2828  broken(res == ERROR_FILE_NOT_FOUND /* WinNT */),
2829  "test key not found in hkcr: %d\n", res);
2830  if (res)
2831  {
2832  skip("HKCR key merging not supported\n");
2833  delete_key( hkey );
2834  RegCloseKey( hkey );
2835  return;
2836  }
2837 
2838  todo_wine ok(IS_HKCR(hkcr), "hkcr mask not set in %p\n", hkcr);
2839 
2840  /* set a value in user's classes */
2841  res = RegSetValueExA(hkey, "val1", 0, REG_SZ, (const BYTE *)"user", sizeof("user"));
2842  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
2843 
2844  /* try to find the value in hkcr */
2845  res = RegQueryValueExA(hkcr, "val1", NULL, &type, (LPBYTE)buffer, &size);
2846  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", res);
2847  ok(!strcmp( buffer, "user" ), "value set to '%s'\n", buffer );
2848 
2849  /* modify the value in hkcr */
2850  res = RegSetValueExA(hkcr, "val1", 0, REG_SZ, (const BYTE *)"hkcr", sizeof("hkcr"));
2851  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
2852 
2853  /* check if the value is also modified in user's classes */
2854  res = RegQueryValueExA(hkey, "val1", NULL, &type, (LPBYTE)buffer, &size);
2855  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d, GLE=%x\n", res, GetLastError());
2856  ok(!strcmp( buffer, "hkcr" ), "value set to '%s'\n", buffer );
2857 
2858  /* set a value in hkcr */
2859  res = RegSetValueExA(hkcr, "val0", 0, REG_SZ, (const BYTE *)"hkcr", sizeof("hkcr"));
2860  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
2861 
2862  /* try to find the value in user's classes */
2863  res = RegQueryValueExA(hkey, "val0", NULL, &type, (LPBYTE)buffer, &size);
2864  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", res);
2865  ok(!strcmp( buffer, "hkcr" ), "value set to '%s'\n", buffer );
2866 
2867  /* modify the value in user's classes */
2868  res = RegSetValueExA(hkey, "val0", 0, REG_SZ, (const BYTE *)"user", sizeof("user"));
2869  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
2870 
2871  /* check if the value is also modified in hkcr */
2872  res = RegQueryValueExA(hkcr, "val0", NULL, &type, (LPBYTE)buffer, &size);
2873  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d, GLE=%x\n", res, GetLastError());
2874  ok(!strcmp( buffer, "user" ), "value set to '%s'\n", buffer );
2875 
2876  /* cleanup */
2877  delete_key( hkey );
2878  delete_key( hkcr );
2879  RegCloseKey( hkey );
2880  RegCloseKey( hkcr );
2881 
2882  /* create a key in the hklm classes */
2883  if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Classes\\WineTestCls", &hklm ))
2884  {
2885  delete_key( hklm );
2886  RegCloseKey( hklm );
2887  }
2888  res = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Classes\\WineTestCls", 0, NULL, REG_OPTION_NON_VOLATILE,
2889  KEY_ALL_ACCESS, NULL, &hklm, NULL );
2890  if (res == ERROR_ACCESS_DENIED)
2891  {
2892  skip("not enough privileges to add a system class\n");
2893  return;
2894  }
2895  ok(!IS_HKCR(hklm), "hkcr mask set in %p\n", hklm);
2896 
2897  /* try to open that key in hkcr */
2898  res = RegOpenKeyExA( HKEY_CLASSES_ROOT, "WineTestCls", 0,
2899  KEY_QUERY_VALUE|KEY_SET_VALUE, &hkcr );
2900  ok(res == ERROR_SUCCESS,
2901  "test key not found in hkcr: %d\n", res);
2902  ok(IS_HKCR(hkcr), "hkcr mask not set in %p\n", hkcr);
2903  if (res)
2904  {
2905  delete_key( hklm );
2906  RegCloseKey( hklm );
2907  return;
2908  }
2909 
2910  /* set a value in hklm classes */
2911  res = RegSetValueExA(hklm, "val2", 0, REG_SZ, (const BYTE *)"hklm", sizeof("hklm"));
2912  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
2913 
2914  /* try to find the value in hkcr */
2915  res = RegQueryValueExA(hkcr, "val2", NULL, &type, (LPBYTE)buffer, &size);
2916  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", res);
2917  ok(!strcmp( buffer, "hklm" ), "value set to '%s'\n", buffer );
2918 
2919  /* modify the value in hkcr */
2920  res = RegSetValueExA(hkcr, "val2", 0, REG_SZ, (const BYTE *)"hkcr", sizeof("hkcr"));
2921  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
2922 
2923  /* check that the value is modified in hklm classes */
2924  res = RegQueryValueExA(hklm, "val2", NULL, &type, (LPBYTE)buffer, &size);
2925  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d, GLE=%x\n", res, GetLastError());
2926  ok(!strcmp( buffer, "hkcr" ), "value set to '%s'\n", buffer );
2927 
2928  if (RegCreateKeyExA( HKEY_CURRENT_USER, "Software\\Classes\\WineTestCls", 0, NULL, 0,
2929  KEY_QUERY_VALUE|KEY_SET_VALUE, NULL, &hkey, NULL )) return;
2930  ok(!IS_HKCR(hkey), "hkcr mask set in %p\n", hkey);
2931 
2932  /* try to open that key in hkcr */
2933  res = RegOpenKeyExA( HKEY_CLASSES_ROOT, "WineTestCls", 0,
2934  KEY_QUERY_VALUE|KEY_SET_VALUE, &hkcr );
2935  ok(res == ERROR_SUCCESS,
2936  "test key not found in hkcr: %d\n", res);
2937  ok(IS_HKCR(hkcr), "hkcr mask not set in %p\n", hkcr);
2938 
2939  /* set a value in user's classes */
2940  res = RegSetValueExA(hkey, "val2", 0, REG_SZ, (const BYTE *)"user", sizeof("user"));
2941  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
2942 
2943  /* try to find the value in hkcr */
2944  res = RegQueryValueExA(hkcr, "val2", NULL, &type, (LPBYTE)buffer, &size);
2945  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", res);
2946  ok(!strcmp( buffer, "user" ), "value set to '%s'\n", buffer );
2947 
2948  /* modify the value in hklm */
2949  res = RegSetValueExA(hklm, "val2", 0, REG_SZ, (const BYTE *)"hklm", sizeof("hklm"));
2950  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
2951 
2952  /* check that the value is not overwritten in hkcr or user's classes */
2953  res = RegQueryValueExA(hkcr, "val2", NULL, &type, (LPBYTE)buffer, &size);
2954  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", res);
2955  ok(!strcmp( buffer, "user" ), "value set to '%s'\n", buffer );
2956  res = RegQueryValueExA(hkey, "val2", NULL, &type, (LPBYTE)buffer, &size);
2957  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d, GLE=%x\n", res, GetLastError());
2958  ok(!strcmp( buffer, "user" ), "value set to '%s'\n", buffer );
2959 
2960  /* modify the value in hkcr */
2961  res = RegSetValueExA(hkcr, "val2", 0, REG_SZ, (const BYTE *)"hkcr", sizeof("hkcr"));
2962  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
2963 
2964  /* check that the value is overwritten in hklm and user's classes */
2965  res = RegQueryValueExA(hkcr, "val2", NULL, &type, (LPBYTE)buffer, &size);
2966  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", res);
2967  ok(!strcmp( buffer, "hkcr" ), "value set to '%s'\n", buffer );
2968  res = RegQueryValueExA(hkey, "val2", NULL, &type, (LPBYTE)buffer, &size);
2969  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d, GLE=%x\n", res, GetLastError());
2970  ok(!strcmp( buffer, "hkcr" ), "value set to '%s'\n", buffer );
2971 
2972  /* create a subkey in hklm */
2973  if (RegCreateKeyExA( hklm, "subkey1", 0, NULL, 0,
2974  KEY_QUERY_VALUE|KEY_SET_VALUE, NULL, &hklmsub1, NULL )) return;
2975  ok(!IS_HKCR(hklmsub1), "hkcr mask set in %p\n", hklmsub1);
2976  /* try to open that subkey in hkcr */
2977  res = RegOpenKeyExA( hkcr, "subkey1", 0, KEY_QUERY_VALUE|KEY_SET_VALUE, &hkcrsub1 );
2978  ok(res == ERROR_SUCCESS, "test key not found in hkcr: %d\n", res);
2979  ok(IS_HKCR(hkcrsub1), "hkcr mask not set in %p\n", hkcrsub1);
2980 
2981  /* set a value in hklm classes */
2982  res = RegSetValueExA(hklmsub1, "subval1", 0, REG_SZ, (const BYTE *)"hklm", sizeof("hklm"));
2983  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
2984 
2985  /* try to find the value in hkcr */
2986  res = RegQueryValueExA(hkcrsub1, "subval1", NULL, &type, (LPBYTE)buffer, &size);
2987  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", res);
2988  ok(!strcmp( buffer, "hklm" ), "value set to '%s'\n", buffer );
2989 
2990  /* modify the value in hkcr */
2991  res = RegSetValueExA(hkcrsub1, "subval1", 0, REG_SZ, (const BYTE *)"hkcr", sizeof("hkcr"));
2992  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
2993 
2994  /* check that the value is modified in hklm classes */
2995  res = RegQueryValueExA(hklmsub1, "subval1", NULL, &type, (LPBYTE)buffer, &size);
2996  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d, GLE=%x\n", res, GetLastError());
2997  ok(!strcmp( buffer, "hkcr" ), "value set to '%s'\n", buffer );
2998 
2999  /* create a subkey in user's classes */
3000  if (RegCreateKeyExA( hkey, "subkey1", 0, NULL, 0,
3001  KEY_QUERY_VALUE|KEY_SET_VALUE, NULL, &hkeysub1, NULL )) return;
3002  ok(!IS_HKCR(hkeysub1), "hkcr mask set in %p\n", hkeysub1);
3003 
3004  /* set a value in user's classes */
3005  res = RegSetValueExA(hkeysub1, "subval1", 0, REG_SZ, (const BYTE *)"user", sizeof("user"));
3006  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
3007 
3008  /* try to find the value in hkcr */
3009  res = RegQueryValueExA(hkcrsub1, "subval1", NULL, &type, (LPBYTE)buffer, &size);
3010  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", res);
3011  ok(!strcmp( buffer, "user" ), "value set to '%s'\n", buffer );
3012 
3013  /* modify the value in hklm */
3014  res = RegSetValueExA(hklmsub1, "subval1", 0, REG_SZ, (const BYTE *)"hklm", sizeof("hklm"));
3015  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
3016 
3017  /* check that the value is not overwritten in hkcr or user's classes */
3018  res = RegQueryValueExA(hkcrsub1, "subval1", NULL, &type, (LPBYTE)buffer, &size);
3019  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", res);
3020  ok(!strcmp( buffer, "user" ), "value set to '%s'\n", buffer );
3021  res = RegQueryValueExA(hkeysub1, "subval1", NULL, &type, (LPBYTE)buffer, &size);
3022  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d, GLE=%x\n", res, GetLastError());
3023  ok(!strcmp( buffer, "user" ), "value set to '%s'\n", buffer );
3024 
3025  /* modify the value in hkcr */
3026  res = RegSetValueExA(hkcrsub1, "subval1", 0, REG_SZ, (const BYTE *)"hkcr", sizeof("hkcr"));
3027  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
3028 
3029  /* check that the value is not overwritten in hklm, but in user's classes */
3030  res = RegQueryValueExA(hklmsub1, "subval1", NULL, &type, (LPBYTE)buffer, &size);
3031  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", res);
3032  ok(!strcmp( buffer, "hklm" ), "value set to '%s'\n", buffer );
3033  res = RegQueryValueExA(hkeysub1, "subval1", NULL, &type, (LPBYTE)buffer, &size);
3034  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d, GLE=%x\n", res, GetLastError());
3035  ok(!strcmp( buffer, "hkcr" ), "value set to '%s'\n", buffer );
3036 
3037  /* new subkey in hkcr */
3038  if (RegCreateKeyExA( hkcr, "subkey2", 0, NULL, 0,
3039  KEY_QUERY_VALUE|KEY_SET_VALUE, NULL, &hkcrsub2, NULL )) return;
3040  ok(IS_HKCR(hkcrsub2), "hkcr mask not set in %p\n", hkcrsub2);
3041  res = RegSetValueExA(hkcrsub2, "subval1", 0, REG_SZ, (const BYTE *)"hkcr", sizeof("hkcr"));
3042  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d, GLE=%x\n", res, GetLastError());
3043 
3044  /* try to open that new subkey in user's classes and hklm */
3045  res = RegOpenKeyExA( hkey, "subkey2", 0, KEY_QUERY_VALUE|KEY_SET_VALUE, &hklmsub2 );
3046  ok(res != ERROR_SUCCESS, "test key found in user's classes: %d\n", res);
3047  hklmsub2 = 0;
3048  res = RegOpenKeyExA( hklm, "subkey2", 0, KEY_QUERY_VALUE|KEY_SET_VALUE, &hklmsub2 );
3049  ok(res == ERROR_SUCCESS, "test key not found in hklm: %d\n", res);
3050  ok(!IS_HKCR(hklmsub2), "hkcr mask set in %p\n", hklmsub2);
3051 
3052  /* check that the value is present in hklm */
3053  res = RegQueryValueExA(hklmsub2, "subval1", NULL, &type, (LPBYTE)buffer, &size);
3054  ok(res == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", res);
3055  ok(!strcmp( buffer, "hkcr" ), "value set to '%s'\n", buffer );
3056 
3057  /* cleanup */
3058  RegCloseKey( hkeysub1 );
3059  RegCloseKey( hklmsub1 );
3060 
3061  /* delete subkey1 from hkcr (should point at user's classes) */
3062  res = RegDeleteKeyA(hkcr, "subkey1");
3063  ok(res == ERROR_SUCCESS, "RegDeleteKey failed: %d\n", res);
3064 
3065  /* confirm key was removed in hkey but not hklm */
3066  res = RegOpenKeyExA(hkey, "subkey1", 0, KEY_READ, &hkeysub1);
3067  ok(res == ERROR_FILE_NOT_FOUND, "test key found in user's classes: %d\n", res);
3068  res = RegOpenKeyExA(hklm, "subkey1", 0, KEY_READ, &hklmsub1);
3069  ok(res == ERROR_SUCCESS, "test key not found in hklm: %d\n", res);
3070  ok(!IS_HKCR(hklmsub1), "hkcr mask set in %p\n", hklmsub1);
3071 
3072  /* delete subkey1 from hkcr again (which should now point at hklm) */
3073  res = RegDeleteKeyA(hkcr, "subkey1");
3074  ok(res == ERROR_SUCCESS, "RegDeleteKey failed: %d\n", res);
3075 
3076  /* confirm hkey was removed in hklm */
3077  RegCloseKey( hklmsub1 );
3078  res = RegOpenKeyExA(hklm, "subkey1", 0, KEY_READ, &hklmsub1);
3079  ok(res == ERROR_FILE_NOT_FOUND, "test key found in hklm: %d\n", res);
3080 
3081  /* final cleanup */
3082  delete_key( hkey );
3083  delete_key( hklm );
3084  delete_key( hkcr );
3085  delete_key( hkeysub1 );
3086  delete_key( hklmsub1 );
3087  delete_key( hkcrsub1 );
3088  delete_key( hklmsub2 );
3089  delete_key( hkcrsub2 );
3090  RegCloseKey( hkey );
3091  RegCloseKey( hklm );
3092  RegCloseKey( hkcr );
3093  RegCloseKey( hkeysub1 );
3094  RegCloseKey( hklmsub1 );
3095  RegCloseKey( hkcrsub1 );
3096  RegCloseKey( hklmsub2 );
3097  RegCloseKey( hkcrsub2 );
3098 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define KEY_READ
Definition: nt_native.h:1023
#define IS_HKCR(hk)
Definition: registry.c:35
#define HKEY_CURRENT_USER
Definition: winreg.h:11
char CHAR
Definition: xmlstorage.h:175
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3331
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
unsigned char * LPBYTE
Definition: typedefs.h:52
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
long LONG
Definition: pedump.c:60
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define todo_wine
Definition: test.h:154
unsigned char BYTE
Definition: mem.h:68
#define broken(x)
Definition: _sntprintf.h:21
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1222
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
static DWORD delete_key(HKEY hkey)
Definition: registry.c:153
#define skip(...)
GLuint res
Definition: glext.h:9613
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1029
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by START_TEST().

◆ test_classesroot_enum()

static void test_classesroot_enum ( void  )
static

Definition at line 3100 of file registry.c.

3101 {
3102  HKEY hkcu=0, hklm=0, hkcr=0, hkcusub[2]={0}, hklmsub[2]={0};
3103  DWORD size;
3104  static CHAR buffer[2];
3105  LONG res;
3106 
3107  /* prepare initial testing env in HKCU */
3108  if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Classes\\WineTestCls", &hkcu ))
3109  {
3110  delete_key( hkcu );
3111  RegCloseKey( hkcu );
3112  }
3113  res = RegCreateKeyExA( HKEY_CURRENT_USER, "Software\\Classes\\WineTestCls", 0, NULL, 0,
3115 
3116  if (res != ERROR_SUCCESS)
3117  {
3118  skip("failed to add a user class\n");
3119  return;
3120  }
3121 
3122  res = RegOpenKeyA( HKEY_CLASSES_ROOT, "WineTestCls", &hkcr );
3124  broken(res == ERROR_FILE_NOT_FOUND /* WinNT */),
3125  "test key not found in hkcr: %d\n", res);
3126  if (res)
3127  {
3128  skip("HKCR key merging not supported\n");
3129  delete_key( hkcu );
3130  RegCloseKey( hkcu );
3131  return;
3132  }
3133 
3134  res = RegSetValueExA( hkcu, "X", 0, REG_SZ, (const BYTE *) "AA", 3 );
3135  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d\n", res);
3136  res = RegSetValueExA( hkcu, "Y", 0, REG_SZ, (const BYTE *) "B", 2 );
3137  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d\n", res);
3138  res = RegCreateKeyA( hkcu, "A", &hkcusub[0] );
3139  ok(res == ERROR_SUCCESS, "RegCreateKeyA failed: %d\n", res);
3140  res = RegCreateKeyA( hkcu, "B", &hkcusub[1] );
3141  ok(res == ERROR_SUCCESS, "RegCreateKeyA failed: %d\n", res);
3142 
3143  /* test on values in HKCU */
3144  size = sizeof(buffer);
3145  res = RegEnumValueA( hkcr, 0, buffer, &size, NULL, NULL, NULL, NULL );
3146  ok(res == ERROR_SUCCESS, "RegEnumValueA failed: %d\n", res );
3147  ok(!strcmp( buffer, "X" ), "expected 'X', got '%s'\n", buffer);
3148  size = sizeof(buffer);
3149  res = RegEnumValueA( hkcr, 1, buffer, &size, NULL, NULL, NULL, NULL );
3150  ok(res == ERROR_SUCCESS, "RegEnumValueA failed: %d\n", res );
3151  ok(!strcmp( buffer, "Y" ), "expected 'Y', got '%s'\n", buffer);
3152  size = sizeof(buffer);
3153  res = RegEnumValueA( hkcr, 2, buffer, &size, NULL, NULL, NULL, NULL );
3154  ok(res == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %d\n", res );
3155 
3156  res = RegEnumKeyA( hkcr, 0, buffer, size );
3157  ok(res == ERROR_SUCCESS, "RegEnumKey failed: %d\n", res );
3158  ok(!strcmp( buffer, "A" ), "expected 'A', got '%s'\n", buffer);
3159  res = RegEnumKeyA( hkcr, 1, buffer, size );
3160  ok(res == ERROR_SUCCESS, "RegEnumKey failed: %d\n", res );
3161  ok(!strcmp( buffer, "B" ), "expected 'B', got '%s'\n", buffer);
3162  res = RegEnumKeyA( hkcr, 2, buffer, size );
3163  ok(res == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %d\n", res );
3164 
3165  /* prepare test env in HKLM */
3166  if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Classes\\WineTestCls", &hklm ))
3167  {
3168  delete_key( hklm );
3169  RegCloseKey( hklm );
3170  }
3171 
3172  res = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Classes\\WineTestCls", 0, NULL, 0,
3174 
3175  if (res == ERROR_ACCESS_DENIED)
3176  {
3177  RegCloseKey( hkcusub[0] );
3178  RegCloseKey( hkcusub[1] );
3179  delete_key( hkcu );
3180  RegCloseKey( hkcu );
3181  RegCloseKey( hkcr );
3182  skip("not enough privileges to add a system class\n");
3183  return;
3184  }
3185 
3186  res = RegSetValueExA( hklm, "X", 0, REG_SZ, (const BYTE *) "AB", 3 );
3187  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d\n", res);
3188  res = RegSetValueExA( hklm, "Z", 0, REG_SZ, (const BYTE *) "C", 2 );
3189  ok(res == ERROR_SUCCESS, "RegSetValueExA failed: %d\n", res);
3190  res = RegCreateKeyA( hklm, "A", &hklmsub[0] );
3191  ok(res == ERROR_SUCCESS, "RegCreateKeyA failed: %d\n", res);
3192  res = RegCreateKeyA( hklm, "C", &hklmsub[1] );
3193  ok(res == ERROR_SUCCESS, "RegCreateKeyA failed: %d\n", res);
3194 
3195  /* test on values/keys in both HKCU and HKLM */
3196  size = sizeof(buffer);
3197  res = RegEnumValueA( hkcr, 0, buffer, &size, NULL, NULL, NULL, NULL );
3198  ok(res == ERROR_SUCCESS, "RegEnumValueA failed: %d\n", res );
3199  ok(!strcmp( buffer, "X" ), "expected 'X', got '%s'\n", buffer);
3200  size = sizeof(buffer);
3201  res = RegEnumValueA( hkcr, 1, buffer, &size, NULL, NULL, NULL, NULL );
3202  ok(res == ERROR_SUCCESS, "RegEnumValueA failed: %d\n", res );
3203  ok(!strcmp( buffer, "Y" ), "expected 'Y', got '%s'\n", buffer);
3204  size = sizeof(buffer);
3205  res = RegEnumValueA( hkcr, 2, buffer, &size, NULL, NULL, NULL, NULL );
3206  ok(res == ERROR_SUCCESS, "RegEnumValueA failed: %d\n", res );
3207  ok(!strcmp( buffer, "Z" ), "expected 'Z', got '%s'\n", buffer);
3208  size = sizeof(buffer);
3209  res = RegEnumValueA( hkcr, 3, buffer, &size, NULL, NULL, NULL, NULL );
3210  ok(res == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %d\n", res );
3211 
3212  res = RegEnumKeyA( hkcr, 0, buffer, size );
3213  ok(res == ERROR_SUCCESS, "RegEnumKey failed: %d\n", res );
3214  ok(!strcmp( buffer, "A" ), "expected 'A', got '%s'\n", buffer);
3215  res = RegEnumKeyA( hkcr, 1, buffer, size );
3216  ok(res == ERROR_SUCCESS, "RegEnumKey failed: %d\n", res );
3217  ok(!strcmp( buffer, "B" ), "expected 'B', got '%s'\n", buffer);
3218  res = RegEnumKeyA( hkcr, 2, buffer, size );
3219  ok(res == ERROR_SUCCESS, "RegEnumKey failed: %d\n", res );
3220  ok(!strcmp( buffer, "C" ), "expected 'C', got '%s'\n", buffer);
3221  res = RegEnumKeyA( hkcr, 3, buffer, size );
3222  ok(res == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %d\n", res );
3223 
3224  /* delete values/keys from HKCU to test only on HKLM */
3225  RegCloseKey( hkcusub[0] );
3226  RegCloseKey( hkcusub[1] );
3227  delete_key( hkcu );
3228  RegCloseKey( hkcu );
3229 
3230  size = sizeof(buffer);
3231  res = RegEnumValueA( hkcr, 0, buffer, &size, NULL, NULL, NULL, NULL );
3232  ok(res == ERROR_KEY_DELETED ||
3233  res == ERROR_NO_SYSTEM_RESOURCES, /* Windows XP */
3234  "expected ERROR_KEY_DELETED, got %d\n", res);
3235  size = sizeof(buffer);
3236  res = RegEnumKeyA( hkcr, 0, buffer, size );
3237  ok(res == ERROR_KEY_DELETED ||
3238  res == ERROR_NO_SYSTEM_RESOURCES, /* Windows XP */
3239  "expected ERROR_KEY_DELETED, got %d\n", res);
3240 
3241  /* reopen HKCR handle */
3242  RegCloseKey( hkcr );
3243  res = RegOpenKeyA( HKEY_CLASSES_ROOT, "WineTestCls", &hkcr );
3244  ok(res == ERROR_SUCCESS, "test key not found in hkcr: %d\n", res);
3245  if (res) goto cleanup;
3246 
3247  /* test on values/keys in HKLM */
3248  size = sizeof(buffer);
3249  res = RegEnumValueA( hkcr, 0, buffer, &size, NULL, NULL, NULL, NULL );
3250  ok(res == ERROR_SUCCESS, "RegEnumValueA failed: %d\n", res );
3251  ok(!strcmp( buffer, "X" ), "expected 'X', got '%s'\n", buffer);
3252  size = sizeof(buffer);
3253  res = RegEnumValueA( hkcr, 1, buffer, &size, NULL, NULL, NULL, NULL );
3254  ok(res == ERROR_SUCCESS, "RegEnumValueA failed: %d\n", res );
3255  ok(!strcmp( buffer, "Z" ), "expected 'Z', got '%s'\n", buffer);
3256  size = sizeof(buffer);
3257  res = RegEnumValueA( hkcr, 2, buffer, &size, NULL, NULL, NULL, NULL );
3258  ok(res == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %d\n", res );
3259 
3260  res = RegEnumKeyA( hkcr, 0, buffer, size );
3261  ok(res == ERROR_SUCCESS, "RegEnumKey failed: %d\n", res );
3262  ok(!strcmp( buffer, "A" ), "expected 'A', got '%s'\n", buffer);
3263  res = RegEnumKeyA( hkcr, 1, buffer, size );
3264  ok(res == ERROR_SUCCESS, "RegEnumKey failed: %d\n", res );
3265  ok(!strcmp( buffer, "C" ), "expected 'C', got '%s'\n", buffer);
3266  res = RegEnumKeyA( hkcr, 2, buffer, size );
3267  ok(res == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %d\n", res );
3268 
3269 cleanup:
3270  RegCloseKey( hklmsub[0] );
3271  RegCloseKey( hklmsub[1] );
3272  delete_key( hklm );
3273  RegCloseKey( hklm );
3274  RegCloseKey( hkcr );
3275 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
#define HKEY_CURRENT_USER
Definition: winreg.h:11
char CHAR
Definition: xmlstorage.h:175
GLuint buffer
Definition: glext.h:5915
#define ERROR_NO_SYSTEM_RESOURCES
Definition: winerror.h:931
#define ERROR_KEY_DELETED
Definition: winerror.h:597
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
long LONG
Definition: pedump.c:60
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1177
GLsizeiptr size
Definition: glext.h:5919
LONG WINAPI RegEnumValueA(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpdwReserved, _Out_opt_ LPDWORD lpdwType, _Out_opt_ LPBYTE lpData, _Inout_opt_ LPDWORD lpcbData)
Definition: reg.c:2691
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI RegEnumKeyA(HKEY hKey, DWORD dwIndex, LPSTR lpName, DWORD cbName)
Definition: reg.c:2391
#define todo_wine
Definition: test.h:154
unsigned char BYTE
Definition: mem.h:68
#define broken(x)
Definition: _sntprintf.h:21
static DWORD delete_key(HKEY hkey)
Definition: registry.c:153
#define skip(...)
GLuint res
Definition: glext.h:9613
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char * cleanup(char *str)
Definition: wpickclick.c:99
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1029
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define REG_SZ
Definition: layer.c:22

Referenced by START_TEST().

◆ test_classesroot_mask()

static void test_classesroot_mask ( void  )
static

Definition at line 3277 of file registry.c.

3278 {
3279  HKEY hkey;
3280  LSTATUS res;
3281 
3282  res = RegOpenKeyA( HKEY_CLASSES_ROOT, "CLSID", &hkey );
3283  ok(res == ERROR_SUCCESS, "RegOpenKeyA failed: %d\n", res);
3284  todo_wine ok(IS_HKCR(hkey) || broken(!IS_HKCR(hkey)) /* WinNT */,
3285  "hkcr mask not set in %p\n", hkey);
3286  RegCloseKey( hkey );
3287 
3288  res = RegOpenKeyA( HKEY_CURRENT_USER, "Software", &hkey );
3289  ok(res == ERROR_SUCCESS, "RegOpenKeyA failed: %d\n", res);
3290  ok(!IS_HKCR(hkey), "hkcr mask set in %p\n", hkey);
3291  RegCloseKey( hkey );
3292 
3293  res = RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software", &hkey );
3294  ok(res == ERROR_SUCCESS, "RegOpenKeyA failed: %d\n", res);
3295  ok(!IS_HKCR(hkey), "hkcr mask set in %p\n", hkey);
3296  RegCloseKey( hkey );
3297 
3298  res = RegOpenKeyA( HKEY_USERS, ".Default", &hkey );
3299  ok(res == ERROR_SUCCESS, "RegOpenKeyA failed: %d\n", res);
3300  ok(!IS_HKCR(hkey), "hkcr mask set in %p\n", hkey);
3301  RegCloseKey( hkey );
3302 
3303  res = RegOpenKeyA( HKEY_CURRENT_CONFIG, "Software", &hkey );
3304  ok(res == ERROR_SUCCESS, "RegOpenKeyA failed: %d\n", res);
3305  ok(!IS_HKCR(hkey), "hkcr mask set in %p\n", hkey);
3306  RegCloseKey( hkey );
3307 }
#define HKEY_USERS
Definition: winreg.h:13
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IS_HKCR(hk)
Definition: registry.c:35
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
#define ok(value,...)
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define todo_wine
Definition: test.h:154
#define broken(x)
Definition: _sntprintf.h:21
GLuint res
Definition: glext.h:9613
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by START_TEST().

◆ test_delete_key_value()

static void test_delete_key_value ( void  )
static

Definition at line 3427 of file registry.c.

3428 {
3429  HKEY subkey;
3430  LONG ret;
3431 
3432  if (!pRegDeleteKeyValueA)
3433  {
3434  win_skip("RegDeleteKeyValue is not available.\n");
3435  return;
3436  }
3437 
3438  ret = pRegDeleteKeyValueA(NULL, NULL, NULL);
3439  ok(ret == ERROR_INVALID_HANDLE, "got %d\n", ret);
3440 
3441  ret = pRegDeleteKeyValueA(hkey_main, NULL, NULL);
3442  ok(ret == ERROR_FILE_NOT_FOUND, "got %d\n", ret);
3443 
3444  ret = RegSetValueExA(hkey_main, "test", 0, REG_SZ, (const BYTE*)"value", 6);
3445  ok(ret == ERROR_SUCCESS, "got %d\n", ret);
3446 
3447  ret = RegQueryValueExA(hkey_main, "test", NULL, NULL, NULL, NULL);
3448  ok(ret == ERROR_SUCCESS, "got %d\n", ret);
3449 
3450  /* NULL subkey name means delete from open key */
3451  ret = pRegDeleteKeyValueA(hkey_main, NULL, "test");
3452  ok(ret == ERROR_SUCCESS, "got %d\n", ret);
3453 
3454  ret = RegQueryValueExA(hkey_main, "test", NULL, NULL, NULL, NULL);
3455  ok(ret == ERROR_FILE_NOT_FOUND, "got %d\n", ret);
3456 
3457  /* now with real subkey */
3458  ret = RegCreateKeyExA(hkey_main, "Subkey1", 0, NULL, 0, KEY_WRITE|KEY_READ, NULL, &subkey, NULL);
3459  ok(!ret, "failed with error %d\n", ret);
3460 
3461  ret = RegSetValueExA(subkey, "test", 0, REG_SZ, (const BYTE*)"value", 6);
3462  ok(ret == ERROR_SUCCESS, "got %d\n", ret);
3463 
3464  ret = RegQueryValueExA(subkey, "test", NULL, NULL, NULL, NULL);
3465  ok(ret == ERROR_SUCCESS, "got %d\n", ret);
3466 
3467  ret = pRegDeleteKeyValueA(hkey_main, "Subkey1", "test");
3468  ok(ret == ERROR_SUCCESS, "got %d\n", ret);
3469 
3470  ret = RegQueryValueExA(subkey, "test", NULL, NULL, NULL, NULL);
3471  ok(ret == ERROR_FILE_NOT_FOUND, "got %d\n", ret);
3472 
3473  /* Default registry value */
3474  ret = RegSetValueExA(subkey, "", 0, REG_SZ, (const BYTE *)"value", 6);
3475  ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
3476 
3477  ret = RegQueryValueExA(subkey, "", NULL, NULL, NULL, NULL);
3478  ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
3479 
3480  ret = pRegDeleteKeyValueA(hkey_main, "Subkey1", "" );
3481  ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
3482 
3483  ret = RegQueryValueExA(subkey, "", NULL, NULL, NULL, NULL);
3484  ok(ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret);
3485 
3486  RegDeleteKeyA(subkey, "");
3487  RegCloseKey(subkey);
3488 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static HKEY hkey_main
Definition: registry.c:37
long LONG
Definition: pedump.c:60
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define KEY_WRITE
Definition: nt_native.h:1031
int ret
unsigned char BYTE
Definition: mem.h:68
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1222
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1029
#define win_skip
Definition: test.h:141
#define REG_SZ
Definition: layer.c:22

Referenced by START_TEST().

◆ test_delete_value()

static void test_delete_value ( void  )
static

Definition at line 3387 of file registry.c.

3388 {
3389  LONG res;
3390  char longname[401];
3391 
3392  res = RegSetValueExA( hkey_main, "test", 0, REG_SZ, (const BYTE*)"value", 6 );
3393  ok(res == ERROR_SUCCESS, "expect ERROR_SUCCESS, got %i\n", res);
3394 
3395  res = RegQueryValueExA( hkey_main, "test", NULL, NULL, NULL, NULL);
3396  ok(res == ERROR_SUCCESS, "expect ERROR_SUCCESS, got %i\n", res);
3397 
3398  res = RegDeleteValueA( hkey_main, "test" );
3399  ok(res == ERROR_SUCCESS, "expect ERROR_SUCCESS, got %i\n", res);
3400 
3401  res = RegQueryValueExA( hkey_main, "test", NULL, NULL, NULL, NULL);
3402  ok(res == ERROR_FILE_NOT_FOUND, "expect ERROR_FILE_NOT_FOUND, got %i\n", res);
3403 
3404  res = RegDeleteValueA( hkey_main, "test" );
3405  ok(res == ERROR_FILE_NOT_FOUND, "expect ERROR_FILE_NOT_FOUND, got %i\n", res);
3406 
3407  memset(longname, 'a', 400);
3408  longname[400] = 0;
3409  res = RegDeleteValueA( hkey_main, longname );
3410  ok(res == ERROR_FILE_NOT_FOUND || broken(res == ERROR_MORE_DATA), /* nt4, win2k */
3411  "expect ERROR_FILE_NOT_FOUND, got %i\n", res);
3412 
3413  /* Default registry value */
3414  res = RegSetValueExA(hkey_main, "", 0, REG_SZ, (const BYTE *)"value", 6);
3415  ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", res);
3416 
3418  ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", res);
3419 
3420  res = RegDeleteValueA(hkey_main, "" );
3421  ok(res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", res);
3422 
3424  ok(res == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %d\n", res);
3425 }
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
#define ERROR_SUCCESS
Definition: deptool.c:10
static HKEY hkey_main
Definition: registry.c:37
long LONG
Definition: pedump.c:60
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
unsigned char BYTE
Definition: mem.h:68
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define broken(x)
Definition: _sntprintf.h:21
LONG WINAPI RegDeleteValueA(HKEY hKey, LPCSTR lpValueName)
Definition: reg.c:2319
GLuint res
Definition: glext.h:9613
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
#define memset(x, y, z)
Definition: compat.h:39
#define REG_SZ
Definition: layer.c:22

Referenced by START_TEST().

◆ test_deleted_key()

static void test_deleted_key ( void  )
static

Definition at line 3341 of file registry.c.

3342 {
3343  HKEY hkey, hkey2;
3344  char value[20];
3345  DWORD val_count, type;
3346  LONG res;
3347 
3348  /* Open the test key, then delete it while it's open */
3349  RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Test", &hkey );
3350 
3351  delete_key( hkey_main );
3352 
3353  val_count = sizeof(value);
3354  type = 0;
3355  res = RegEnumValueA( hkey, 0, value, &val_count, NULL, &type, 0, 0 );
3356  ok(res == ERROR_KEY_DELETED, "expect ERROR_KEY_DELETED, got %i\n", res);
3357 
3358  res = RegEnumKeyA( hkey, 0, value, sizeof(value) );
3359  ok(res == ERROR_KEY_DELETED, "expect ERROR_KEY_DELETED, got %i\n", res);
3360 
3361  val_count = sizeof(value);
3362  type = 0;
3363  res = RegQueryValueExA( hkey, "test", NULL, &type, (BYTE *)value, &val_count );
3364  ok(res == ERROR_KEY_DELETED, "expect ERROR_KEY_DELETED, got %i\n", res);
3365 
3366  res = RegSetValueExA( hkey, "test", 0, REG_SZ, (const BYTE*)"value", 6);
3367  ok(res == ERROR_KEY_DELETED, "expect ERROR_KEY_DELETED, got %i\n", res);
3368 
3369  res = RegOpenKeyA( hkey, "test", &hkey2 );
3370  ok(res == ERROR_KEY_DELETED, "expect ERROR_KEY_DELETED, got %i\n", res);
3371  if (res == 0)
3372  RegCloseKey( hkey2 );
3373 
3374  res = RegCreateKeyA( hkey, "test", &hkey2 );
3375  ok(res == ERROR_KEY_DELETED, "expect ERROR_KEY_DELETED, got %i\n", res);
3376  if (res == 0)
3377  RegCloseKey( hkey2 );
3378 
3379  res = RegFlushKey( hkey );
3380  ok(res == ERROR_KEY_DELETED, "expect ERROR_KEY_DELETED, got %i\n", res);
3381 
3382  RegCloseKey( hkey );
3383 
3384  setup_main_key();
3385 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static HKEY hkey_main
Definition: registry.c:37
LONG WINAPI RegFlushKey(HKEY hKey)
Definition: reg.c:2974
static void setup_main_key(void)
Definition: registry.c:175
#define ERROR_KEY_DELETED
Definition: winerror.h:597
long LONG
Definition: pedump.c:60
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1177
LONG WINAPI RegEnumValueA(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpdwReserved, _Out_opt_ LPDWORD lpdwType, _Out_opt_ LPBYTE lpData, _Inout_opt_ LPDWORD lpcbData)
Definition: reg.c:2691
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI RegEnumKeyA(HKEY hKey, DWORD dwIndex, LPSTR lpName, DWORD cbName)
Definition: reg.c:2391
unsigned char BYTE
Definition: mem.h:68
GLsizei const GLfloat * value
Definition: glext.h:6069
static DWORD delete_key(HKEY hkey)
Definition: registry.c:153
GLuint res
Definition: glext.h:9613
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
#define REG_SZ
Definition: layer.c:22

Referenced by START_TEST().

◆ test_enum_value()

static void test_enum_value ( void  )
static

Definition at line 518 of file registry.c.

519 {
520  DWORD res;
521  HKEY test_key;
522  char value[20], data[20];
523  WCHAR valueW[20], dataW[20];
524  DWORD val_count, data_count, type;
525  static const WCHAR foobarW[] = {'f','o','o','b','a','r',0};
526  static const WCHAR testW[] = {'T','e','s','t',0};
527  static const WCHAR xxxW[] = {'x','x','x','x','x','x','x','x',0};
528 
529  /* create the working key for new 'Test' value */
530  res = RegCreateKeyA( hkey_main, "TestKey", &test_key );
531  ok( res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", res);
532 
533  /* check NULL data with zero length */
534  res = RegSetValueExA( test_key, "Test", 0, REG_SZ, NULL, 0 );
535  if (GetVersion() & 0x80000000)
536  ok( res == ERROR_INVALID_PARAMETER, "RegSetValueExA returned %d\n", res );
537  else
538  ok( !res, "RegSetValueExA returned %d\n", res );
539  res = RegSetValueExA( test_key, "Test", 0, REG_EXPAND_SZ, NULL, 0 );
540  ok( ERROR_SUCCESS == res || ERROR_INVALID_PARAMETER == res, "RegSetValueExA returned %d\n", res );
541  res = RegSetValueExA( test_key, "Test", 0, REG_BINARY, NULL, 0 );
542  ok( ERROR_SUCCESS == res || ERROR_INVALID_PARAMETER == res, "RegSetValueExA returned %d\n", res );
543 
544  /* test reading the value and data without setting them */
545  val_count = 20;
546  data_count = 20;
547  type = 1234;
548  strcpy( value, "xxxxxxxxxx" );
549  strcpy( data, "xxxxxxxxxx" );
550  res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, (LPBYTE)data, &data_count );
551  ok( res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", res );
552  ok( val_count == 4, "val_count set to %d instead of 4\n", val_count );
553  ok( data_count == 0, "data_count set to %d instead of 0\n", data_count );
554  ok( type == REG_BINARY, "type %d is not REG_BINARY\n", type );
555  ok( !strcmp( value, "Test" ), "value is '%s' instead of Test\n", value );
556  ok( !strcmp( data, "xxxxxxxxxx" ), "data is '%s' instead of xxxxxxxxxx\n", data );
557 
558  val_count = 20;
559  data_count = 20;
560  type = 1234;
561  memcpy( valueW, xxxW, sizeof(xxxW) );
562  memcpy( dataW, xxxW, sizeof(xxxW) );
563  res = RegEnumValueW( test_key, 0, valueW, &val_count, NULL, &type, (BYTE*)dataW, &data_count );
564  ok( res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", res );
565  ok( val_count == 4, "val_count set to %d instead of 4\n", val_count );
566  ok( data_count == 0, "data_count set to %d instead of 0\n", data_count );
567  ok( type == REG_BINARY, "type %d is not REG_BINARY\n", type );
568  ok( !memcmp( valueW, testW, sizeof(testW) ), "value is not 'Test'\n" );
569  ok( !memcmp( dataW, xxxW, sizeof(xxxW) ), "data is not 'xxxxxxxxxx'\n" );
570 
571  res = RegSetValueExA( test_key, "Test", 0, REG_SZ, (const BYTE *)"foobar", 7 );
572  ok( res == 0, "RegSetValueExA failed error %d\n", res );
573 
574  /* overflow both name and data */
575  val_count = 2;
576  data_count = 2;
577  type = 1234;
578  strcpy( value, "xxxxxxxxxx" );
579  strcpy( data, "xxxxxxxxxx" );
580  res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, (LPBYTE)data, &data_count );
581  ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %d\n", res );
582  ok( val_count == 2, "val_count set to %d\n", val_count );
583  ok( data_count == 7 || broken( data_count == 8 ), "data_count set to %d instead of 7\n", data_count );
584  ok( type == REG_SZ, "type %d is not REG_SZ\n", type );
585  ok( !strcmp( value, "xxxxxxxxxx" ), "value set to '%s'\n", value );
586  ok( !strcmp( data, "xxxxxxxxxx" ), "data set to '%s'\n", data );
587 
588  /* overflow name */
589  val_count = 3;
590  data_count = 20;
591  type = 1234;
592  strcpy( value, "xxxxxxxxxx" );
593  strcpy( data, "xxxxxxxxxx" );
594  res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, (LPBYTE)data, &data_count );
595  ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %d\n", res );
596  ok( val_count == 3, "val_count set to %d\n", val_count );
597  ok( data_count == 7 || broken( data_count == 8 ), "data_count set to %d instead of 7\n", data_count );
598  ok( type == REG_SZ, "type %d is not REG_SZ\n", type );
599  /* v5.1.2600.0 (XP Home and Professional) does not touch value or data in this case */
600  ok( !strcmp( value, "Te" ) || !strcmp( value, "xxxxxxxxxx" ),
601  "value set to '%s' instead of 'Te' or 'xxxxxxxxxx'\n", value );
602  ok( !strcmp( data, "foobar" ) || !strcmp( data, "xxxxxxx" ) || broken( !strcmp( data, "xxxxxxxx" ) && data_count == 8 ),
603  "data set to '%s' instead of 'foobar' or 'xxxxxxx'\n", data );
604 
605  /* overflow empty name */
606  val_count = 0;
607  data_count = 20;
608  type = 1234;
609  strcpy( value, "xxxxxxxxxx" );
610  strcpy( data, "xxxxxxxxxx" );
611  res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, (LPBYTE)data, &data_count );
612  ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %d\n", res );
613  ok( val_count == 0, "val_count set to %d\n", val_count );
614  ok( data_count == 7 || broken( data_count == 8 ), "data_count set to %d instead of 7\n", data_count );
615  ok( type == REG_SZ, "type %d is not REG_SZ\n", type );
616  ok( !strcmp( value, "xxxxxxxxxx" ), "value set to '%s'\n", value );
617  /* v5.1.2600.0 (XP Home and Professional) does not touch data in this case */
618  ok( !strcmp( data, "foobar" ) || !strcmp( data, "xxxxxxx" ) || broken( !strcmp( data, "xxxxxxxx" ) && data_count == 8 ),
619  "data set to '%s' instead of 'foobar' or 'xxxxxxx'\n", data );
620 
621  /* overflow data */
622  val_count = 20;
623  data_count = 2;
624  type = 1234;
625  strcpy( value, "xxxxxxxxxx" );
626  strcpy( data, "xxxxxxxxxx" );
627  res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, (LPBYTE)data, &data_count );
628  ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %d\n", res );
629  ok( val_count == 20, "val_count set to %d\n", val_count );
630  ok( data_count == 7, "data_count set to %d instead of 7\n", data_count );
631  ok( type == REG_SZ, "type %d is not REG_SZ\n", type );
632  ok( !strcmp( value, "xxxxxxxxxx" ), "value set to '%s'\n", value );
633  ok( !strcmp( data, "xxxxxxxxxx" ), "data set to '%s'\n", data );
634 
635  /* no overflow */
636  val_count = 20;
637  data_count = 20;
638  type = 1234;
639  strcpy( value, "xxxxxxxxxx" );
640  strcpy( data, "xxxxxxxxxx" );
641  res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, (LPBYTE)data, &data_count );
642  ok( res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", res );
643  ok( val_count == 4, "val_count set to %d instead of 4\n", val_count );
644  ok( data_count == 7, "data_count set to %d instead of 7\n", data_count );
645  ok( type == REG_SZ, "type %d is not REG_SZ\n", type );
646  ok( !strcmp( value, "Test" ), "value is '%s' instead of Test\n", value );
647  ok( !strcmp( data, "foobar" ), "data is '%s' instead of foobar\n", data );
648 
649  if (pRegGetValueA) /* avoid a crash on Windows 2000 */
650  {
651  /* no value and no val_count parameter */
652  data_count = 20;
653  type = 1234;
654  strcpy( data, "xxxxxxxxxx" );
655  res = RegEnumValueA( test_key, 0, NULL, NULL, NULL, &type, (BYTE*)data, &data_count );
656  ok( res == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", res );
657 
658  /* no value parameter */
659  val_count = 20;
660  data_count = 20;
661  type = 1234;
662  strcpy( data, "xxxxxxxxxx" );
663  res = RegEnumValueA( test_key, 0, NULL, &val_count, NULL, &type, (BYTE*)data, &data_count );
664  ok( res == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", res );
665 
666  /* no val_count parameter */
667  data_count = 20;
668  type = 1234;
669  strcpy( value, "xxxxxxxxxx" );
670  strcpy( data, "xxxxxxxxxx" );
671  res = RegEnumValueA( test_key, 0, value, NULL, NULL, &type, (BYTE*)data, &data_count );
672  ok( res == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", res );
673  }
674 
675  /* Unicode tests */
676 
677  SetLastError(0xdeadbeef);
678  res = RegSetValueExW( test_key, testW, 0, REG_SZ, (const BYTE *)foobarW, 7*sizeof(WCHAR) );
680  {
681  win_skip("RegSetValueExW is not implemented\n");
682  goto cleanup;
683  }
684  ok( res == 0, "RegSetValueExW failed error %d\n", res );
685 
686  /* overflow both name and data */
687  val_count = 2;
688  data_count = 2;
689  type = 1234;
690  memcpy( valueW, xxxW, sizeof(xxxW) );
691  memcpy( dataW, xxxW, sizeof(xxxW) );
692  res = RegEnumValueW( test_key, 0, valueW, &val_count, NULL, &type, (BYTE*)dataW, &data_count );
693  ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %d\n", res );
694  ok( val_count == 2, "val_count set to %d\n", val_count );
695  ok( data_count == 7*sizeof(WCHAR), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count );
696  ok( type == REG_SZ, "type %d is not REG_SZ\n", type );
697  ok( !memcmp( valueW, xxxW, sizeof(xxxW) ), "value modified\n" );
698  ok( !memcmp( dataW, xxxW, sizeof(xxxW) ), "data modified\n" );
699 
700  /* overflow name */
701  val_count = 3;
702  data_count = 20;
703  type = 1234;
704  memcpy( valueW, xxxW, sizeof(xxxW) );
705  memcpy( dataW, xxxW, sizeof(xxxW) );
706  res = RegEnumValueW( test_key, 0, valueW, &val_count, NULL, &type, (BYTE*)dataW, &data_count );
707  ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %d\n", res );
708  ok( val_count == 3, "val_count set to %d\n", val_count );
709  ok( data_count == 7*sizeof(WCHAR), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count );
710  ok( type == REG_SZ, "type %d is not REG_SZ\n", type );
711  ok( !memcmp( valueW, xxxW, sizeof(xxxW) ), "value modified\n" );
712  ok( !memcmp( dataW, xxxW, sizeof(xxxW) ), "data modified\n" );
713 
714  /* overflow data */
715  val_count = 20;
716  data_count = 2;
717  type = 1234;
718  memcpy( valueW, xxxW, sizeof(xxxW) );
719  memcpy( dataW, xxxW, sizeof(xxxW) );
720  res = RegEnumValueW( test_key, 0, valueW, &val_count, NULL, &type, (BYTE*)dataW, &data_count );
721  ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %d\n", res );
722  ok( val_count == 4, "val_count set to %d instead of 4\n", val_count );
723  ok( data_count == 7*sizeof(WCHAR), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count );
724  ok( type == REG_SZ, "type %d is not REG_SZ\n", type );
725  ok( !memcmp( valueW, testW, sizeof(testW) ), "value is not 'Test'\n" );
726  ok( !memcmp( dataW, xxxW, sizeof(xxxW) ), "data modified\n" );
727 
728  /* no overflow */
729  val_count = 20;
730  data_count = 20;
731  type = 1234;
732  memcpy( valueW, xxxW, sizeof(xxxW) );
733  memcpy( dataW, xxxW, sizeof(xxxW) );
734  res = RegEnumValueW( test_key, 0, valueW, &val_count, NULL, &type, (BYTE*)dataW, &data_count );
735  ok( res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", res );
736  ok( val_count == 4, "val_count set to %d instead of 4\n", val_count );
737  ok( data_count == 7*sizeof(WCHAR), "data_count set to %d instead of 7*sizeof(WCHAR)\n", data_count );
738  ok( type == REG_SZ, "type %d is not REG_SZ\n", type );
739  ok( !memcmp( valueW, testW, sizeof(testW) ), "value is not 'Test'\n" );
740  ok( !memcmp( dataW, foobarW, sizeof(foobarW) ), "data is not 'foobar'\n" );
741 
742  if (pRegGetValueA) /* avoid a crash on Windows 2000 */
743  {
744  /* no valueW and no val_count parameter */
745  data_count = 20;
746  type = 1234;
747  memcpy( dataW, xxxW, sizeof(xxxW) );
748  res = RegEnumValueW( test_key, 0, NULL, NULL, NULL, &type, (BYTE*)dataW, &data_count );
749  ok( res == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", res );
750 
751  /* no valueW parameter */
752  val_count = 20;
753  data_count = 20;
754  type = 1234;
755  memcpy( dataW, xxxW, sizeof(xxxW) );
756  res = RegEnumValueW( test_key, 0, NULL, &val_count, NULL, &type, (BYTE*)dataW, &data_count );
757  ok( res == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", res );
758 
759  /* no val_count parameter */
760  data_count = 20;
761  type = 1234;
762  memcpy( valueW, xxxW, sizeof(xxxW) );
763  memcpy( dataW, xxxW, sizeof(xxxW) );
764  res = RegEnumValueW( test_key, 0, valueW, NULL, NULL, &type, (BYTE*)dataW, &data_count );
765  ok( res == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", res );
766  }
767 
768 cleanup:
769  RegDeleteKeyA(test_key, "");
770  RegCloseKey(test_key);
771 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ERROR_SUCCESS
Definition: deptool.c:10
#define REG_BINARY
Definition: nt_native.h:1496
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static HKEY hkey_main
Definition: registry.c:37
LONG WINAPI RegSetValueExW(IN HKEY hKey, IN LPCWSTR lpValueName OPTIONAL, IN ULONG Reserved, IN ULONG dwType, IN const UCHAR *lpData, IN ULONG cbData)
Definition: registry.c:656
DWORD WINAPI GetVersion(VOID)
Definition: version.c:22
unsigned char * LPBYTE
Definition: typedefs.h:52
#define ok(value,...)
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2853
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR valueW[]
Definition: object.c:45
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1177
LONG WINAPI RegEnumValueA(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpdwReserved, _Out_opt_ LPDWORD lpdwType, _Out_opt_ LPBYTE lpData, _Inout_opt_ LPDWORD lpcbData)
Definition: reg.c:2691
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define broken(x)
Definition: _sntprintf.h:21
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1222
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
static const WCHAR foobarW[]
Definition: atom.c:32
GLuint res
Definition: glext.h:9613
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
char * cleanup(char *str)
Definition: wpickclick.c:99
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
#define win_skip
Definition: test.h:141
static const WCHAR testW[]
Definition: jsregexp.c:44
#define REG_SZ
Definition: layer.c:22

Referenced by START_TEST().

◆ test_get_value()

static void test_get_value ( void  )
static

Definition at line 800 of file registry.c.

801 {
802  DWORD ret;
803  DWORD size;
804  DWORD type;
805  DWORD dw, qw[2];
806  CHAR buf[80];
807  CHAR expanded[] = "bar\\subdir1";
808  CHAR expanded2[] = "ImARatherLongButIndeedNeededString\\subdir1";
809 
810  if(!pRegGetValueA)
811  {
812  win_skip("RegGetValue not available on this platform\n");
813  return;
814  }
815 
816  /* Invalid parameter */
817  ret = pRegGetValueA(hkey_main, NULL, "DWORD", RRF_RT_REG_DWORD, &type, &dw, NULL);
818  ok(ret == ERROR_INVALID_PARAMETER, "ret=%d\n", ret);
819 
820  /* Query REG_DWORD using RRF_RT_REG_DWORD (ok) */
821  size = type = dw = 0xdeadbeef;
822  ret = pRegGetValueA(hkey_main, NULL, "DWORD", RRF_RT_REG_DWORD, &type, &dw, &size);
823  ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
824  ok(size == 4, "size=%d\n", size);
825  ok(type == REG_DWORD, "type=%d\n", type);
826  ok(dw == 0x12345678, "dw=%d\n", dw);
827 
828  /* Query by subkey-name */
829  ret = pRegGetValueA(HKEY_CURRENT_USER, "Software\\Wine\\Test", "DWORD", RRF_RT_REG_DWORD, NULL, NULL, NULL);
830  ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
831 
832  /* Query REG_DWORD using RRF_RT_REG_BINARY (restricted) */
833  size = type = dw = 0xdeadbeef;
834  ret = pRegGetValueA(hkey_main, NULL, "DWORD", RRF_RT_REG_BINARY, &type, &dw, &size);
835  ok(ret == ERROR_UNSUPPORTED_TYPE, "ret=%d\n", ret);
836  /* Although the function failed all values are retrieved */
837  ok(size == 4, "size=%d\n", size);
838  ok(type == REG_DWORD, "type=%d\n", type);
839  ok(dw == 0x12345678, "dw=%d\n", dw);
840 
841  /* Test RRF_ZEROONFAILURE */
842  type = dw = 0xdeadbeef; size = 4;
843  ret = pRegGetValueA(hkey_main, NULL, "DWORD", RRF_RT_REG_SZ|RRF_ZEROONFAILURE, &type, &dw, &size);
844  ok(ret == ERROR_UNSUPPORTED_TYPE, "ret=%d\n", ret);
845  /* Again all values are retrieved ... */
846  ok(size == 4, "size=%d\n", size);
847  ok(type == REG_DWORD, "type=%d\n", type);
848  /* ... except the buffer, which is zeroed out */
849  ok(dw == 0, "dw=%d\n", dw);
850 
851  /* Test RRF_ZEROONFAILURE with a NULL buffer... */
852  type = size = 0xbadbeef;
853  ret = pRegGetValueA(hkey_main, NULL, "DWORD", RRF_RT_REG_SZ|RRF_ZEROONFAILURE, &type, NULL, &size);
854  ok(ret == ERROR_UNSUPPORTED_TYPE, "ret=%d\n", ret);
855  ok(size == 4, "size=%d\n", size);
856  ok(type == REG_DWORD, "type=%d\n", type);
857 
858  /* Query REG_DWORD using RRF_RT_DWORD (ok) */
859  size = type = dw = 0xdeadbeef;
860  ret = pRegGetValueA(hkey_main, NULL, "DWORD", RRF_RT_DWORD, &type, &dw, &size);
861  ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
862  ok(size == 4, "size=%d\n", size);
863  ok(type == REG_DWORD, "type=%d\n", type);
864  ok(dw == 0x12345678, "dw=%d\n", dw);
865 
866  /* Query 32-bit REG_BINARY using RRF_RT_DWORD (ok) */
867  size = type = dw = 0xdeadbeef;
868  ret = pRegGetValueA(hkey_main, NULL, "BIN32", RRF_RT_DWORD, &type, &dw, &size);
869  ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
870  ok(size == 4, "size=%d\n", size);
871  ok(type == REG_BINARY, "type=%d\n", type);
872  ok(dw == 0x12345678, "dw=%d\n", dw);
873 
874  /* Query 64-bit REG_BINARY using RRF_RT_DWORD (type mismatch) */
875  qw[0] = qw[1] = size = type = 0xdeadbeef;
876  ret = pRegGetValueA(hkey_main, NULL, "BIN64", RRF_RT_DWORD, &type, qw, &size);
877  ok(ret == ERROR_DATATYPE_MISMATCH, "ret=%d\n", ret);
878  ok(size == 8, "size=%d\n", size);
879  ok(type == REG_BINARY, "type=%d\n", type);
880  ok(qw[0] == 0x12345678 &&
881  qw[1] == 0x87654321, "qw={%d,%d}\n", qw[0], qw[1]);
882 
883  /* Query 64-bit REG_BINARY using 32-bit buffer (buffer too small) */
884  type = dw = 0xdeadbeef; size = 4;
885  ret = pRegGetValueA(hkey_main, NULL, "BIN64", RRF_RT_REG_BINARY, &type, &dw, &size);
886  ok(ret == ERROR_MORE_DATA, "ret=%d\n", ret);
887  ok(dw == 0xdeadbeef, "dw=%d\n", dw);
888  ok(size == 8, "size=%d\n", size);
889 
890  /* Query 64-bit REG_BINARY using RRF_RT_QWORD (ok) */
891  qw[0] = qw[1] = size = type = 0xdeadbeef;
892  ret = pRegGetValueA(hkey_main, NULL, "BIN64", RRF_RT_QWORD, &type, qw, &size);
893  ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
894  ok(size == 8, "size=%d\n", size);
895  ok(type == REG_BINARY, "type=%d\n", type);
896  ok(qw[0] == 0x12345678 &&
897  qw[1] == 0x87654321, "qw={%d,%d}\n", qw[0], qw[1]);
898 
899  /* Query REG_SZ using RRF_RT_REG_SZ (ok) */
900  buf[0] = 0; type = 0xdeadbeef; size = sizeof(buf);
901  ret = pRegGetValueA(hkey_main, NULL, "TP1_SZ", RRF_RT_REG_SZ, &type, buf, &size);
902  ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
903  ok(size == strlen(sTestpath1)+1, "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1), size);
904  ok(type == REG_SZ, "type=%d\n", type);
905  ok(!strcmp(sTestpath1, buf), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1, buf);
906 
907  /* Query REG_SZ using RRF_RT_REG_SZ and no buffer (ok) */
908  type = 0xdeadbeef; size = 0;
909  ret = pRegGetValueA(hkey_main, NULL, "TP1_SZ", RRF_RT_REG_SZ, &type, NULL, &size);
910  ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
911  /* v5.2.3790.1830 (2003 SP1) returns sTestpath1 length + 2 here. */
913  "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1), size);
914  ok(type == REG_SZ, "type=%d\n", type);
915 
916  /* Query REG_SZ using RRF_RT_REG_SZ on a zero-byte value (ok) */
918  type = 0xdeadbeef;
919  size = sizeof(buf);
920  ret = pRegGetValueA(hkey_main, NULL, "TP1_ZB_SZ", RRF_RT_REG_SZ, &type, buf, &size);
921  ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
922  /* v5.2.3790.1830 (2003 SP1) returns sTestpath1 length + 2 here. */
923  ok(size == 0 ||
924  size == 1, /* win2k3 */
925  "size=%d\n", size);
926  ok(type == REG_SZ, "type=%d\n", type);
927  ok(!strcmp(sTestpath1, buf) ||
928  !strcmp(buf, ""),
929  "Expected \"%s\" or \"\", got \"%s\"\n", sTestpath1, buf);
930 
931  /* Query REG_SZ using RRF_RT_REG_SZ|RRF_NOEXPAND (ok) */
932  buf[0] = 0; type = 0xdeadbeef; size = sizeof(buf);
933  ret = pRegGetValueA(hkey_main, NULL, "TP1_SZ", RRF_RT_REG_SZ|RRF_NOEXPAND, &type, buf, &size);
934  ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
935  ok(size == strlen(sTestpath1)+1, "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1), size);
936  ok(type == REG_SZ, "type=%d\n", type);
937  ok(!strcmp(sTestpath1, buf), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1, buf);
938 
939  /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ and no buffer (ok, expands) */
940  size = 0;
941  ret = pRegGetValueA(hkey_main, NULL, "TP2_EXP_SZ", RRF_RT_REG_SZ, NULL, NULL, &size);
942  ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
943  ok((size == strlen(expanded2)+1) || /* win2k3 SP1 */
944  (size == strlen(expanded2)+2) || /* win2k3 SP2 */
945  (size == strlen(sTestpath2)+1),
946  "strlen(expanded2)=%d, strlen(sTestpath2)=%d, size=%d\n", lstrlenA(expanded2), lstrlenA(sTestpath2), size);
947 
948  /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ (ok, expands) */
949  buf[0] = 0; type = 0xdeadbeef; size = sizeof(buf);
950  ret = pRegGetValueA(hkey_main, NULL, "TP1_EXP_SZ", RRF_RT_REG_SZ, &type, buf, &size);
951  ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
952  /* At least v5.2.3790.1830 (2003 SP1) returns the unexpanded sTestpath1 length + 1 here. */
953  ok(size == strlen(expanded)+1 || broken(size == strlen(sTestpath1)+1),
954  "strlen(expanded)=%d, strlen(sTestpath1)=%d, size=%d\n", lstrlenA(expanded), lstrlenA(sTestpath1), size);
955  ok(type == REG_SZ, "type=%d\n", type);
956  ok(!strcmp(expanded, buf), "expanded=\"%s\" buf=\"%s\"\n", expanded, buf);
957 
958  /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ (ok, expands a lot) */
959  buf[0] = 0; type = 0xdeadbeef; size = sizeof(buf);
960  ret = pRegGetValueA(hkey_main, NULL, "TP2_EXP_SZ", RRF_RT_REG_SZ, &type, buf, &size);
961  ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
962  /* At least v5.2.3790.1830 (2003 SP1) returns the unexpanded sTestpath2 length + 1 here. */
963  ok(size == strlen(expanded2)+1 || broken(size == strlen(sTestpath2)+1),
964  "strlen(expanded2)=%d, strlen(sTestpath1)=%d, size=%d\n", lstrlenA(expanded2), lstrlenA(sTestpath2), size);
965  ok(type == REG_SZ, "type=%d\n", type);
966  ok(!strcmp(expanded2, buf), "expanded2=\"%s\" buf=\"%s\"\n", expanded2, buf);
967 
968  /* Query REG_EXPAND_SZ using RRF_RT_REG_EXPAND_SZ|RRF_NOEXPAND (ok, doesn't expand) */
969  buf[0] = 0; type = 0xdeadbeef; size = sizeof(buf);
970  ret = pRegGetValueA(hkey_main, NULL, "TP1_EXP_SZ", RRF_RT_REG_EXPAND_SZ|RRF_NOEXPAND, &type, buf, &size);
971  ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
972  ok(size == strlen(sTestpath1)+1, "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1), size);
973  ok(type == REG_EXPAND_SZ, "type=%d\n", type);
974  ok(!strcmp(sTestpath1, buf), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1, buf);
975 
976  /* Query REG_EXPAND_SZ using RRF_RT_REG_EXPAND_SZ|RRF_NOEXPAND and no buffer (ok, doesn't expand) */
977  size = 0xbadbeef;
978  ret = pRegGetValueA(hkey_main, NULL, "TP1_EXP_SZ", RRF_RT_REG_EXPAND_SZ|RRF_NOEXPAND, NULL, NULL, &size);
979  ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
980  /* v5.2.3790.1830 (2003 SP1) returns sTestpath1 length + 2 here. */
982  "strlen(sTestpath1)=%d size=%d\n", lstrlenA(sTestpath1), size);
983 
984  /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ|RRF_NOEXPAND (type mismatch) */
985  ret = pRegGetValueA(hkey_main, NULL, "TP1_EXP_SZ", RRF_RT_REG_SZ|RRF_NOEXPAND, NULL, NULL, NULL);
986  ok(ret == ERROR_UNSUPPORTED_TYPE, "ret=%d\n", ret);
987 
988  /* Query REG_EXPAND_SZ using RRF_RT_REG_EXPAND_SZ (not allowed without RRF_NOEXPAND) */
989  ret = pRegGetValueA(hkey_main, NULL, "TP1_EXP_SZ", RRF_RT_REG_EXPAND_SZ, NULL, NULL, NULL);
990  /* before win8: ERROR_INVALID_PARAMETER, win8: ERROR_UNSUPPORTED_TYPE */
992 
993  /* Query REG_EXPAND_SZ using RRF_RT_ANY */
994  buf[0] = 0; type = 0xdeadbeef; size = sizeof(buf);
995  ret = pRegGetValueA(hkey_main, NULL, "TP1_EXP_SZ", RRF_RT_ANY, &type, buf, &size);
996  ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
997  /* At least v5.2.3790.1830 (2003 SP1) returns the unexpanded sTestpath1 length + 1 here. */
998  ok(size == strlen(expanded)+1 || broken(size == strlen(sTestpath1)+1),
999  "strlen(expanded)=%d, strlen(sTestpath1)=%d, size=%d\n", lstrlenA(expanded), lstrlenA(sTestpath1), size);
1000  ok(type == REG_SZ, "type=%d\n", type);
1001  ok(!strcmp(expanded, buf), "expanded=\"%s\" buf=\"%s\"\n", expanded, buf);
1002 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define REG_BINARY
Definition: nt_native.h:1496
#define HKEY_CURRENT_USER
Definition: winreg.h:11
char CHAR
Definition: xmlstorage.h:175
#define ERROR_DATATYPE_MISMATCH
Definition: winerror.h:987
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define RRF_RT_REG_EXPAND_SZ
Definition: driver.c:576
#define RRF_RT_REG_SZ
Definition: driver.c:575
static HKEY hkey_main
Definition: registry.c:37
static const char * sTestpath1
Definition: registry.c:40
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_UNSUPPORTED_TYPE
Definition: winerror.h:988
#define RRF_RT_DWORD
Definition: driver.c:581
static const char * sTestpath2
Definition: registry.c:41
GLsizeiptr size
Definition: glext.h:5919
#define RRF_ZEROONFAILURE
Definition: driver.c:584
#define RRF_RT_QWORD
Definition: driver.c:582
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID LPVOID DWORD dw
Definition: atlbase.h:40
int ret
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define broken(x)
Definition: _sntprintf.h:21
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define RRF_NOEXPAND
Definition: driver.c:583
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define RRF_RT_ANY
Definition: winreg.h:64
#define REG_DWORD
Definition: sdbapi.c:596
#define RRF_RT_REG_DWORD
Definition: driver.c:578
#define win_skip
Definition: test.h:141
#define RRF_RT_REG_BINARY
Definition: driver.c:577
#define REG_SZ
Definition: layer.c:22

Referenced by START_TEST().

◆ test_perflib_key()

static void test_perflib_key ( void  )
static

Definition at line 3309 of file registry.c.

3310 {
3311  DWORD size;
3312  LONG ret;
3313  HKEY key;
3314 
3315  ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009", &key);
3316  ok(ret == ERROR_SUCCESS, "RegOpenKeyA failed with error %u\n", ret);
3317 
3318  ret = RegQueryValueExA(key, "Counter", NULL, NULL, NULL, &size);
3319  if (ret != ERROR_SUCCESS)
3320  {
3321  skip("Perflib\\009\\Counter does not exist, skipping perflib test\n");
3322  goto done;
3323  }
3324  ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed with error %u\n", ret);
3325 
3326  /* Windows only compares the first few characters of the value name.
3327  * On Windows XP / 2003, it is sufficient to use "Cou", newer versions
3328  * require a longer substring. */
3329 
3330  ret = RegQueryValueExA(key, "Counters", NULL, NULL, NULL, &size);
3331  ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed with error %u\n", ret);
3332  ret = RegQueryValueExA(key, "Counter2", NULL, NULL, NULL, &size);
3333  todo_wine ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed with error %u\n", ret);
3334  ret = RegQueryValueExA(key, "CounterWine", NULL, NULL, NULL, &size);
3335  todo_wine ok(ret == ERROR_SUCCESS, "RegQueryValueExA failed with error %u\n", ret);
3336 
3337 done:
3338  RegCloseKey(key);
3339 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
#define ERROR_SUCCESS
Definition: deptool.c:10
long LONG
Definition: pedump.c:60
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define todo_wine
Definition: test.h:154
HKEY key
Definition: reg.c:42
#define skip(...)
Definition: path.c:42
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by START_TEST().

◆ test_query_value_ex()

static void test_query_value_ex ( void  )
static

Definition at line 773 of file registry.c.

774 {
775  DWORD ret, size, type;
776  BYTE buffer[10];
777 
778  size = sizeof(buffer);
779  ret = RegQueryValueExA(hkey_main, "TP1_SZ", NULL, &type, NULL, &size);
780  ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
781  ok(size == strlen(sTestpath1) + 1, "(%d,%d)\n", (DWORD)strlen(sTestpath1) + 1, size);
782  ok(type == REG_SZ, "type %d is not REG_SZ\n", type);
783 
784  type = 0xdeadbeef;
785  size = 0xdeadbeef;
786  ret = RegQueryValueExA(HKEY_CLASSES_ROOT, "Nonexistent Value", NULL, &type, NULL, &size);
787  ok(ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret);
788  ok(size == 0, "size should have been set to 0 instead of %d\n", size);
789 
790  size = sizeof(buffer);
791  ret = RegQueryValueExA(HKEY_CLASSES_ROOT, "Nonexistent Value", NULL, &type, buffer, &size);
792  ok(ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %d\n", ret);
793  ok(size == sizeof(buffer), "size shouldn't have been changed to %d\n", size);
794 
795  size = 4;
796  ret = RegQueryValueExA(hkey_main, "BIN32", NULL, &size, buffer, &size);
797  ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
798 }
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
#define ERROR_SUCCESS
Definition: deptool.c:10
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
static HKEY hkey_main
Definition: registry.c:37
static const char * sTestpath1
Definition: registry.c:40
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
unsigned char BYTE
Definition: mem.h:68
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define REG_SZ
Definition: layer.c:22

Referenced by START_TEST().

◆ test_redirection()

static void test_redirection ( void  )
static

Definition at line 2500 of file registry.c.

2501 {
2502  DWORD err, type, dw, len;
2503  HKEY key, root32, root64, key32, key64, native, op_key;
2504  BOOL is_vista = FALSE;
2505  REGSAM opposite = (sizeof(void*) == 8 ? KEY_WOW64_32KEY : KEY_WOW64_64KEY);
2506 
2507  if (ptr_size != 64)
2508  {
2509  BOOL is_wow64;
2510  if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 ) || !is_wow64)
2511  {
2512  skip( "Not on Wow64, no redirection\n" );
2513  return;
2514  }
2515  }
2516 
2517  if (limited_user)
2518  {
2519  skip("not enough privileges to modify HKLM\n");
2520  return;
2521  }
2522 
2523  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine", 0, NULL, 0,
2524  KEY_WOW64_64KEY | KEY_ALL_ACCESS, NULL, &root64, NULL );
2525  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2526 
2527  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine", 0, NULL, 0,
2528  KEY_WOW64_32KEY | KEY_ALL_ACCESS, NULL, &root32, NULL );
2529  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2530 
2531  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest", 0, NULL, 0,
2532  KEY_WOW64_64KEY | KEY_ALL_ACCESS, NULL, &key64, NULL );
2533  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2534 
2535  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest", 0, NULL, 0,
2536  KEY_WOW64_32KEY | KEY_ALL_ACCESS, NULL, &key32, NULL );
2537  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2538 
2539  dw = 64;
2540  err = RegSetValueExA( key64, "value", 0, REG_DWORD, (BYTE *)&dw, sizeof(dw) );
2541  ok( err == ERROR_SUCCESS, "RegSetValueExA failed: %u\n", err );
2542 
2543  dw = 32;
2544  err = RegSetValueExA( key32, "value", 0, REG_DWORD, (BYTE *)&dw, sizeof(dw) );
2545  ok( err == ERROR_SUCCESS, "RegSetValueExA failed: %u\n", err );
2546 
2547  dw = 0;
2548  len = sizeof(dw);
2549  err = RegQueryValueExA( key32, "value", NULL, &type, (BYTE *)&dw, &len );
2550  ok( err == ERROR_SUCCESS, "RegQueryValueExA failed: %u\n", err );
2551  ok( dw == 32, "wrong value %u\n", dw );
2552 
2553  dw = 0;
2554  len = sizeof(dw);
2555  err = RegQueryValueExA( key64, "value", NULL, &type, (BYTE *)&dw, &len );
2556  ok( err == ERROR_SUCCESS, "RegQueryValueExA failed: %u\n", err );
2557  ok( dw == 64, "wrong value %u\n", dw );
2558 
2559  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software", 0, NULL, 0,
2560  KEY_ALL_ACCESS, NULL, &key, NULL );
2561  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2562 
2563  if (ptr_size == 32)
2564  {
2565  /* the Vista mechanism allows opening Wow6432Node from a 32-bit key too */
2566  /* the new (and simpler) Win7 mechanism doesn't */
2567  if (get_key_value( key, "Wow6432Node\\Wine\\Winetest", 0 ) == 32)
2568  {
2569  trace( "using Vista-style Wow6432Node handling\n" );
2570  is_vista = TRUE;
2571  }
2572  check_key_value( key, "Wine\\Winetest", 0, 32 );
2573  check_key_value( key, "Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 );
2574  check_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY, 32 );
2575  check_key_value( key, "Wow6432Node\\Wine\\Winetest", 0, is_vista ? 32 : 0 );
2576  check_key_value( key, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 0 );
2577  check_key_value( key, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY, is_vista ? 32 : 0 );
2578  }
2579  else
2580  {
2581  if (get_key_value( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY ) == 64)
2582  {
2583  trace( "using Vista-style Wow6432Node handling\n" );
2584  is_vista = TRUE;
2585  }
2586  check_key_value( key, "Wine\\Winetest", 0, 64 );
2587  check_key_value( key, "Wow6432Node\\Wine\\Winetest", 0, 32 );
2588  }
2589  RegCloseKey( key );
2590 
2591  if (ptr_size == 32)
2592  {
2593  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software", 0, NULL, 0,
2595  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2596  dw = get_key_value( key, "Wine\\Winetest", 0 );
2597  ok( dw == 64 || broken(dw == 32) /* xp64 */, "wrong value %u\n", dw );
2598  check_key_value( key, "Wine\\Winetest", KEY_WOW64_64KEY, 64 );
2599  check_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY, 32 );
2600  check_key_value( key, "Wow6432Node\\Wine\\Winetest", 0, 32 );
2601  dw = get_key_value( key, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY );
2602  ok( dw == 32 || broken(dw == 64) /* xp64 */, "wrong value %u\n", dw );
2603  check_key_value( key, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY, 32 );
2604  RegCloseKey( key );
2605 
2606  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software", 0, NULL, 0,
2608  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2609  check_key_value( key, "Wine\\Winetest", 0, 32 );
2610  check_key_value( key, "Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 );
2611  check_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY, 32 );
2612  check_key_value( key, "Wow6432Node\\Wine\\Winetest", 0, is_vista ? 32 : 0 );
2613  check_key_value( key, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 0 );
2614  check_key_value( key, "Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY, is_vista ? 32 : 0 );
2615  RegCloseKey( key );
2616  }
2617  else
2618  {
2619  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software", 0, NULL, 0,
2621  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2622  check_key_value( key, "Wine\\Winetest", 0, 64 );
2623  check_key_value( key, "Wine\\Winetest", KEY_WOW64_64KEY, 64 );
2624  dw = get_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY );
2625  todo_wine ok( dw == 32, "wrong value %u\n", dw );
2626  check_key_value( key, "Wow6432Node\\Wine\\Winetest", 0, 32 );
2627  RegCloseKey( key );
2628 
2629  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software", 0, NULL, 0,
2631  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2632  check_key_value( key, "Wine\\Winetest", 0, 32 );
2633  dw = get_key_value( key, "Wine\\Winetest", KEY_WOW64_64KEY );
2634  ok( dw == 32 || broken(dw == 64) /* vista */, "wrong value %u\n", dw );
2635  check_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY, 32 );
2636  RegCloseKey( key );
2637  }
2638 
2639  check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest", 0, ptr_size );
2640  check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine\\Winetest", 0, 32 );
2641  if (ptr_size == 64)
2642  {
2643  /* KEY_WOW64 flags have no effect on 64-bit */
2644  check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest", KEY_WOW64_64KEY, 64 );
2645  check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest", KEY_WOW64_32KEY, 32 );
2646  check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 );
2647  check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY, 32 );
2648  }
2649  else
2650  {
2651  check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest", KEY_WOW64_64KEY, 64 );
2652  check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest", KEY_WOW64_32KEY, 32 );
2653  check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 );
2654  check_key_value( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine\\Winetest", KEY_WOW64_32KEY, 32 );
2655  }
2656 
2657  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node", 0, NULL, 0,
2658  KEY_ALL_ACCESS, NULL, &key, NULL );
2659  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2660  check_key_value( key, "Wine\\Winetest", 0, 32 );
2661  check_key_value( key, "Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 );
2662  check_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY, 32 );
2663  RegCloseKey( key );
2664 
2665  if (ptr_size == 32)
2666  {
2667  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node", 0, NULL, 0,
2669  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2670  dw = get_key_value( key, "Wine\\Winetest", 0 );
2671  ok( dw == (is_vista ? 64 : 32) || broken(dw == 32) /* xp64 */, "wrong value %u\n", dw );
2672  check_key_value( key, "Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 );
2673  check_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY, 32 );
2674  RegCloseKey( key );
2675 
2676  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node", 0, NULL, 0,
2678  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2679  check_key_value( key, "Wine\\Winetest", 0, 32 );
2680  check_key_value( key, "Wine\\Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 );
2681  check_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY, 32 );
2682  RegCloseKey( key );
2683  }
2684 
2685  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine", 0, NULL, 0,
2686  KEY_ALL_ACCESS, NULL, &key, NULL );
2687  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2688  check_key_value( key, "Winetest", 0, 32 );
2689  check_key_value( key, "Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 );
2690  check_key_value( key, "Winetest", KEY_WOW64_32KEY, 32 );
2691  RegCloseKey( key );
2692 
2693  if (ptr_size == 32)
2694  {
2695  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine", 0, NULL, 0,
2697  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2698  dw = get_key_value( key, "Winetest", 0 );
2699  ok( dw == 32 || (is_vista && dw == 64), "wrong value %u\n", dw );
2700  check_key_value( key, "Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 );
2701  check_key_value( key, "Winetest", KEY_WOW64_32KEY, 32 );
2702  RegCloseKey( key );
2703 
2704  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Wine", 0, NULL, 0,
2706  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2707  check_key_value( key, "Winetest", 0, 32 );
2708  check_key_value( key, "Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 );
2709  check_key_value( key, "Winetest", KEY_WOW64_32KEY, 32 );
2710  RegCloseKey( key );
2711  }
2712 
2713  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine", 0, NULL, 0,
2714  KEY_ALL_ACCESS, NULL, &key, NULL );
2715  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2716  check_key_value( key, "Winetest", 0, ptr_size );
2717  check_key_value( key, "Winetest", KEY_WOW64_64KEY, is_vista ? 64 : ptr_size );
2718  dw = get_key_value( key, "Winetest", KEY_WOW64_32KEY );
2719  todo_wine_if (ptr_size != 32)
2720  ok( dw == 32, "wrong value %u\n", dw );
2721  RegCloseKey( key );
2722 
2723  if (ptr_size == 32)
2724  {
2725  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine", 0, NULL, 0,
2727  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2728  dw = get_key_value( key, "Winetest", 0 );
2729  ok( dw == 64 || broken(dw == 32) /* xp64 */, "wrong value %u\n", dw );
2730  check_key_value( key, "Winetest", KEY_WOW64_64KEY, 64 );
2731  dw = get_key_value( key, "Winetest", KEY_WOW64_32KEY );
2732  todo_wine ok( dw == 32, "wrong value %u\n", dw );
2733  RegCloseKey( key );
2734 
2735  err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine", 0, NULL, 0,
2737  ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
2738  check_key_value( key, "Winetest", 0, 32 );
2739  check_key_value( key, "Winetest", KEY_WOW64_64KEY, is_vista ? 64 : 32 );
2740  check_key_value( key, "Winetest", KEY_WOW64_32KEY, 32 );
2741  RegCloseKey( key );
2742  }
2743 
2744  if (pRegDeleteKeyExA)
2745  {
2746  err = pRegDeleteKeyExA( key32, "", KEY_WOW64_32KEY, 0 );
2747  ok( err == ERROR_SUCCESS, "RegDeleteKey failed: %u\n", err );
2748  err = pRegDeleteKeyExA( key64, "", KEY_WOW64_64KEY, 0 );
2749  ok( err == ERROR_SUCCESS, "RegDeleteKey failed: %u\n", err );
2750  pRegDeleteKeyExA( key64, "", KEY_WOW64_64KEY, 0 );
2751  pRegDeleteKeyExA( root64, "", KEY_WOW64_64KEY, 0 );
2752  }
2753  else
2754  {
2755  err = RegDeleteKeyA( key32, "" );
2756  ok( err == ERROR_SUCCESS, "RegDeleteKey failed: %u\n", err );
2757  err = RegDeleteKeyA( key64, "" );
2758  ok( err == ERROR_SUCCESS, "RegDeleteKey failed: %u\n", err );
2759  RegDeleteKeyA( key64, "" );
2760  RegDeleteKeyA( root64, "" );
2761  }
2762  RegCloseKey( key32 );
2763  RegCloseKey( key64 );
2764  RegCloseKey( root32 );
2765  RegCloseKey( root64 );
2766 
2767  /* open key in native bit mode */
2768  err = RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface", 0, KEY_ALL_ACCESS, &native);
2769  ok(err == ERROR_SUCCESS, "got %i\n", err);
2770 
2771  pRegDeleteKeyExA(native, "AWineTest", 0, 0);
2772 
2773  /* write subkey in opposite bit mode */
2774  err = RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface", 0, KEY_ALL_ACCESS | opposite, &op_key);
2775  ok(err == ERROR_SUCCESS, "got %i\n", err);
2776 
2777  err = RegCreateKeyExA(op_key, "AWineTest", 0, NULL, 0, KEY_ALL_ACCESS | opposite,
2778  NULL, &key, NULL);
2779  ok(err == ERROR_SUCCESS || err == ERROR_ACCESS_DENIED, "got %i\n", err);
2780  if(err != ERROR_SUCCESS){
2781  win_skip("Can't write to registry\n");
2782  RegCloseKey(op_key);
2783  RegCloseKey(native);
2784  return;
2785  }
2786  RegCloseKey(key);
2787 
2788  /* verify subkey is not present in native mode */
2789  err = RegOpenKeyExA(native, "AWineTest", 0, KEY_ALL_ACCESS, &key);
2791  broken(err == ERROR_SUCCESS), /* before Win7, HKCR is reflected instead of redirected */
2792  "got %i\n", err);
2793 
2794  err = pRegDeleteKeyExA(op_key, "AWineTest", opposite, 0);
2795  ok(err == ERROR_SUCCESS, "got %i\n", err);
2796 
2797  RegCloseKey(op_key);
2798  RegCloseKey(native);
2799 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
#define trace(...)
Definition: kmt_test.h:217
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
static const DWORD ptr_size
Definition: registry.c:42
GLdouble n
Definition: glext.h:7729
static BOOL limited_user
Definition: registry.c:55
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3331
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static DWORD get_key_value(HKEY root, const char *name, DWORD flags)
Definition: registry.c:2475
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define todo_wine_if(is_todo)
Definition: test.h:155
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
if(!(yy_init))
Definition: macro.lex.yy.c:714
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168
static BOOL is_wow64
Definition: loader.c:55
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID LPVOID DWORD dw
Definition: atlbase.h:40
#define todo_wine
Definition: test.h:154
HKEY key
Definition: reg.c:42
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
#define err(...)
#define broken(x)
Definition: _sntprintf.h:21
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1222
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
ACCESS_MASK REGSAM
Definition: winreg.h:69
#define check_key_value(root, name, flags, expect)
Definition: registry.c:2498
#define skip(...)
#define KEY_WOW64_32KEY
Definition: cmtypes.h:45
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
Definition: reg.c:1029
#define REG_DWORD
Definition: sdbapi.c:596
#define win_skip
Definition: test.h:141
Definition: path.c:42
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by START_TEST().

◆ test_reg_close_key()

static void test_reg_close_key ( void  )
static

Definition at line 1458 of file registry.c.

1459 {
1460  DWORD ret = 0;
1461  HKEY hkHandle;
1462 
1463  /* successfully close key
1464  * hkHandle remains changed after call to RegCloseKey
1465  */
1466  ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Test", &hkHandle);
1467  ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
1468  ret = RegCloseKey(hkHandle);
1469  ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
1470 
1471  /* try to close the key twice */
1472  ret = RegCloseKey(hkHandle); /* Windows 95 doesn't mind. */
1474  "expected ERROR_INVALID_HANDLE or ERROR_SUCCESS, got %d\n", ret);
1475 
1476  /* try to close a NULL handle */
1477  ret = RegCloseKey(NULL);
1478  ok(ret == ERROR_INVALID_HANDLE || ret == ERROR_BADKEY, /* Windows 95 returns BADKEY */
1479  "expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %d\n", ret);
1480 
1481  /* Check to see if we didn't potentially close our main handle, which could happen on win98 as
1482  * win98 doesn't give a new handle when the same key is opened.
1483  * Not re-opening will make some next tests fail.
1484  */
1485  if (hkey_main == hkHandle)
1486  {
1487  trace("The main handle is most likely closed, so re-opening\n");
1488  RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Test", &hkey_main );
1489  }
1490 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
#define trace(...)
Definition: kmt_test.h:217
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static HKEY hkey_main
Definition: registry.c:37
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define ERROR_BADKEY
Definition: winerror.h:589

Referenced by START_TEST().

◆ test_reg_copy_tree()

static void test_reg_copy_tree ( void  )
static

Definition at line 2115 of file registry.c.

2116 {
2117  HKEY src, dst, subkey;
2118  CHAR buffer[MAX_PATH];
2119  DWORD dwsize, type;
2120  LONG size, ret;
2121 
2122  if (!pRegCopyTreeA)
2123  {
2124  win_skip("Skipping RegCopyTreeA tests, function not present\n");
2125  return;
2126  }
2127 
2128  ret = RegCreateKeyA(hkey_main, "src", &src);
2129  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2130  ret = RegCreateKeyA(hkey_main, "dst", &dst);
2131  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2132 
2133  /* Copy nonexistent subkey */
2134  ret = pRegCopyTreeA(src, "nonexistent_subkey", dst);
2135  ok(ret == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", ret);
2136 
2137  /* Create test keys and values */
2138  ret = RegSetValueA(src, NULL, REG_SZ, "data", 4);
2139  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2140  ret = RegSetValueExA(src, "value", 0, REG_SZ, (const BYTE *)"data2", 5);
2141  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2142 
2143  ret = RegCreateKeyA(src, "subkey2", &subkey);
2144  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2145  ret = RegSetValueA(subkey, NULL, REG_SZ, "data3", 5);
2146  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2147  ret = RegSetValueExA(subkey, "value", 0, REG_SZ, (const BYTE *)"data4", 5);
2148  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2149  ret = RegCloseKey(subkey);
2150  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2151 
2152  ret = RegCreateKeyA(src, "subkey3", &subkey);
2153  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2154  ret = RegCloseKey(subkey);
2155  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2156 
2157  /* Copy subkey */
2158  ret = pRegCopyTreeA(src, "subkey2", dst);
2159  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2160 
2161  size = MAX_PATH;
2163  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2164  ok(!strcmp(buffer, "data3"), "Expected 'data3', got '%s'\n", buffer);
2165 
2166  dwsize = MAX_PATH;
2167  ret = RegQueryValueExA(dst, "value", NULL, &type, (BYTE *)buffer, &dwsize);
2168  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2169  ok(type == REG_SZ, "Expected REG_SZ, got %u\n", type);
2170  ok(!strcmp(buffer, "data4"), "Expected 'data4', got '%s'\n", buffer);
2171 
2172  /* Copy full tree */
2173  ret = pRegCopyTreeA(src, NULL, dst);
2174  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2175 
2176  size = MAX_PATH;
2178  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2179  ok(!strcmp(buffer, "data"), "Expected 'data', got '%s'\n", buffer);
2180 
2181  dwsize = MAX_PATH;
2182  ret = RegQueryValueExA(dst, "value", NULL, &type, (BYTE *)buffer, &dwsize);
2183  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2184  ok(type == REG_SZ, "Expected REG_SZ, got %u\n", type);
2185  ok(!strcmp(buffer, "data2"), "Expected 'data2', got '%s'\n", buffer);
2186 
2187  ret = RegOpenKeyA(dst, "subkey2", &subkey);
2188  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2189  size = MAX_PATH;
2190  ret = RegQueryValueA(subkey, NULL, buffer, &size);
2191  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2192  ok(!strcmp(buffer, "data3"), "Expected 'data3', got '%s'\n", buffer);
2193  dwsize = MAX_PATH;
2194  ret = RegQueryValueExA(subkey, "value", NULL, &type, (BYTE *)buffer, &dwsize);
2195  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2196  ok(type == REG_SZ, "Expected REG_SZ, got %u\n", type);
2197  ok(!strcmp(buffer, "data4"), "Expected 'data4', got '%s'\n", buffer);
2198  ret = RegCloseKey(subkey);
2199  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2200 
2201  ret = RegOpenKeyA(dst, "subkey3", &subkey);
2202  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2203  ret = RegCloseKey(subkey);
2204  ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
2205 
2206  delete_key(src);
2207  delete_key(dst);
2208 }
LONG WINAPI RegCloseKey(IN HKEY hKey)
Definition: registry.c:512
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
LSTATUS WINAPI RegQueryValueA(HKEY hkey, LPCSTR name, LPSTR data, LPLONG count)
Definition: reg.c:4225
#define ERROR_SUCCESS
Definition: deptool.c:10
char CHAR
Definition: xmlstorage.h:175
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
LONG WINAPI RegSetValueA(HKEY hKeyOriginal, LPCSTR lpSubKey, DWORD dwType, LPCSTR lpData, DWORD cbData)
Definition: reg.c:4968
static HKEY hkey_main
Definition: registry.c:37
long LONG
Definition: pedump.c:60
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1177
GLsizeiptr size
Definition: glext.h:5919
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
static DWORD delete_key(HKEY hkey)
Definition: registry.c:153
GLenum GLenum dst
Definition: glext.h:6340
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4812
#define win_skip
Definition: test.h:141
#define REG_SZ
Definition: layer.c:22

Referenced by START_TEST().

◆ test_reg_create_key()

static void test_reg_create_key ( void  )
static

Definition at line 1283 of file registry.c.

1284 {
1285  LONG ret;
1286  HKEY hkey1, hkey2;
1287  HKEY hkRoot64 = NULL;
1288  HKEY hkRoot32 = NULL;
1289  DWORD dwRet;
1290  BOOL bRet;
1292  PSID world_sid;
1294  PACL key_acl;
1296 
1297  ret = RegCreateKeyExA(hkey_main, "Subkey1", 0, NULL, 0, KEY_NOTIFY, NULL, &hkey1, NULL);
1298  ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
1299  /* should succeed: all versions of Windows ignore the access rights
1300  * to the parent handle */
1301  ret = RegCreateKeyExA(hkey1, "Subkey2", 0, NULL, 0, KEY_SET_VALUE, NULL, &hkey2, NULL);
1302  ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
1303 
1304  /* clean up */
1305  RegDeleteKeyA(hkey2, "");
1306  RegDeleteKeyA(hkey1, "");
1307  RegCloseKey(hkey2);
1308  RegCloseKey(hkey1);
1309 
1310  /* test creation of volatile keys */
1312  ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
1313  ret = RegCreateKeyExA(hkey1, "Subkey2", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey2, NULL);
1314  ok(ret == ERROR_CHILD_MUST_BE_VOLATILE, "RegCreateKeyExA failed with error %d\n", ret);
1315  if (!ret) RegCloseKey( hkey2 );
1316  ret = RegCreateKeyExA(hkey1, "Subkey2", 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey2, NULL);
1317  ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
1318  RegCloseKey(hkey2);
1319  /* should succeed if the key already exists */
1320  ret = RegCreateKeyExA(hkey1, "Subkey2", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey2, NULL);
1321  ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
1322 
1323  /* clean up */
1324  RegDeleteKeyA(hkey2, "");
1325  RegDeleteKeyA(hkey1, "");
1326  RegCloseKey(hkey2);
1327  RegCloseKey(hkey1);
1328 
1329  /* beginning backslash character */
1330  ret = RegCreateKeyExA(hkey_main, "\\Subkey3", 0, NULL, 0, KEY_NOTIFY, NULL, &hkey1, NULL);
1331  if (!(GetVersion() & 0x80000000))
1332  ok(ret == ERROR_BAD_PATHNAME, "expected ERROR_BAD_PATHNAME, got %d\n", ret);
1333  else {
1334  ok(!ret, "RegCreateKeyExA failed with error %d\n", ret);
1335  RegDeleteKeyA(hkey1, "");
1336  RegCloseKey(hkey1);
1337  }
1338 
1339  /* trailing backslash characters */
1340  ret = RegCreateKeyExA(hkey_main, "Subkey4\\\\", 0, NULL, 0, KEY_NOTIFY, NULL, &hkey1, NULL);
1341  ok(ret == ERROR_SUCCESS, "RegCreateKeyExA failed with error %d\n", ret);
1342  RegDeleteKeyA(hkey1, "");