ReactOS 0.4.15-dev-7928-g68a8619
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)
 
static int load_string (HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cMaxChars)
 
LONG WINAPI RegLoadMUIStringW (IN HKEY hKey, IN LPCWSTR pszValue OPTIONAL, OUT LPWSTR pszOutBuf, IN DWORD cbOutBuf, OUT LPDWORD pcbData OPTIONAL, IN DWORD Flags, IN LPCWSTR pszDirectory OPTIONAL)
 
LONG WINAPI RegLoadMUIStringA (IN HKEY hKey, IN LPCSTR pszValue OPTIONAL, OUT LPSTR pszOutBuf, IN DWORD cbOutBuf, OUT LPDWORD pcbData OPTIONAL, IN DWORD Flags, IN LPCSTR pszDirectory OPTIONAL)
 

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 920 of file reg.c.

926{
927 OBJECT_ATTRIBUTES LocalObjectAttributes;
928 UNICODE_STRING LocalKeyName;
931 ULONG FullNameLength;
933 PWCHAR Ptr;
934 HANDLE LocalKeyHandle;
935
937 samDesired,
939 0,
940 ClassString,
941 dwOptions,
942 (PULONG)lpdwDisposition);
943 TRACE("NtCreateKey(%wZ) called (Status %lx)\n", ObjectAttributes->ObjectName, Status);
945 return Status;
946
947 /* Copy object attributes */
948 RtlCopyMemory(&LocalObjectAttributes,
950 sizeof(OBJECT_ATTRIBUTES));
951 RtlCreateUnicodeString(&LocalKeyName,
952 ObjectAttributes->ObjectName->Buffer);
953 LocalObjectAttributes.ObjectName = &LocalKeyName;
954 FullNameLength = LocalKeyName.Length / sizeof(WCHAR);
955
956 LocalKeyHandle = NULL;
957
958 /* Remove the last part of the key name and try to create the key again. */
960 {
961 Ptr = wcsrchr(LocalKeyName.Buffer, '\\');
962 if (Ptr == NULL || Ptr == LocalKeyName.Buffer)
963 {
965 break;
966 }
967
968 *Ptr = (WCHAR)0;
969 LocalKeyName.Length = (USHORT)wcslen(LocalKeyName.Buffer) * sizeof(WCHAR);
970
971 Status = NtCreateKey(&LocalKeyHandle,
973 &LocalObjectAttributes,
974 0,
975 NULL,
976 0,
977 &Disposition);
978 TRACE("NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName, Status);
979 }
980
981 if (!NT_SUCCESS(Status))
982 {
983 RtlFreeUnicodeString(&LocalKeyName);
984 return Status;
985 }
986
987 /* Add removed parts of the key name and create them too. */
988 Length = wcslen(LocalKeyName.Buffer);
989 while (TRUE)
990 {
991 if (LocalKeyHandle)
992 NtClose (LocalKeyHandle);
993
994 LocalKeyName.Buffer[Length] = L'\\';
995 Length = wcslen (LocalKeyName.Buffer);
996 LocalKeyName.Length = Length * sizeof(WCHAR);
997
998 if (Length == FullNameLength)
999 {
1001 samDesired,
1003 0,
1004 ClassString,
1005 dwOptions,
1006 (PULONG)lpdwDisposition);
1007 break;
1008 }
1009
1010 Status = NtCreateKey(&LocalKeyHandle,
1012 &LocalObjectAttributes,
1013 0,
1014 NULL,
1015 0,
1016 &Disposition);
1017 TRACE("NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName, Status);
1018 if (!NT_SUCCESS(Status))
1019 break;
1020 }
1021
1022 RtlFreeUnicodeString(&LocalKeyName);
1023
1024 return Status;
1025}
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().

◆ load_string()

static int load_string ( HINSTANCE  hModule,
UINT  resId,
LPWSTR  pwszBuffer,
INT  cMaxChars 
)
static

Definition at line 5126 of file reg.c.

5127{
5129 HRSRC hResource;
5130 WCHAR* pString;
5131 int idxString;
5132
5133 /* Negative values have to be inverted. */
5134 if (HIWORD(resId) == 0xffff)
5135 resId = (UINT)(-((INT)resId));
5136
5137 /* Load the resource into memory and get a pointer to it. */
5138 hResource = FindResourceW(hModule, MAKEINTRESOURCEW(LOWORD(resId >> 4) + 1), (LPWSTR)RT_STRING);
5139 if (!hResource) return 0;
5140 hMemory = LoadResource(hModule, hResource);
5141 if (!hMemory) return 0;
5143
5144 /* Strings are length-prefixed. Lowest nibble of resId is an index. */
5145 idxString = resId & 0xf;
5146 while (idxString--) pString += *pString + 1;
5147
5148 /* If no buffer is given, return length of the string. */
5149 if (!pwszBuffer) return *pString;
5150
5151 /* Else copy over the string, respecting the buffer size. */
5152 cMaxChars = (*pString < cMaxChars) ? *pString : (cMaxChars - 1);
5153 if (cMaxChars >= 0)
5154 {
5155 memcpy(pwszBuffer, pString + 1, cMaxChars * sizeof(WCHAR));
5156 pwszBuffer[cMaxChars] = L'\0';
5157 }
5158
5159 return cMaxChars;
5160}
HMODULE hModule
Definition: animate.c:44
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
FxString * pString
WDFMEMORY hMemory
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define RT_STRING
Definition: pedump.c:368
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by RegLoadMUIStringW().

◆ 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 424 of file reg.c.

425{
427
428 /* don't close null handle or a pseudo handle */
429 if (!hKey)
430 {
432 }
433
434 if (((ULONG_PTR)hKey & 0xF0000000) == 0x80000000)
435 {
436 return ERROR_SUCCESS;
437 }
438
440 if (!NT_SUCCESS(Status))
441 {
443 }
444
445 return ERROR_SUCCESS;
446}
#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 845 of file reg.c.

848{
849 UNICODE_STRING MachineName = { 0, 0, NULL };
850 LONG Ret;
851
852 if (lpMachineName != NULL &&
854 {
856 }
857
858 Ret = RegConnectRegistryW(MachineName.Buffer,
859 hKey,
860 phkResult);
861
863
864 return Ret;
865}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
LONG WINAPI RegConnectRegistryW(LPCWSTR lpMachineName, HKEY hKey, PHKEY phkResult)
Definition: reg.c:874
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 874 of file reg.c.

877{
878 LONG ret;
879
880 TRACE("(%s,%p,%p): stub\n",debugstr_w(lpMachineName),hKey,phkResult);
881
882 if (!lpMachineName || !*lpMachineName)
883 {
884 /* Use the local machine name */
885 ret = RegOpenKeyW( hKey, NULL, phkResult );
886 }
887 else
888 {
889 WCHAR compName[MAX_COMPUTERNAME_LENGTH + 1];
890 DWORD len = sizeof(compName) / sizeof(WCHAR);
891
892 /* MSDN says lpMachineName must start with \\ : not so */
893 if( lpMachineName[0] == '\\' && lpMachineName[1] == '\\')
894 lpMachineName += 2;
895
896 if (GetComputerNameW(compName, &len))
897 {
898 if (!_wcsicmp(lpMachineName, compName))
899 ret = RegOpenKeyW(hKey, NULL, phkResult);
900 else
901 {
902 FIXME("Connect to %s is not supported.\n",debugstr_w(lpMachineName));
904 }
905 }
906 else
907 ret = GetLastError();
908 }
909
910 return ret;
911}
#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:3268
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 816 of file reg.c.

819{
820 UNICODE_STRING SubKeyName = { 0, 0, NULL };
821 LONG Ret;
822
823 if (lpSubKey != NULL &&
825 {
827 }
828
829 Ret = RegCopyTreeW(hKeySrc,
830 SubKeyName.Buffer,
831 hKeyDest);
832
834
835 return Ret;
836}
LONG WINAPI RegCopyTreeW(IN HKEY hKeySrc, IN LPCWSTR lpSubKey OPTIONAL, IN HKEY hKeyDest)
Definition: reg.c:740
_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 740 of file reg.c.

743{
744 HANDLE DestKeyHandle, KeyHandle, CurKey, SubKeyHandle = NULL;
746
748 hKeySrc);
749 if (!NT_SUCCESS(Status))
750 {
752 }
753
754 Status = MapDefaultKey(&DestKeyHandle,
755 hKeyDest);
756 if (!NT_SUCCESS(Status))
757 {
758 goto Cleanup2;
759 }
760
761 if (lpSubKey != NULL)
762 {
765
767
769 &SubKeyName,
771 KeyHandle,
772 NULL);
773
777 if (!NT_SUCCESS(Status))
778 {
779 goto Cleanup;
780 }
781
782 CurKey = SubKeyHandle;
783 }
784 else
785 CurKey = KeyHandle;
786
787 Status = RegpCopyTree(CurKey,
788 hKeyDest);
789
790 if (SubKeyHandle != NULL)
791 {
793 }
794
795Cleanup:
796 ClosePredefKey(DestKeyHandle);
797Cleanup2:
799
800 if (!NT_SUCCESS(Status))
801 {
803 }
804
805 return ERROR_SUCCESS;
806}
#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:451
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 RegCopyTreeA().

◆ RegCreateKeyA()

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

Definition at line 1179 of file reg.c.

1182{
1183 return RegCreateKeyExA(hKey,
1184 lpSubKey,
1185 0,
1186 NULL,
1187 0,
1189 NULL,
1190 phkResult,
1191 NULL);
1192}
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:1034

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 1034 of file reg.c.

1044{
1045 UNICODE_STRING SubKeyString;
1046 UNICODE_STRING ClassString;
1048
1049 RtlInitEmptyUnicodeString(&ClassString, NULL, 0);
1050 RtlInitEmptyUnicodeString(&SubKeyString, NULL, 0);
1051
1052 if (lpClass)
1053 {
1054 if (!RtlCreateUnicodeStringFromAsciiz(&ClassString, lpClass))
1055 {
1057 goto Exit;
1058 }
1059 }
1060
1061 if (lpSubKey)
1062 {
1063 if (!RtlCreateUnicodeStringFromAsciiz(&SubKeyString, lpSubKey))
1064 {
1066 goto Exit;
1067 }
1068 }
1069
1071 hKey,
1072 SubKeyString.Buffer,
1073 Reserved,
1074 ClassString.Buffer,
1075 dwOptions,
1076 samDesired,
1077 lpSecurityAttributes,
1078 phkResult,
1079 lpdwDisposition);
1080
1081Exit:
1082 RtlFreeUnicodeString(&SubKeyString);
1083 RtlFreeUnicodeString(&ClassString);
1084
1085 return ErrorCode;
1086}
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:1096
_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 1096 of file reg.c.

1106{
1107 UNICODE_STRING SubKeyString;
1108 UNICODE_STRING ClassString;
1113
1114 TRACE("RegCreateKeyExW() called\n");
1115
1116 /* get the real parent key */
1118 hKey);
1119 if (!NT_SUCCESS(Status))
1120 {
1122 }
1123
1124 TRACE("ParentKey %p\n", ParentKey);
1125
1126 if (IsHKCRKey(ParentKey))
1127 {
1129 ParentKey,
1130 lpSubKey,
1131 Reserved,
1132 lpClass,
1133 dwOptions,
1134 samDesired,
1135 lpSecurityAttributes,
1136 phkResult,
1137 lpdwDisposition);
1139 return ErrorCode;
1140 }
1141
1144
1145 RtlInitUnicodeString(&ClassString,
1146 lpClass);
1147 RtlInitUnicodeString(&SubKeyString,
1148 lpSubKey);
1150 &SubKeyString,
1151 Attributes,
1153 lpSecurityAttributes ? (PSECURITY_DESCRIPTOR)lpSecurityAttributes->lpSecurityDescriptor : NULL);
1154 Status = CreateNestedKey(phkResult,
1156 (lpClass == NULL)? NULL : &ClassString,
1157 dwOptions,
1158 samDesired,
1159 lpdwDisposition);
1160
1162
1163 TRACE("Status %x\n", Status);
1164 if (!NT_SUCCESS(Status))
1165 {
1167 }
1168
1169 return ERROR_SUCCESS;
1170}
static NTSTATUS CreateNestedKey(PHKEY KeyHandle, POBJECT_ATTRIBUTES ObjectAttributes, PUNICODE_STRING ClassString, DWORD dwOptions, REGSAM samDesired, DWORD *lpdwDisposition)
Definition: reg.c:920
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:266
#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(), CreateAppPath(), 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(), ImageView_SaveSettings(), 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(), 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 1201 of file reg.c.

1204{
1205 return RegCreateKeyExW(hKey,
1206 lpSubKey,
1207 0,
1208 NULL,
1209 0,
1211 NULL,
1212 phkResult,
1213 NULL);
1214}

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(), 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 1224 of file reg.c.

1227{
1228 return RegDeleteKeyExA(hKey, lpSubKey, 0, 0);
1229}
LONG WINAPI RegDeleteKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ REGSAM samDesired, _In_ DWORD Reserved)
Definition: reg.c:1254

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 1254 of file reg.c.

1259{
1262
1263 if (lpSubKey)
1264 {
1267 }
1268 else
1269 RtlInitEmptyUnicodeString(&SubKeyName, NULL, 0);
1270
1271 ErrorCode = RegDeleteKeyExW(hKey, SubKeyName.Buffer, samDesired, Reserved);
1272
1274
1275 return ErrorCode;
1276}
LONG WINAPI RegDeleteKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ REGSAM samDesired, _In_ DWORD Reserved)
Definition: reg.c:1286

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 1286 of file reg.c.

1291{
1295 HANDLE TargetKey;
1297
1298 /* Make sure we got a subkey */
1299 if (!lpSubKey)
1300 {
1301 /* Fail */
1303 }
1304
1306 hKey);
1307 if (!NT_SUCCESS(Status))
1308 {
1310 }
1311
1312 if (IsHKCRKey(ParentKey))
1313 {
1314 LONG ErrorCode = DeleteHKCRKey(ParentKey, lpSubKey, samDesired, Reserved);
1316 return ErrorCode;
1317 }
1318
1319 if (samDesired & KEY_WOW64_32KEY)
1320 ERR("Wow64 not yet supported!\n");
1321
1322 if (samDesired & KEY_WOW64_64KEY)
1323 ERR("Wow64 not yet supported!\n");
1324
1325
1326 RtlInitUnicodeString(&SubKeyName, lpSubKey);
1328 &SubKeyName,
1330 ParentKey,
1331 NULL);
1332 Status = NtOpenKey(&TargetKey,
1333 DELETE,
1335 if (!NT_SUCCESS(Status))
1336 {
1337 goto Cleanup;
1338 }
1339
1340 Status = NtDeleteKey(TargetKey);
1341 NtClose(TargetKey);
1342
1343Cleanup:
1345
1346 if (!NT_SUCCESS(Status))
1347 {
1349 }
1350
1351 return ERROR_SUCCESS;
1352}
#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:441
#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 1392 of file reg.c.

1395{
1396 UNICODE_STRING SubKey = { 0, 0, NULL }, ValueName = { 0, 0, NULL };
1397 LONG Ret;
1398
1399 if (lpSubKey != NULL &&
1400 !RtlCreateUnicodeStringFromAsciiz(&SubKey, lpSubKey))
1401 {
1403 }
1404
1405 if (lpValueName != NULL &&
1407 {
1408 RtlFreeUnicodeString(&SubKey);
1410 }
1411
1413 SubKey.Buffer,
1414 ValueName.Buffer);
1415
1416 RtlFreeUnicodeString(&SubKey);
1418
1419 return Ret;
1420}
LONG WINAPI RegDeleteKeyValueW(IN HKEY hKey, IN LPCWSTR lpSubKey OPTIONAL, IN LPCWSTR lpValueName OPTIONAL)
Definition: reg.c:1361
_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 1361 of file reg.c.

1364{
1365 HKEY hSubKey = hKey;
1367
1368 if (lpSubKey)
1369 {
1370 ErrorCode = RegOpenKeyExW(hKey, lpSubKey, 0, KEY_SET_VALUE, &hSubKey);
1371 if (ErrorCode)
1372 {
1373 return ErrorCode;
1374 }
1375 }
1376 ErrorCode = RegDeleteValueW(hSubKey, lpValueName);
1377
1378 if (hSubKey != hKey)
1379 {
1380 RegCloseKey(hSubKey);
1381 }
1382 return ErrorCode;
1383}
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
#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 1239 of file reg.c.

1242{
1243 return RegDeleteKeyExW(hKey, lpSubKey, 0, 0);
1244}

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(), DeleteAppPath(), 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(), 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 1805 of file reg.c.

1807{
1808 UNICODE_STRING SubKeyName = { 0, 0, NULL };
1809 LONG Ret;
1810
1811 if (lpSubKey != NULL &&
1813 {
1815 }
1816
1817 Ret = RegDeleteTreeW(hKey,
1818 SubKeyName.Buffer);
1819
1821
1822 return Ret;
1823}
LSTATUS WINAPI RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
Definition: reg.c:1711

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

◆ RegDeleteTreeW()

LSTATUS WINAPI RegDeleteTreeW ( HKEY  hKey,
LPCWSTR  lpszSubKey 
)

Definition at line 1711 of file reg.c.

1713{
1714 LONG ret;
1715 DWORD dwMaxSubkeyLen, dwMaxValueLen;
1716 DWORD dwMaxLen, dwSize;
1719 HKEY hSubKey;
1720 WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
1721
1722 TRACE("(hkey=%p,%p %s)\n", hKey, lpszSubKey, debugstr_w(lpszSubKey));
1723
1725 hKey);
1726 if (!NT_SUCCESS(Status))
1727 {
1729 }
1730
1731 hSubKey = KeyHandle;
1732
1733 if(lpszSubKey)
1734 {
1735 ret = RegOpenKeyExW(KeyHandle, lpszSubKey, 0, KEY_READ, &hSubKey);
1736 if (ret)
1737 {
1739 return ret;
1740 }
1741 }
1742
1743 /* Get highest length for keys, values */
1744 ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
1745 &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
1746 if (ret) goto cleanup;
1747
1748 dwMaxSubkeyLen++;
1749 dwMaxValueLen++;
1750 dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
1751 if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
1752 {
1753 /* Name too big: alloc a buffer for it */
1754 if (!(lpszName = RtlAllocateHeap( RtlGetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
1755 {
1757 goto cleanup;
1758 }
1759 }
1760
1761
1762 /* Recursively delete all the subkeys */
1763 while (TRUE)
1764 {
1765 dwSize = dwMaxLen;
1766 if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
1767 NULL, NULL, NULL)) break;
1768
1769 ret = RegDeleteTreeW(hSubKey, lpszName);
1770 if (ret) goto cleanup;
1771 }
1772
1773 if (lpszSubKey)
1774 ret = RegDeleteKeyW(KeyHandle, lpszSubKey);
1775 else
1776 while (TRUE)
1777 {
1778 dwSize = dwMaxLen;
1779 if (RegEnumValueW(KeyHandle, 0, lpszName, &dwSize,
1780 NULL, NULL, NULL, NULL)) break;
1781
1782 ret = RegDeleteValueW(KeyHandle, lpszName);
1783 if (ret) goto cleanup;
1784 }
1785
1786cleanup:
1787 /* Free buffer if allocated */
1788 if (lpszName != szNameBuf)
1789 RtlFreeHeap( RtlGetProcessHeap(), 0, lpszName);
1790 if(lpszSubKey)
1791 RegCloseKey(hSubKey);
1792
1794
1795 return ret;
1796}
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
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:2504
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
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:2830
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:3662
#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 RegDeleteTreeA(), and RegDeleteTreeW().

◆ RegDeleteValueA()

LONG WINAPI RegDeleteValueA ( HKEY  hKey,
LPCSTR  lpValueName 
)

Definition at line 2287 of file reg.c.

2289{
2294
2296 hKey);
2297 if (!NT_SUCCESS(Status))
2298 {
2300 }
2301
2302 if (!RtlCreateUnicodeStringFromAsciiz(&ValueName, lpValueName))
2303 {
2306 }
2307
2308 if (IsHKCRKey(KeyHandle))
2309 {
2311 }
2312 else
2313 {
2315 if (!NT_SUCCESS(Status))
2317 }
2320 return ErrorCode;
2321}
LONG WINAPI DeleteHKCRValue(_In_ HKEY hKey, _In_ PUNICODE_STRING ValueName)
Definition: hkcr.c:504
NTSYSAPI NTSTATUS NTAPI NtDeleteValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName)
Definition: ntapi.c:1014

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 2330 of file reg.c.

2332{
2337
2339 hKey);
2340 if (!NT_SUCCESS(Status))
2341 {
2343 }
2344
2345 RtlInitUnicodeString(&ValueName, lpValueName);
2346
2347 if (IsHKCRKey(KeyHandle))
2348 {
2350 }
2351 else
2352 {
2354 if (!NT_SUCCESS(Status))
2356 }
2358 return ErrorCode;
2359}

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(), RegDeleteKeyValueW(), RegDeleteTreeW(), remove_product_upgrade_code(), run_delete(), SaveSetting(), 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 333 of file reg.c.

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

◆ RegDisablePredefinedCacheEx()

LONG WINAPI RegDisablePredefinedCacheEx ( VOID  )

Definition at line 349 of file reg.c.

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

◆ RegDisableReflectionKey()

LONG WINAPI RegDisableReflectionKey ( IN HKEY  hBase)

Definition at line 1833 of file reg.c.

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

◆ RegEnableReflectionKey()

LONG WINAPI RegEnableReflectionKey ( IN HKEY  hBase)

Definition at line 1846 of file reg.c.

1847{
1848 FIXME("RegEnableReflectionKey(0x%p) UNIMPLEMENTED!\n", hBase);
1850}

◆ RegEnumKeyA()

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

Definition at line 2368 of file reg.c.

2372{
2374
2375 dwLength = cbName;
2376 return RegEnumKeyExA(hKey,
2377 dwIndex,
2378 lpName,
2379 &dwLength,
2380 NULL,
2381 NULL,
2382 NULL,
2383 NULL);
2384}
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:2419
static DWORD DWORD * dwLength
Definition: fusion.c:86
_In_ LPCSTR lpName
Definition: winbase.h:2789

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 2419 of file reg.c.

2428{
2429 WCHAR* NameBuffer = NULL;
2430 WCHAR* ClassBuffer = NULL;
2431 DWORD NameLength, ClassLength;
2433
2434 /* Allocate our buffers */
2435 if (*lpcbName > 0)
2436 {
2437 NameLength = *lpcbName;
2438 NameBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, *lpcbName * sizeof(WCHAR));
2439 if (NameBuffer == NULL)
2440 {
2442 goto Exit;
2443 }
2444 }
2445
2446 if (lpClass)
2447 {
2448 if (*lpcbClass > 0)
2449 {
2450 ClassLength = *lpcbClass;
2451 ClassBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, *lpcbClass * sizeof(WCHAR));
2452 if (ClassBuffer == NULL)
2453 {
2455 goto Exit;
2456 }
2457 }
2458 }
2459
2460 /* Do the actual call */
2462 hKey,
2463 dwIndex,
2464 NameBuffer,
2465 lpcbName,
2466 lpReserved,
2467 ClassBuffer,
2468 lpcbClass,
2469 lpftLastWriteTime);
2470
2471 if (ErrorCode != ERROR_SUCCESS)
2472 goto Exit;
2473
2474 /* Convert the strings */
2475 RtlUnicodeToMultiByteN(lpName, *lpcbName, 0, NameBuffer, *lpcbName * sizeof(WCHAR));
2476 /* NULL terminate if we can */
2477 if (NameLength > *lpcbName)
2478 lpName[*lpcbName] = '\0';
2479
2480 if (lpClass)
2481 {
2482 RtlUnicodeToMultiByteN(lpClass, *lpcbClass, 0, NameBuffer, *lpcbClass * sizeof(WCHAR));
2483 if (ClassLength > *lpcbClass)
2484 lpClass[*lpcbClass] = '\0';
2485 }
2486
2487Exit:
2488 if (NameBuffer)
2489 RtlFreeHeap(RtlGetProcessHeap(), 0, NameBuffer);
2490 if (ClassBuffer)
2491 RtlFreeHeap(RtlGetProcessHeap(), 0, ClassBuffer);
2492
2493 return ErrorCode;
2494}
_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 2504 of file reg.c.

2513{
2514 union
2515 {
2518 } *KeyInfo;
2519
2521 ULONG ResultSize;
2522 ULONG NameLength;
2523 ULONG ClassLength = 0;
2527
2529 hKey);
2530 if (!NT_SUCCESS(Status))
2531 {
2533 }
2534
2535 if (IsHKCRKey(KeyHandle))
2536 {
2538 KeyHandle,
2539 dwIndex,
2540 lpName,
2541 lpcbName,
2542 lpReserved,
2543 lpClass,
2544 lpcbClass,
2545 lpftLastWriteTime);
2547 return ErrorCode;
2548 }
2549
2550 if (*lpcbName > 0)
2551 {
2552 NameLength = min (*lpcbName - 1, REG_MAX_NAME_SIZE) * sizeof (WCHAR);
2553 }
2554 else
2555 {
2556 NameLength = 0;
2557 }
2558
2559 if (lpClass)
2560 {
2561 if (*lpcbClass > 0)
2562 {
2563 ClassLength = min (*lpcbClass - 1, REG_MAX_NAME_SIZE) * sizeof(WCHAR);
2564 }
2565 else
2566 {
2567 ClassLength = 0;
2568 }
2569
2570 BufferSize = ((sizeof(KEY_NODE_INFORMATION) + NameLength + 3) & ~3) + ClassLength;
2571 }
2572 else
2573 {
2574 BufferSize = sizeof(KEY_BASIC_INFORMATION) + NameLength;
2575 }
2576
2577 KeyInfo = RtlAllocateHeap(ProcessHeap,
2578 0,
2579 BufferSize);
2580 if (KeyInfo == NULL)
2581 {
2583 goto Cleanup;
2584 }
2585
2587 (ULONG)dwIndex,
2589 KeyInfo,
2590 BufferSize,
2591 &ResultSize);
2592 TRACE("NtEnumerateKey() returned status 0x%X\n", Status);
2593 if (!NT_SUCCESS(Status))
2594 {
2596 }
2597 else
2598 {
2599 if (lpClass == NULL)
2600 {
2601 if (KeyInfo->Basic.NameLength > NameLength)
2602 {
2604 }
2605 else
2606 {
2608 KeyInfo->Basic.Name,
2609 KeyInfo->Basic.NameLength);
2610 *lpcbName = (DWORD)(KeyInfo->Basic.NameLength / sizeof(WCHAR));
2611 lpName[*lpcbName] = 0;
2612 }
2613 }
2614 else
2615 {
2616 if (KeyInfo->Node.NameLength > NameLength ||
2617 KeyInfo->Node.ClassLength > ClassLength)
2618 {
2620 }
2621 else
2622 {
2624 KeyInfo->Node.Name,
2625 KeyInfo->Node.NameLength);
2626 *lpcbName = KeyInfo->Node.NameLength / sizeof(WCHAR);
2627 lpName[*lpcbName] = 0;
2628 RtlCopyMemory(lpClass,
2629 (PVOID)((ULONG_PTR)KeyInfo->Node.Name + KeyInfo->Node.ClassOffset),
2630 KeyInfo->Node.ClassLength);
2631 *lpcbClass = (DWORD)(KeyInfo->Node.ClassLength / sizeof(WCHAR));
2632 lpClass[*lpcbClass] = 0;
2633 }
2634 }
2635
2636 if (ErrorCode == ERROR_SUCCESS && lpftLastWriteTime != NULL)
2637 {
2638 if (lpClass == NULL)
2639 {
2640 lpftLastWriteTime->dwLowDateTime = KeyInfo->Basic.LastWriteTime.u.LowPart;
2641 lpftLastWriteTime->dwHighDateTime = KeyInfo->Basic.LastWriteTime.u.HighPart;
2642 }
2643 else
2644 {
2645 lpftLastWriteTime->dwLowDateTime = KeyInfo->Node.LastWriteTime.u.LowPart;
2646 lpftLastWriteTime->dwHighDateTime = KeyInfo->Node.LastWriteTime.u.HighPart;
2647 }
2648 }
2649 }
2650
2652 0,
2653 KeyInfo);
2654
2655Cleanup:
2657
2658 return ErrorCode;
2659}
#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:682
#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(), ScmCreateServiceDatabase(), ScmDeleteRegKey(), 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 2668 of file reg.c.

2677{
2678 WCHAR* NameBuffer;
2679 DWORD NameBufferSize, NameLength;
2681 DWORD LocalType = REG_NONE;
2682 BOOL NameOverflow = FALSE;
2683
2684 /* Do parameter checks now, once and for all. */
2685 if (!lpName || !lpcbName)
2687
2688 if ((lpData && !lpcbData) || lpdwReserved)
2690
2691 /* Get the size of the buffer we must use for the first call to RegEnumValueW */
2693 hKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &NameBufferSize, NULL, NULL, NULL);
2694 if (ErrorCode != ERROR_SUCCESS)
2695 return ErrorCode;
2696
2697 /* Add space for the null terminator */
2698 NameBufferSize++;
2699
2700 /* Allocate the buffer for the unicode name */
2701 NameBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, NameBufferSize * sizeof(WCHAR));
2702 if (NameBuffer == NULL)
2703 {
2705 }
2706
2707 /*
2708 * This code calls RegEnumValueW twice, because we need to know the type of the enumerated value.
2709 * So for the first call, we check if we overflow on the name, as we have no way of knowing if this
2710 * is an overflow on the data or on the name during the the second call. So the first time, we make the
2711 * call with the supplied value. This is merdique, but this is how it is.
2712 */
2713 NameLength = *lpcbName;
2715 hKey,
2716 dwIndex,
2717 NameBuffer,
2718 &NameLength,
2719 NULL,
2720 &LocalType,
2721 NULL,
2722 NULL);
2723 if (ErrorCode != ERROR_SUCCESS)
2724 {
2726 NameOverflow = TRUE;
2727 else
2728 goto Exit;
2729 }
2730
2731 if (is_string(LocalType) && lpcbData)
2732 {
2733 /* We must allocate a buffer to get the unicode data */
2734 DWORD DataBufferSize = *lpcbData * sizeof(WCHAR);
2735 WCHAR* DataBuffer = NULL;
2736 DWORD DataLength = *lpcbData;
2737 LPSTR DataStr = (LPSTR)lpData;
2738
2739 if (lpData)
2740 DataBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, *lpcbData * sizeof(WCHAR));
2741
2742 /* Do the real call */
2744 hKey,
2745 dwIndex,
2746 NameBuffer,
2747 &NameBufferSize,
2748 lpdwReserved,
2749 lpdwType,
2750 (LPBYTE)DataBuffer,
2751 &DataBufferSize);
2752
2753 *lpcbData = DataBufferSize / sizeof(WCHAR);
2754
2755 if (ErrorCode != ERROR_SUCCESS)
2756 {
2757 RtlFreeHeap(RtlGetProcessHeap(), 0, DataBuffer);
2758 goto Exit;
2759 }
2760
2761 /* Copy the data whatever the error code is */
2762 if (lpData)
2763 {
2764 /* Do the data conversion */
2765 RtlUnicodeToMultiByteN(DataStr, DataLength, 0, DataBuffer, DataBufferSize);
2766 /* NULL-terminate if there is enough room */
2767 if ((DataLength > *lpcbData) && (DataStr[*lpcbData - 1] != '\0'))
2768 DataStr[*lpcbData] = '\0';
2769 }
2770
2771 RtlFreeHeap(RtlGetProcessHeap(), 0, DataBuffer);
2772 }
2773 else
2774 {
2775 /* No data conversion needed. Do the call with provided buffers */
2777 hKey,
2778 dwIndex,
2779 NameBuffer,
2780 &NameBufferSize,
2781 lpdwReserved,
2782 lpdwType,
2783 lpData,
2784 lpcbData);
2785
2786 if (ErrorCode != ERROR_SUCCESS)
2787 {
2788 goto Exit;
2789 }
2790 }
2791
2792 if (NameOverflow)
2793 {
2795 goto Exit;
2796 }
2797
2798 /* Convert the name string */
2799 RtlUnicodeToMultiByteN(lpName, *lpcbName, lpcbName, NameBuffer, NameBufferSize * sizeof(WCHAR));
2800 lpName[*lpcbName] = ANSI_NULL;
2801
2802Exit:
2803 if (NameBuffer)
2804 RtlFreeHeap(RtlGetProcessHeap(), 0, NameBuffer);
2805
2806 return ErrorCode;
2807}
_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 2830 of file reg.c.

2839{
2842 ULONG total_size;
2843 char buffer[256], *buf_ptr = buffer;
2845 static const int info_size = FIELD_OFFSET( KEY_VALUE_FULL_INFORMATION, Name );
2846
2847 TRACE("(%p,%ld,%p,%p,%p,%p,%p,%p)\n",
2848 hKey, index, value, val_count, reserved, type, data, count );
2849
2850 if (!value || !val_count)
2852
2853 if ((data && !count) || reserved)
2855
2857 if (!NT_SUCCESS(status))
2858 {
2860 }
2861
2862 if (IsHKCRKey(KeyHandle))
2863 {
2865 KeyHandle,
2866 index,
2867 value,
2868 val_count,
2869 reserved,
2870 type,
2871 data,
2872 count);
2874 return ErrorCode;
2875 }
2876
2877 total_size = info_size + (MAX_PATH + 1) * sizeof(WCHAR);
2878 if (data) total_size += *count;
2879 total_size = min( sizeof(buffer), total_size );
2880
2882 buffer, total_size, &total_size );
2883 if (status && (status != STATUS_BUFFER_OVERFLOW) && (status != STATUS_BUFFER_TOO_SMALL)) goto done;
2884
2885 if (value || data)
2886 {
2887 /* retry with a dynamically allocated buffer */
2889 {
2890 if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr );
2891 if (!(buf_ptr = HeapAlloc( GetProcessHeap(), 0, total_size )))
2892 {
2894 goto done;
2895 }
2896 info = (KEY_VALUE_FULL_INFORMATION *)buf_ptr;
2898 buf_ptr, total_size, &total_size );
2899 }
2900
2901 if (status) goto done;
2902
2903 if (value)
2904 {
2905 if (info->NameLength/sizeof(WCHAR) >= *val_count)
2906 {
2908 goto overflow;
2909 }
2910 memcpy( value, info->Name, info->NameLength );
2911 *val_count = info->NameLength / sizeof(WCHAR);
2912 value[*val_count] = 0;
2913 }
2914
2915 if (data)
2916 {
2917 if (info->DataLength > *count)
2918 {
2920 goto overflow;
2921 }
2922 memcpy( data, buf_ptr + info->DataOffset, info->DataLength );
2923 if (is_string(info->Type) && info->DataLength <= *count - sizeof(WCHAR))
2924 {
2925 /* if the type is REG_SZ and data is not 0-terminated
2926 * and there is enough space in the buffer NT appends a \0 */
2927 WCHAR *ptr = (WCHAR *)(data + info->DataLength);
2928 if (ptr > (WCHAR *)data && ptr[-1]) *ptr = 0;
2929 }
2930 }
2931 }
2932 else status = STATUS_SUCCESS;
2933
2934 overflow:
2935 if (type) *type = info->Type;
2936 if (count) *count = info->DataLength;
2937
2938 done:
2939 if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr );
2942}
#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:873
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(), 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 2951 of file reg.c.

2952{
2955
2957 {
2958 return ERROR_SUCCESS;
2959 }
2960
2962 hKey);
2963 if (!NT_SUCCESS(Status))
2964 {
2966 }
2967
2969
2971
2972 if (!NT_SUCCESS(Status))
2973 {
2975 }
2976
2977 return ERROR_SUCCESS;
2978}
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 2987 of file reg.c.

2991{
2994
2996 {
2997 return ERROR_INVALID_HANDLE;
2998 }
2999
3001 hKey);
3002 if (!NT_SUCCESS(Status))
3003 {
3004 TRACE("MapDefaultKey() failed (Status %lx)\n", Status);
3006 }
3007
3010 pSecurityDescriptor,
3011 *lpcbSecurityDescriptor,
3012 lpcbSecurityDescriptor);
3013
3015
3016 if (!NT_SUCCESS(Status))
3017 {
3018 WARN("NtQuerySecurityObject() failed (Status %lx)\n", Status);
3020 }
3021
3022 return ERROR_SUCCESS;
3023}
_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 2037 of file reg.c.

2044{
2045 DWORD dwType, cbData = pcbData ? *pcbData : 0;
2046 PVOID pvBuf = NULL;
2047 LONG ret;
2048
2049 TRACE("(%p,%s,%s,%ld,%p,%p,%p=%ld)\n",
2050 hKey, pszSubKey, pszValue, dwFlags, pdwType, pvData, pcbData,
2051 cbData);
2052
2053 if (pvData && !pcbData)
2056 ((dwFlags & RRF_RT_ANY) != RRF_RT_ANY))
2058
2059 if (pszSubKey && pszSubKey[0])
2060 {
2061 ret = RegOpenKeyExA(hKey, pszSubKey, 0, KEY_QUERY_VALUE, &hKey);
2062 if (ret != ERROR_SUCCESS) return ret;
2063 }
2064
2065 ret = RegQueryValueExA(hKey, pszValue, NULL, &dwType, pvData, &cbData);
2066
2067 /* If we are going to expand we need to read in the whole the value even
2068 * if the passed buffer was too small as the expanded string might be
2069 * smaller than the unexpanded one and could fit into cbData bytes. */
2070 if ((ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) &&
2071 (dwType == REG_EXPAND_SZ && !(dwFlags & RRF_NOEXPAND)))
2072 {
2073 do {
2074 HeapFree(GetProcessHeap(), 0, pvBuf);
2075
2076 pvBuf = HeapAlloc(GetProcessHeap(), 0, cbData);
2077 if (!pvBuf)
2078 {
2080 break;
2081 }
2082
2083 if (ret == ERROR_MORE_DATA || !pvData)
2084 ret = RegQueryValueExA(hKey, pszValue, NULL,
2085 &dwType, pvBuf, &cbData);
2086 else
2087 {
2088 /* Even if cbData was large enough we have to copy the
2089 * string since ExpandEnvironmentStrings can't handle
2090 * overlapping buffers. */
2091 CopyMemory(pvBuf, pvData, cbData);
2092 }
2093
2094 /* Both the type or the value itself could have been modified in
2095 * between so we have to keep retrying until the buffer is large
2096 * enough or we no longer have to expand the value. */
2097 } while (dwType == REG_EXPAND_SZ && ret == ERROR_MORE_DATA);
2098
2099 if (ret == ERROR_SUCCESS)
2100 {
2101 /* Recheck dwType in case it changed since the first call */
2102 if (dwType == REG_EXPAND_SZ)
2103 {
2104 cbData = ExpandEnvironmentStringsA(pvBuf, pvData,
2105 pcbData ? *pcbData : 0);
2106 dwType = REG_SZ;
2107 if(pvData && pcbData && cbData > *pcbData)
2109 }
2110 else if (pvData)
2111 CopyMemory(pvData, pvBuf, *pcbData);
2112 }
2113
2114 HeapFree(GetProcessHeap(), 0, pvBuf);
2115 }
2116
2117 if (pszSubKey && pszSubKey[0])
2119
2120 RegpApplyRestrictions(dwFlags, dwType, cbData, &ret);
2121
2124
2125 if (pdwType) *pdwType = dwType;
2126 if (pcbData) *pcbData = cbData;
2127
2128 return ret;
2129}
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3298
static VOID RegpApplyRestrictions(DWORD dwFlags, DWORD dwType, DWORD cbData, PLONG ret)
Definition: reg.c:1859
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:4009
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:1712
#define CopyMemory
Definition: winbase.h:1710
_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 1931 of file reg.c.

1938{
1939 DWORD dwType, cbData = pcbData ? *pcbData : 0;
1940 PVOID pvBuf = NULL;
1941 LONG ret;
1942
1943 TRACE("(%p,%s,%s,%ld,%p,%p,%p=%ld)\n",
1944 hKey, debugstr_w(pszSubKey), debugstr_w(pszValue), dwFlags, pdwType,
1945 pvData, pcbData, cbData);
1946
1947 if (pvData && !pcbData)
1950 ((dwFlags & RRF_RT_ANY) != RRF_RT_ANY))
1952
1953 if (pszSubKey && pszSubKey[0])
1954 {
1955 ret = RegOpenKeyExW(hKey, pszSubKey, 0, KEY_QUERY_VALUE, &hKey);
1956 if (ret != ERROR_SUCCESS) return ret;
1957 }
1958
1959 ret = RegQueryValueExW(hKey, pszValue, NULL, &dwType, pvData, &cbData);
1960
1961 /* If we are going to expand we need to read in the whole the value even
1962 * if the passed buffer was too small as the expanded string might be
1963 * smaller than the unexpanded one and could fit into cbData bytes. */
1964 if ((ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) &&
1965 dwType == REG_EXPAND_SZ && !(dwFlags & RRF_NOEXPAND))
1966 {
1967 do
1968 {
1969 HeapFree(GetProcessHeap(), 0, pvBuf);
1970
1971 pvBuf = HeapAlloc(GetProcessHeap(), 0, cbData);
1972 if (!pvBuf)
1973 {
1975 break;
1976 }
1977
1978 if (ret == ERROR_MORE_DATA || !pvData)
1979 ret = RegQueryValueExW(hKey, pszValue, NULL,
1980 &dwType, pvBuf, &cbData);
1981 else
1982 {
1983 /* Even if cbData was large enough we have to copy the
1984 * string since ExpandEnvironmentStrings can't handle
1985 * overlapping buffers. */
1986 CopyMemory(pvBuf, pvData, cbData);
1987 }
1988
1989 /* Both the type or the value itself could have been modified in
1990 * between so we have to keep retrying until the buffer is large
1991 * enough or we no longer have to expand the value. */
1992 }
1993 while (dwType == REG_EXPAND_SZ && ret == ERROR_MORE_DATA);
1994
1995 if (ret == ERROR_SUCCESS)
1996 {
1997 /* Recheck dwType in case it changed since the first call */
1998 if (dwType == REG_EXPAND_SZ)
1999 {
2000 cbData = ExpandEnvironmentStringsW(pvBuf, pvData,
2001 pcbData ? *pcbData : 0) * sizeof(WCHAR);
2002 dwType = REG_SZ;
2003 if (pvData && pcbData && cbData > *pcbData)
2005 }
2006 else if (pvData)
2007 CopyMemory(pvData, pvBuf, *pcbData);
2008 }
2009
2010 HeapFree(GetProcessHeap(), 0, pvBuf);
2011 }
2012
2013 if (pszSubKey && pszSubKey[0])
2015
2016 RegpApplyRestrictions(dwFlags, dwType, cbData, &ret);
2017
2020
2021 if (pdwType)
2022 *pdwType = dwType;
2023
2024 if (pcbData)
2025 *pcbData = cbData;
2026
2027 return ret;
2028}
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
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(), FindExeCplClass(), 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(), SHELL_GetRegCLSID(), 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 3032 of file reg.c.

3035{
3039
3040 RtlInitEmptyUnicodeString(&KeyName, NULL, 0);
3041 RtlInitEmptyUnicodeString(&FileName, NULL, 0);
3042
3043 if (lpSubKey)
3044 {
3046 {
3048 goto Exit;
3049 }
3050 }
3051
3052 if (lpFile)
3053 {
3055 {
3057 goto Exit;
3058 }
3059 }
3060
3062 KeyName.Buffer,
3063 FileName.Buffer);
3064
3065Exit:
3068
3069 return ErrorCode;
3070}
LONG WINAPI RegLoadKeyW(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpFile)
Definition: reg.c:3079
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 3079 of file reg.c.

3082{
3084 OBJECT_ATTRIBUTES KeyObjectAttributes;
3090
3092 {
3093 return ERROR_INVALID_HANDLE;
3094 }
3095
3097 hKey);
3098 if (!NT_SUCCESS(Status))
3099 {
3101 }
3102
3103 if (!RtlDosPathNameToNtPathName_U(lpFile,
3104 &FileName,
3105 NULL,
3106 NULL))
3107 {
3109 goto Cleanup;
3110 }
3111
3113 &FileName,
3115 NULL,
3116 NULL);
3117
3118 RtlInitUnicodeString(&KeyName, lpSubKey);
3119
3120 InitializeObjectAttributes(&KeyObjectAttributes,
3121 &KeyName,
3123 KeyHandle,
3124 NULL);
3125
3126 Status = NtLoadKey(&KeyObjectAttributes,
3128
3129 RtlFreeHeap(RtlGetProcessHeap(),
3130 0,
3131 FileName.Buffer);
3132
3133 if (!NT_SUCCESS(Status))
3134 {
3136 goto Cleanup;
3137 }
3138
3139Cleanup:
3141
3142 return ErrorCode;
3143}
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().

◆ RegLoadMUIStringA()

LONG WINAPI RegLoadMUIStringA ( IN HKEY  hKey,
IN LPCSTR pszValue  OPTIONAL,
OUT LPSTR  pszOutBuf,
IN DWORD  cbOutBuf,
OUT LPDWORD pcbData  OPTIONAL,
IN DWORD  Flags,
IN LPCSTR pszDirectory  OPTIONAL 
)

Definition at line 5268 of file reg.c.

5276{
5277 UNICODE_STRING valueW, baseDirW;
5278 WCHAR* pwszBuffer;
5279 DWORD cbData = cbOutBuf * sizeof(WCHAR);
5280 LONG result;
5281
5282 valueW.Buffer = baseDirW.Buffer = pwszBuffer = NULL;
5283 if (!RtlCreateUnicodeStringFromAsciiz(&valueW, pszValue) ||
5284 !RtlCreateUnicodeStringFromAsciiz(&baseDirW, pszDirectory) ||
5285 !(pwszBuffer = HeapAlloc(GetProcessHeap(), 0, cbData)))
5286 {
5288 goto cleanup;
5289 }
5290
5291 result = RegLoadMUIStringW(hKey, valueW.Buffer, pwszBuffer, cbData, NULL, Flags,
5292 baseDirW.Buffer);
5293
5294 if (result == ERROR_SUCCESS)
5295 {
5296 cbData = WideCharToMultiByte(CP_ACP, 0, pwszBuffer, -1, pszOutBuf, cbOutBuf, NULL, NULL);
5297 if (pcbData)
5298 *pcbData = cbData;
5299 }
5300
5301cleanup:
5302 HeapFree(GetProcessHeap(), 0, pwszBuffer);
5303 RtlFreeUnicodeString(&baseDirW);
5305
5306 return result;
5307}
LONG WINAPI RegLoadMUIStringW(IN HKEY hKey, IN LPCWSTR pszValue OPTIONAL, OUT LPWSTR pszOutBuf, IN DWORD cbOutBuf, OUT LPDWORD pcbData OPTIONAL, IN DWORD Flags, IN LPCWSTR pszDirectory OPTIONAL)
Definition: reg.c:5168
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
static const WCHAR valueW[]
Definition: object.c:48
GLuint64EXT * result
Definition: glext.h:11304
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by CRegFolder::GetDetailsOf(), HCR_GetClassNameA(), and HCR_MapTypeToValueA().

◆ RegLoadMUIStringW()

LONG WINAPI RegLoadMUIStringW ( IN HKEY  hKey,
IN LPCWSTR pszValue  OPTIONAL,
OUT LPWSTR  pszOutBuf,
IN DWORD  cbOutBuf,
OUT LPDWORD pcbData  OPTIONAL,
IN DWORD  Flags,
IN LPCWSTR pszDirectory  OPTIONAL 
)

Definition at line 5168 of file reg.c.

5176{
5177 DWORD dwValueType, cbData;
5178 LPWSTR pwszTempBuffer = NULL, pwszExpandedBuffer = NULL;
5179 LONG result;
5180
5181 /* Parameter sanity checks. */
5182 if (!hKey || !pszOutBuf)
5184
5185 if (pszDirectory && *pszDirectory)
5186 {
5187 FIXME("BaseDir parameter not yet supported!\n");
5189 }
5190
5191 /* Check for value existence and correctness of it's type, allocate a buffer and load it. */
5192 result = RegQueryValueExW(hKey, pszValue, NULL, &dwValueType, NULL, &cbData);
5193 if (result != ERROR_SUCCESS) goto cleanup;
5194 if (!(dwValueType == REG_SZ || dwValueType == REG_EXPAND_SZ) || !cbData)
5195 {
5197 goto cleanup;
5198 }
5199 pwszTempBuffer = HeapAlloc(GetProcessHeap(), 0, cbData);
5200 if (!pwszTempBuffer)
5201 {
5203 goto cleanup;
5204 }
5205 result = RegQueryValueExW(hKey, pszValue, NULL, &dwValueType, (LPBYTE)pwszTempBuffer, &cbData);
5206 if (result != ERROR_SUCCESS) goto cleanup;
5207
5208 /* Expand environment variables, if appropriate, or copy the original string over. */
5209 if (dwValueType == REG_EXPAND_SZ)
5210 {
5211 cbData = ExpandEnvironmentStringsW(pwszTempBuffer, NULL, 0) * sizeof(WCHAR);
5212 if (!cbData) goto cleanup;
5213 pwszExpandedBuffer = HeapAlloc(GetProcessHeap(), 0, cbData);
5214 if (!pwszExpandedBuffer)
5215 {
5217 goto cleanup;
5218 }
5219 ExpandEnvironmentStringsW(pwszTempBuffer, pwszExpandedBuffer, cbData);
5220 }
5221 else
5222 {
5223 pwszExpandedBuffer = HeapAlloc(GetProcessHeap(), 0, cbData);
5224 memcpy(pwszExpandedBuffer, pwszTempBuffer, cbData);
5225 }
5226
5227 /* If the value references a resource based string, parse the value and load the string.
5228 * Else just copy over the original value. */
5230 if (*pwszExpandedBuffer != L'@') /* '@' is the prefix for resource based string entries. */
5231 {
5232 lstrcpynW(pszOutBuf, pwszExpandedBuffer, cbOutBuf / sizeof(WCHAR));
5233 }
5234 else
5235 {
5236 WCHAR* pComma = wcsrchr(pwszExpandedBuffer, L',');
5237 UINT uiStringId;
5239
5240 /* Format of the expanded value is 'path_to_dll,-resId' */
5241 if (!pComma || pComma[1] != L'-')
5242 {
5244 goto cleanup;
5245 }
5246
5247 uiStringId = _wtoi(pComma + 2);
5248 *pComma = L'\0';
5249
5250 hModule = LoadLibraryExW(pwszExpandedBuffer + 1, NULL, LOAD_LIBRARY_AS_DATAFILE);
5251 if (!hModule || !load_string(hModule, uiStringId, pszOutBuf, cbOutBuf / sizeof(WCHAR)))
5254 }
5255
5256cleanup:
5257 HeapFree(GetProcessHeap(), 0, pwszTempBuffer);
5258 HeapFree(GetProcessHeap(), 0, pwszExpandedBuffer);
5259 return result;
5260}
static int load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cMaxChars)
Definition: reg.c:5126
#define FreeLibrary(x)
Definition: compat.h:748
#define lstrcpynW
Definition: compat.h:738
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:342
#define ERROR_BADKEY
Definition: winerror.h:589

Referenced by RegLoadMUIStringA().

◆ RegNotifyChangeKeyValue()

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

Definition at line 3152 of file reg.c.

3157{
3162
3164 {
3165 return ERROR_INVALID_HANDLE;
3166 }
3167
3168 if ((fAsynchronous != FALSE) && (hEvent == NULL))
3169 {
3171 }
3172
3174 hKey);
3175 if (!NT_SUCCESS(Status))
3176 {
3178 }
3179
3180 /* FIXME: Remote key handles must fail */
3181
3183 hEvent,
3184 0,
3185 0,
3187 dwNotifyFilter,
3188 bWatchSubtree,
3189 0,
3190 0,
3191 fAsynchronous);
3193 {
3195 }
3196
3198
3199 return ErrorCode;
3200}
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 3234 of file reg.c.

3237{
3238 TRACE("RegOpenKeyA hKey 0x%x lpSubKey %s phkResult %p\n",
3239 hKey, lpSubKey, phkResult);
3240
3241 if (!phkResult)
3243
3244 if (!hKey && !lpSubKey)
3245 {
3246 *phkResult = hKey;
3247 return ERROR_SUCCESS;
3248 }
3249
3250 return RegOpenKeyExA(hKey,
3251 lpSubKey,
3252 0,
3254 phkResult);
3255}

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(), 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 3298 of file reg.c.

3304{
3305 UNICODE_STRING SubKeyString;
3307
3308 TRACE("RegOpenKeyExA hKey 0x%x lpSubKey %s ulOptions 0x%x samDesired 0x%x phkResult %p\n",
3309 hKey, lpSubKey, ulOptions, samDesired, phkResult);
3310
3311 if (lpSubKey)
3312 {
3313 if (!RtlCreateUnicodeStringFromAsciiz(&SubKeyString, lpSubKey))
3315 }
3316 else
3317 RtlInitEmptyUnicodeString(&SubKeyString, NULL, 0);
3318
3319 ErrorCode = RegOpenKeyExW(hKey, SubKeyString.Buffer, ulOptions, samDesired, phkResult);
3320
3321 RtlFreeUnicodeString(&SubKeyString);
3322
3323 return ErrorCode;
3324}

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 3333 of file reg.c.

3338{
3340 UNICODE_STRING SubKeyString;
3345 BOOLEAN SubKeyStringAllocated = FALSE;
3346
3347 TRACE("RegOpenKeyExW hKey 0x%x lpSubKey %S ulOptions 0x%x samDesired 0x%x phkResult %p\n",
3348 hKey, lpSubKey, ulOptions, samDesired, phkResult);
3349 if (!phkResult)
3350 {
3352 }
3353
3354 if (!hKey && lpSubKey && phkResult)
3355 {
3356 return ERROR_INVALID_HANDLE;
3357 }
3358
3359 if (IsPredefKey(hKey) && (!lpSubKey || !*lpSubKey))
3360 {
3361 *phkResult = hKey;
3362 return ERROR_SUCCESS;
3363 }
3364
3366 if (!NT_SUCCESS(Status))
3367 {
3369 }
3370
3371 if (IsHKCRKey(KeyHandle))
3372 {
3373 ErrorCode = OpenHKCRKey(KeyHandle, lpSubKey, ulOptions, samDesired, phkResult);
3375 return ErrorCode;
3376 }
3377
3378 if (ulOptions & REG_OPTION_OPEN_LINK)
3380
3381 if (lpSubKey == NULL || wcscmp(lpSubKey, L"\\") == 0)
3382 {
3383 RtlInitUnicodeString(&SubKeyString, L"");
3384 }
3385 else
3386 {
3387 RtlInitUnicodeString(&SubKeyString, lpSubKey);
3388
3389 /* Handle unaligned lpSubKey */
3390 if ((ULONG_PTR)lpSubKey & 1)
3391 {
3392 UNICODE_STRING AlignedString;
3393
3395 &SubKeyString,
3396 &AlignedString);
3397 if (!NT_SUCCESS(Status))
3398 {
3399 goto Exit;
3400 }
3401
3402 SubKeyString = AlignedString;
3403 SubKeyStringAllocated = TRUE;
3404 }
3405 }
3406
3408 &SubKeyString,
3409 Attributes,
3410 KeyHandle,
3411 NULL);
3412
3413 Status = NtOpenKey((PHANDLE)phkResult,
3414 samDesired,
3416
3417Exit:
3418
3419 if (SubKeyStringAllocated)
3420 {
3421 RtlFreeUnicodeString(&SubKeyString);
3422 }
3423
3424 if (!NT_SUCCESS(Status))
3425 {
3427 }
3428
3430
3431 return ErrorCode;
3432}
#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:370
NTSYSAPI NTSTATUS WINAPI RtlDuplicateUnicodeString(int, const UNICODE_STRING *, UNICODE_STRING *)
_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(), 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(), FindExeCplClass(), FindNetworkAdapter(), ForceFriendlyUI(), get_default_proxy_reg_value(), get_fusion_filename(), get_install_root(), get_mono_path_from_registry(), GetActivePwrScheme(), GetAllUsersProfileDirectoryW(), GetAssocClass(), GetAutoDaylight(), GetBooleanRegValue(), GetBootResourceList(), GetClassMediaFile(), CQueryAssociations::GetCommand(), GetComputerNames(), GetCurrentHwProfileW(), GetCurrentUserKey(), GetDefaultPrinterFromRegistry(), GetDefaultPrinterW(), GetDefaultUserProfileDirectoryW(), GetDesktopPath(), CNetConnectionPropertyUi::GetDeviceInstanceID(), GetDeviceInstanceList(), GetDeviceInstanceListSize(), GetDisplayNameFileAndID(), GetEnumeratorInstanceList(), GetEnumeratorInstanceListSize(), GetEnumOptions(), GetEventMessageFileDLL(), 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(), GetSubkeyInfoHelper(), 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(), InstallScreenSaverW(), Int_EnumDependentServicesW(), IntGetIcdData(), IntLoadKeyboardLayout(), IsConsoleBoot(), IsExtensionAShortcut(), IsFriendlyUIActive(), IsInternetESCEnabledLocal(), IsLayoutExists(), IsLiveCD(), IsShowHibernateButtonActive(), IsWindowsOS(), KLIDFromSpecialHKL(), CNetConnectionPropertyUi::LANPropertiesUIDlg(), LayoutList_Create(), load_mapi_providers(), LoadAdvancedSettings(), 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(), OpenKeyboardLayouts(), 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(), RegDeleteKeyValueW(), 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(), SaveAdvancedSettings(), SaveAppSettings(), SaveCurrentLocale(), SaveDefaultUserHive(), SaveGeoID(), SavePropertiesDlg(), SaveSettings(), ScmAssignNewTag(), ScmAutoStartServices(), ScmCopyControlSet(), ScmCreateServiceDatabase(), ScmCreateServiceKey(), ScmDeleteControlSet(), ScmDeleteMarkedServices(), ScmDeleteRegKey(), 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(), SockLoadHelperDll(), SockLoadTransportList(), SockLoadTransportMapping(), SQLGetInstalledDriversW(), START_TEST(), StartScreenSaver(), StartShell(), test4(), test_CallForAttributes(), Test_CreateOpenKey(), Test_DuplicateHandle(), Test_KLID(), 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(), W32TmServiceMain(), 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 3268 of file reg.c.

3271{
3272 TRACE("RegOpenKeyW hKey 0x%x lpSubKey %S phkResult %p\n",
3273 hKey, lpSubKey, phkResult);
3274
3275 if (!phkResult)
3277
3278 if (!hKey && !lpSubKey)
3279 {
3280 *phkResult = hKey;
3281 return ERROR_SUCCESS;
3282 }
3283
3284 return RegOpenKeyExW(hKey,
3285 lpSubKey,
3286 0,
3288 phkResult);
3289}

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(), Imm32IsCUASEnabledInRegistry(), Imm32IsTIMDisabledInRegistry(), 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 3441 of file reg.c.

3445{
3446 const WCHAR UserClassesKeyPrefix[] = L"\\Registry\\User\\";
3447 const WCHAR UserClassesKeySuffix[] = L"_Classes";
3448 PTOKEN_USER TokenUserData;
3450 UNICODE_STRING UserSidString, UserClassesKeyRoot;
3453
3454 /* check parameters */
3455 if (hToken == NULL || dwOptions != 0 || phkResult == NULL)
3456 {
3458 }
3459
3460 /*
3461 * Get the user sid from the token
3462 */
3463
3464ReadTokenSid:
3465 /* determine how much memory we need */
3467 TokenUser,
3468 NULL,
3469 0,
3472 {
3473 /* NOTE - as opposed to all other registry functions windows does indeed
3474 change the last error code in case the caller supplied a invalid
3475 handle for example! */
3477 }
3478 RegInitialize(); /* HACK until delay-loading is implemented */
3479 TokenUserData = RtlAllocateHeap(ProcessHeap,
3480 0,
3482 if (TokenUserData == NULL)
3483 {
3485 }
3486
3487 /* attempt to read the information */
3489 TokenUser,
3490 TokenUserData,
3493 if (!NT_SUCCESS(Status))
3494 {
3496 0,
3497 TokenUserData);
3499 {
3500 /* the information appears to have changed?! try again */
3501 goto ReadTokenSid;
3502 }
3503
3504 /* NOTE - as opposed to all other registry functions windows does indeed
3505 change the last error code in case the caller supplied a invalid
3506 handle for example! */
3508 }
3509
3510 /*
3511 * Build the absolute path for the user's registry in the form
3512 * "\Registry\User<SID>_Classes"
3513 */
3514 Status = RtlConvertSidToUnicodeString(&UserSidString,
3515 TokenUserData->User.Sid,
3516 TRUE);
3517
3518 /* we don't need the user data anymore, free it */
3520 0,
3521 TokenUserData);
3522
3523 if (!NT_SUCCESS(Status))
3524 {
3526 }
3527
3528 /* allocate enough memory for the entire key string */
3529 UserClassesKeyRoot.Length = 0;
3530 UserClassesKeyRoot.MaximumLength = UserSidString.Length +
3531 sizeof(UserClassesKeyPrefix) +
3532 sizeof(UserClassesKeySuffix);
3533 UserClassesKeyRoot.Buffer = RtlAllocateHeap(ProcessHeap,
3534 0,
3535 UserClassesKeyRoot.MaximumLength);
3536 if (UserClassesKeyRoot.Buffer == NULL)
3537 {
3538 RtlFreeUnicodeString(&UserSidString);
3540 }
3541
3542 /* build the string */
3543 RtlAppendUnicodeToString(&UserClassesKeyRoot,
3544 UserClassesKeyPrefix);
3545 RtlAppendUnicodeStringToString(&UserClassesKeyRoot,
3546 &UserSidString);
3547 RtlAppendUnicodeToString(&UserClassesKeyRoot,
3548 UserClassesKeySuffix);
3549
3550 TRACE("RegOpenUserClassesRoot: Absolute path: %wZ\n", &UserClassesKeyRoot);
3551
3552 /*
3553 * Open the key
3554 */
3556 &UserClassesKeyRoot,
3558 NULL,
3559 NULL);
3560
3561 Status = NtOpenKey((PHANDLE)phkResult,
3562 samDesired,
3564
3565 RtlFreeUnicodeString(&UserSidString);
3566 RtlFreeUnicodeString(&UserClassesKeyRoot);
3567
3568 if (!NT_SUCCESS(Status))
3569 {
3571 }
3572
3573 return ERROR_SUCCESS;
3574}
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 366 of file reg.c.

368{
370
371 if ((hKey == HKEY_CLASSES_ROOT ||
376 hKey == HKEY_USERS) &&
377 !IsPredefKey(hNewHKey))
378 {
380 ULONG Index;
381
384
385 if (hNewHKey == NULL)
386 {
387 /* restore the default mapping */
389 &hNewHKey);
390 if (!NT_SUCCESS(Status))
391 {
393 }
394
395 ASSERT(hNewHKey != NULL);
396 }
397 RegInitialize(); /* HACK until delay-loading is implemented */
399
400 /* close the currently mapped handle if existing */
401 if (*Handle != NULL)
402 {
403 NtClose(*Handle);
404 }
405
406 /* update the mapping */
407 *Handle = hNewHKey;
408
410 }
411 else