ReactOS 0.4.15-dev-6712-g46b4b55
reg.c File Reference
#include <advapi32.h>
#include <ndk/cmfuncs.h>
#include <pseh/pseh2.h>
#include "reg.h"
Include dependency graph for reg.c:

Go to the source code of this file.

Macros

#define MAX_DEFAULT_HANDLES   6
 
#define REG_MAX_NAME_SIZE   256
 
#define REG_MAX_DATA_SIZE   2048
 
#define ClosePredefKey(Handle)
 
#define IsPredefKey(HKey)    (((ULONG_PTR)(HKey) & 0xF0000000) == 0x80000000)
 
#define GetPredefKeyIndex(HKey)    ((ULONG_PTR)(HKey) & 0x0FFFFFFF)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (reg)
 
static NTSTATUS MapDefaultKey (PHANDLE ParentKey, HKEY Key)
 
static VOID CloseDefaultKeys (VOID)
 
static NTSTATUS OpenClassesRootKey (PHANDLE KeyHandle)
 
static NTSTATUS OpenLocalMachineKey (PHANDLE KeyHandle)
 
static NTSTATUS OpenUsersKey (PHANDLE KeyHandle)
 
static NTSTATUS OpenCurrentConfigKey (PHANDLE KeyHandle)
 
static __inline int is_string (DWORD type)
 
BOOL RegInitialize (VOID)
 
BOOL RegCleanup (VOID)
 
static NTSTATUS OpenPredefinedKey (IN ULONG Index, OUT HANDLE Handle)
 
static NTSTATUS MapDefaultKey (OUT PHANDLE RealKey, IN HKEY Key)
 
static NTSTATUS OpenClassesRootKey (_Out_ PHANDLE KeyHandle)
 
LONG WINAPI RegDisablePredefinedCache (VOID)
 
LONG WINAPI RegDisablePredefinedCacheEx (VOID)
 
LONG WINAPI RegOverridePredefKey (IN HKEY hKey, IN HKEY hNewHKey OPTIONAL)
 
LONG WINAPI RegCloseKey (HKEY hKey)
 
static NTSTATUS RegpCopyTree (IN HKEY hKeySrc, IN HKEY hKeyDest)
 
LONG WINAPI RegCopyTreeW (IN HKEY hKeySrc, IN LPCWSTR lpSubKey OPTIONAL, IN HKEY hKeyDest)
 
LONG WINAPI RegCopyTreeA (IN HKEY hKeySrc, IN LPCSTR lpSubKey OPTIONAL, IN HKEY hKeyDest)
 
LONG WINAPI RegConnectRegistryA (IN LPCSTR lpMachineName, IN HKEY hKey, OUT PHKEY phkResult)
 
LONG WINAPI RegConnectRegistryW (LPCWSTR lpMachineName, HKEY hKey, PHKEY phkResult)
 
static NTSTATUS CreateNestedKey (PHKEY KeyHandle, POBJECT_ATTRIBUTES ObjectAttributes, PUNICODE_STRING ClassString, DWORD dwOptions, REGSAM samDesired, DWORD *lpdwDisposition)
 
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)
 
LONG WINAPI RegCreateKeyExW (_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
 
LONG WINAPI RegCreateKeyA (HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
 
LONG WINAPI RegCreateKeyW (HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
 
LONG WINAPI RegDeleteKeyA (_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
 
LONG WINAPI RegDeleteKeyW (_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
 
LONG WINAPI RegDeleteKeyExA (_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ REGSAM samDesired, _In_ DWORD Reserved)
 
LONG WINAPI RegDeleteKeyExW (_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ REGSAM samDesired, _In_ DWORD Reserved)
 
LONG WINAPI RegDeleteKeyValueW (IN HKEY hKey, IN LPCWSTR lpSubKey OPTIONAL, IN LPCWSTR lpValueName OPTIONAL)
 
LONG WINAPI RegDeleteKeyValueA (IN HKEY hKey, IN LPCSTR lpSubKey OPTIONAL, IN LPCSTR lpValueName OPTIONAL)
 
LSTATUS WINAPI RegDeleteTreeW (HKEY hKey, LPCWSTR lpszSubKey)
 
LONG WINAPI RegDeleteTreeA (IN HKEY hKey, IN LPCSTR lpSubKey OPTIONAL)
 
LONG WINAPI RegDisableReflectionKey (IN HKEY hBase)
 
LONG WINAPI RegEnableReflectionKey (IN HKEY hBase)
 
static VOID RegpApplyRestrictions (DWORD dwFlags, DWORD dwType, DWORD cbData, PLONG ret)
 
LSTATUS WINAPI RegGetValueW (HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
 
LSTATUS WINAPI RegGetValueA (HKEY hKey, LPCSTR pszSubKey, LPCSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
 
LONG WINAPI RegSetKeyValueW (IN HKEY hKey, IN LPCWSTR lpSubKey OPTIONAL, IN LPCWSTR lpValueName OPTIONAL, IN DWORD dwType, IN LPCVOID lpData OPTIONAL, IN DWORD cbData)
 
LONG WINAPI RegSetKeyValueA (IN HKEY hKey, IN LPCSTR lpSubKey OPTIONAL, IN LPCSTR lpValueName OPTIONAL, IN DWORD dwType, IN LPCVOID lpData OPTIONAL, IN DWORD cbData)
 
LONG WINAPI RegDeleteValueA (HKEY hKey, LPCSTR lpValueName)
 
LONG WINAPI RegDeleteValueW (HKEY hKey, LPCWSTR lpValueName)
 
LONG WINAPI RegEnumKeyA (HKEY hKey, DWORD dwIndex, LPSTR lpName, DWORD cbName)
 
LONG WINAPI RegEnumKeyW (HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
 
LONG WINAPI RegEnumKeyExA (_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
 
LONG WINAPI RegEnumKeyExW (_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
 
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)
 
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)
 
LONG WINAPI RegFlushKey (HKEY hKey)
 
LONG WINAPI RegGetKeySecurity (HKEY hKey, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor, LPDWORD lpcbSecurityDescriptor)
 
LONG WINAPI RegLoadKeyA (HKEY hKey, LPCSTR lpSubKey, LPCSTR lpFile)
 
LONG WINAPI RegLoadKeyW (HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpFile)
 
LONG WINAPI RegNotifyChangeKeyValue (HKEY hKey, BOOL bWatchSubtree, DWORD dwNotifyFilter, HANDLE hEvent, BOOL fAsynchronous)
 
LONG WINAPI RegOpenCurrentUser (IN REGSAM samDesired, OUT PHKEY phkResult)
 
LONG WINAPI RegOpenKeyA (HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
 
LONG WINAPI RegOpenKeyW (HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
 
LONG WINAPI RegOpenKeyExA (_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
 
LONG WINAPI RegOpenKeyExW (HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
 
LONG WINAPI RegOpenUserClassesRoot (IN HANDLE hToken, IN DWORD dwOptions, IN REGSAM samDesired, OUT PHKEY phkResult)
 
LONG WINAPI RegQueryInfoKeyA (HKEY hKey, LPSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
 
LONG WINAPI RegQueryInfoKeyW (HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
 
LONG WINAPI RegQueryMultipleValuesA (HKEY hKey, PVALENTA val_list, DWORD num_vals, LPSTR lpValueBuf, LPDWORD ldwTotsize)
 
LONG WINAPI RegQueryMultipleValuesW (HKEY hKey, PVALENTW val_list, DWORD num_vals, LPWSTR lpValueBuf, LPDWORD ldwTotsize)
 
LONG WINAPI RegQueryReflectionKey (IN HKEY hBase, OUT BOOL *bIsReflectionDisabled)
 
LONG WINAPI RegQueryValueExA (_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
 
LONG WINAPI RegQueryValueExW (_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
 
LSTATUS WINAPI RegQueryValueA (HKEY hkey, LPCSTR name, LPSTR data, LPLONG count)
 
LSTATUS WINAPI RegQueryValueW (HKEY hkey, LPCWSTR name, LPWSTR data, LPLONG count)
 
LONG WINAPI RegReplaceKeyA (HKEY hKey, LPCSTR lpSubKey, LPCSTR lpNewFile, LPCSTR lpOldFile)
 
LONG WINAPI RegReplaceKeyW (HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpNewFile, LPCWSTR lpOldFile)
 
LONG WINAPI RegRestoreKeyA (HKEY hKey, LPCSTR lpFile, DWORD dwFlags)
 
LONG WINAPI RegRestoreKeyW (HKEY hKey, LPCWSTR lpFile, DWORD dwFlags)
 
LONG WINAPI RegSaveKeyA (HKEY hKey, LPCSTR lpFile, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
 
LONG WINAPI RegSaveKeyW (HKEY hKey, LPCWSTR lpFile, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
 
LONG WINAPI RegSaveKeyExA (HKEY hKey, LPCSTR lpFile, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD Flags)
 
LONG WINAPI RegSaveKeyExW (HKEY hKey, LPCWSTR lpFile, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD Flags)
 
LONG WINAPI RegSetKeySecurity (HKEY hKey, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor)
 
LONG WINAPI RegSetValueExA (HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
 
LONG WINAPI RegSetValueExW (_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
 
LONG WINAPI RegSetValueA (HKEY hKeyOriginal, LPCSTR lpSubKey, DWORD dwType, LPCSTR lpData, DWORD cbData)
 
LONG WINAPI RegSetValueW (HKEY hKeyOriginal, LPCWSTR lpSubKey, DWORD dwType, LPCWSTR lpData, DWORD cbData)
 
LONG WINAPI RegUnLoadKeyA (HKEY hKey, LPCSTR lpSubKey)
 
LONG WINAPI RegUnLoadKeyW (HKEY hKey, LPCWSTR lpSubKey)
 

Variables

static RTL_CRITICAL_SECTION HandleTableCS
 
static HANDLE DefaultHandleTable [MAX_DEFAULT_HANDLES]
 
static HANDLE ProcessHeap
 
static BOOLEAN DefaultHandlesDisabled = FALSE
 
static BOOLEAN DefaultHandleHKUDisabled = FALSE
 
static BOOLEAN DllInitialized = FALSE
 

Macro Definition Documentation

◆ ClosePredefKey

#define ClosePredefKey (   Handle)
Value:
if ((ULONG_PTR)Handle & 0x1) { \
NtClose(Handle); \
}
ULONG Handle
Definition: gdb_input.c:15
uint32_t ULONG_PTR
Definition: typedefs.h:65

Definition at line 44 of file reg.c.

◆ GetPredefKeyIndex

#define GetPredefKeyIndex (   HKey)     ((ULONG_PTR)(HKey) & 0x0FFFFFFF)

Definition at line 50 of file reg.c.

◆ IsPredefKey

#define IsPredefKey (   HKey)     (((ULONG_PTR)(HKey) & 0xF0000000) == 0x80000000)

Definition at line 48 of file reg.c.

◆ MAX_DEFAULT_HANDLES

#define MAX_DEFAULT_HANDLES   6

Definition at line 27 of file reg.c.

◆ REG_MAX_DATA_SIZE

#define REG_MAX_DATA_SIZE   2048

Definition at line 29 of file reg.c.

◆ REG_MAX_NAME_SIZE

#define REG_MAX_NAME_SIZE   256

Definition at line 28 of file reg.c.

Function Documentation

◆ CloseDefaultKeys()

static VOID CloseDefaultKeys ( VOID  )
static

Definition at line 216 of file reg.c.

217{
218 ULONG i;
219 RegInitialize(); /* HACK until delay-loading is implemented */
221
222 for (i = 0; i < MAX_DEFAULT_HANDLES; i++)
223 {
224 if (DefaultHandleTable[i] != NULL)
225 {
228 }
229 }
230
232}
#define NULL
Definition: types.h:112
static HANDLE DefaultHandleTable[MAX_DEFAULT_HANDLES]
Definition: reg.c:34
BOOL RegInitialize(VOID)
Definition: reg.c:70
#define MAX_DEFAULT_HANDLES
Definition: reg.c:27
static RTL_CRITICAL_SECTION HandleTableCS
Definition: reg.c:33
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
uint32_t ULONG
Definition: typedefs.h:59

Referenced by RegCleanup().

◆ CreateNestedKey()

static NTSTATUS CreateNestedKey ( PHKEY  KeyHandle,
POBJECT_ATTRIBUTES  ObjectAttributes,
PUNICODE_STRING  ClassString,
DWORD  dwOptions,
REGSAM  samDesired,
DWORD lpdwDisposition 
)
static

Definition at line 915 of file reg.c.

921{
922 OBJECT_ATTRIBUTES LocalObjectAttributes;
923 UNICODE_STRING LocalKeyName;
926 ULONG FullNameLength;
928 PWCHAR Ptr;
929 HANDLE LocalKeyHandle;
930
932 samDesired,
934 0,
935 ClassString,
936 dwOptions,
937 (PULONG)lpdwDisposition);
938 TRACE("NtCreateKey(%wZ) called (Status %lx)\n", ObjectAttributes->ObjectName, Status);
940 return Status;
941
942 /* Copy object attributes */
943 RtlCopyMemory(&LocalObjectAttributes,
945 sizeof(OBJECT_ATTRIBUTES));
946 RtlCreateUnicodeString(&LocalKeyName,
947 ObjectAttributes->ObjectName->Buffer);
948 LocalObjectAttributes.ObjectName = &LocalKeyName;
949 FullNameLength = LocalKeyName.Length / sizeof(WCHAR);
950
951 LocalKeyHandle = NULL;
952
953 /* Remove the last part of the key name and try to create the key again. */
955 {
956 Ptr = wcsrchr(LocalKeyName.Buffer, '\\');
957 if (Ptr == NULL || Ptr == LocalKeyName.Buffer)
958 {
960 break;
961 }
962
963 *Ptr = (WCHAR)0;
964 LocalKeyName.Length = (USHORT)wcslen(LocalKeyName.Buffer) * sizeof(WCHAR);
965
966 Status = NtCreateKey(&LocalKeyHandle,
968 &LocalObjectAttributes,
969 0,
970 NULL,
971 0,
972 &Disposition);
973 TRACE("NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName, Status);
974 }
975
976 if (!NT_SUCCESS(Status))
977 {
978 RtlFreeUnicodeString(&LocalKeyName);
979 return Status;
980 }
981
982 /* Add removed parts of the key name and create them too. */
983 Length = wcslen(LocalKeyName.Buffer);
984 while (TRUE)
985 {
986 if (LocalKeyHandle)
987 NtClose (LocalKeyHandle);
988
989 LocalKeyName.Buffer[Length] = L'\\';
990 Length = wcslen (LocalKeyName.Buffer);
991 LocalKeyName.Length = Length * sizeof(WCHAR);
992
993 if (Length == FullNameLength)
994 {
996 samDesired,
998 0,
999 ClassString,
1000 dwOptions,
1001 (PULONG)lpdwDisposition);
1002 break;
1003 }
1004
1005 Status = NtCreateKey(&LocalKeyHandle,
1007 &LocalObjectAttributes,
1008 0,
1009 NULL,
1010 0,
1011 &Disposition);
1012 TRACE("NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName, Status);
1013 if (!NT_SUCCESS(Status))
1014 break;
1015 }
1016
1017 RtlFreeUnicodeString(&LocalKeyName);
1018
1019 return Status;
1020}
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define wcsrchr
Definition: compat.h:16
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
Status
Definition: gdiplustypes.h:25
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
Definition: ntapi.c:240
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwOptions
Definition: solitaire.cpp:25
PUNICODE_STRING ObjectName
Definition: umtypes.h:185
uint32_t * PULONG
Definition: typedefs.h:59
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint16_t * PWCHAR
Definition: typedefs.h:56
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by RegCreateKeyExW().

◆ is_string()

static __inline int is_string ( DWORD  type)
static

Definition at line 61 of file reg.c.

62{
63 return (type == REG_SZ) || (type == REG_EXPAND_SZ) || (type == REG_MULTI_SZ);
64}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define REG_SZ
Definition: layer.c:22
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define REG_EXPAND_SZ
Definition: nt_native.h:1494

Referenced by RegEnumValueA(), RegEnumValueW(), RegQueryValueExA(), RegQueryValueExW(), RegSetValueExA(), and RegSetValueExW().

◆ MapDefaultKey() [1/2]

static NTSTATUS MapDefaultKey ( OUT PHANDLE  RealKey,
IN HKEY  Key 
)
static

Definition at line 153 of file reg.c.

155{
157 ULONG Index;
158 BOOLEAN DoOpen, DefDisabled;
160
161 TRACE("MapDefaultKey (Key %x)\n", Key);
162
163 if (!IsPredefKey(Key))
164 {
165 *RealKey = (HANDLE)((ULONG_PTR)Key & ~0x1);
166 return STATUS_SUCCESS;
167 }
168
169 /* Handle special cases here */
172 {
174 }
175 RegInitialize(); /* HACK until delay-loading is implemented */
177
178 if (Key == HKEY_CURRENT_USER)
179 DefDisabled = DefaultHandleHKUDisabled;
180 else
181 DefDisabled = DefaultHandlesDisabled;
182
183 if (!DefDisabled)
184 {
186 DoOpen = (*Handle == NULL);
187 }
188 else
189 {
190 Handle = RealKey;
191 DoOpen = TRUE;
192 }
193
194 if (DoOpen)
195 {
196 /* create/open the default handle */
198 Handle);
199 }
200
201 if (NT_SUCCESS(Status))
202 {
203 if (!DefDisabled)
204 *RealKey = *Handle;
205 else
206 *(PULONG_PTR)Handle |= 0x1;
207 }
208
210
211 return Status;
212}
unsigned char BOOLEAN
static BOOLEAN DefaultHandlesDisabled
Definition: reg.c:36
static BOOLEAN DefaultHandleHKUDisabled
Definition: reg.c:37
static NTSTATUS OpenPredefinedKey(IN ULONG Index, OUT HANDLE Handle)
Definition: reg.c:105
#define IsPredefKey(HKey)
Definition: reg.c:48
#define GetPredefKeyIndex(HKey)
Definition: reg.c:50
int DoOpen(void)
Definition: cmds.c:2168
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t * PULONG_PTR
Definition: typedefs.h:65
PVOID HANDLE
Definition: typedefs.h:73
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ WDFCOLLECTION _In_ ULONG Index
#define HKEY_CURRENT_USER
Definition: winreg.h:11

◆ MapDefaultKey() [2/2]

◆ OpenClassesRootKey() [1/2]

static NTSTATUS OpenClassesRootKey ( _Out_ PHANDLE  KeyHandle)
static

Definition at line 236 of file reg.c.

237{
239 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software\\CLASSES");
241
242 TRACE("OpenClassesRootKey()\n");
243
245 &KeyName,
247 NULL,
248 NULL);
251 &Attributes);
252
253 if (!NT_SUCCESS(Status))
254 return Status;
255
256 /* Mark it as HKCR */
258
259 return Status;
260}
FORCEINLINE void MakeHKCRKey(_Inout_ HKEY *hKey)
Definition: reg.h:20
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699

◆ OpenClassesRootKey() [2/2]

static NTSTATUS OpenClassesRootKey ( PHANDLE  KeyHandle)
static

Referenced by OpenPredefinedKey().

◆ OpenCurrentConfigKey()

static NTSTATUS OpenCurrentConfigKey ( PHANDLE  KeyHandle)
static

Definition at line 307 of file reg.c.

308{
311 RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Hardware Profiles\\Current");
312
313 TRACE("OpenCurrentConfigKey()\n");
314
316 &KeyName,
318 NULL,
319 NULL);
320 return NtOpenKey(KeyHandle,
322 &Attributes);
323}

Referenced by OpenPredefinedKey().

◆ OpenLocalMachineKey()

static NTSTATUS OpenLocalMachineKey ( PHANDLE  KeyHandle)
static

Definition at line 264 of file reg.c.

265{
267 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine");
269
270 TRACE("OpenLocalMachineKey()\n");
271
273 &KeyName,
275 NULL,
276 NULL);
279 &Attributes);
280
281 TRACE("NtOpenKey(%wZ) => %08x\n", &KeyName, Status);
282
283 return Status;
284}

Referenced by OpenPredefinedKey().

◆ OpenPredefinedKey()

static NTSTATUS OpenPredefinedKey ( IN ULONG  Index,
OUT HANDLE  Handle 
)
static

Definition at line 105 of file reg.c.

107{
109
110 switch (Index)
111 {
112 case 0: /* HKEY_CLASSES_ROOT */
114 break;
115
116 case 1: /* HKEY_CURRENT_USER */
118 Handle);
119 break;
120
121 case 2: /* HKEY_LOCAL_MACHINE */
123 break;
124
125 case 3: /* HKEY_USERS */
127 break;
128#if 0
129 case 4: /* HKEY_PERFORMANCE_DATA */
130 Status = OpenPerformanceDataKey (Handle);
131 break;
132#endif
133
134 case 5: /* HKEY_CURRENT_CONFIG */
136 break;
137
138 case 6: /* HKEY_DYN_DATA */
140 break;
141
142 default:
143 WARN("MapDefaultHandle() no handle creator\n");
145 break;
146 }
147
148 return Status;
149}
#define WARN(fmt,...)
Definition: debug.h:112
static NTSTATUS OpenLocalMachineKey(PHANDLE KeyHandle)
Definition: reg.c:264
static NTSTATUS OpenClassesRootKey(PHANDLE KeyHandle)
static NTSTATUS OpenCurrentConfigKey(PHANDLE KeyHandle)
Definition: reg.c:307
static NTSTATUS OpenUsersKey(PHANDLE KeyHandle)
Definition: reg.c:288
NTSYSAPI NTSTATUS NTAPI RtlOpenCurrentUser(_In_ ACCESS_MASK DesiredAccess, _Out_ PHANDLE KeyHandle)
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

Referenced by MapDefaultKey(), and RegOverridePredefKey().

◆ OpenUsersKey()

static NTSTATUS OpenUsersKey ( PHANDLE  KeyHandle)
static

Definition at line 288 of file reg.c.

289{
291 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\User");
292
293 TRACE("OpenUsersKey()\n");
294
296 &KeyName,
298 NULL,
299 NULL);
300 return NtOpenKey(KeyHandle,
302 &Attributes);
303}

Referenced by OpenPredefinedKey().

◆ RegCleanup()

BOOL RegCleanup ( VOID  )

Definition at line 93 of file reg.c.

94{
95 TRACE("RegCleanup()\n");
96
99
100 return TRUE;
101}
static VOID CloseDefaultKeys(VOID)
Definition: reg.c:216
NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)

Referenced by DllMain().

◆ RegCloseKey()

LONG WINAPI RegCloseKey ( HKEY  hKey)

Definition at line 423 of file reg.c.

424{
426
427 /* don't close null handle or a pseudo handle */
428 if (!hKey)
429 {
431 }
432
433 if (((ULONG_PTR)hKey & 0xF0000000) == 0x80000000)
434 {
435 return ERROR_SUCCESS;
436 }
437
439 if (!NT_SUCCESS(Status))
440 {
442 }
443
444 return ERROR_SUCCESS;
445}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
FxAutoRegKey hKey
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)

◆ RegConnectRegistryA()

LONG WINAPI RegConnectRegistryA ( IN LPCSTR  lpMachineName,
IN HKEY  hKey,
OUT PHKEY  phkResult 
)

Definition at line 840 of file reg.c.

843{
844 UNICODE_STRING MachineName = { 0, 0, NULL };
845 LONG Ret;
846
847 if (lpMachineName != NULL &&
849 {
851 }
852
853 Ret = RegConnectRegistryW(MachineName.Buffer,
854 hKey,
855 phkResult);
856
858
859 return Ret;
860}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
LONG WINAPI RegConnectRegistryW(LPCWSTR lpMachineName, HKEY hKey, PHKEY phkResult)
Definition: reg.c:869
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
long LONG
Definition: pedump.c:60
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1293

Referenced by test_regconnectregistry().

◆ RegConnectRegistryW()

LONG WINAPI RegConnectRegistryW ( LPCWSTR  lpMachineName,
HKEY  hKey,
PHKEY  phkResult 
)

Definition at line 869 of file reg.c.

872{
873 LONG ret;
874
875 TRACE("(%s,%p,%p): stub\n",debugstr_w(lpMachineName),hKey,phkResult);
876
877 if (!lpMachineName || !*lpMachineName)
878 {
879 /* Use the local machine name */
880 ret = RegOpenKeyW( hKey, NULL, phkResult );
881 }
882 else
883 {
884 WCHAR compName[MAX_COMPUTERNAME_LENGTH + 1];
885 DWORD len = sizeof(compName) / sizeof(WCHAR);
886
887 /* MSDN says lpMachineName must start with \\ : not so */
888 if( lpMachineName[0] == '\\' && lpMachineName[1] == '\\')
889 lpMachineName += 2;
890
891 if (GetComputerNameW(compName, &len))
892 {
893 if (!_wcsicmp(lpMachineName, compName))
894 ret = RegOpenKeyW(hKey, NULL, phkResult);
895 else
896 {
897 FIXME("Connect to %s is not supported.\n",debugstr_w(lpMachineName));
899 }
900 }
901 else
902 ret = GetLastError();
903 }
904
905 return ret;
906}
#define FIXME(fmt,...)
Definition: debug.h:111
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3288
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define debugstr_w
Definition: kernel32.h:32
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:243
#define ERROR_BAD_NETPATH
Definition: winerror.h:145

Referenced by CM_Open_Class_Key_ExW(), CM_Open_DevNode_Key_Ex(), RegConnectRegistryA(), SetupDiCreateDeviceInfoListExW(), and SetupDiOpenClassRegKeyExW().

◆ RegCopyTreeA()

LONG WINAPI RegCopyTreeA ( IN HKEY  hKeySrc,
IN LPCSTR lpSubKey  OPTIONAL,
IN HKEY  hKeyDest 
)

Definition at line 811 of file reg.c.

814{
815 UNICODE_STRING SubKeyName = { 0, 0, NULL };
816 LONG Ret;
817
818 if (lpSubKey != NULL &&
820 {
822 }
823
824 Ret = RegCopyTreeW(hKeySrc,
825 SubKeyName.Buffer,
826 hKeyDest);
827
829
830 return Ret;
831}
LONG WINAPI RegCopyTreeW(IN HKEY hKeySrc, IN LPCWSTR lpSubKey OPTIONAL, IN HKEY hKeyDest)
Definition: reg.c:736
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING SubKeyName
Definition: ndis.h:4725

Referenced by InitFunctionPtrs().

◆ RegCopyTreeW()

LONG WINAPI RegCopyTreeW ( IN HKEY  hKeySrc,
IN LPCWSTR lpSubKey  OPTIONAL,
IN HKEY  hKeyDest 
)

Definition at line 736 of file reg.c.

739{
740 HANDLE DestKeyHandle, KeyHandle, CurKey, SubKeyHandle = NULL;
742
744 hKeySrc);
745 if (!NT_SUCCESS(Status))
746 {
748 }
749
750 Status = MapDefaultKey(&DestKeyHandle,
751 hKeyDest);
752 if (!NT_SUCCESS(Status))
753 {
754 goto Cleanup2;
755 }
756
757 if (lpSubKey != NULL)
758 {
761
763
765 &SubKeyName,
767 KeyHandle,
768 NULL);
769
773 if (!NT_SUCCESS(Status))
774 {
775 goto Cleanup;
776 }
777
778 CurKey = SubKeyHandle;
779 }
780 else
781 CurKey = KeyHandle;
782
783 Status = RegpCopyTree(CurKey,
784 hKeyDest);
785
786 if (SubKeyHandle != NULL)
787 {
789 }
790
791Cleanup:
792 ClosePredefKey(DestKeyHandle);
793Cleanup2:
795
796 if (!NT_SUCCESS(Status))
797 {
799 }
800
801 return ERROR_SUCCESS;
802}
#define ClosePredefKey(Handle)
Definition: reg.c:44
static NTSTATUS MapDefaultKey(PHANDLE ParentKey, HKEY Key)
static NTSTATUS RegpCopyTree(IN HKEY hKeySrc, IN HKEY hKeyDest)
Definition: reg.c:449
static const WCHAR Cleanup[]
Definition: register.c:80
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING _Out_ PNDIS_HANDLE SubKeyHandle
Definition: ndis.h:4726
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019

Referenced by CopyKey(), RegCopyTreeA(), and ScmCopyControlSet().

◆ RegCreateKeyA()

LONG WINAPI RegCreateKeyA ( HKEY  hKey,
LPCSTR  lpSubKey,
PHKEY  phkResult 
)

Definition at line 1174 of file reg.c.

1177{
1178 return RegCreateKeyExA(hKey,
1179 lpSubKey,
1180 0,
1181 NULL,
1182 0,
1184 NULL,
1185 phkResult,
1186 NULL);
1187}
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

Referenced by create_new_eventlog(), create_reg_entries(), create_test_entries(), CryptRegisterOIDFunction(), CryptRegisterOIDInfo(), DllRegisterServer(), init_key(), lineGetTranslateCapsA(), register_testentry(), register_zone_domains(), RegSetValueA(), setup_main_key(), test_AddERExcludedApplicationA(), test_appsearch_reglocator(), test_classesroot_enum(), test_CreateMRUListLazyW(), test_CreateMRUListW(), test_debug_heap(), test_deleted_key(), test_enum_value(), test_ExitCode(), test_getstring_no_extra(), test_install_from(), test_internet_features(), test_internet_features_registry(), test_MRUListA(), test_MsiEnumPatches(), test_MsiEnumPatchesEx_userunmanaged(), test_MsiEnumProducts(), test_MsiGetComponentPath(), test_MsiGetComponentPathEx(), test_MsiGetPatchInfoEx(), test_MsiGetProductCode(), test_MsiGetProductInfoEx(), test_MsiGetUserInfo(), test_MsiOpenProduct(), test_MsiQueryComponentState(), test_MsiQueryFeatureState(), test_MsiQueryProductState(), test_MsiSourceListAddMediaDisk(), test_MsiSourceListAddSource(), test_MsiSourceListAddSourceEx(), test_MsiSourceListEnumMediaDisks(), test_MsiSourceListEnumSources(), test_MsiSourceListGetInfo(), test_MsiSourceListSetInfo(), test_open_class_key(), test_publish_components(), test_reg_copy_tree(), test_reg_delete_key(), test_reg_delete_tree(), test_reg_query_value(), test_registerOIDInfo(), test_registry(), test_RegNotifyChangeKeyValue(), test_rw_order(), test_SetZoneAttributes(), test_SHCopyKey(), test_SHDeleteKey(), test_string_termination(), test_write_registry_values(), test_zone_domain_cache(), WNetCachePassword(), WNetEnumCachedPasswords(), WNetGetCachedPassword(), and WNetRemoveCachedPassword().

◆ RegCreateKeyExA()

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 at line 1029 of file reg.c.

1039{
1040 UNICODE_STRING SubKeyString;
1041 UNICODE_STRING ClassString;
1043
1044 RtlInitEmptyUnicodeString(&ClassString, NULL, 0);
1045 RtlInitEmptyUnicodeString(&SubKeyString, NULL, 0);
1046
1047 if (lpClass)
1048 {
1049 if (!RtlCreateUnicodeStringFromAsciiz(&ClassString, lpClass))
1050 {
1052 goto Exit;
1053 }
1054 }
1055
1056 if (lpSubKey)
1057 {
1058 if (!RtlCreateUnicodeStringFromAsciiz(&SubKeyString, lpSubKey))
1059 {
1061 goto Exit;
1062 }
1063 }
1064
1066 hKey,
1067 SubKeyString.Buffer,
1068 Reserved,
1069 ClassString.Buffer,
1070 dwOptions,
1071 samDesired,
1072 lpSecurityAttributes,
1073 phkResult,
1074 lpdwDisposition);
1075
1076Exit:
1077 RtlFreeUnicodeString(&SubKeyString);
1078 RtlFreeUnicodeString(&ClassString);
1079
1080 return ErrorCode;
1081}
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
static void Exit(void)
Definition: sock.c:1330
_Reserved_ PVOID Reserved
Definition: winddi.h:3974

Referenced by add_key_(), create_container_key(), create_test_association(), create_test_class(), create_test_verb_dde(), CRYPT_GetDefaultOIDKey(), CryptGetDefaultOIDDllList(), CryptRegisterOIDInfo(), expect_LayerValue_imp(), FindAdapterKey(), get_key_value(), is_elevated_process(), ODBC_ReplicateODBCInstToRegistry(), ODBC_ReplicateODBCToRegistry(), reg_unreg_wine_test_class(), RegCreateKeyA(), register_keys(), register_mediatypes_extension(), register_progid(), set_component_path(), setLayerValue(), SHAddToRecentDocs(), SHGetSettings(), SHOpenRegStream2A(), SHSetValueA(), START_TEST(), test_appsearch(), test_basic_import_31(), test_classesroot(), test_classesroot_enum(), test_CoGetClassObject(), test_CoGetPSClsid(), test_copy_key_class(), test_delete_key_value(), test_envvar(), test_ExitCode(), test_invalid_import_31(), test_MsiEnumClients(), test_MsiEnumComponents(), test_MsiEnumComponentsEx(), test_MsiEnumPatches(), test_MsiEnumPatchesEx_machine(), test_MsiEnumPatchesEx_usermanaged(), test_MsiEnumPatchesEx_userunmanaged(), test_MsiEnumProducts(), test_MsiEnumProductsEx(), test_MsiGetComponentPath(), test_MsiGetComponentPathEx(), test_MsiGetPatchInfo(), test_MsiGetPatchInfoEx(), test_MsiGetProductCode(), test_MsiGetProductInfoEx(), test_MsiGetProductProperty(), test_MsiGetUserInfo(), test_MsiOpenProduct(), test_MsiProvideQualifiedComponentEx(), test_MsiQueryComponentState(), test_MsiQueryFeatureState(), test_MsiQueryProductState(), test_MsiSourceListAddMediaDisk(), test_MsiSourceListAddSource(), test_MsiSourceListAddSourceEx(), test_MsiSourceListEnumMediaDisks(), test_MsiSourceListEnumSources(), test_MsiSourceListSetInfo(), test_null(), test_OleRegGetUserType(), test_publish_components(), test_redirection(), test_reg_create_key(), test_reg_open_key(), test_reg_query_info(), test_register_progid_info(), test_symlinks(), test_TreatAsClass(), and testRegStore().

◆ RegCreateKeyExW()

LONG WINAPI RegCreateKeyExW ( _In_ HKEY  hKey,
_In_ LPCWSTR  lpSubKey,
_In_ DWORD  Reserved,
_In_opt_ LPWSTR  lpClass,
_In_ DWORD  dwOptions,
_In_ REGSAM  samDesired,
_In_opt_ LPSECURITY_ATTRIBUTES  lpSecurityAttributes,
_Out_ PHKEY  phkResult,
_Out_opt_ LPDWORD  lpdwDisposition 
)

Definition at line 1091 of file reg.c.

1101{
1102 UNICODE_STRING SubKeyString;
1103 UNICODE_STRING ClassString;
1108
1109 TRACE("RegCreateKeyExW() called\n");
1110
1111 /* get the real parent key */
1113 hKey);
1114 if (!NT_SUCCESS(Status))
1115 {
1117 }
1118
1119 TRACE("ParentKey %p\n", ParentKey);
1120
1121 if (IsHKCRKey(ParentKey))
1122 {
1124 ParentKey,
1125 lpSubKey,
1126 Reserved,
1127 lpClass,
1128 dwOptions,
1129 samDesired,
1130 lpSecurityAttributes,
1131 phkResult,
1132 lpdwDisposition);
1134 return ErrorCode;
1135 }
1136
1139
1140 RtlInitUnicodeString(&ClassString,
1141 lpClass);
1142 RtlInitUnicodeString(&SubKeyString,
1143 lpSubKey);
1145 &SubKeyString,
1146 Attributes,
1148 lpSecurityAttributes ? (PSECURITY_DESCRIPTOR)lpSecurityAttributes->lpSecurityDescriptor : NULL);
1149 Status = CreateNestedKey(phkResult,
1151 (lpClass == NULL)? NULL : &ClassString,
1152 dwOptions,
1153 samDesired,
1154 lpdwDisposition);
1155
1157
1158 TRACE("Status %x\n", Status);
1159 if (!NT_SUCCESS(Status))
1160 {
1162 }
1163
1164 return ERROR_SUCCESS;
1165}
static NTSTATUS CreateNestedKey(PHKEY KeyHandle, POBJECT_ATTRIBUTES ObjectAttributes, PUNICODE_STRING ClassString, DWORD dwOptions, REGSAM samDesired, DWORD *lpdwDisposition)
Definition: reg.c:915
FORCEINLINE BOOL IsHKCRKey(_In_ HKEY hKey)
Definition: reg.h:13
LONG WINAPI CreateHKCRKey(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: hkcr.c:220
#define OBJ_OPENLINK
Definition: winternl.h:230
#define REG_OPTION_OPEN_LINK
Definition: nt_native.h:1070
_Must_inspect_result_ _In_opt_ WDFKEY ParentKey
Definition: wdfregistry.h:69

Referenced by _InitializeLocalSpooler(), _SHOpenProfilesKey(), ACTION_RegisterClassInfo(), ACTION_UnregisterClassInfo(), add_userkey(), COpenWithList::AddAppToMRUList(), AddNewLayout(), AddUninstallKey(), ApplyEventlogSettings(), ApplyRegistryValues(), BuildVolatileEnvironment(), CategoryMgr_RegisterCategory(), CliSaveImeHotKey(), CM_Open_Class_Key_ExW(), CM_Open_DevNode_Key_Ex(), ComDBOpen(), ConCfgOpenUserSettings(), connections_on_notify(), ConnectRegistry(), CopyKey(), CopySystemProfile(), create_key(), create_mru_list(), CreateAppPathRegKey(), CreateDeviceInstance(), CreateEventLog(), CreateHKCRKey(), CreateInstanceKey(), CreateNewKey(), CreateRegAppPath(), CreateSymLink(), CreateUserProfileExW(), CredWriteW(), CriticalDeviceCoInstaller(), CRYPT_ImportSystemRootCertsToReg(), CRYPT_RegReadFromReg(), CRYPT_RegWriteToReg(), CRYPT_SysRegOpenStoreW(), CRYPT_WriteSerializedToReg(), DeleteJob(), DeleteUninstallKey(), DIALOG_Execute(), CNetConnection::Disconnect(), DllRegisterServer(), DMORegister(), do_typelib_reg_key(), DoStartStartupItems(), EditTypeDlg_WriteClass(), CSysTray::EnableService(), EnumTfLanguageProfiles_Constructor(), FillList(), FilterMapper3_CreateCategory(), FilterMapper_RegisterFilter(), FilterMapper_RegisterPin(), FilterMapper_RegisterPinType(), get_cert_mgr_usages(), get_fusion_filename(), GetCurrentDPI(), GetFallbackHKCRKey(), CSysTray::GetServicesEnabled(), INetCfgComponentControl_fnApplyRegistryChanges(), INetCfgLock_fnAcquireWriteLock(), CRegPropertyBag::Init(), InitAppRegKey(), InitializeFormList(), InitLogs(), InitSettings(), InputProcessorProfiles_AddLanguageProfile(), InputProcessorProfiles_Register(), InputProcessorProfiles_SetDefaultLanguageProfile(), InstallDefaultSystemSoundScheme(), InstallEventSource(), InstallNetDevice(), InstallOneInterface(), InstallSystemSoundLabels(), InstallSystemSoundScheme(), InstallSystemSoundSchemeNames(), load_devices_from_reg(), LoadJobs(), LoadRecoveryOptions(), LocalAddMonitor(), MAIN_LoadSettings(), MainWnd_OnOpenRegKey(), MMDevice_Create(), MRU_SaveChanged(), msi_publish_patches(), MSIREG_OpenClassesUpgradeCodesKey(), MSIREG_OpenFeaturesKey(), MSIREG_OpenInstallerFeaturesKey(), MSIREG_OpenInstallProps(), MSIREG_OpenPatchesKey(), MSIREG_OpenProductKey(), MSIREG_OpenUninstallKey(), MSIREG_OpenUpgradeCodesKey(), MSIREG_OpenUserDataComponentKey(), MSIREG_OpenUserDataFeaturesKey(), MSIREG_OpenUserDataPatchKey(), MSIREG_OpenUserDataProductKey(), MSIREG_OpenUserDataProductPatchesKey(), myAddPrinterDriverEx(), notif_thread_proc(), open_cred_mgr_key(), open_key(), OpenConfigurationKey(), OpenImageFileExecOptions(), PNP_CreateKey(), PNP_GetClassInstance(), PNP_GetHwProfInfo(), PNP_SetClassRegProp(), ProcessSetupInf(), ProcessUnattendSection(), ProfilesEnumGuid_Constructor(), RegCreateKeyExA(), RegCreateKeyW(), register_categories(), register_coclasses(), register_converters(), register_decoders(), register_encoders(), register_interfaces(), register_key_defvalueA(), register_key_defvalueW(), register_mediatypes_extension(), register_mediatypes_parsing(), register_metadatareaders(), register_pixelformats(), register_server(), RegisterBDAComponent(), RegisterComponent(), RegisterHelperDll(), RegisterSdbEntry(), RegisterService(), RegisterTypeLib(), registry_callback(), registry_get_handle(), RegSetDWORDValue(), run_add(), run_copy(), SampSetupAddMemberToAlias(), save_cert_mgr_usages(), save_sys_colors(), SaveBoard(), SaveDWORDToRegistry(), SaveJob(), SaveSettings(), SaveShutdownSelState(), SaveStringToRegistry(), ScmCopyControlSet(), ScmCopyTree(), ScmCreateNewControlPipe(), ScmCreateServiceKey(), ScmWriteSecurityDescriptor(), set_profile_device_key(), set_proxy(), COpenWithList::SetDefaultHandler(), SetFindFlags(), SetHotPlugFlags(), SetNtpClientValues(), SetParametersValues(), SetPerUserSecValuesW(), SETUP_CreateClassKey(), SETUPDI_CreateDevKey(), SETUPDI_CreateDrvKey(), SetupDiCreateDeviceInterfaceRegKeyW(), SetupDiCreateDevRegKeyW(), SHAddToRecentDocs(), SHCreateSessionKey(), SHELL_FS_HideExtension(), SHGetShellKey(), SHOpenRegStream2W(), SHRegCreateUSKeyW(), SHSetValueW(), START_TEST(), StoreDriveSettings(), test4(), Test_CreateOpenKey(), test_IQueryAssociations_GetString(), test_legacy_filter_registration(), test_OleDoAutoConvert(), test_OleRegGetUserType(), test_system_security_access(), TestMyEventProvider(), testSystemStore(), TLB_register_interface(), TRASH_CanTrashFile(), unregister_converters(), unregister_decoders(), unregister_encoders(), unregister_metadatareaders(), unregister_pixelformats(), unregister_server(), UpdateRegistryString(), UXTHEME_BackupSystemMetrics(), WinHttpSetDefaultProxyConfiguration(), WINTRUST_WriteProviderToReg(), WINTRUST_WriteSingleUsageEntry(), WintrustGetRegPolicyFlags(), WintrustSetRegPolicyFlags(), wnet_use_connection(), write_reg_key(), write_types(), WriteCabinetState(), WritePortSettings(), WriteStartupRecoveryOptions(), and WriteUserLocale().

◆ RegCreateKeyW()

LONG WINAPI RegCreateKeyW ( HKEY  hKey,
LPCWSTR  lpSubKey,
PHKEY  phkResult 
)

Definition at line 1196 of file reg.c.

1199{
1200 return RegCreateKeyExW(hKey,
1201 lpSubKey,
1202 0,
1203 NULL,
1204 0,
1206 NULL,
1207 phkResult,
1208 NULL);
1209}

Referenced by _SHGetCurrentVersionPath(), _SHGetUserShellFolderPath(), _SHRegisterFolders(), ACTION_ForceReboot(), ACTION_RegisterClassInfo(), ACTION_RegisterExtensionInfo(), AddERExcludedApplicationW(), ApplyScheme(), CRYPT_SIPWriteFunction(), DEVENUM_CreateAMCategoryKey(), DEVENUM_IPropertyBag_Write(), do_process_key(), ATL::CRegObject::do_process_key(), FILEDLG95_MRU_get_slot(), get_mapping_key(), CTrayBandSite::GetDefaultBandsStream(), CTrayBandSite::GetUserBandsStream(), I_CryptReadTrustedPublisherDWORDValueFromRegistry(), Imm32WriteImeLayout(), InputList_PrepareUserRegistry(), ITERATE_RegisterFonts(), ITERATE_UnregisterFonts(), KmtFltAddAltitude(), LocalAddMonitor(), LocalDeleteMonitor(), MSACM_ReadCache(), MSACM_WriteCache(), MSACM_WriteCurrentPriorities(), msi_publish_sourcelist(), msi_reg_set_subkey_val(), MSIREG_OpenUserComponentsKey(), MSIREG_OpenUserPatchesKey(), MSIREG_OpenUserUpgradeCodesKey(), NdrDllRegisterProxy(), open_assemblies_key(), open_driver_reg(), open_global_assembly_key(), open_local_assembly_key(), OpenMediaSubkey(), OpenNetworkSubkey(), OpenSourceKey(), OpenURLSubkey(), RegInitializeRegistry(), register_appid(), register_codepages(), register_progid(), register_verb(), registry_callback(), RegSetKeyValueW(), RegSetValueW(), SaveSettings(), SetupRegisterAllClasses(), SetupRegisterClass(), SHCopyKeyW(), SHPropertyBag_OnRegKey(), SHRegGetCLSIDKeyW(), SHRegWriteUSValueW(), SQLWritePrivateProfileStringW(), START_TEST(), stillimagew_RegisterLaunchApplication(), stillimagew_UnregisterLaunchApplication(), test_FolderShortcut(), test_Installer_RegistryValue(), TOOLBAR_Save(), UXTHEME_ApplyTheme(), and write_registry_values().

◆ RegDeleteKeyA()

LONG WINAPI RegDeleteKeyA ( _In_ HKEY  hKey,
_In_ LPCSTR  lpSubKey 
)

Definition at line 1219 of file reg.c.

1222{
1223 return RegDeleteKeyExA(hKey, lpSubKey, 0, 0);
1224}
LONG WINAPI RegDeleteKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ REGSAM samDesired, _In_ DWORD Reserved)
Definition: reg.c:1249

Referenced by cleanup_eventlog(), CryptUnregisterOIDFunction(), CryptUnregisterOIDInfo(), delete_container_key(), delete_key(), delete_key_(), delete_key_portable(), delete_tree(), delete_tree_(), DllUnregisterServer(), init_key(), is_elevated_process(), mru_RegDeleteTreeA(), myRegDeleteTreeA(), ok_registry(), reg_unreg_wine_test_class(), setperusersecvalues_test(), SHAddToRecentDocs(), SHDeleteEmptyKeyA(), SHDeleteOrphanKeyA(), START_TEST(), test_appsearch(), test_appsearch_reglocator(), test_classesroot(), test_debug_heap(), test_delete_key_value(), test_directshow_filter(), test_enum_value(), test_ExitCode(), test_install_from(), test_Installer_InstallProduct(), test_internet_features(), test_internet_features_registry(), test_key_formats(), test_MsiEnumPatches(), test_MsiEnumPatchesEx_userunmanaged(), test_MsiEnumProducts(), test_MsiGetComponentPath(), test_MsiGetComponentPathEx(), test_MsiGetPatchInfoEx(), test_MsiGetProductCode(), test_MsiGetProductInfoEx(), test_MsiGetProductProperty(), test_MsiGetUserInfo(), test_MsiInstallProduct(), test_MsiOpenProduct(), test_MsiQueryComponentState(), test_MsiQueryFeatureState(), test_MsiQueryProductState(), test_MsiSourceListAddMediaDisk(), test_MsiSourceListAddSource(), test_MsiSourceListEnumMediaDisks(), test_MsiSourceListEnumSources(), test_MsiSourceListGetInfo(), test_MsiSourceListSetInfo(), test_OleDoAutoConvert(), test_OleRegGetUserType(), test_open_class_key(), test_publish_components(), test_publish_product(), test_redirection(), test_reg_create_key(), test_reg_delete_key(), test_reg_open_key(), test_reg_query_info(), test_reg_query_value(), test_regcat(), test_register_product(), test_register_progid_info(), test_registerOIDFunction(), test_registry(), test_RegNotifyChangeKeyValue(), test_rw_order(), test_string_termination(), test_symlinks(), test_TreatAsClass(), test_write_registry_values(), test_zone_domain_cache(), testRegStore(), unregister_keys(), unregister_server(), unregister_testentry(), and unregister_zone_domains().

◆ RegDeleteKeyExA()

LONG WINAPI RegDeleteKeyExA ( _In_ HKEY  hKey,
_In_ LPCSTR  lpSubKey,
_In_ REGSAM  samDesired,
_In_ DWORD  Reserved 
)

Definition at line 1249 of file reg.c.

1254{
1257
1258 if (lpSubKey)
1259 {
1262 }
1263 else
1264 RtlInitEmptyUnicodeString(&SubKeyName, NULL, 0);
1265
1266 ErrorCode = RegDeleteKeyExW(hKey, SubKeyName.Buffer, samDesired, Reserved);
1267
1269
1270 return ErrorCode;
1271}
LONG WINAPI RegDeleteKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ REGSAM samDesired, _In_ DWORD Reserved)
Definition: reg.c:1281

Referenced by delete_key_(), delete_tree_(), init_functionpointers(), InitFunctionPtrs(), and RegDeleteKeyA().

◆ RegDeleteKeyExW()

LONG WINAPI RegDeleteKeyExW ( _In_ HKEY  hKey,
_In_ LPCWSTR  lpSubKey,
_In_ REGSAM  samDesired,
_In_ DWORD  Reserved 
)

Definition at line 1281 of file reg.c.

1286{
1290 HANDLE TargetKey;
1292
1293 /* Make sure we got a subkey */
1294 if (!lpSubKey)
1295 {
1296 /* Fail */
1298 }
1299
1301 hKey);
1302 if (!NT_SUCCESS(Status))
1303 {
1305 }
1306
1307 if (IsHKCRKey(ParentKey))
1308 {
1309 LONG ErrorCode = DeleteHKCRKey(ParentKey, lpSubKey, samDesired, Reserved);
1311 return ErrorCode;
1312 }
1313
1314 if (samDesired & KEY_WOW64_32KEY)
1315 ERR("Wow64 not yet supported!\n");
1316
1317 if (samDesired & KEY_WOW64_64KEY)
1318 ERR("Wow64 not yet supported!\n");
1319
1320
1321 RtlInitUnicodeString(&SubKeyName, lpSubKey);
1323 &SubKeyName,
1325 ParentKey,
1326 NULL);
1327 Status = NtOpenKey(&TargetKey,
1328 DELETE,
1330 if (!NT_SUCCESS(Status))
1331 {
1332 goto Cleanup;
1333 }
1334
1335 Status = NtDeleteKey(TargetKey);
1336 NtClose(TargetKey);
1337
1338Cleanup:
1340
1341 if (!NT_SUCCESS(Status))
1342 {
1344 }
1345
1346 return ERROR_SUCCESS;
1347}
#define ERR(fmt,...)
Definition: debug.h:110
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
LONG WINAPI DeleteHKCRKey(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ REGSAM RegSam, _In_ DWORD Reserved)
Definition: hkcr.c:395
#define DELETE
Definition: nt_native.h:57
NTSTATUS NTAPI NtDeleteKey(IN HANDLE KeyHandle)
Definition: ntapi.c:408
#define KEY_WOW64_32KEY
Definition: cmtypes.h:45
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46

Referenced by delete_key(), DeleteHKCRKey(), init_functionpointers(), RegDeleteKeyExA(), RegDeleteKeyW(), and TLB_unregister_interface().

◆ RegDeleteKeyValueA()

LONG WINAPI RegDeleteKeyValueA ( IN HKEY  hKey,
IN LPCSTR lpSubKey  OPTIONAL,
IN LPCSTR lpValueName  OPTIONAL 
)

Definition at line 1425 of file reg.c.

1428{
1429 UNICODE_STRING SubKey = { 0, 0, NULL }, ValueName = { 0, 0, NULL };
1430 LONG Ret;
1431
1432 if (lpSubKey != NULL &&
1433 !RtlCreateUnicodeStringFromAsciiz(&SubKey, lpSubKey))
1434 {
1436 }
1437
1438 if (lpValueName != NULL &&
1440 {
1441 RtlFreeUnicodeString(&SubKey);
1443 }
1444
1446 SubKey.Buffer,
1447 SubKey.Buffer);
1448
1449 RtlFreeUnicodeString(&SubKey);
1451
1452 return Ret;
1453}
LONG WINAPI RegDeleteKeyValueW(IN HKEY hKey, IN LPCWSTR lpSubKey OPTIONAL, IN LPCWSTR lpValueName OPTIONAL)
Definition: reg.c:1356
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243

Referenced by InitFunctionPtrs().

◆ RegDeleteKeyValueW()

LONG WINAPI RegDeleteKeyValueW ( IN HKEY  hKey,
IN LPCWSTR lpSubKey  OPTIONAL,
IN LPCWSTR lpValueName  OPTIONAL 
)

Definition at line 1356 of file reg.c.

1359{
1361 HANDLE KeyHandle, CurKey, SubKeyHandle = NULL;
1363
1365 hKey);
1366 if (!NT_SUCCESS(Status))
1367 {
1369 }
1370
1371 if (lpSubKey != NULL)
1372 {
1375
1376 RtlInitUnicodeString(&SubKeyName, lpSubKey);
1377
1379 &SubKeyName,
1381 KeyHandle,
1382 NULL);
1383
1387 if (!NT_SUCCESS(Status))
1388 {
1389 goto Cleanup;
1390 }
1391
1392 CurKey = SubKeyHandle;
1393 }
1394 else
1395 CurKey = KeyHandle;
1396
1397 RtlInitUnicodeString(&ValueName, lpValueName);
1398
1399 Status = NtDeleteValueKey(CurKey,
1400 &ValueName);
1401
1402 if (SubKeyHandle != NULL)
1403 {
1405 }
1406
1407Cleanup:
1409
1410 if (!NT_SUCCESS(Status))
1411 {
1413 }
1414
1415 return ERROR_SUCCESS;
1416}
NTSYSAPI NTSTATUS NTAPI NtDeleteValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName)
Definition: ntapi.c:1014
#define KEY_SET_VALUE
Definition: nt_native.h:1017

Referenced by RegDeleteKeyValueA().

◆ RegDeleteKeyW()

LONG WINAPI RegDeleteKeyW ( _In_ HKEY  hKey,
_In_ LPCWSTR  lpSubKey 
)

Definition at line 1234 of file reg.c.

1237{
1238 return RegDeleteKeyExW(hKey, lpSubKey, 0, 0);
1239}

Referenced by ACTION_UnregisterClassInfo(), ACTION_UnregisterExtensionInfo(), ACTION_UnregisterMIMEInfo(), ATL::AtlRegisterClassCategoriesHelper(), AtlRegisterClassCategoriesHelper(), CliSaveImeHotKey(), COMCAT_ICatRegister_UnRegisterCategories(), COMCAT_UnRegisterClassCategories(), CoTreatAsClass(), CredDeleteW(), CRYPT_RegWriteToReg(), CRYPT_SIPDeleteFunction(), del_mapping_key(), delete_key(), delete_local_assembly_key(), delete_test_key(), DeleteAppPathRegKey(), DeleteRegAppPath(), DeleteSubKey(), DeleteUninstallKey(), devinst_RegDeleteTreeW(), DllUnregisterServer(), DMOUnregister(), do_process_key(), ATL::CRegObject::do_process_key(), do_reg_operation(), FilterMapper3_UnregisterFilter(), FilterMapper_UnregisterFilter(), Imm32WriteImeLayout(), InputList_PrepareUserRegistry(), ITERATE_UnpublishComponent(), LocalAddMonitor(), MSACM_WriteCurrentPriorities(), myRegDeleteTreeW(), package_RegDeleteTreeW(), PNP_DeleteClassKey(), PNP_GetClassInstance(), reg_delete_tree(), RegDeleteTreeW(), ATL::CRegObject::RegDeleteTreeX(), RegisterSdbEntry(), RemoveEventLog(), run_delete(), ScmDeleteRegKey(), ScmDeleteTree(), ServicesPageWndProc(), SETUP_CreateClassKey(), SHDeleteEmptyKeyW(), SHDeleteKeyW(), SHDeleteOrphanKeyW(), SHPropertyBag_OnRegKey(), SQLRemoveDriverW(), SQLRemoveTranslatorW(), START_TEST(), Test_CreateOpenKey(), test_DeletePwrScheme(), test_directshow_filter(), test_FolderShortcut(), test_install_class(), test_IQueryAssociations_GetString(), test_legacy_filter_registration(), test_OleRegGetUserType(), test_SetupDiInstallClassExA(), test_SHGetShellKey(), test_SQLGetPrivateProfileString(), test_SQLGetPrivateProfileStringW(), test_SQLWritePrivateProfileString(), test_StdRegProv(), test_system_security_access(), testCertOpenSystemStore(), testSystemRegStore(), testSystemStore(), TLB_unregister_interface(), UnloadUserProfile(), unregister_dmo_from_category(), unregister_mediatypes_parsing(), UnregisterComponent(), UnRegisterTypeLib(), WINTRUST_RemoveProviderFromReg(), and WNetCancelConnection2W().

◆ RegDeleteTreeA()

LONG WINAPI RegDeleteTreeA ( IN HKEY  hKey,
IN LPCSTR lpSubKey  OPTIONAL 
)

Definition at line 1837 of file reg.c.

1839{
1840 UNICODE_STRING SubKeyName = { 0, 0, NULL };
1841 LONG Ret;
1842
1843 if (lpSubKey != NULL &&
1845 {
1847 }
1848
1849 Ret = RegDeleteTreeW(hKey,
1850 SubKeyName.Buffer);
1851
1853
1854 return Ret;
1855}
LSTATUS WINAPI RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
Definition: reg.c:1743

Referenced by InitFunctionPtrs(), unregister_coclasses(), and unregister_mediatypes_extension().

◆ RegDeleteTreeW()

LSTATUS WINAPI RegDeleteTreeW ( HKEY  hKey,
LPCWSTR  lpszSubKey 
)

Definition at line 1743 of file reg.c.

1745{
1746 LONG ret;
1747 DWORD dwMaxSubkeyLen, dwMaxValueLen;
1748 DWORD dwMaxLen, dwSize;
1751 HKEY hSubKey;
1752 WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
1753
1754 TRACE("(hkey=%p,%p %s)\n", hKey, lpszSubKey, debugstr_w(lpszSubKey));
1755
1757 hKey);
1758 if (!NT_SUCCESS(Status))
1759 {
1761 }
1762
1763 hSubKey = KeyHandle;
1764
1765 if(lpszSubKey)
1766 {
1767 ret = RegOpenKeyExW(KeyHandle, lpszSubKey, 0, KEY_READ, &hSubKey);
1768 if (ret)
1769 {
1771 return ret;
1772 }
1773 }
1774
1775 /* Get highest length for keys, values */
1776 ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
1777 &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
1778 if (ret) goto cleanup;
1779
1780 dwMaxSubkeyLen++;
1781 dwMaxValueLen++;
1782 dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
1783 if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
1784 {
1785 /* Name too big: alloc a buffer for it */
1786 if (!(lpszName = RtlAllocateHeap( RtlGetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
1787 {
1789 goto cleanup;
1790 }
1791 }
1792
1793
1794 /* Recursively delete all the subkeys */
1795 while (TRUE)
1796 {
1797 dwSize = dwMaxLen;
1798 if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
1799 NULL, NULL, NULL)) break;
1800
1801 ret = RegDeleteTreeW(hSubKey, lpszName);
1802 if (ret) goto cleanup;
1803 }
1804
1805 if (lpszSubKey)
1806 ret = RegDeleteKeyW(KeyHandle, lpszSubKey);
1807 else
1808 while (TRUE)
1809 {
1810 dwSize = dwMaxLen;
1811 if (RegEnumValueW(KeyHandle, 0, lpszName, &dwSize,
1812 NULL, NULL, NULL, NULL)) break;
1813
1814 ret = RegDeleteValueW(KeyHandle, lpszName);
1815 if (ret) goto cleanup;
1816 }
1817
1818cleanup:
1819 /* Free buffer if allocated */
1820 if (lpszName != szNameBuf)
1821 RtlFreeHeap( RtlGetProcessHeap(), 0, lpszName);
1822 if(lpszSubKey)
1823 RegCloseKey(hSubKey);
1824
1826
1827 return ret;
1828}
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define RegCloseKey(hKey)
Definition: registry.h:47
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3353
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2524
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1234
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2352
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:2850
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3687
#define MAX_PATH
Definition: compat.h:34
static void cleanup(void)
Definition: main.c:1335
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define KEY_READ
Definition: nt_native.h:1023
#define max(a, b)
Definition: svc.c:63

Referenced by ACTION_UnregisterClassInfo(), ACTION_UnregisterExtensionInfo(), ACTION_UnregisterProgIdInfo(), CategoryMgr_UnregisterCategory(), CRYPT_RegOpenStore(), delete_key_state(), delete_registry_key(), delete_tree(), DEVENUM_ICreateDevEnum_CreateClassEnumerator(), do_process_key(), FilterMapper_UnregisterFilter(), FilterMapper_UnregisterPin(), InputProcessorProfiles_Unregister(), LocalDeleteMonitor(), MSIREG_DeleteClassesUpgradeCodesKey(), MSIREG_DeleteLocalClassesFeaturesKey(), MSIREG_DeleteLocalClassesProductKey(), MSIREG_DeleteProductKey(), MSIREG_DeleteUninstallKey(), MSIREG_DeleteUpgradeCodesKey(), MSIREG_DeleteUserDataComponentKey(), MSIREG_DeleteUserDataPatchKey(), MSIREG_DeleteUserDataProductKey(), MSIREG_DeleteUserFeaturesKey(), MSIREG_DeleteUserProductKey(), MSIREG_DeleteUserUpgradeCodesKey(), NdrDllUnregisterProxy(), RegDeleteTreeA(), RegDeleteTreeW(), run_delete(), ScmDeleteControlSet(), SetupRegisterAllClasses(), unregister_categories(), unregister_coclasses(), unregister_converters(), unregister_decoders(), unregister_encoders(), unregister_interfaces(), unregister_mediatypes_parsing(), unregister_metadatareaders(), and unregister_pixelformats().

◆ RegDeleteValueA()

LONG WINAPI RegDeleteValueA ( HKEY  hKey,
LPCSTR  lpValueName 
)

Definition at line 2316 of file reg.c.

2318{
2322
2324 hKey);
2325 if (!NT_SUCCESS(Status))
2326 {
2328 }
2329
2332 &ValueName);
2334
2336
2337 if (!NT_SUCCESS(Status))
2338 {
2340 }
2341
2342 return ERROR_SUCCESS;
2343}

Referenced by cleanup_eventlog(), delete_value_(), DeleteRegistryValue(), ICRemove(), IStream_fnRelease(), mru_RegDeleteTreeA(), myRegDeleteTreeA(), process_pending_renames(), restore_value(), save_cert_mgr_usages(), setLayerValue(), SHDeleteValueA(), START_TEST(), test_AddERExcludedApplicationA(), test_appsearch_reglocator(), test_debug_heap(), test_delete_value(), test_envvar(), test_GetAcceptLanguagesA(), test_ICInfo(), test_internet_features_registry(), test_machine_guid(), test_MsiEnumClients(), test_MsiEnumComponentsEx(), test_MsiEnumPatches(), test_MsiEnumPatchesEx_machine(), test_MsiEnumPatchesEx_usermanaged(), test_MsiEnumPatchesEx_userunmanaged(), test_MsiGetComponentPath(), test_MsiGetComponentPathEx(), test_MsiGetPatchInfoEx(), test_MsiGetProductCode(), test_MsiGetProductInfoEx(), test_MsiGetProductProperty(), test_MsiGetUserInfo(), test_MsiOpenProduct(), test_MsiQueryComponentState(), test_MsiQueryFeatureState(), test_MsiQueryProductState(), test_MsiSourceListAddMediaDisk(), test_MsiSourceListAddSource(), test_MsiSourceListEnumMediaDisks(), test_MsiSourceListEnumSources(), test_MsiSourceListGetInfo(), test_MsiSourceListSetInfo(), test_null(), test_process_components(), test_publish_assemblies(), test_publish_features(), test_register_font(), test_register_product(), test_register_user(), test_registry(), test_symlinks(), test_XcvDataPort_ConfigureLPTPortCommandOK(), test_XcvDataPort_GetTransmissionRetryTimeout(), WhichPlatform(), and WNetRemoveCachedPassword().

◆ RegDeleteValueW()

LONG WINAPI RegDeleteValueW ( HKEY  hKey,
LPCWSTR  lpValueName 
)

Definition at line 2352 of file reg.c.

2354{
2358
2360 hKey);
2361 if (!NT_SUCCESS(Status))
2362 {
2364 }
2365
2366 RtlInitUnicodeString(&ValueName, lpValueName);
2367
2369 &ValueName);
2370
2372
2373 if (!NT_SUCCESS(Status))
2374 {
2376 }
2377
2378 return ERROR_SUCCESS;
2379}

Referenced by _CmdWndProc(), _HandleDeletePort(), ACTION_MsiUnpublishAssemblies(), ACTION_ProcessComponents(), ConCfgWriteUserSettings(), connections_on_notify(), CryptSetProviderExW(), delete_value(), delete_value_state(), devinst_RegDeleteTreeW(), do_reg_operation(), FilterMapper_UnregisterFilter(), INetCfgComponentControl_fnApplyRegistryChanges(), INTERNET_SaveProxySettings(), IStream_fnRelease(), ITERATE_RemoveEnvironmentString(), ITERATE_UnregisterFonts(), ITERATE_WriteEnvironmentString(), LocalDeleteForm(), LocalmonDeletePort(), MainWnd_OnUpdateRegistry(), ModifyStatus(), msi_unpublish_feature(), myRegDeleteTreeW(), package_RegDeleteTreeW(), pendingRename(), PNP_SetClassRegProp(), PNP_SetDeviceRegProp(), ProcessRunKeys(), RChangeServiceConfig2W(), RegDeleteTreeW(), remove_product_upgrade_code(), run_delete(), SaveSetting(), ScmDeleteTree(), ScmSetFailureActions(), ScmWriteDependencies(), set_domain(), set_name_servers(), set_profile_device_key(), set_proxy(), SetAutoDaylight(), SHDeleteValueW(), SKDeleteValueW(), SQLRemoveDriverW(), SQLRemoveTranslatorW(), START_TEST(), stillimagew_UnregisterLaunchApplication(), test_save(), UXTHEME_ApplyTheme(), write_shared_dlls_count(), and WriteParameterArray().

◆ RegDisablePredefinedCache()

LONG WINAPI RegDisablePredefinedCache ( VOID  )

Definition at line 332 of file reg.c.

333{
334 RegInitialize(); /* HACK until delay-loading is implemented */
338 return ERROR_SUCCESS;
339}

◆ RegDisablePredefinedCacheEx()

LONG WINAPI RegDisablePredefinedCacheEx ( VOID  )

Definition at line 348 of file reg.c.

349{
350 RegInitialize(); /* HACK until delay-loading is implemented */
355 return ERROR_SUCCESS;
356}

◆ RegDisableReflectionKey()

LONG WINAPI RegDisableReflectionKey ( IN HKEY  hBase)

Definition at line 1864 of file reg.c.

1865{
1866 FIXME("RegDisableReflectionKey(0x%p) UNIMPLEMENTED!\n", hBase);
1868}
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102

◆ RegEnableReflectionKey()

LONG WINAPI RegEnableReflectionKey ( IN HKEY  hBase)

Definition at line 1877 of file reg.c.

1878{
1879 FIXME("RegEnableReflectionKey(0x%p) UNIMPLEMENTED!\n", hBase);
1881}

◆ RegEnumKeyA()

LONG WINAPI RegEnumKeyA ( HKEY  hKey,
DWORD  dwIndex,
LPSTR  lpName,
DWORD  cbName 
)

Definition at line 2388 of file reg.c.

2392{
2394
2395 dwLength = cbName;
2396 return RegEnumKeyExA(hKey,
2397 dwIndex,
2398 lpName,
2399 &dwLength,
2400 NULL,
2401 NULL,
2402 NULL,
2403 NULL);
2404}
LONG WINAPI RegEnumKeyExA(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2439
static DWORD DWORD * dwLength
Definition: fusion.c:86
_In_ LPCSTR lpName
Definition: winbase.h:2779

Referenced by delete_key(), delete_registry_key(), find_registry_key(), init_registered_oid_info(), lineGetCountryA(), lineGetTranslateCapsA(), test_classesroot_enum(), test_deleted_key(), test_RegQueryValueExPerformanceData(), and test_SHGetObjectCompatFlags().

◆ RegEnumKeyExA()

LONG WINAPI RegEnumKeyExA ( _In_ HKEY  hKey,
_In_ DWORD  dwIndex,
_Out_ LPSTR  lpName,
_Inout_ LPDWORD  lpcbName,
_Reserved_ LPDWORD  lpReserved,
_Out_opt_ LPSTR  lpClass,
_Inout_opt_ LPDWORD  lpcbClass,
_Out_opt_ PFILETIME  lpftLastWriteTime 
)

Definition at line 2439 of file reg.c.

2448{
2449 WCHAR* NameBuffer = NULL;
2450 WCHAR* ClassBuffer = NULL;
2451 DWORD NameLength, ClassLength;
2453
2454 /* Allocate our buffers */
2455 if (*lpcbName > 0)
2456 {
2457 NameLength = *lpcbName;
2458 NameBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, *lpcbName * sizeof(WCHAR));
2459 if (NameBuffer == NULL)
2460 {
2462 goto Exit;
2463 }
2464 }
2465
2466 if (lpClass)
2467 {
2468 if (*lpcbClass > 0)
2469 {
2470 ClassLength = *lpcbClass;
2471 ClassBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, *lpcbClass * sizeof(WCHAR));
2472 if (ClassBuffer == NULL)
2473 {
2475 goto Exit;
2476 }
2477 }
2478 }
2479
2480 /* Do the actual call */
2482 hKey,
2483 dwIndex,
2484 NameBuffer,
2485 lpcbName,
2486 lpReserved,
2487 ClassBuffer,
2488 lpcbClass,
2489 lpftLastWriteTime);
2490
2491 if (ErrorCode != ERROR_SUCCESS)
2492 goto Exit;
2493
2494 /* Convert the strings */
2495 RtlUnicodeToMultiByteN(lpName, *lpcbName, 0, NameBuffer, *lpcbName * sizeof(WCHAR));
2496 /* NULL terminate if we can */
2497 if (NameLength > *lpcbName)
2498 lpName[*lpcbName] = '\0';
2499
2500 if (lpClass)
2501 {
2502 RtlUnicodeToMultiByteN(lpClass, *lpcbClass, 0, NameBuffer, *lpcbClass * sizeof(WCHAR));
2503 if (ClassLength > *lpcbClass)
2504 lpClass[*lpcbClass] = '\0';
2505 }
2506
2507Exit:
2508 if (NameBuffer)
2509 RtlFreeHeap(RtlGetProcessHeap(), 0, NameBuffer);
2510 if (ClassBuffer)
2511 RtlFreeHeap(RtlGetProcessHeap(), 0, ClassBuffer);
2512
2513 return ErrorCode;
2514}
_Use_decl_annotations_ NTSTATUS NTAPI RtlUnicodeToMultiByteN(_Out_ PCHAR MbString, _In_ ULONG MbSize, _Out_opt_ PULONG ResultSize, _In_ PCWCH UnicodeString, _In_ ULONG UnicodeSize)
Definition: nlsboot.c:107

Referenced by delete_tree(), delete_tree_(), DP_LoadSP(), find_typelib_key(), FindProvRegVals(), FindProvTypesRegVals(), IDirectPlay4AImpl_EnumConnections(), IDirectPlayLobby3AImpl_EnumAddressTypes(), IDirectPlayLobby3AImpl_EnumLocalApplications(), mru_RegDeleteTreeA(), myRegDeleteTreeA(), RegEnumKeyA(), RSAENH_CPGetProvParam(), scan_subkeys(), SHEnumKeyExA(), and SHRegEnumUSKeyA().

◆ RegEnumKeyExW()

LONG WINAPI RegEnumKeyExW ( _In_ HKEY  hKey,
_In_ DWORD  dwIndex,
_Out_ LPWSTR  lpName,
_Inout_ LPDWORD  lpcbName,
_Reserved_ LPDWORD  lpReserved,
_Out_opt_ LPWSTR  lpClass,
_Inout_opt_ LPDWORD  lpcbClass,
_Out_opt_ PFILETIME  lpftLastWriteTime 
)

Definition at line 2524 of file reg.c.

2533{
2534 union
2535 {
2538 } *KeyInfo;
2539
2541 ULONG ResultSize;
2542 ULONG NameLength;
2543 ULONG ClassLength = 0;
2547
2549 hKey);
2550 if (!NT_SUCCESS(Status))
2551 {
2553 }
2554
2555 if (IsHKCRKey(KeyHandle))
2556 {
2558 KeyHandle,
2559 dwIndex,
2560 lpName,
2561 lpcbName,
2562 lpReserved,
2563 lpClass,
2564 lpcbClass,
2565 lpftLastWriteTime);
2567 return ErrorCode;
2568 }
2569
2570 if (*lpcbName > 0)
2571 {
2572 NameLength = min (*lpcbName - 1, REG_MAX_NAME_SIZE) * sizeof (WCHAR);
2573 }
2574 else
2575 {
2576 NameLength = 0;
2577 }
2578
2579 if (lpClass)
2580 {
2581 if (*lpcbClass > 0)
2582 {
2583 ClassLength = min (*lpcbClass - 1, REG_MAX_NAME_SIZE) * sizeof(WCHAR);
2584 }
2585 else
2586 {
2587 ClassLength = 0;
2588 }
2589
2590 BufferSize = ((sizeof(KEY_NODE_INFORMATION) + NameLength + 3) & ~3) + ClassLength;
2591 }
2592 else
2593 {
2594 BufferSize = sizeof(KEY_BASIC_INFORMATION) + NameLength;
2595 }
2596
2597 KeyInfo = RtlAllocateHeap(ProcessHeap,
2598 0,
2599 BufferSize);
2600 if (KeyInfo == NULL)
2601 {
2603 goto Cleanup;
2604 }
2605
2607 (ULONG)dwIndex,
2609 KeyInfo,
2610 BufferSize,
2611 &ResultSize);
2612 TRACE("NtEnumerateKey() returned status 0x%X\n", Status);
2613 if (!NT_SUCCESS(Status))
2614 {
2616 }
2617 else
2618 {
2619 if (lpClass == NULL)
2620 {
2621 if (KeyInfo->Basic.NameLength > NameLength)
2622 {
2624 }
2625 else
2626 {
2628 KeyInfo->Basic.Name,
2629 KeyInfo->Basic.NameLength);
2630 *lpcbName = (DWORD)(KeyInfo->Basic.NameLength / sizeof(WCHAR));
2631 lpName[*lpcbName] = 0;
2632 }
2633 }
2634 else
2635 {
2636 if (KeyInfo->Node.NameLength > NameLength ||
2637 KeyInfo->Node.ClassLength > ClassLength)
2638 {
2640 }
2641 else
2642 {
2644 KeyInfo->Node.Name,
2645 KeyInfo->Node.NameLength);
2646 *lpcbName = KeyInfo->Node.NameLength / sizeof(WCHAR);
2647 lpName[*lpcbName] = 0;
2648 RtlCopyMemory(lpClass,
2649 (PVOID)((ULONG_PTR)KeyInfo->Node.Name + KeyInfo->Node.ClassOffset),
2650 KeyInfo->Node.ClassLength);
2651 *lpcbClass = (DWORD)(KeyInfo->Node.ClassLength / sizeof(WCHAR));
2652 lpClass[*lpcbClass] = 0;
2653 }
2654 }
2655
2656 if (ErrorCode == ERROR_SUCCESS && lpftLastWriteTime != NULL)
2657 {
2658 if (lpClass == NULL)
2659 {
2660 lpftLastWriteTime->dwLowDateTime = KeyInfo->Basic.LastWriteTime.u.LowPart;
2661 lpftLastWriteTime->dwHighDateTime = KeyInfo->Basic.LastWriteTime.u.HighPart;
2662 }
2663 else
2664 {
2665 lpftLastWriteTime->dwLowDateTime = KeyInfo->Node.LastWriteTime.u.LowPart;
2666 lpftLastWriteTime->dwHighDateTime = KeyInfo->Node.LastWriteTime.u.HighPart;
2667 }
2668 }
2669 }
2670
2672 0,
2673 KeyInfo);
2674
2675Cleanup:
2677
2678 return ErrorCode;
2679}
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define BufferSize
Definition: mmc.h:75
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
union node Node
Definition: types.h:1255
static HANDLE ProcessHeap
Definition: reg.c:35
#define REG_MAX_NAME_SIZE
Definition: reg.c:28
LONG WINAPI EnumHKCRKey(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: hkcr.c:592
#define min(a, b)
Definition: monoChain.cc:55
@ KeyBasicInformation
Definition: nt_native.h:1131
@ KeyNodeInformation
Definition: nt_native.h:1132
struct _KEY_BASIC_INFORMATION KEY_BASIC_INFORMATION
struct _KEY_NODE_INFORMATION KEY_NODE_INFORMATION
NTSYSAPI NTSTATUS NTAPI NtEnumerateKey(IN HANDLE KeyHandle, IN ULONG Index, IN KEY_INFORMATION_CLASS KeyInformationClass, IN PVOID KeyInformation, IN ULONG Length, IN PULONG ResultLength)
#define DWORD
Definition: nt_native.h:44
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by _enumeratorRememberedW(), _InitializePrintProviderList(), CDefaultContextMenu::AddStaticEntriesForKey(), AddUserProfiles(), AllSysInfo(), build_zonemap_from_reg(), BuildLogListAndFilterList(), BuildParameterArray(), capGetDriverDescriptionW(), CategoryMgr_FindClosestCategory(), CATIDEnumGUID_Next(), CertEnumSystemStore(), CheckLogOrSourceExistence(), CliGetImeHotKeysFromRegistry(), CLSIDEnumGUID_Next(), COMCAT_IEnumCATEGORYINFO_Next(), COMCAT_IsClassOfCategories(), ComponentInfo_GetGuidList(), CopyKey(), CreateComponentEnumerator(), CreateKeyboardLayoutList(), CRYPT_RegReadSerializedFromReg(), CryptEnumProvidersW(), CryptSIPRetrieveSubjectGuid(), delete_test_key(), DEVENUM_ReadPins(), DEVENUM_ReadPinTypes(), devinst_RegDeleteTreeW(), DirectPlayEnumerateAW(), DMOUnregister(), EnumClientServiceProtocol(), CDefaultContextMenu::EnumerateDynamicContextHandlerForKey(), EnumerateSoundProfiles(), EnumerateTimeZoneList(), EnumHKCRKey(), EnumInterfaces(), EnumPwrSchemes(), EnumTfLanguageProfiles_Next(), export_registry_data(), fetch_machine_component(), fetch_machine_product(), fetch_user_component(), fetch_user_product(), FileTypesDlg_DoList(), GetAllInstanceList(), GetAllInstanceListSize(), GetClassMediaFile(), CQueryAssociations::GetCommand(), GetDeviceInstanceList(), GetEnumeratorInstanceList(), GetEnumeratorInstanceListSize(), GetNthChildKeyName(), GetProfiles(), IEnumDMO_fnNext(), ImportAppProfile(), ImportSoundEntry(), InitializePrinterList(), InitializePrintMonitorList(), InitializePrintProcessorList(), InitIconOverlays(), InitNotifications(), Int_EnumDependentServicesW(), LayoutList_Create(), load_devices_from_reg(), COpenWithList::LoadAppList(), LoadEventLabels(), LoadEventSources(), LoadLogFiles(), LoadUsernameHint(), LocalEnumPrintProcessors(), MCI_SysInfo(), MSACM_RegisterAllDrivers(), myRegDeleteTreeW(), next_LanguageProfile(), CEnumRegKey::NextKey(), OnTreeExpanding(), package_RegDeleteTreeW(), PNP_EnumerateSubKeys(), ProfilesEnumGuid_Next(), query_all(), query_value(), read_types(), RefreshTreeItem(), reg_delete_tree(), RegDeleteTreeW(), ATL::CRegObject::RegDeleteTreeX(), RegEnumKeyExA(), RegEnumKeyW(), RegFindRecurse(), RegFindWalk(), register_legacy_filters(), RegQueryRegistryKeys(), RemoveEventLog(), run_copy(), ScmCopyTree(), ScmCreateServiceDatabase(), ScmDeleteRegKey(), ScmDeleteTree(), SdbUninstallByName(), search_domain_for_zone(), search_for_domain_mapping(), SETUP_CreateInterfaceList(), SetupDiClassGuidsFromNameExW(), SetupDiOpenDeviceInterfaceW(), SHCopyKeyW(), SHCreatePropSheetExtArrayEx(), SHDeleteKeyW(), SHEnumKeyExW(), SHRegEnumUSKeyW(), START_TEST(), txt_export_registry_data(), UnRegisterTypeLib(), and wnetInit().

◆ RegEnumKeyW()

◆ RegEnumValueA()

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 at line 2688 of file reg.c.

2697{
2698 WCHAR* NameBuffer;
2699 DWORD NameBufferSize, NameLength;
2701 DWORD LocalType = REG_NONE;
2702 BOOL NameOverflow = FALSE;
2703
2704 /* Do parameter checks now, once and for all. */
2705 if (!lpName || !lpcbName)
2707
2708 if ((lpData && !lpcbData) || lpdwReserved)
2710
2711 /* Get the size of the buffer we must use for the first call to RegEnumValueW */
2713 hKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &NameBufferSize, NULL, NULL, NULL);
2714 if (ErrorCode != ERROR_SUCCESS)
2715 return ErrorCode;
2716
2717 /* Add space for the null terminator */
2718 NameBufferSize++;
2719
2720 /* Allocate the buffer for the unicode name */
2721 NameBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, NameBufferSize * sizeof(WCHAR));
2722 if (NameBuffer == NULL)
2723 {
2725 }
2726
2727 /*
2728 * This code calls RegEnumValueW twice, because we need to know the type of the enumerated value.
2729 * So for the first call, we check if we overflow on the name, as we have no way of knowing if this
2730 * is an overflow on the data or on the name during the the second call. So the first time, we make the
2731 * call with the supplied value. This is merdique, but this is how it is.
2732 */
2733 NameLength = *lpcbName;
2735 hKey,
2736 dwIndex,
2737 NameBuffer,
2738 &NameLength,
2739 NULL,
2740 &LocalType,
2741 NULL,
2742 NULL);
2743 if (ErrorCode != ERROR_SUCCESS)
2744 {
2746 NameOverflow = TRUE;
2747 else
2748 goto Exit;
2749 }
2750
2751 if (is_string(LocalType) && lpcbData)
2752 {
2753 /* We must allocate a buffer to get the unicode data */
2754 DWORD DataBufferSize = *lpcbData * sizeof(WCHAR);
2755 WCHAR* DataBuffer = NULL;
2756 DWORD DataLength = *lpcbData;
2757 LPSTR DataStr = (LPSTR)lpData;
2758
2759 if (lpData)
2760 DataBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, *lpcbData * sizeof(WCHAR));
2761
2762 /* Do the real call */
2764 hKey,
2765 dwIndex,
2766 NameBuffer,
2767 &NameBufferSize,
2768 lpdwReserved,
2769 lpdwType,
2770 (LPBYTE)DataBuffer,
2771 &DataBufferSize);
2772
2773 *lpcbData = DataBufferSize / sizeof(WCHAR);
2774
2775 if (ErrorCode != ERROR_SUCCESS)
2776 {
2777 RtlFreeHeap(RtlGetProcessHeap(), 0, DataBuffer);
2778 goto Exit;
2779 }
2780
2781 /* Copy the data whatever the error code is */
2782 if (lpData)
2783 {
2784 /* Do the data conversion */
2785 RtlUnicodeToMultiByteN(DataStr, DataLength, 0, DataBuffer, DataBufferSize);
2786 /* NULL-terminate if there is enough room */
2787 if ((DataLength > *lpcbData) && (DataStr[*lpcbData - 1] != '\0'))
2788 DataStr[*lpcbData] = '\0';
2789 }
2790
2791 RtlFreeHeap(RtlGetProcessHeap(), 0, DataBuffer);
2792 }
2793 else
2794 {
2795 /* No data conversion needed. Do the call with provided buffers */
2797 hKey,
2798 dwIndex,
2799 NameBuffer,
2800 &NameBufferSize,
2801 lpdwReserved,
2802 lpdwType,
2803 lpData,
2804 lpcbData);
2805
2806 if (ErrorCode != ERROR_SUCCESS)
2807 {
2808 goto Exit;
2809 }
2810 }
2811
2812 if (NameOverflow)
2813 {
2815 goto Exit;
2816 }
2817
2818 /* Convert the name string */
2819 RtlUnicodeToMultiByteN(lpName, *lpcbName, lpcbName, NameBuffer, NameBufferSize * sizeof(WCHAR));
2820 lpName[*lpcbName] = ANSI_NULL;
2821
2822Exit:
2823 if (NameBuffer)
2824 RtlFreeHeap(RtlGetProcessHeap(), 0, NameBuffer);
2825
2826 return ErrorCode;
2827}
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
#define FALSE
Definition: types.h:117
static __inline int is_string(DWORD type)
Definition: reg.c:61
unsigned int BOOL
Definition: ntddk_ex.h:94
#define REG_NONE
Definition: nt_native.h:1492
#define ANSI_NULL
unsigned char * LPBYTE
Definition: typedefs.h:53
char * LPSTR
Definition: xmlstorage.h:182

Referenced by ICInfo(), mru_RegDeleteTreeA(), myRegDeleteTreeA(), RegisterDefaultAcceptHeaders(), SHEnumValueA(), SHRegEnumUSValueA(), SQLGetPrivateProfileString(), test_classesroot_enum(), test_deleted_key(), test_enum_value(), test_RegQueryValueExPerformanceData(), test_rw_order(), test_SHGetObjectCompatFlags(), test_string_termination(), TTIsEmbeddingEnabledForFacename(), and WNetEnumCachedPasswords().

◆ RegEnumValueW()

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 at line 2850 of file reg.c.

2859{
2862 ULONG total_size;
2863 char buffer[256], *buf_ptr = buffer;
2865 static const int info_size = FIELD_OFFSET( KEY_VALUE_FULL_INFORMATION, Name );
2866
2867 TRACE("(%p,%ld,%p,%p,%p,%p,%p,%p)\n",
2868 hKey, index, value, val_count, reserved, type, data, count );
2869
2870 if (!value || !val_count)
2872
2873 if ((data && !count) || reserved)
2875
2877 if (!NT_SUCCESS(status))
2878 {
2880 }
2881
2882 if (IsHKCRKey(KeyHandle))
2883 {
2885 KeyHandle,
2886 index,
2887 value,
2888 val_count,
2889 reserved,
2890 type,
2891 data,
2892 count);
2894 return ErrorCode;
2895 }
2896
2897 total_size = info_size + (MAX_PATH + 1) * sizeof(WCHAR);
2898 if (data) total_size += *count;
2899 total_size = min( sizeof(buffer), total_size );
2900
2902 buffer, total_size, &total_size );
2903 if (status && (status != STATUS_BUFFER_OVERFLOW) && (status != STATUS_BUFFER_TOO_SMALL)) goto done;
2904
2905 if (value || data)
2906 {
2907 /* retry with a dynamically allocated buffer */
2909 {
2910 if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr );
2911 if (!(buf_ptr = HeapAlloc( GetProcessHeap(), 0, total_size )))
2912 {
2914 goto done;
2915 }
2916 info = (KEY_VALUE_FULL_INFORMATION *)buf_ptr;
2918 buf_ptr, total_size, &total_size );
2919 }
2920
2921 if (status) goto done;
2922
2923 if (value)
2924 {
2925 if (info->NameLength/sizeof(WCHAR) >= *val_count)
2926 {
2928 goto overflow;
2929 }
2930 memcpy( value, info->Name, info->NameLength );
2931 *val_count = info->NameLength / sizeof(WCHAR);
2932 value[*val_count] = 0;
2933 }
2934
2935 if (data)
2936 {
2937 if (info->DataLength > *count)
2938 {
2940 goto overflow;
2941 }
2942 memcpy( data, buf_ptr + info->DataOffset, info->DataLength );
2943 if (is_string(info->Type) && info->DataLength <= *count - sizeof(WCHAR))
2944 {
2945 /* if the type is REG_SZ and data is not 0-terminated
2946 * and there is enough space in the buffer NT appends a \0 */
2947 WCHAR *ptr = (WCHAR *)(data + info->DataLength);
2948 if (ptr > (WCHAR *)data && ptr[-1]) *ptr = 0;
2949 }
2950 }
2951 }
2952 else status = STATUS_SUCCESS;
2953
2954 overflow:
2955 if (type) *type = info->Type;
2956 if (count) *count = info->DataLength;
2957
2958 done:
2959 if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr );
2962}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
r reserved
Definition: btrfs.c:3006
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint buffer
Definition: glext.h:5915
GLuint index
Definition: glext.h:6031
LONG WINAPI EnumHKCRValue(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ PDWORD lpcbName, _Reserved_ PDWORD lpReserved, _Out_opt_ PDWORD lpdwType, _Out_opt_ LPBYTE lpData, _Inout_opt_ PDWORD lpcbData)
Definition: hkcr.c:807
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
@ KeyValueFullInformation
Definition: nt_native.h:1181
NTSTATUS NTAPI NtEnumerateValueKey(IN HANDLE KeyHandle, IN ULONG Index, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, OUT PVOID KeyValueInformation, IN ULONG Length, OUT PULONG ResultLength)
Definition: ntapi.c:542
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
Definition: ps.c:97
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
Definition: pdh_main.c:94

Referenced by CDesktopFolderEnum::AddItemsFromClassicStartMenuKey(), BuildCodePageList(), ConCfgReadUserSettings(), Control_RegisterRegistryApplets(), CopyKey(), CreateNTPServerList(), devinst_RegDeleteTreeW(), DoLoadItems(), ensure_useragent(), enum_values(), EnumHKCRValue(), CRegKeyEx::EnumValueName(), export_registry_data(), fill_source_list(), FillServerAddressCombo(), GetClassMediaFile(), GetEnumOptions(), GetUsedPorts(), InitializePrintMonitor2(), InitShellServices(), InitTTFontCache(), InstallerImpl_RegistryValue(), IsLayoutExists(), ITERATE_FindRelatedProducts(), LoadHelpers(), LocaleList_Create(), MainWnd_OnUpdateRegistry(), MMDevPropStore_GetAt(), MMDevPropStore_GetCount(), MSACM_RegisterAllDrivers(), MSI_EnumComponentQualifiers(), MsiEnumClientsW(), MsiEnumFeaturesW(), MsiEnumRelatedProductsW(), MsiGetProductCodeW(), MsiSourceListEnumMediaDisksW(), myRegDeleteTreeW(), CEnumRegKey::NextValue(), OnInitMenu(), package_RegDeleteTreeW(), ProcessRunKeys(), query_all(), CFontCache::Read(), RefreshListView(), RegDeleteTreeW(), RegEnumValueA(), RegFindRecurse(), CControlPanelEnum::RegisterRegistryCPanelApps(), RegQueryRegistryValues(), SSOThread::Run(), run_copy(), run_delete(), ScmCopyTree(), ScmDeleteTree(), SetDefaultPrinterW(), SetSystemEnvironment(), SetUserEnvironment(), SHCopyKeyW(), SHEnumValueW(), SHGetObjectCompatFlags(), SHRegEnumUSValueW(), SQLGetInstalledDriversW(), SQLGetPrivateProfileStringW(), START_TEST(), test_enum_value(), txt_export_registry_data(), URL_GuessScheme(), and wWinMain().

◆ RegFlushKey()

LONG WINAPI RegFlushKey ( HKEY  hKey)

Definition at line 2971 of file reg.c.

2972{
2975
2977 {
2978 return ERROR_SUCCESS;
2979 }
2980
2982 hKey);
2983 if (!NT_SUCCESS(Status))
2984 {
2986 }
2987
2989
2991
2992 if (!NT_SUCCESS(Status))
2993 {
2995 }
2996
2997 return ERROR_SUCCESS;
2998}
NTSTATUS NTAPI NtFlushKey(IN HANDLE KeyHandle)
Definition: ntapi.c:1085
#define HKEY_PERFORMANCE_DATA
Definition: winreg.h:14

Referenced by create_new_eventlog(), CreateEventLog(), CreateUserHive(), ATL::CRegKey::Flush(), ImportRegistryFile(), InstallEventSource(), RemoveEventLog(), RSetServiceObjectSecurity(), SaveCurrentLocale(), SaveGeoID(), ScmCopyControlSet(), ScmSetLastKnownGoodControlSet(), test_deleted_key(), test_NonExistentPath(), TestMyEventProvider(), and UnloadUserProfile().

◆ RegGetKeySecurity()

LONG WINAPI RegGetKeySecurity ( HKEY  hKey,
SECURITY_INFORMATION  SecurityInformation,
PSECURITY_DESCRIPTOR  pSecurityDescriptor,
LPDWORD  lpcbSecurityDescriptor 
)

Definition at line 3007 of file reg.c.

3011{
3014
3016 {
3017 return ERROR_INVALID_HANDLE;
3018 }
3019
3021 hKey);
3022 if (!NT_SUCCESS(Status))
3023 {
3024 TRACE("MapDefaultKey() failed (Status %lx)\n", Status);
3026 }
3027
3030 pSecurityDescriptor,
3031 *lpcbSecurityDescriptor,
3032 lpcbSecurityDescriptor);
3033
3035
3036 if (!NT_SUCCESS(Status))
3037 {
3038 WARN("NtQuerySecurityObject() failed (Status %lx)\n", Status);
3040 }
3041
3042 return ERROR_SUCCESS;
3043}
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ SECURITY_INFORMATION SecurityInformation
Definition: fltkernel.h:1340
NTSTATUS NTAPI NtQuerySecurityObject(IN HANDLE Handle, IN SECURITY_INFORMATION SecurityInformation, OUT PSECURITY_DESCRIPTOR SecurityDescriptor, IN ULONG Length, OUT PULONG ResultLength)
Definition: obsecure.c:803

Referenced by AccRewriteGetHandleRights(), ATL::CRegKey::GetKeySecurity(), and CRegistryKey::GetSecurityDescriptor().

◆ RegGetValueA()

LSTATUS WINAPI RegGetValueA ( HKEY  hKey,
LPCSTR  pszSubKey,
LPCSTR  pszValue,
DWORD  dwFlags,
LPDWORD  pdwType,
PVOID  pvData,
LPDWORD  pcbData 
)

Definition at line 2068 of file reg.c.

2075{
2076 DWORD dwType, cbData = pcbData ? *pcbData : 0;
2077 PVOID pvBuf = NULL;
2078 LONG ret;
2079
2080 TRACE("(%p,%s,%s,%ld,%p,%p,%p=%ld)\n",
2081 hKey, pszSubKey, pszValue, dwFlags, pdwType, pvData, pcbData,
2082 cbData);
2083
2084 if (pvData && !pcbData)
2087 ((dwFlags & RRF_RT_ANY) != RRF_RT_ANY))
2089
2090 if (pszSubKey && pszSubKey[0])
2091 {
2092 ret = RegOpenKeyExA(hKey, pszSubKey, 0, KEY_QUERY_VALUE, &hKey);
2093 if (ret != ERROR_SUCCESS) return ret;
2094 }
2095
2096 ret = RegQueryValueExA(hKey, pszValue, NULL, &dwType, pvData, &cbData);
2097
2098 /* If we are going to expand we need to read in the whole the value even
2099 * if the passed buffer was too small as the expanded string might be
2100 * smaller than the unexpanded one and could fit into cbData bytes. */
2101 if ((ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) &&
2102 (dwType == REG_EXPAND_SZ && !(dwFlags & RRF_NOEXPAND)))
2103 {
2104 do {
2105 HeapFree(GetProcessHeap(), 0, pvBuf);
2106
2107 pvBuf = HeapAlloc(GetProcessHeap(), 0, cbData);
2108 if (!pvBuf)
2109 {
2111 break;
2112 }
2113
2114 if (ret == ERROR_MORE_DATA || !pvData)
2115 ret = RegQueryValueExA(hKey, pszValue, NULL,
2116 &dwType, pvBuf, &cbData);
2117 else
2118 {
2119 /* Even if cbData was large enough we have to copy the
2120 * string since ExpandEnvironmentStrings can't handle
2121 * overlapping buffers. */
2122 CopyMemory(pvBuf, pvData, cbData);
2123 }
2124
2125 /* Both the type or the value itself could have been modified in
2126 * between so we have to keep retrying until the buffer is large
2127 * enough or we no longer have to expand the value. */
2128 } while (dwType == REG_EXPAND_SZ && ret == ERROR_MORE_DATA);
2129
2130 if (ret == ERROR_SUCCESS)
2131 {
2132 /* Recheck dwType in case it changed since the first call */
2133 if (dwType == REG_EXPAND_SZ)
2134 {
2135 cbData = ExpandEnvironmentStringsA(pvBuf, pvData,
2136 pcbData ? *pcbData : 0);
2137 dwType = REG_SZ;
2138 if(pvData && pcbData && cbData > *pcbData)
2140 }
2141 else if (pvData)
2142 CopyMemory(pvData, pvBuf, *pcbData);
2143 }
2144
2145 HeapFree(GetProcessHeap(), 0, pvBuf);
2146 }
2147
2148 if (pszSubKey && pszSubKey[0])
2150
2151 RegpApplyRestrictions(dwFlags, dwType, cbData, &ret);
2152
2155
2156 if (pdwType) *pdwType = dwType;
2157 if (pcbData) *pcbData = cbData;
2158
2159 return ret;
2160}
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3318
static VOID RegpApplyRestrictions(DWORD dwFlags, DWORD dwType, DWORD cbData, PLONG ret)
Definition: reg.c:1890
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:4024
DWORD WINAPI ExpandEnvironmentStringsA(IN LPCSTR lpSrc, IN LPSTR lpDst, IN DWORD nSize)
Definition: environ.c:399
#define RRF_NOEXPAND
Definition: driver.c:583
#define RRF_ZEROONFAILURE
Definition: driver.c:584
#define RRF_RT_REG_EXPAND_SZ
Definition: driver.c:576
#define ZeroMemory
Definition: winbase.h:1700
#define CopyMemory
Definition: winbase.h:1698
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ DWORD _Out_writes_bytes_to_opt_ pcbData void _Inout_ DWORD * pcbData
Definition: wincrypt.h:4950
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3749
#define RRF_RT_ANY
Definition: winreg.h:64

Referenced by HCR_GetClassNameA(), InitFunctionPtrs(), install_from_registered_dir(), SQLGetPrivateProfileString(), SQLRemoveDriverW(), SQLRemoveTranslatorW(), and write_registry_values().

◆ RegGetValueW()

LSTATUS WINAPI RegGetValueW ( HKEY  hKey,
LPCWSTR  pszSubKey,
LPCWSTR  pszValue,
DWORD  dwFlags,
LPDWORD  pdwType,
PVOID  pvData,
LPDWORD  pcbData 
)

Definition at line 1962 of file reg.c.

1969{
1970 DWORD dwType, cbData = pcbData ? *pcbData : 0;
1971 PVOID pvBuf = NULL;
1972 LONG ret;
1973
1974 TRACE("(%p,%s,%s,%ld,%p,%p,%p=%ld)\n",
1975 hKey, debugstr_w(pszSubKey), debugstr_w(pszValue), dwFlags, pdwType,
1976 pvData, pcbData, cbData);
1977
1978 if (pvData && !pcbData)
1981 ((dwFlags & RRF_RT_ANY) != RRF_RT_ANY))
1983
1984 if (pszSubKey && pszSubKey[0])
1985 {
1986 ret = RegOpenKeyExW(hKey, pszSubKey, 0, KEY_QUERY_VALUE, &hKey);
1987 if (ret != ERROR_SUCCESS) return ret;
1988 }
1989
1990 ret = RegQueryValueExW(hKey, pszValue, NULL, &dwType, pvData, &cbData);
1991
1992 /* If we are going to expand we need to read in the whole the value even
1993 * if the passed buffer was too small as the expanded string might be
1994 * smaller than the unexpanded one and could fit into cbData bytes. */
1995 if ((ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) &&
1996 dwType == REG_EXPAND_SZ && !(dwFlags & RRF_NOEXPAND))
1997 {
1998 do
1999 {
2000 HeapFree(GetProcessHeap(), 0, pvBuf);
2001
2002 pvBuf = HeapAlloc(GetProcessHeap(), 0, cbData);
2003 if (!pvBuf)
2004 {
2006 break;
2007 }
2008
2009 if (ret == ERROR_MORE_DATA || !pvData)
2010 ret = RegQueryValueExW(hKey, pszValue, NULL,
2011 &dwType, pvBuf, &cbData);
2012 else
2013 {
2014 /* Even if cbData was large enough we have to copy the
2015 * string since ExpandEnvironmentStrings can't handle
2016 * overlapping buffers. */
2017 CopyMemory(pvBuf, pvData, cbData);
2018 }
2019
2020 /* Both the type or the value itself could have been modified in
2021 * between so we have to keep retrying until the buffer is large
2022 * enough or we no longer have to expand the value. */
2023 }
2024 while (dwType == REG_EXPAND_SZ && ret == ERROR_MORE_DATA);
2025
2026 if (ret == ERROR_SUCCESS)
2027 {
2028 /* Recheck dwType in case it changed since the first call */
2029 if (dwType == REG_EXPAND_SZ)
2030 {
2031 cbData = ExpandEnvironmentStringsW(pvBuf, pvData,
2032 pcbData ? *pcbData : 0) * sizeof(WCHAR);
2033 dwType = REG_SZ;
2034 if (pvData && pcbData && cbData > *pcbData)
2036 }
2037 else if (pvData)
2038 CopyMemory(pvData, pvBuf, *pcbData);
2039 }
2040
2041 HeapFree(GetProcessHeap(), 0, pvBuf);
2042 }
2043
2044 if (pszSubKey && pszSubKey[0])
2046
2047 RegpApplyRestrictions(dwFlags, dwType, cbData, &ret);
2048
2051
2052 if (pdwType)
2053 *pdwType = dwType;
2054
2055 if (pcbData)
2056 *pcbData = cbData;
2057
2058 return ret;
2059}
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4118
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519

Referenced by AddFSClassKeysToArray(), CRegFolderEnum::AddItemsFromKey(), AssocGetPerceivedType(), CDefaultContextMenu::BrowserFlagsFromVerb(), ComponentInfo_GetDWORDValue(), ComponentInfo_GetGUIDValue(), ComponentInfo_GetStringValue(), create_monodata(), DoGetProductType(), CDefaultContextMenu::EnumerateDynamicContextHandlerForKey(), CDrvDefExt::ExtraPageProc(), FILEDLG95_MRU_get_slot(), FILEDLG95_MRU_save_filename(), CDrvDefExt::GeneralPageProc(), get_stringvalue(), GetCLSIDForFileTypeFromExtension(), CNetConnectionPropertyUi::GetDeviceInstanceID(), GetInterfaceName(), CQueryAssociations::GetString(), HCR_GetClassNameW(), InitializeRecycleBinDlg(), InitIconOverlays(), CFileDefExt::InitOpensWithField(), COpenWithList::IsHidden(), IsNamespaceExtensionHidden(), COpenWithList::Load(), load_config_driver(), load_settings(), COpenWithList::LoadFromProgIdKey(), CNewMenu::LoadItem(), LoadPropSheetHandlers(), COpenWithList::LoadRecommendedFromHKCR(), COpenWithList::LoadRecommendedFromHKCU(), MMDevice_GetPropValue(), msi_check_product_patches(), msi_get_patch_state(), OpenKeyFromFileType(), PixelFormatInfo_GetChannelMask(), read_bitmap_patterns(), read_metadata_patterns(), COpenWithList::SetDefaultHandler(), SQLGetPrivateProfileStringW(), and WshShell3_RegRead().

◆ RegInitialize()

BOOL RegInitialize ( VOID  )

Definition at line 70 of file reg.c.

71{
72 TRACE("RegInitialize()\n");
73
74 /* Lazy init hack */
75 if (!DllInitialized)
76 {
77 ProcessHeap = RtlGetProcessHeap();
79 MAX_DEFAULT_HANDLES * sizeof(HANDLE));
81
83 }
84
85 return TRUE;
86}
static BOOLEAN DllInitialized
Definition: reg.c:38
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by CloseDefaultKeys(), DllMain(), MapDefaultKey(), RegDisablePredefinedCache(), RegDisablePredefinedCacheEx(), RegOpenUserClassesRoot(), and RegOverridePredefKey().

◆ RegLoadKeyA()

LONG WINAPI RegLoadKeyA ( HKEY  hKey,
LPCSTR  lpSubKey,
LPCSTR  lpFile 
)

Definition at line 3052 of file reg.c.

3055{
3059
3060 RtlInitEmptyUnicodeString(&KeyName, NULL, 0);
3061 RtlInitEmptyUnicodeString(&FileName, NULL, 0);
3062
3063 if (lpSubKey)
3064 {
3066 {
3068 goto Exit;
3069 }
3070 }
3071
3072 if (lpFile)
3073 {
3075 {
3077 goto Exit;
3078 }
3079 }
3080
3082 KeyName.Buffer,
3083 FileName.Buffer);
3084
3085Exit:
3088
3089 return ErrorCode;
3090}
LONG WINAPI RegLoadKeyW(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpFile)
Definition: reg.c:3099
struct _FileName FileName
Definition: fatprocs.h:896

Referenced by test_reg_load_key().

◆ RegLoadKeyW()

LONG WINAPI RegLoadKeyW ( HKEY  hKey,
LPCWSTR  lpSubKey,
LPCWSTR  lpFile 
)

Definition at line 3099 of file reg.c.

3102{
3104 OBJECT_ATTRIBUTES KeyObjectAttributes;
3110
3112 {
3113 return ERROR_INVALID_HANDLE;
3114 }
3115
3117 hKey);
3118 if (!NT_SUCCESS(Status))
3119 {
3121 }
3122
3123 if (!RtlDosPathNameToNtPathName_U(lpFile,
3124 &FileName,
3125 NULL,
3126 NULL))
3127 {
3129 goto Cleanup;
3130 }
3131
3133 &FileName,
3135 NULL,
3136 NULL);
3137
3138 RtlInitUnicodeString(&KeyName, lpSubKey);
3139
3140 InitializeObjectAttributes(&KeyObjectAttributes,
3141 &KeyName,
3143 KeyHandle,
3144 NULL);
3145
3146 Status = NtLoadKey(&KeyObjectAttributes,
3148
3149 RtlFreeHeap(RtlGetProcessHeap(),
3150 0,
3151 FileName.Buffer);
3152
3153 if (!NT_SUCCESS(Status))
3154 {
3156 goto Cleanup;
3157 }
3158
3159Cleanup:
3161
3162 return ErrorCode;
3163}
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
NTSTATUS NTAPI NtLoadKey(IN POBJECT_ATTRIBUTES KeyObjectAttributes, IN POBJECT_ATTRIBUTES FileObjectAttributes)
Definition: ntapi.c:1129
_In_ PWDFDEVICE_INIT _In_ PWDF_FILEOBJECT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES FileObjectAttributes
Definition: wdfdevice.h:3400
#define ERROR_BAD_PATHNAME
Definition: winerror.h:233

Referenced by CreateUserProfileExW(), LoadHive(), LoadUserProfileW(), and RegLoadKeyA().

◆ RegNotifyChangeKeyValue()

LONG WINAPI RegNotifyChangeKeyValue ( HKEY  hKey,
BOOL  bWatchSubtree,
DWORD  dwNotifyFilter,
HANDLE  hEvent,
BOOL  fAsynchronous 
)

Definition at line 3172 of file reg.c.

3177{
3182
3184 {
3185 return ERROR_INVALID_HANDLE;
3186 }
3187
3188 if ((fAsynchronous != FALSE) && (hEvent == NULL))
3189 {
3191 }
3192
3194 hKey);
3195 if (!NT_SUCCESS(Status))
3196 {
3198 }
3199
3200 /* FIXME: Remote key handles must fail */
3201
3203 hEvent,
3204 0,
3205 0,
3207 dwNotifyFilter,
3208 bWatchSubtree,
3209 0,
3210 0,
3211 fAsynchronous);
3213 {
3215 }
3216
3218
3219 return ErrorCode;
3220}
static HANDLE hEvent
Definition: comm.c:54
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSTATUS NTAPI NtNotifyChangeKey(IN HANDLE KeyHandle, IN HANDLE Event, IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, IN PVOID ApcContext OPTIONAL, OUT PIO_STATUS_BLOCK IoStatusBlock, IN ULONG CompletionFilter, IN BOOLEAN WatchTree, OUT PVOID Buffer, IN ULONG Length, IN BOOLEAN Asynchronous)
Definition: ntapi.c:1290
#define STATUS_TIMEOUT
Definition: ntstatus.h:81

Referenced by notif_thread_proc(), ATL::CRegKey::NotifyChangeKeyValue(), test_RegNotifyChangeKeyValue(), and WsSetupCatalogProtection().

◆ RegOpenCurrentUser()

LONG WINAPI RegOpenCurrentUser ( IN REGSAM  samDesired,
OUT PHKEY  phkResult 
)

◆ RegOpenKeyA()

LONG WINAPI RegOpenKeyA ( HKEY  hKey,
LPCSTR  lpSubKey,
PHKEY  phkResult 
)

Definition at line 3254 of file reg.c.

3257{
3258 TRACE("RegOpenKeyA hKey 0x%x lpSubKey %s phkResult %p\n",
3259 hKey, lpSubKey, phkResult);
3260
3261 if (!phkResult)
3263
3264 if (!hKey && !lpSubKey)
3265 {
3266 *phkResult = hKey;
3267 return ERROR_SUCCESS;
3268 }
3269
3270 return RegOpenKeyExA(hKey,
3271 lpSubKey,
3272 0,
3274 phkResult);
3275}

Referenced by _test_key_exists(), _test_key_not_exists(), _test_reg_key(), check_dirid(), check_reg_entries(), cleanup_eventlog(), create_new_eventlog(), CryptGetOIDFunctionValue(), CryptSetOIDFunctionValue(), device_disabled_registry(), DirectDrawEnumerateExA(), DllMain(), env_absent(), env_present(), filedlg_collect_places_pidls(), find_fallback_font(), FindDfltProvRegVals(), FindProvRegVals(), FindProvTypesRegVals(), get_app_key(), get_owner_company(), get_progfiles_dir(), get_program_files_dir(), get_reg_dword(), get_shell_icon_size(), get_user_dirs(), GetAdaptersInfo(), is_places_bar_enabled(), lffromreg(), lineGetCountryA(), lineGetTranslateCapsA(), load_wine_gecko_v(), LoadRegistryMMEDrivers(), metricfromreg(), MIDIMAP_LoadSettingsScheme(), MMDRV_Init(), pa_absent(), pa_present(), pub_absent(), pub_present(), r_verifyProxyEnable(), rci_absent(), rci_present(), register_zone_domains(), RegisterDefaultAcceptHeaders(), RegQueryValueA(), rei_absent(), rei_present(), rmi_absent(), rmi_present(), rpi_absent(), rpi_present(), setup_dsound_options(), setup_main_key(), SHRegOpenKeyA(), SHRestricted(), SmoothScrollWindow(), spy_init(), sr_absent(), sr_present(), test_AddERExcludedApplicationA(), test_autocreation(), test_child_heap(), test_classesroot(), test_classesroot_enum(), test_classesroot_mask(), test_deleted_key(), test_device_interface_key(), test_GetAcceptLanguagesA(), test_install_from(), test_install_services(), test_Installer_InstallProduct(), test_installprops(), test_internet_features(), test_internet_features_registry(), test_MsiInstallProduct(), test_MsiSourceListAddMediaDisk(), test_MsiSourceListAddSource(), test_MsiSourceListAddSourceEx(), test_MsiSourceListSetInfo(), test_perflib_key(), test_publish_assemblies(), test_publish_components(), test_publish_features(), test_publish_product(), test_reg_close_key(), test_reg_copy_tree(), test_reg_delete_key(), test_reg_delete_tree(), test_reg_load_key(), test_reg_open_key(), test_register_class_info(), test_register_extension_info(), test_register_mime_info(), test_register_product(), test_register_progid_info(), test_registerDefaultOIDFunction(), test_registerOIDInfo(), test_registrar(), test_registry(), test_registry_property_a(), test_RegQueryValueExPerformanceData(), test_self_registration(), test_SetZoneAttributes(), test_SHCopyKey(), test_SHDeleteKey(), test_SHGetFolderPathA(), test_SHGetObjectCompatFlags(), test_symlinks(), test_url_action(), test_write_registry_values(), test_zone_domain_cache(), test_zone_domain_mappings(), uniquecontainer(), unregister_zone_domains(), wined3d_dll_init(), wrv_absent(), and wrv_present().

◆ RegOpenKeyExA()

LONG WINAPI RegOpenKeyExA ( _In_ HKEY  hKey,
_In_ LPCSTR  lpSubKey,
_In_ DWORD  ulOptions,
_In_ REGSAM  samDesired,
_Out_ PHKEY  phkResult 
)

Definition at line 3318 of file reg.c.

3324{
3325 UNICODE_STRING SubKeyString;
3327
3328 TRACE("RegOpenKeyExA hKey 0x%x lpSubKey %s ulOptions 0x%x samDesired 0x%x phkResult %p\n",
3329 hKey, lpSubKey, ulOptions, samDesired, phkResult);
3330
3331 if (lpSubKey)
3332 {
3333 if (!RtlCreateUnicodeStringFromAsciiz(&SubKeyString, lpSubKey))
3335 }
3336 else
3337 RtlInitEmptyUnicodeString(&SubKeyString, NULL, 0);
3338
3339 ErrorCode = RegOpenKeyExW(hKey, SubKeyString.Buffer, ulOptions, samDesired, phkResult);
3340
3341 RtlFreeUnicodeString(&SubKeyString);
3342
3343 return ErrorCode;
3344}

Referenced by check_user_privs(), create_test_verb_dde(), CRYPT_GetFuncFromReg(), CryptUnregisterOIDInfo(), debugstr_iid(), delete_key(), delete_reg_entries(), delete_registry_key(), delete_tree(), delete_tree_(), DeleteRegistryValue(), DP_LoadSP(), find_default_printer(), find_registry_key(), font_absent(), font_present(), get_owner_company(), get_system_dirs(), GetAdapterFriendlyName(), GetDriverName(), GetNetworkParams(), HaveDefaultMailClient(), HCR_GetIconA(), HCR_MapTypeToValueA(), HCR_RegOpenClassIDKey(), ICInfo(), ICInstall(), ICRemove(), IDirectMusic8Impl_GetDefaultPort(), IDirectPlay4AImpl_EnumConnections(), IDirectPlayLobby3AImpl_EnumAddressTypes(), IDirectPlayLobby3AImpl_EnumLocalApplications(), init_registered_oid_info(), initialize(), is_ie_hardened(), main(), Main_DirectDraw_GetDeviceIdentifier7(), mru_RegDeleteTreeA(), myRegDeleteTreeA(), on_vmware(), open_container_key(), open_key_(), pf_absent(), pf_present(), pp_absent(), pp_present(), ppc_absent(), ppc_present(), PrintSystemInfo(), proxy_active(), QueryConfig2A(), rci_absent(), rci_present(), read_oid_info(), ReadRegistryComputerNameValue(), ReadRegistryValue(), reg_get_typelib_module(), RegGetValueA(), RegOpenKeyA(), rp_absent(), rp_present(), rpi_absent(), rpi_present(), ru_absent(), ru_present(), scan_subkeys(), set_domain(), set_name_servers(), setup_adapter(), SHADD_get_policy(), SHDeleteEmptyKeyA(), SHDeleteOrphanKeyA(), SHDeleteValueA(), SHELL_IsShortcut(), SHGetValueA(), SHOpenRegStream2A(), SHPinDllOfCLSID(), SHRegDuplicateHKey(), START_TEST(), test_classesroot(), test_enumdisplaydevices_adapter(), test_file_in_use(), test_file_in_use_cab(), test_get_profiles_dir(), test_ICInfo(), test_impersonation_level(), test_installprops(), test_machine_guid(), test_mixed_package(), test_MsiConfigureProductEx(), test_MsiInstallProduct(), test_MsiSourceListAddMediaDisk(), test_MsiSourceListAddSource(), test_MsiSourceListAddSourceEx(), test_MsiSourceListSetInfo(), test_NonExistentPath(), test_null(), test_process_components(), test_publish(), test_publish_assemblies(), test_publish_features(), test_publish_product(), test_redirection(), test_reg_open_key(), test_register_font(), test_register_product(), test_register_typelib(), test_register_user(), test_RegPolicyFlags(), test_RegQueryValueExPerformanceData(), test_remove_upgrade_code(), test_SetupDiOpenClassRegKeyExA(), test_SHCreateDefaultContextMenu(), test_SHQueryValueEx(), test_SQLInstallDriverEx(), test_SQLInstallTranslatorEx(), test_stub(), test_symlinks(), test_TreatAsClass(), test_XcvDataPort_ConfigureLPTPortCommandOK(), test_XcvDataPort_GetTransmissionRetryTimeout(), uniquecontainer(), unregister_keys(), verify_key_(), verify_key_nonexist_(), WhichPlatform(), and WriteRegistryValue().

◆ RegOpenKeyExW()

LONG WINAPI RegOpenKeyExW ( HKEY  hKey,
LPCWSTR  lpSubKey,
DWORD  ulOptions,
REGSAM  samDesired,
PHKEY  phkResult 
)

Definition at line 3353 of file reg.c.

3358{
3360 UNICODE_STRING SubKeyString;
3365
3366 TRACE("RegOpenKeyExW hKey 0x%x lpSubKey %S ulOptions 0x%x samDesired 0x%x phkResult %p\n",
3367 hKey, lpSubKey, ulOptions, samDesired, phkResult);
3368 if (!phkResult)
3369 {
3371 }
3372
3373 if (!hKey && lpSubKey && phkResult)
3374 {
3375 return ERROR_INVALID_HANDLE;
3376 }
3377
3378 if (IsPredefKey(hKey) && (!lpSubKey || !*lpSubKey))
3379 {
3380 *phkResult = hKey;
3381 return ERROR_SUCCESS;
3382 }
3383
3385 if (!NT_SUCCESS(Status))
3386 {
3388 }
3389
3390 if (IsHKCRKey(KeyHandle))
3391 {
3392 ErrorCode = OpenHKCRKey(KeyHandle, lpSubKey, ulOptions, samDesired, phkResult);
3394 return ErrorCode;
3395 }
3396
3397 if (ulOptions & REG_OPTION_OPEN_LINK)
3399
3400 if (lpSubKey == NULL || wcscmp(lpSubKey, L"\\") == 0)
3401 RtlInitUnicodeString(&SubKeyString, L"");
3402 else
3403 RtlInitUnicodeString(&SubKeyString, lpSubKey);
3404
3406 &SubKeyString,
3407 Attributes,
3408 KeyHandle,
3409 NULL);
3410
3411 Status = NtOpenKey((PHANDLE)phkResult,
3412 samDesired,
3414
3416 {
3417 HANDLE hAligned;
3418 UNICODE_STRING AlignedString;
3419
3421 &SubKeyString,
3422 &AlignedString);
3423 if (NT_SUCCESS(Status))
3424 {
3425 /* Try again with aligned parameters */
3427 &AlignedString,
3428 Attributes,
3429 KeyHandle,
3430 NULL);
3431
3432 Status = NtOpenKey(&hAligned,
3433 samDesired,
3435
3436 RtlFreeUnicodeString(&AlignedString);
3437
3438 if (NT_SUCCESS(Status))
3439 *phkResult = hAligned;
3440 }
3441 else
3442 {
3443 /* Restore the original error */
3445 }
3446 }
3447
3448 if (!NT_SUCCESS(Status))
3449 {
3451 }
3452
3453
3455
3456 return ErrorCode;
3457}
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
LONG WINAPI OpenHKCRKey(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _In_ PHKEY phkResult)
Definition: hkcr.c:324
NTSYSAPI NTSTATUS WINAPI RtlDuplicateUnicodeString(int, const UNICODE_STRING *, UNICODE_STRING *)
#define STATUS_DATATYPE_MISALIGNMENT
Definition: ntstatus.h:183
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by _CmdWndProc(), CBandSiteMenu::_CreateMenuPart(), _enumeratorRememberedW(), _HandleConfigureLPTPortCommandOK(), _InitializeLocalSpooler(), _InitializePrintProviderList(), _LocalGetPrinterHandleData(), _LocalGetPrintServerHandleData(), _LocalSetPrinterHandleData(), _LocalSetPrintServerHandleData(), _OpenEnvironment(), _tryLoadProvider(), AboutDlgProc(), AddClassKeyToArray(), CDesktopFolderEnum::AddItemsFromClassicStartMenuKey(), AddNewLayout(), AddNotificationDll(), AddSoundProfile(), CDefaultContextMenu::AddStaticEntriesForKey(), AddUserProfiles(), AllSysInfo(), ApplyChanges(), ApplyOrCancelChanges(), BuildCodePageList(), BuildLogListAndFilterList(), BuildParameterArray(), BuildServiceArray(), BuildVolatileEnvironment(), CallNotificationDll(), CallNotificationDlls(), CanUserWritePwrScheme(), capGetDriverDescriptionW(), CategoryMgr_FindClosestCategory(), CategoryMgr_RegisterCategory(), CategoryMgr_UnregisterCategory(), ChangeNtProductType(), CheckForLiveCD(), CheckForLoadedProfile(), CheckLogOrSourceExistence(), ChooseFavorite(), ChooseGinaUI(), CliGetImeHotKeysFromRegistry(), CliGetPreloadKeyboardLayouts(), CliSetSingleHotKey(), CM_Open_Class_Key_ExW(), CM_Open_DevNode_Key_Ex(), ComponentInfo_GetGuidList(), ConCfgOpenUserSettings(), ConverterSupportsFormat(), CopyKey(), create_EnumMoniker(), create_monodata(), CreateAppPathRegKey(), CreateComponentEnumerator(), CreateComponentInfo(), CreateDeviceInstance(), CreateEnvironmentBlock(), CreateEventLog(), CreateHKCRKey(), CreateKeyboardLayoutList(), CreateNewValue(), CreateNotificationObject(), CreateNTPServerList(), CreateStandardProfile(), CreateTempDir(), CreateUserHive(), CreateUserProfileExW(), CredReadW(), CriticalDeviceCoInstaller(), CRYPT_CreateMachineGuid(), CRYPT_OpenParentStore(), CRYPT_OpenSIPFunctionKey(), CRYPT_RegReadSerializedFromReg(), CRYPT_SysRegOpenStoreW(), CRYPTDLG_CheckOnlineCRL(), CryptSIPRetrieveSubjectGuid(), DecrementRefCount(), delete_key(), delete_test_key(), DeleteExt(), DeleteHelperCommand(), DeleteKey(), DeleteProfileW(), DeleteSubKey(), DEVENUM_IEnumMoniker_Next(), DEVENUM_ReadPins(), DEVENUM_ReadPinTypes(), devinst_RegDeleteTreeW(), DirectPlayEnumerateAW(), DisableShellext(), CNetConnection::Disconnect(), DisplayClassCoinstallers(), DisplayImageInfo(), DllMain(), DllRegisterServer(), DllUnregisterServer(), DMOGetName(), DMOGetTypes(), DMOUnregister(), DoGetProductType(), DoLoadItems(), DoWriteProductOption(), DoWriteSoundEvents(), DRIVER_GetLibName(), EditTypeDlg_ReadClass(), enum_key(), enum_values(), EnumClientServiceProtocol(), CDefaultContextMenu::EnumerateDynamicContextHandlerForKey(), CNetConnectionManager::EnumerateINetConnections(), EnumerateNetworkAdapter(), EnumerateNetworkComponent(), EnumerateSoundProfiles(), EnumerateTimeZoneList(), EnumHKCRKey(), EnumInterfaces(), EnumPwrSchemes(), EnumTfLanguageProfiles_Clone(), export_registry_data(), ExportRegistryFile(), FDebugBreakForService(), fetch_machine_component(), fetch_machine_product(), fetch_user_component(), fetch_user_product(), FILEDLG95_unixfs_is_rooted_at_desktop(), FileTypesDlg_InsertToLV(), FillServerAddressCombo(), FilterMapper_RegisterPin(), FilterMapper_RegisterPinType(), FilterMapper_UnregisterFilter(), FilterMapper_UnregisterPin(), find_typelib_key(), FindNetworkAdapter(), ForceFriendlyUI(), get_default_proxy_reg_value(), get_fusion_filename(), get_install_root(), get_mono_path_from_registry(), GetActivePwrScheme(), GetAllUsersProfileDirectoryW(), GetAutoDaylight(), GetBooleanRegValue(), GetBootResourceList(), GetClassMediaFile(), CQueryAssociations::GetCommand(), GetComputerNames(), GetCurrentHwProfileW(), GetCurrentUserKey(), GetDefaultPrinterFromRegistry(), GetDefaultPrinterW(), GetDefaultUserProfileDirectoryW(), GetDesktopPath(), CNetConnectionPropertyUi::GetDeviceInstanceID(), GetDeviceInstanceList(), GetDeviceInstanceListSize(), GetDisplayNameFileAndID(), GetEnumeratorInstanceList(), GetEnumeratorInstanceListSize(), GetEnumOptions(), GetEventMessageFileDLL(), GetExplorerRegValueSet(), GetFallbackHKCRKey(), GetFileTypeIconsByKey(), GetGinaPath(), GetHotPlugFlags(), GetInterfaceFriendlyName(), GetInterfaceNameInternal(), GetIntervalSetting(), GetJapaneseUninstallCmdLine(), GetLayoutCount(), GetLayoutName(), GetLPTTransmissionRetryTimeout(), GetPerAdapterInfo(), GetPreferredHKCRKey(), GetProfile(), GetProfileCount(), GetProfiles(), GetProfilesDirectoryW(), GetProfileType(), GetProgramsPath(), CNetConnection::GetProperties(), GetPwrDiskSpindownRange(), GetRegistrySettings(), GetRegValue(), GetResourceList(), GetServiceInstanceList(), GetServiceInstanceListSize(), GetSetupType(), GetShell(), GetShutdownReasonUI(), CQueryAssociations::GetString(), GetSyncSetting(), GetTimeZoneListIndex(), CZipFolder::GetUIObjectOf(), GetUsedPorts(), GetUserProfileDirectoryW(), GetUserWaitInterval(), GUILoggedOutSAS(), HCR_GetDefaultVerbW(), HCR_GetExecuteCommandW(), HCR_GetFolderAttributes(), HCR_GetIconW(), HCR_MapTypeToValueW(), IEnumDMO_Constructor(), IEnumDMO_fnNext(), ImageView_LoadSettings(), ImmLoadLayout(), ImpersonateTokenWithEveryoneOrWithout(), ImportAppProfile(), ImportRegistryFile(), ImportSoundEntry(), ImportSoundLabel(), ImportSoundProfiles(), IncrementRefCount(), INetCfgComponent_fnOpenParamKey(), INetCfgLock_fnAcquireWriteLock(), INetCfgLock_fnIsWriteLocked(), CQueryAssociations::Init(), CRegPropertyBag::Init(), InitAudioDlg(), CEnumRegKey::Initialize(), InitializeDefaultUserLocale(), InitializeDialog(), InitializeDirectPlayDialog(), InitializeFormList(), InitializePnPManager(), InitializePrinterList(), InitializePrintMonitor2(), InitializePrintMonitorList(), InitializePrintProcessorList(), InitializeProfiles(), InitializeProgramFilesDir(), InitIconOverlays(), InitKeyboardLayouts(), InitNotifications(), InitPropertiesDlg(), InitSettings(), InitTTFontCache(), InputList_PrepareUserRegistry(), InputProcessorProfiles_AddLanguageProfile(), InputProcessorProfiles_EnableLanguageProfile(), InputProcessorProfiles_EnableLanguageProfileByDefault(), InputProcessorProfiles_GetDefaultLanguageProfile(), InputProcessorProfiles_IsEnabledLanguageProfile(), InstallDevice(), InstallOneService(), InstallReactOS(), Int_EnumDependentServicesW(), IntGetIcdData(), IntLoadKeyboardLayout(), IsConsoleBoot(), IsExtensionAShortcut(), IsFriendlyUIActive(), IsInternetESCEnabledLocal(), IsLayoutExists(), IsLiveCD(), IsShowHibernateButtonActive(), IsWindowsOS(), CNetConnectionPropertyUi::LANPropertiesUIDlg(), LayoutList_Create(), load_mapi_providers(), COpenWithList::LoadAppList(), LoadBoard(), CNewMenu::LoadCachedItems(), LoadCurrentLocale(), LoadDNSSettings(), LoadDWORDFromRegistry(), LoadEventLabel(), LoadEventLabels(), LoadFilterSettings(), LoadHelpers(), LoadInstallableVDD(), CNewMenu::LoadItem(), LoadLogFiles(), COpenWithList::LoadProgIdList(), CInputPin::LoadProxyPlugins(), COutputPin::LoadProxyPlugins(), CKsProxy::LoadProxyPlugins(), COpenWithList::LoadRecommendedFromHKCR(), COpenWithList::LoadRecommendedFromHKCU(), LoadRegistrySettings(), LoadSettings(), LoadShutdownSelState(), LoadSoundProfiles(), LoadStringFromRegistry(), LoadUsernameHint(), LoadUserProfileW(), LocaleList_Create(), LocalEnumPrintProcessors(), MainWnd_OnInstall(), MainWnd_OnUpdateRegistry(), MCI_GetDevTypeFromFileName(), MCI_SysInfo(), MMDevPropStore_OpenPropKey(), MMSYS_InstallDevice(), MRU_SaveChanged(), MSACM_RegisterAllDrivers(), MSACM_RegisterDriverFromRegistry(), msi_check_product_patches(), msi_get_patch_state(), MsiGetPatchInfoExW(), MSIREG_DeleteClassesUpgradeCodesKey(), MSIREG_DeleteLocalClassesFeaturesKey(), MSIREG_DeleteLocalClassesProductKey(), MSIREG_DeleteProductKey(), MSIREG_DeleteUninstallKey(), MSIREG_DeleteUpgradeCodesKey(), MSIREG_DeleteUserDataComponentKey(), MSIREG_DeleteUserDataPatchKey(), MSIREG_DeleteUserDataProductKey(), MSIREG_OpenClassesUpgradeCodesKey(), MSIREG_OpenFeaturesKey(), MSIREG_OpenInstallerFeaturesKey(), MSIREG_OpenInstallProps(), MSIREG_OpenPatchesKey(), MSIREG_OpenProductKey(), MSIREG_OpenUninstallKey(), MSIREG_OpenUpgradeCodesKey(), MSIREG_OpenUserComponentsKey(), MSIREG_OpenUserDataComponentKey(), MSIREG_OpenUserDataFeaturesKey(), MSIREG_OpenUserDataPatchKey(), MSIREG_OpenUserDataProductKey(), MSIREG_OpenUserDataProductPatchesKey(), myRegDeleteTreeW(), NetBTInit(), NetIDPage_OnApply(), NetIDPage_OnInitDialog(), NetworkDlg_OnOK(), next_LanguageProfile(), OnAutoSync(), OnTreeExpanding(), open_env_key(), open_export_key(), open_key(), OpenChildKeyRead(), OpenComputerNameKey(), OpenConfigurationKey(), OpenHardwareProfileKey(), OpenHKCRKey(), OpenHostNameKey(), OpenHostsFile(), OpenImageFileExecOptions(), OpenKey(), OpenKeyFromFileType(), OpenRegKey(), OpenServiceParametersKey(), package_RegDeleteTreeW(), pendingRename(), PNP_AddID(), PNP_CreateKey(), PNP_GetClassCount(), PNP_GetClassInstance(), PNP_GetClassName(), PNP_GetClassRegProp(), PNP_GetCustomDevProp(), PNP_GetDeviceRegProp(), PNP_GetHwProfInfo(), PNP_HwProfFlags(), PNP_IsDockStationPresent(), PNP_SetClassRegProp(), PNP_SetDeviceRegProp(), PNP_ValidateDeviceInstance(), POWRPROF_GetMachinePowerPolicy(), POWRPROF_GetUserPowerPolicy(), PrintOSVersion(), process_extensions(), ProcessPage_OnDebug(), ProcessPageShowContextMenu(), ProcessRunKeys(), ProcessRunOnceEx(), ProcessSetupInf(), ProcessUnattendSection(), query_all(), query_typelib_path(), query_value(), QueryAppSettings(), QueryConfig2W(), QueryUserRegValueW(), RCloseServiceHandle(), RControlService(), read_bitmap_patterns(), read_key(), read_metadata_patterns(), read_types(), ReadAttributes(), ReadBindingString(), ReadGlobalPwrPolicy(), ReadKeysSettings(), ReadPerInstanceRegistryParameters(), ReadPortSettings(), ReadRegistryValue(), RefreshListView(), RefreshTreeItem(), reg_delete_tree(), reg_export(), RegDeleteTreeW(), ATL::CRegObject::RegDeleteTreeX(), RegFindRecurse(), RegFindWalk(), RegGetDWORD(), RegGetDWORDValue(), RegGetSZ(), RegGetValueW(), register_legacy_filters(), registry_enumerate_credentials(), registry_get_handle(), RegOpenKeyExA(), RegOpenKeyW(), RegQueryRegistryKeys(), RegQueryRegistryValues(), RegSetDWORDValue(), RegTGetKeyHandle(), RemoveEventLog(), CNetConnection::Rename(), REnumDependentServicesA(), REnumDependentServicesW(), ReportProductInfoEvent(), ReturnNtProduct(), run_copy(), run_delete(), run_query(), RunSetupThreadProc(), SampIsSetupRunning(), SaveAppSettings(), SaveCurrentLocale(), SaveDefaultUserHive(), SaveGeoID(), SavePropertiesDlg(), SaveSettings(), ScmAssignNewTag(), ScmAutoStartServices(), ScmCopyControlSet(), ScmCopyTree(), ScmCreateServiceDatabase(), ScmCreateServiceKey(), ScmDeleteControlSet(), ScmDeleteMarkedServices(), ScmDeleteRegKey(), ScmDeleteTree(), ScmGetControlSetValues(), ScmGetNoInteractiveServicesValue(), ScmGetSetupInProgress(), ScmInitNamedPipeCriticalSection(), ScmOpenServiceKey(), ScmReadSecurityDescriptor(), ScmSetLastKnownGoodControlSet(), SdbUninstallByGuid(), SdbUninstallByName(), search_reg(), SECUR32_initializeProviders(), SelectExtOnRename(), set_installer_properties(), SetAutoAdminLogon(), SetAutoDaylight(), COpenWithList::SetDefaultHandler(), SetDefaultLanguage(), SetDefaultPrinterW(), SetInstallationCompleted(), SetKeyboardLayoutName(), SetNTPServer(), SetProfileData(), SetSetupType(), SetSystemEnvironment(), SetTime(), SETUP_CreateClassKey(), SETUP_CreateInterfaceList(), SETUPAPI_GetCurrentHwProfile(), SetupDeviceInstance(), SETUPDI_CreateDrvKey(), SETUPDI_OpenDevKey(), SETUPDI_OpenDrvKey(), SetupDiCallClassInstaller(), SetupDiClassGuidsFromNameExW(), SetupDiOpenClassRegKeyExW(), SetupDiOpenDeviceInfoW(), SetupDiOpenDeviceInterfaceRegKey(), SetupDiOpenDeviceInterfaceW(), SetupDiOpenDevRegKey(), SetupIsActive(), SetUserEnvironment(), SetUserSysColors(), SetUserWaitInterval(), SetUserWallpaper(), SetWelcomeText(), SHAboutInfoW(), SHCoCreateInstance(), SHCopyKeyW(), SHCreatePropSheetExtArrayEx(), SHDeleteEmptyKeyW(), SHDeleteKeyW(), SHDeleteOrphanKeyW(), SHDeleteValueW(), SHDOCVW_GetShellInstanceObjectClassObject(), SHELL_FindExecutableByVerb(), SHELL_TryAppPathW(), SHGetShellKey(), SHGetValueW(), SHOpenRegStream2W(), SHPropertyBag_OnRegKey(), SHRegGetCLSIDKeyW(), SHRegOpenUSKeyW(), SIC_LoadOverlayIcon(), SockLoadHelperDll(), SockLoadTransportList(), SockLoadTransportMapping(), SQLGetInstalledDriversW(), START_TEST(), StartScreenSaver(), StartShell(), test4(), test_CallForAttributes(), Test_CreateOpenKey(), Test_DuplicateHandle(), test_set_value(), test_SetupDiInstallClassExA(), test_setvalue_on_wow64(), test_SQLGetPrivateProfileString(), test_SQLGetPrivateProfileStringW(), test_SQLWritePrivateProfileString(), TestInterfaceRegistry(), TestKeyAccess_(), TestModuleRegistry(), TestMyEventProvider(), testRegStoreSavedCerts(), TLB_unregister_interface(), TOOLBAR_Restore(), TreeWndNotifyProc(), TTIsEmbeddingEnabledForFacename(), txt_export_registry_data(), txt_open_export_key(), UIINSERTOBJECTDLG_PopulateObjectTypes(), UnloadUserProfile(), unregister_categories(), unregister_coclasses(), unregister_converters(), unregister_decoders(), unregister_dmo_from_category(), unregister_encoders(), unregister_interfaces(), unregister_mediatypes_extension(), unregister_mediatypes_parsing(), unregister_metadatareaders(), unregister_pixelformats(), UnregisterComponent(), UnRegisterTypeLib(), UpdateCaretBlinkTimeReg(), UpdateRegistryForFontSubstitutes(), UpdateTcpIpInformation(), UpdateUsersShellFolderSettings(), URL_ApplyDefault(), URL_GuessScheme(), UserInstStubWrapperW(), UXTHEME_RestoreSystemMetrics(), ViewDlg_Apply(), ViewDlg_RestoreDefaults(), ViewTree_LoadAll(), ViewTree_LoadTree(), WinHttpGetDefaultProxyConfiguration(), WinHttpGetIEProxyConfigForCurrentUser(), WINTRUST_ReadProviderFromReg(), WlxActivateUserShell(), WlxScreenSaverNotify(), wmain(), wnetInit(), WNetOpenEnumW(), WriteComputerSettings(), WriteDefaultLogonData(), WriteKeysSettings(), WriteOwnerSettings(), WritePortSettings(), WriteSettings(), and wWinMain().

◆ RegOpenKeyW()

LONG WINAPI RegOpenKeyW ( HKEY  hKey,
LPCWSTR  lpSubKey,
PHKEY  phkResult 
)

Definition at line 3288 of file reg.c.

3291{
3292 TRACE("RegOpenKeyW hKey 0x%x lpSubKey %S phkResult %p\n",
3293 hKey, lpSubKey, phkResult);
3294
3295 if (!phkResult)
3297
3298 if (!hKey && !lpSubKey)
3299 {
3300 *phkResult = hKey;
3301 return ERROR_SUCCESS;
3302 }
3303
3304 return RegOpenKeyExW(hKey,
3305 lpSubKey,
3306 0,
3308 phkResult);
3309}

Referenced by _HandleAddPort(), _HandleDeletePort(), ACTION_UnregisterClassInfo(), CRegFolderEnum::AddItemsFromKey(), AddPrintMonitorList(), CDefaultContextMenu::AddStaticContextMenusToMenu(), AVIBuildFilterW(), build_zonemap_from_reg(), cache_container_set_size(), capGetDriverDescriptionW(), connections_on_initdialog(), connections_on_notify(), Control_RegisterRegistryApplets(), CreateNewKey(), CryptAcquireContextW(), CryptEnumProvidersW(), CryptEnumProviderTypesW(), CryptGetDefaultProviderW(), CryptSetProviderExW(), DEVENUM_ICreateDevEnum_CreateClassEnumerator(), DEVENUM_IPropertyBag_Read(), do_process_key(), ATL::CRegObject::do_process_key(), EnableTheming(), ensure_useragent(), find_mime_from_ext(), FTP_Connect(), general_on_notify(), get_dest_dir(), get_engine_clsid(), get_feature_from_reg(), get_mapping_key(), get_mime_clsid(), get_mime_filter(), get_mmioFromProfile(), get_privateprofile_sectionkey(), get_protocol_cf(), get_url_encoding(), get_zone_from_domains(), get_zone_from_reg(), GetAcceptLanguagesW(), GetActiveClassicTheme(), GetFindFlags(), go_home(), HlinkGetSpecialReference(), Imm32GetImeLayout(), Imm32WriteImeLayout(), init_driver(), InitShellServices(), InstallerImpl_RegistryValue(), InstallOneService(), INTERNET_LoadProxySettings(), INTERNET_SaveProxySettings(), IntLoadPreloadKeyboardLayouts(), IsThemeActive(), lineGetCountryW(), COpenWithList::Load(), load_config_driver(), load_process_feature(), load_settings(), load_wine_gecko(), LoadClassicColorSchemes(), LoadCurrentScheme(), LoadSchemeFromReg(), LoadSchemeSizes(), LoadSettings(), LoadSMBiosData(), LocalmonAddPort(), LocalmonAddPortEx(), LocalmonDeletePort(), MakeService(), MIDIMAP_LoadSettings(), MIDIMAP_LoadSettingsScheme(), MMDevEnum_GetDefaultAudioEndpoint(), MSACM_ReorderDriversByPriority(), MSI_GetProductInfo(), MSIREG_OpenUserComponentsKey(), MSIREG_OpenUserPatchesKey(), MSIREG_OpenUserUpgradeCodesKey(), NetBTInit(), OnInitMenu(), open_zone_key(), OpenMediaSubkey(), OpenNetworkSubkey(), OpenSourceKey(), OpenURLSubkey(), process_args_from_reg(), QueryStringValue(), ReadCabinetState(), RegConnectRegistryW(), RegDeleteKeyW(), CControlPanelEnum::RegisterRegistryCPanelApps(), registry_callback(), RegQueryValueW(), RenameValue(), SaveSystemSettings(), search_domain_for_zone(), set_installer_properties(), set_lang(), SHCreatePropSheetExtArrayEx(), SHELL_FS_HideExtension(), ShellExecute_FromContextMenuHandlers(), ShellExecute_GetClassKey(), SHGetObjectCompatFlags(), SHGetRestriction(), SHRegOpenKeyW(), SQLRemoveDriverW(), SQLRemoveTranslatorW(), START_TEST(), StartWithDesktop(), SuggestKeys(), tapiGetLocationInfoW(), test_BCryptGetFipsAlgorithmMode(), test_DeletePwrScheme(), test_device_key(), test_Installer_RegistryValue(), test_readTrustedPublisherDWORD(), test_register_device_iface(), test_registry_property_w(), test_save(), test_SHCreateSessionKey(), test_WritePwrScheme(), try_application_url(), UniformResourceLocatorW_InvokeCommand(), UXTHEME_LoadTheme(), and write_config_value().

◆ RegOpenUserClassesRoot()

LONG WINAPI RegOpenUserClassesRoot ( IN HANDLE  hToken,
IN DWORD  dwOptions,
IN REGSAM  samDesired,
OUT PHKEY  phkResult 
)

Definition at line 3466 of file reg.c.

3470{
3471 const WCHAR UserClassesKeyPrefix[] = L"\\Registry\\User\\";
3472 const WCHAR UserClassesKeySuffix[] = L"_Classes";
3473 PTOKEN_USER TokenUserData;
3475 UNICODE_STRING UserSidString, UserClassesKeyRoot;
3478
3479 /* check parameters */
3480 if (hToken == NULL || dwOptions != 0 || phkResult == NULL)
3481 {
3483 }
3484
3485 /*
3486 * Get the user sid from the token
3487 */
3488
3489ReadTokenSid:
3490 /* determine how much memory we need */
3492 TokenUser,
3493 NULL,
3494 0,
3497 {
3498 /* NOTE - as opposed to all other registry functions windows does indeed
3499 change the last error code in case the caller supplied a invalid
3500 handle for example! */
3502 }
3503 RegInitialize(); /* HACK until delay-loading is implemented */
3504 TokenUserData = RtlAllocateHeap(ProcessHeap,
3505 0,
3507 if (TokenUserData == NULL)
3508 {
3510 }
3511
3512 /* attempt to read the information */
3514 TokenUser,
3515 TokenUserData,
3518 if (!NT_SUCCESS(Status))
3519 {
3521 0,
3522 TokenUserData);
3524 {
3525 /* the information appears to have changed?! try again */
3526 goto ReadTokenSid;
3527 }
3528
3529 /* NOTE - as opposed to all other registry functions windows does indeed
3530 change the last error code in case the caller supplied a invalid
3531 handle for example! */
3533 }
3534
3535 /*
3536 * Build the absolute path for the user's registry in the form
3537 * "\Registry\User<SID>_Classes"
3538 */
3539 Status = RtlConvertSidToUnicodeString(&UserSidString,
3540 TokenUserData->User.Sid,
3541 TRUE);
3542
3543 /* we don't need the user data anymore, free it */
3545 0,
3546 TokenUserData);
3547
3548 if (!NT_SUCCESS(Status))
3549 {
3551 }
3552
3553 /* allocate enough memory for the entire key string */
3554 UserClassesKeyRoot.Length = 0;
3555 UserClassesKeyRoot.MaximumLength = UserSidString.Length +
3556 sizeof(UserClassesKeyPrefix) +
3557 sizeof(UserClassesKeySuffix);
3558 UserClassesKeyRoot.Buffer = RtlAllocateHeap(ProcessHeap,
3559 0,
3560 UserClassesKeyRoot.MaximumLength);
3561 if (UserClassesKeyRoot.Buffer == NULL)
3562 {
3563 RtlFreeUnicodeString(&UserSidString);
3565 }
3566
3567 /* build the string */
3568 RtlAppendUnicodeToString(&UserClassesKeyRoot,
3569 UserClassesKeyPrefix);
3570 RtlAppendUnicodeStringToString(&UserClassesKeyRoot,
3571 &UserSidString);
3572 RtlAppendUnicodeToString(&UserClassesKeyRoot,
3573 UserClassesKeySuffix);
3574
3575 TRACE("RegOpenUserClassesRoot: Absolute path: %wZ\n", &UserClassesKeyRoot);
3576
3577 /*
3578 * Open the key
3579 */
3581 &UserClassesKeyRoot,
3583 NULL,
3584 NULL);
3585
3586 Status = NtOpenKey((PHANDLE)phkResult,
3587 samDesired,
3589
3590 RtlFreeUnicodeString(&UserSidString);
3591 RtlFreeUnicodeString(&UserClassesKeyRoot);
3592
3593 if (!NT_SUCCESS(Status))
3594 {
3596 }
3597
3598 return ERROR_SUCCESS;
3599}
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSYSAPI NTSTATUS NTAPI RtlConvertSidToUnicodeString(OUT PUNICODE_STRING DestinationString, IN PVOID Sid, IN BOOLEAN AllocateDestinationString)
SID_AND_ATTRIBUTES User
Definition: setypes.h:1010
USHORT MaximumLength
Definition: env_spec_w32.h:370
_Must_inspect_result_ __kernel_entry NTSTATUS NTAPI NtQueryInformationToken(_In_ HANDLE TokenHandle, _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, _Out_writes_bytes_to_opt_(TokenInformationLength, *ReturnLength) PVOID TokenInformation, _In_ ULONG TokenInformationLength, _Out_ PULONG ReturnLength)
Queries a specific type of information in regard of an access token based upon the information class....
Definition: tokencls.c:473
_In_ ULONG _Out_opt_ PULONG RequiredLength
Definition: wmifuncs.h:30
@ TokenUser
Definition: setypes.h:966

◆ RegOverridePredefKey()

LONG WINAPI RegOverridePredefKey ( IN HKEY  hKey,
IN HKEY hNewHKey  OPTIONAL 
)

Definition at line 365 of file reg.c.

367{
369
370 if ((hKey == HKEY_CLASSES_ROOT ||
375 hKey == HKEY_USERS) &&
376 !IsPredefKey(hNewHKey))
377 {
379 ULONG Index;
380
383
384 if (hNewHKey == NULL)
385 {
386 /* restore the default mapping */
388 &hNewHKey);
389 if (!NT_SUCCESS(Status))
390 {
392 }
393
394 ASSERT(hNewHKey != NULL);
395 }
396 RegInitialize(); /* HACK until delay-loading is implemented */
398
399 /* close the currently mapped handle if existing */
400 if (*Handle != NULL)
401 {
402 NtClose(*Handle);
403 }
404
405 /* update the mapping */
406 *Handle = hNewHKey;
407
409 }
410 else
412
413 return ErrorCode;
414}
#define ASSERT(a)
Definition: mode.c:44
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define HKEY_USERS
Definition: winreg.h:13

◆ RegpApplyRestrictions()

static VOID RegpApplyRestrictions ( DWORD  dwFlags,
DWORD  dwType,
DWORD  cbData,
PLONG  ret 
)
static

Definition at line 1890 of file reg.c.

1894{
1895 /* Check if the type is restricted by the passed flags */
1896 if (*ret == ERROR_SUCCESS || *ret == ERROR_MORE_DATA)
1897 {
1898 DWORD dwMask = 0;
1899
1900 switch (dwType)
1901 {
1902 case REG_NONE: dwMask = RRF_RT_REG_NONE; break;
1903 case REG_SZ: dwMask = RRF_RT_REG_SZ; break;
1904 case REG_EXPAND_SZ: dwMask = RRF_RT_REG_EXPAND_SZ; break;
1905 case REG_MULTI_SZ: dwMask = RRF_RT_REG_MULTI_SZ; break;
1906 case REG_BINARY: dwMask = RRF_RT_REG_BINARY; break;
1907 case REG_DWORD: dwMask = RRF_RT_REG_DWORD; break;
1908 case REG_QWORD: dwMask = RRF_RT_REG_QWORD; break;
1909 }
1910
1911 if (dwFlags & dwMask)
1912 {
1913 /* Type is not restricted, check for size mismatch */
1914 if (dwType == REG_BINARY)
1915 {
1916 DWORD cbExpect = 0;
1917
1918 if ((dwFlags & RRF_RT_ANY) == RRF_RT_DWORD)
1919 cbExpect = 4;
1920 else if ((dwFlags & RRF_RT_ANY) == RRF_RT_QWORD)
1921 cbExpect = 8;
1922
1923 if (cbExpect && cbData != cbExpect)
1925 }
1926 }
1928 }
1929}
#define RRF_RT_REG_BINARY
Definition: driver.c:577
#define RRF_RT_REG_QWORD
Definition: driver.c:580
#define RRF_RT_REG_DWORD
Definition: driver.c:578
#define RRF_RT_REG_MULTI_SZ
Definition: driver.c:579
#define RRF_RT_REG_NONE
Definition: driver.c:574
#define RRF_RT_DWORD
Definition: driver.c:581
#define RRF_RT_QWORD
Definition: driver.c:582
#define RRF_RT_REG_SZ
Definition: driver.c:575
#define REG_BINARY
Definition: nt_native.h:1496
#define REG_QWORD
Definition: sdbapi.c:597
#define REG_DWORD
Definition: sdbapi.c:596
#define ERROR_UNSUPPORTED_TYPE
Definition: winerror.h:988
#define ERROR_DATATYPE_MISMATCH
Definition: winerror.h:987

Referenced by RegGetValueA(), and RegGetValueW().

◆ RegpCopyTree()

static NTSTATUS RegpCopyTree ( IN HKEY  hKeySrc,
IN HKEY  hKeyDest 
)
static

Definition at line 449 of file reg.c.

451{
452 typedef struct
453 {
454 LIST_ENTRY ListEntry;
455 HANDLE hKeySrc;
456 HANDLE hKeyDest;
457 } REGP_COPY_KEYS, *PREGP_COPY_KEYS;
458
459 LIST_ENTRY copyQueueHead;
460 PREGP_COPY_KEYS copyKeys, newCopyKeys;
461 union
462 {
464 KEY_NODE_INFORMATION *KeyNode;
466 } Info;
467 ULONG Index, BufferSizeRequired, BufferSize = 0x200;
469 NTSTATUS Status2 = STATUS_SUCCESS;
470
471 InitializeListHead(&copyQueueHead);
472
474 0,
475 BufferSize);
476 if (Info.Buffer == NULL)
477 {
479 }
480
481 copyKeys = RtlAllocateHeap(ProcessHeap,
482 0,
483 sizeof(REGP_COPY_KEYS));
484 if (copyKeys != NULL)
485 {
486 copyKeys->hKeySrc = hKeySrc;
487 copyKeys->hKeyDest = hKeyDest;
488 InsertHeadList(&copyQueueHead,
489 &copyKeys->ListEntry);
490
491 /* FIXME - copy security from hKeySrc to hKeyDest or just for the subkeys? */
492
493 do
494 {
495 copyKeys = CONTAINING_RECORD(copyQueueHead.Flink,
496 REGP_COPY_KEYS,
497 ListEntry);
498
499 /* enumerate all values and copy them */
500 Index = 0;
501 for (;;)
502 {
503 Status2 = NtEnumerateValueKey(copyKeys->hKeySrc,
504 Index,
506 Info.KeyValue,
508 &BufferSizeRequired);
509 if (NT_SUCCESS(Status2))
510 {
512 PVOID Data;
513
514 /* don't use RtlInitUnicodeString as the string is not NULL-terminated! */
515 ValueName.Length = Info.KeyValue->NameLength;
516 ValueName.MaximumLength = ValueName.Length;
517 ValueName.Buffer = Info.KeyValue->Name;
518
519 Data = (PVOID)((ULONG_PTR)Info.KeyValue + Info.KeyValue->DataOffset);
520
521 Status2 = NtSetValueKey(copyKeys->hKeyDest,
522 &ValueName,
523 Info.KeyValue->TitleIndex,
524 Info.KeyValue->Type,
525 Data,
526 Info.KeyValue->DataLength);
527
528 /* don't break, let's try to copy as many values as possible */
529 if (!NT_SUCCESS(Status2) && NT_SUCCESS(Status))
530 {
531 Status = Status2;
532 }
533
534 Index++;
535 }
536 else if (Status2 == STATUS_BUFFER_OVERFLOW)
537 {
539
540 ASSERT(BufferSize < BufferSizeRequired);
541
543 0,
544 Info.Buffer,
545 BufferSizeRequired);
546 if (Buffer != NULL)
547 {
548 Info.Buffer = Buffer;
549 /* try again */
550 }
551 else
552 {
553 /* don't break, let's try to copy as many values as possible */
555 Index++;
556
557 if (NT_SUCCESS(Status))
558 {
559 Status = Status2;
560 }
561 }
562 }
563 else
564 {
565 /* break to avoid an infinite loop in case of denied access or
566 other errors! */
567 if (Status2 != STATUS_NO_MORE_ENTRIES && NT_SUCCESS(Status))
568 {
569 Status = Status2;
570 }
571
572 break;
573 }
574 }
575
576 /* enumerate all subkeys and open and enqueue them */
577 Index = 0;
578 for (;;)
579 {
580 Status2 = NtEnumerateKey(copyKeys->hKeySrc,
581 Index,
583 Info.KeyNode,
585 &BufferSizeRequired);
586 if (NT_SUCCESS(Status2))
587 {
588 HANDLE KeyHandle, NewKeyHandle;
590 UNICODE_STRING SubKeyName, ClassName;
591
592 /* don't use RtlInitUnicodeString as the string is not NULL-terminated! */
593 SubKeyName.Length = Info.KeyNode->NameLength;
594 SubKeyName.MaximumLength = SubKeyName.Length;
595 SubKeyName.Buffer = Info.KeyNode->Name;
596 ClassName.Length = Info.KeyNode->ClassLength;
597 ClassName.MaximumLength = ClassName.Length;
598 ClassName.Buffer = (PWSTR)((ULONG_PTR)Info.KeyNode + Info.KeyNode->ClassOffset);
599
600 /* open the subkey with sufficient rights */
601
603 &SubKeyName,
605 copyKeys->hKeySrc,
606 NULL);
607
608 Status2 = NtOpenKey(&KeyHandle,
611 if (NT_SUCCESS(Status2))
612 {
613 /* FIXME - attempt to query the security information */
614
616 &SubKeyName,
618 copyKeys->hKeyDest,
619