1999-11-23 20:41:34 +01:00
|
|
|
/*
|
|
|
|
* Registry management
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999 Alexandre Julliard
|
2018-07-11 06:16:07 +02:00
|
|
|
* Copyright (C) 2017 Dmitry Timoshkov
|
1999-11-23 20:41:34 +01:00
|
|
|
*
|
|
|
|
* Based on misc/registry.c code
|
|
|
|
* Copyright (C) 1996 Marcus Meissner
|
|
|
|
* Copyright (C) 1998 Matthew Becker
|
|
|
|
* Copyright (C) 1999 Sylvain St-Germain
|
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-11-23 20:41:34 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-02-10 23:15:21 +01:00
|
|
|
#include <stdio.h>
|
1999-11-23 20:41:34 +01:00
|
|
|
|
2005-11-28 17:32:54 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
1999-11-23 20:41:34 +01:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winerror.h"
|
2005-05-16 16:08:11 +02:00
|
|
|
#include "winternl.h"
|
|
|
|
|
2000-08-14 16:41:19 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2019-05-26 14:15:11 +02:00
|
|
|
#include "wine/list.h"
|
1999-11-23 20:41:34 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(reg);
|
1999-11-23 20:41:34 +01:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
NTSTATUS WINAPI RemapPredefinedHandleInternal( HKEY hkey, HKEY override );
|
|
|
|
NTSTATUS WINAPI DisablePredefinedHandleTableInternal( HKEY hkey );
|
2002-09-13 23:42:28 +02:00
|
|
|
|
2002-05-09 21:39:10 +02:00
|
|
|
|
2008-03-11 19:48:57 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* RegOverridePredefKey [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
LSTATUS WINAPI RegOverridePredefKey( HKEY hkey, HKEY override )
|
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
return RtlNtStatusToDosError( RemapPredefinedHandleInternal( hkey, override ));
|
1999-11-23 20:41:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2004-07-14 01:33:14 +02:00
|
|
|
* RegCreateKeyW [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* Creates the specified reg key.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hKey [I] Handle to an open key.
|
|
|
|
* lpSubKey [I] Name of a key that will be opened or created.
|
|
|
|
* phkResult [O] Receives a handle to the opened or created key.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS
|
|
|
|
* Failure: nonzero error code defined in Winerror.h
|
1999-11-23 20:41:34 +01:00
|
|
|
*/
|
2007-09-18 00:40:48 +02:00
|
|
|
LSTATUS WINAPI RegCreateKeyW( HKEY hkey, LPCWSTR lpSubKey, PHKEY phkResult )
|
1999-11-23 20:41:34 +01:00
|
|
|
{
|
2004-07-14 01:33:14 +02:00
|
|
|
return RegCreateKeyExW( hkey, lpSubKey, 0, NULL, REG_OPTION_NON_VOLATILE,
|
2009-12-04 16:07:27 +01:00
|
|
|
MAXIMUM_ALLOWED, NULL, phkResult, NULL );
|
1999-11-23 20:41:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2004-07-14 01:33:14 +02:00
|
|
|
* RegCreateKeyA [ADVAPI32.@]
|
|
|
|
*
|
2005-11-04 12:43:27 +01:00
|
|
|
* See RegCreateKeyW.
|
1999-11-23 20:41:34 +01:00
|
|
|
*/
|
2007-09-18 00:40:48 +02:00
|
|
|
LSTATUS WINAPI RegCreateKeyA( HKEY hkey, LPCSTR lpSubKey, PHKEY phkResult )
|
1999-11-23 20:41:34 +01:00
|
|
|
{
|
2004-07-14 01:33:14 +02:00
|
|
|
return RegCreateKeyExA( hkey, lpSubKey, 0, NULL, REG_OPTION_NON_VOLATILE,
|
2009-12-04 16:07:27 +01:00
|
|
|
MAXIMUM_ALLOWED, NULL, phkResult, NULL );
|
1999-11-23 20:41:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-23 17:18:38 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* RegCreateKeyTransactedW [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
LSTATUS WINAPI RegCreateKeyTransactedW( HKEY hkey, LPCWSTR name, DWORD reserved, LPWSTR class,
|
|
|
|
DWORD options, REGSAM access, SECURITY_ATTRIBUTES *sa,
|
|
|
|
PHKEY retkey, LPDWORD dispos, HANDLE transaction, PVOID reserved2 )
|
|
|
|
{
|
|
|
|
FIXME( "(%p,%s,%u,%s,%u,%u,%p,%p,%p,%p,%p): stub\n", hkey, debugstr_w(name), reserved,
|
|
|
|
debugstr_w(class), options, access, sa, retkey, dispos, transaction, reserved2 );
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RegCreateKeyTransactedA [ADVAPI32.@]
|
|
|
|
*/
|
|
|
|
LSTATUS WINAPI RegCreateKeyTransactedA( HKEY hkey, LPCSTR name, DWORD reserved, LPSTR class,
|
|
|
|
DWORD options, REGSAM access, SECURITY_ATTRIBUTES *sa,
|
|
|
|
PHKEY retkey, LPDWORD dispos, HANDLE transaction, PVOID reserved2 )
|
|
|
|
{
|
|
|
|
FIXME( "(%p,%s,%u,%s,%u,%u,%p,%p,%p,%p,%p): stub\n", hkey, debugstr_a(name), reserved,
|
|
|
|
debugstr_a(class), options, access, sa, retkey, dispos, transaction, reserved2 );
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1999-11-23 20:41:34 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
2004-07-14 01:33:14 +02:00
|
|
|
* RegOpenKeyW [ADVAPI32.@]
|
1999-11-23 20:41:34 +01:00
|
|
|
*
|
2004-04-23 23:32:34 +02:00
|
|
|
* See RegOpenKeyA.
|
1999-11-23 20:41:34 +01:00
|
|
|
*/
|
2007-09-18 00:40:48 +02:00
|
|
|
LSTATUS WINAPI RegOpenKeyW( HKEY hkey, LPCWSTR name, PHKEY retkey )
|
1999-11-23 20:41:34 +01:00
|
|
|
{
|
2009-06-28 20:40:04 +02:00
|
|
|
if (!retkey)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2005-02-25 17:52:10 +01:00
|
|
|
if (!name || !*name)
|
|
|
|
{
|
|
|
|
*retkey = hkey;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2009-12-04 16:07:27 +01:00
|
|
|
return RegOpenKeyExW( hkey, name, 0, MAXIMUM_ALLOWED, retkey );
|
1999-11-23 20:41:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2004-07-14 01:33:14 +02:00
|
|
|
* RegOpenKeyA [ADVAPI32.@]
|
2019-06-25 12:34:15 +02:00
|
|
|
*
|
2004-04-23 23:32:34 +02:00
|
|
|
* Open a registry key.
|
|
|
|
*
|
|
|
|
* PARAMS
|
2004-07-14 01:33:14 +02:00
|
|
|
* hkey [I] Handle of parent key to open the new key under
|
|
|
|
* name [I] Name of the key under hkey to open
|
|
|
|
* retkey [O] Destination for the resulting Handle
|
2004-04-23 23:32:34 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2004-07-14 01:33:14 +02:00
|
|
|
* Success: ERROR_SUCCESS
|
2009-06-28 20:40:04 +02:00
|
|
|
* Failure: A standard Win32 error code. When retkey is valid, *retkey is set to 0.
|
1999-11-23 20:41:34 +01:00
|
|
|
*/
|
2007-09-18 00:40:48 +02:00
|
|
|
LSTATUS WINAPI RegOpenKeyA( HKEY hkey, LPCSTR name, PHKEY retkey )
|
1999-11-23 20:41:34 +01:00
|
|
|
{
|
2009-06-28 20:40:04 +02:00
|
|
|
if (!retkey)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2005-02-25 17:52:10 +01:00
|
|
|
if (!name || !*name)
|
|
|
|
{
|
|
|
|
*retkey = hkey;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2009-12-04 16:07:27 +01:00
|
|
|
return RegOpenKeyExA( hkey, name, 0, MAXIMUM_ALLOWED, retkey );
|
1999-11-23 20:41:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-29 02:24:54 +01:00
|
|
|
/******************************************************************************
|
2019-06-25 12:34:15 +02:00
|
|
|
* RegEnumKeyW [ADVAPI32.@]
|
2005-11-12 20:12:03 +01:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* Enumerates subkeys of the specified open reg key.
|
2005-11-12 20:12:03 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
2019-06-25 12:34:15 +02:00
|
|
|
* hKey [I] Handle to an open key.
|
|
|
|
* dwIndex [I] Index of the subkey of hKey to retrieve.
|
|
|
|
* lpName [O] Name of the subkey.
|
|
|
|
* cchName [I] Size of lpName in TCHARS.
|
2005-11-12 20:12:03 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS
|
2019-06-25 12:34:15 +02:00
|
|
|
* Failure: system error code. If there are no more subkeys available, the
|
|
|
|
* function returns ERROR_NO_MORE_ITEMS.
|
2000-10-29 02:24:54 +01:00
|
|
|
*/
|
2019-06-25 12:34:15 +02:00
|
|
|
LSTATUS WINAPI RegEnumKeyW( HKEY hkey, DWORD index, LPWSTR name, DWORD name_len )
|
2000-10-29 02:24:54 +01:00
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
return RegEnumKeyExW( hkey, index, name, &name_len, NULL, NULL, NULL, NULL );
|
|
|
|
}
|
2015-12-27 23:18:00 +01:00
|
|
|
|
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* RegEnumKeyA [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* See RegEnumKeyW.
|
|
|
|
*/
|
|
|
|
LSTATUS WINAPI RegEnumKeyA( HKEY hkey, DWORD index, LPSTR name, DWORD name_len )
|
|
|
|
{
|
|
|
|
return RegEnumKeyExA( hkey, index, name, &name_len, NULL, NULL, NULL, NULL );
|
2000-10-29 02:24:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-23 20:41:34 +01:00
|
|
|
/******************************************************************************
|
2019-06-25 12:34:15 +02:00
|
|
|
* RegQueryMultipleValuesA [ADVAPI32.@]
|
1999-11-23 20:41:34 +01:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* Retrieves the type and data for a list of value names associated with a key.
|
2005-11-12 20:12:03 +01:00
|
|
|
*
|
1999-11-23 20:41:34 +01:00
|
|
|
* PARAMS
|
2019-06-25 12:34:15 +02:00
|
|
|
* hKey [I] Handle to an open key.
|
|
|
|
* val_list [O] Array of VALENT structures that describes the entries.
|
|
|
|
* num_vals [I] Number of elements in val_list.
|
|
|
|
* lpValueBuf [O] Pointer to a buffer that receives the data for each value.
|
|
|
|
* ldwTotsize [I/O] Size of lpValueBuf.
|
2004-07-14 01:33:14 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2019-06-25 12:34:15 +02:00
|
|
|
* Success: ERROR_SUCCESS. ldwTotsize contains num bytes copied.
|
|
|
|
* Failure: nonzero error code from Winerror.h ldwTotsize contains num needed
|
|
|
|
* bytes.
|
1999-11-23 20:41:34 +01:00
|
|
|
*/
|
2019-06-25 12:34:15 +02:00
|
|
|
LSTATUS WINAPI RegQueryMultipleValuesA( HKEY hkey, PVALENTA val_list, DWORD num_vals,
|
|
|
|
LPSTR lpValueBuf, LPDWORD ldwTotsize )
|
1999-11-23 20:41:34 +01:00
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
unsigned int i;
|
|
|
|
DWORD maxBytes = *ldwTotsize;
|
|
|
|
LSTATUS status;
|
|
|
|
LPSTR bufptr = lpValueBuf;
|
|
|
|
*ldwTotsize = 0;
|
1999-11-23 20:41:34 +01:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
TRACE("(%p,%p,%d,%p,%p=%d)\n", hkey, val_list, num_vals, lpValueBuf, ldwTotsize, *ldwTotsize);
|
1999-11-23 20:41:34 +01:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
for(i=0; i < num_vals; ++i)
|
1999-11-23 20:41:34 +01:00
|
|
|
{
|
2000-10-02 05:46:58 +02:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
val_list[i].ve_valuelen=0;
|
|
|
|
status = RegQueryValueExA(hkey, val_list[i].ve_valuename, NULL, NULL, NULL, &val_list[i].ve_valuelen);
|
|
|
|
if(status != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
return status;
|
|
|
|
}
|
2000-10-02 05:46:58 +02:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
if(lpValueBuf != NULL && *ldwTotsize + val_list[i].ve_valuelen <= maxBytes)
|
2000-10-02 05:46:58 +02:00
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
status = RegQueryValueExA(hkey, val_list[i].ve_valuename, NULL, &val_list[i].ve_type,
|
|
|
|
(LPBYTE)bufptr, &val_list[i].ve_valuelen);
|
|
|
|
if(status != ERROR_SUCCESS)
|
2000-10-02 05:46:58 +02:00
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
return status;
|
2000-10-02 05:46:58 +02:00
|
|
|
}
|
2019-06-25 12:34:15 +02:00
|
|
|
|
|
|
|
val_list[i].ve_valueptr = (DWORD_PTR)bufptr;
|
|
|
|
|
|
|
|
bufptr += val_list[i].ve_valuelen;
|
2000-10-02 05:46:58 +02:00
|
|
|
}
|
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
*ldwTotsize += val_list[i].ve_valuelen;
|
|
|
|
}
|
|
|
|
return lpValueBuf != NULL && *ldwTotsize <= maxBytes ? ERROR_SUCCESS : ERROR_MORE_DATA;
|
1999-11-23 20:41:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2019-06-25 12:34:15 +02:00
|
|
|
* RegQueryMultipleValuesW [ADVAPI32.@]
|
2004-07-14 01:33:14 +02:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* See RegQueryMultipleValuesA.
|
1999-11-23 20:41:34 +01:00
|
|
|
*/
|
2019-06-25 12:34:15 +02:00
|
|
|
LSTATUS WINAPI RegQueryMultipleValuesW( HKEY hkey, PVALENTW val_list, DWORD num_vals,
|
|
|
|
LPWSTR lpValueBuf, LPDWORD ldwTotsize )
|
1999-11-23 20:41:34 +01:00
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
unsigned int i;
|
|
|
|
DWORD maxBytes = *ldwTotsize;
|
|
|
|
LSTATUS status;
|
|
|
|
LPSTR bufptr = (LPSTR)lpValueBuf;
|
|
|
|
*ldwTotsize = 0;
|
2002-07-05 03:21:13 +02:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
TRACE("(%p,%p,%d,%p,%p=%d)\n", hkey, val_list, num_vals, lpValueBuf, ldwTotsize, *ldwTotsize);
|
1999-11-23 20:41:34 +01:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
for(i=0; i < num_vals; ++i)
|
2002-07-20 22:02:55 +02:00
|
|
|
{
|
|
|
|
val_list[i].ve_valuelen=0;
|
|
|
|
status = RegQueryValueExW(hkey, val_list[i].ve_valuename, NULL, NULL, NULL, &val_list[i].ve_valuelen);
|
|
|
|
if(status != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
if(lpValueBuf != NULL && *ldwTotsize + val_list[i].ve_valuelen <= maxBytes)
|
|
|
|
{
|
|
|
|
status = RegQueryValueExW(hkey, val_list[i].ve_valuename, NULL, &val_list[i].ve_type,
|
|
|
|
(LPBYTE)bufptr, &val_list[i].ve_valuelen);
|
|
|
|
if(status != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
return status;
|
|
|
|
}
|
2014-06-28 18:15:47 +02:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
val_list[i].ve_valueptr = (DWORD_PTR)bufptr;
|
2014-06-28 18:15:47 +02:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
bufptr += val_list[i].ve_valuelen;
|
|
|
|
}
|
2014-06-28 18:15:47 +02:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
*ldwTotsize += val_list[i].ve_valuelen;
|
2014-06-28 18:15:47 +02:00
|
|
|
}
|
2019-06-25 12:34:15 +02:00
|
|
|
return lpValueBuf != NULL && *ldwTotsize <= maxBytes ? ERROR_SUCCESS : ERROR_MORE_DATA;
|
2014-06-28 18:15:47 +02:00
|
|
|
}
|
|
|
|
|
1999-11-23 20:41:34 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
2019-06-25 12:34:15 +02:00
|
|
|
* RegQueryReflectionKey [ADVAPI32.@]
|
1999-11-23 20:41:34 +01:00
|
|
|
*/
|
2019-06-25 12:34:15 +02:00
|
|
|
LONG WINAPI RegQueryReflectionKey( HKEY hkey, BOOL *is_reflection_disabled )
|
1999-11-23 20:41:34 +01:00
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
FIXME( "%p, %p stub\n", hkey, is_reflection_disabled );
|
|
|
|
*is_reflection_disabled = TRUE;
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
1999-11-23 20:41:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2019-06-25 12:34:15 +02:00
|
|
|
* RegDeleteKeyW [ADVAPI32.@]
|
2004-07-14 01:33:14 +02:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* See RegDeleteKeyA.
|
1999-11-23 20:41:34 +01:00
|
|
|
*/
|
2019-06-25 12:34:15 +02:00
|
|
|
LSTATUS WINAPI RegDeleteKeyW( HKEY hkey, LPCWSTR name )
|
1999-11-23 20:41:34 +01:00
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
return RegDeleteKeyExW( hkey, name, 0, 0 );
|
1999-11-23 20:41:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2019-06-25 12:34:15 +02:00
|
|
|
* RegDeleteKeyA [ADVAPI32.@]
|
1999-11-23 20:41:34 +01:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* Delete a registry key.
|
2005-11-12 20:12:03 +01:00
|
|
|
*
|
1999-11-23 20:41:34 +01:00
|
|
|
* PARAMS
|
2019-06-25 12:34:15 +02:00
|
|
|
* hkey [I] Handle to parent key containing the key to delete
|
|
|
|
* name [I] Name of the key user hkey to delete
|
2004-07-14 01:33:14 +02:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* NOTES
|
2004-07-14 01:33:14 +02:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* MSDN is wrong when it says that hkey must be opened with the DELETE access
|
|
|
|
* right. In reality, it opens a new handle with DELETE access.
|
2017-04-13 18:00:22 +02:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS
|
|
|
|
* Failure: Error code
|
2017-04-13 18:00:22 +02:00
|
|
|
*/
|
2019-06-25 12:34:15 +02:00
|
|
|
LSTATUS WINAPI RegDeleteKeyA( HKEY hkey, LPCSTR name )
|
2017-04-13 18:00:22 +02:00
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
return RegDeleteKeyExA( hkey, name, 0, 0 );
|
2017-04-13 18:00:22 +02:00
|
|
|
}
|
|
|
|
|
2000-11-30 21:31:41 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
2019-06-25 12:34:15 +02:00
|
|
|
* RegSetValueW [ADVAPI32.@]
|
2000-11-30 21:31:41 +01:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* Sets the data for the default or unnamed value of a reg key.
|
2005-11-12 20:12:03 +01:00
|
|
|
*
|
2000-11-30 21:31:41 +01:00
|
|
|
* PARAMS
|
2019-06-25 12:34:15 +02:00
|
|
|
* hkey [I] Handle to an open key.
|
|
|
|
* subkey [I] Name of a subkey of hKey.
|
|
|
|
* type [I] Type of information to store.
|
|
|
|
* data [I] String that contains the data to set for the default value.
|
|
|
|
* count [I] Ignored.
|
2004-07-14 01:33:14 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS
|
|
|
|
* Failure: nonzero error code from Winerror.h
|
2000-11-30 21:31:41 +01:00
|
|
|
*/
|
2019-06-25 12:34:15 +02:00
|
|
|
LSTATUS WINAPI RegSetValueW( HKEY hkey, LPCWSTR subkey, DWORD type, LPCWSTR data, DWORD count )
|
2000-11-30 21:31:41 +01:00
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
TRACE("(%p,%s,%d,%s,%d)\n", hkey, debugstr_w(subkey), type, debugstr_w(data), count );
|
2000-11-30 21:31:41 +01:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
if (type != REG_SZ || !data) return ERROR_INVALID_PARAMETER;
|
2000-11-30 21:31:41 +01:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
return RegSetKeyValueW( hkey, subkey, NULL, type, data, (strlenW(data) + 1)*sizeof(WCHAR) );
|
2000-11-30 21:31:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2019-06-25 12:34:15 +02:00
|
|
|
* RegSetValueA [ADVAPI32.@]
|
2004-07-14 01:33:14 +02:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* See RegSetValueW.
|
2000-11-30 21:31:41 +01:00
|
|
|
*/
|
2019-06-25 12:34:15 +02:00
|
|
|
LSTATUS WINAPI RegSetValueA( HKEY hkey, LPCSTR subkey, DWORD type, LPCSTR data, DWORD count )
|
2000-11-30 21:31:41 +01:00
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
TRACE("(%p,%s,%d,%s,%d)\n", hkey, debugstr_a(subkey), type, debugstr_a(data), count );
|
2003-01-21 00:23:12 +01:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
if (type != REG_SZ || !data) return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
return RegSetKeyValueA( hkey, subkey, NULL, type, data, strlen(data) + 1 );
|
2000-11-30 21:31:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2019-06-25 12:34:15 +02:00
|
|
|
* RegQueryValueW [ADVAPI32.@]
|
2000-11-30 21:31:41 +01:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* Retrieves the data associated with the default or unnamed value of a key.
|
2005-11-12 20:12:03 +01:00
|
|
|
*
|
2000-11-30 21:31:41 +01:00
|
|
|
* PARAMS
|
2019-06-25 12:34:15 +02:00
|
|
|
* hkey [I] Handle to an open key.
|
|
|
|
* name [I] Name of the subkey of hKey.
|
|
|
|
* data [O] Receives the string associated with the default value
|
|
|
|
* of the key.
|
|
|
|
* count [I/O] Size of lpValue in bytes.
|
2004-07-14 01:33:14 +02:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS
|
|
|
|
* Failure: nonzero error code from Winerror.h
|
2000-11-30 21:31:41 +01:00
|
|
|
*/
|
2019-06-25 12:34:15 +02:00
|
|
|
LSTATUS WINAPI RegQueryValueW( HKEY hkey, LPCWSTR name, LPWSTR data, LPLONG count )
|
2000-11-30 21:31:41 +01:00
|
|
|
{
|
2003-08-19 05:08:17 +02:00
|
|
|
DWORD ret;
|
2019-06-25 12:34:15 +02:00
|
|
|
HKEY subkey = hkey;
|
2005-03-30 12:21:15 +02:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
TRACE("(%p,%s,%p,%d)\n", hkey, debugstr_w(name), data, count ? *count : 0 );
|
2003-08-19 05:08:17 +02:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
if (name && name[0])
|
|
|
|
{
|
|
|
|
if ((ret = RegOpenKeyW( hkey, name, &subkey )) != ERROR_SUCCESS) return ret;
|
|
|
|
}
|
|
|
|
ret = RegQueryValueExW( subkey, NULL, NULL, NULL, (LPBYTE)data, (LPDWORD)count );
|
|
|
|
if (subkey != hkey) RegCloseKey( subkey );
|
|
|
|
if (ret == ERROR_FILE_NOT_FOUND)
|
|
|
|
{
|
|
|
|
/* return empty string if default value not found */
|
|
|
|
if (data) *data = 0;
|
|
|
|
if (count) *count = sizeof(WCHAR);
|
|
|
|
ret = ERROR_SUCCESS;
|
|
|
|
}
|
2003-08-19 05:08:17 +02:00
|
|
|
return ret;
|
2000-11-30 21:31:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2019-06-25 12:34:15 +02:00
|
|
|
* RegQueryValueA [ADVAPI32.@]
|
2004-07-14 01:33:14 +02:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* See RegQueryValueW.
|
2000-11-30 21:31:41 +01:00
|
|
|
*/
|
2019-06-25 12:34:15 +02:00
|
|
|
LSTATUS WINAPI RegQueryValueA( HKEY hkey, LPCSTR name, LPSTR data, LPLONG count )
|
2000-11-30 21:31:41 +01:00
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
DWORD ret;
|
|
|
|
HKEY subkey = hkey;
|
2003-01-21 00:23:12 +01:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
TRACE("(%p,%s,%p,%d)\n", hkey, debugstr_a(name), data, count ? *count : 0 );
|
|
|
|
|
|
|
|
if (name && name[0])
|
|
|
|
{
|
|
|
|
if ((ret = RegOpenKeyA( hkey, name, &subkey )) != ERROR_SUCCESS) return ret;
|
|
|
|
}
|
|
|
|
ret = RegQueryValueExA( subkey, NULL, NULL, NULL, (LPBYTE)data, (LPDWORD)count );
|
|
|
|
if (subkey != hkey) RegCloseKey( subkey );
|
|
|
|
if (ret == ERROR_FILE_NOT_FOUND)
|
|
|
|
{
|
|
|
|
/* return empty string if default value not found */
|
|
|
|
if (data) *data = 0;
|
|
|
|
if (count) *count = 1;
|
|
|
|
ret = ERROR_SUCCESS;
|
|
|
|
}
|
2000-11-30 21:31:41 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2019-06-25 12:34:15 +02:00
|
|
|
* RegSaveKeyW [ADVAPI32.@]
|
2000-11-30 21:31:41 +01:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* Save a key and all of its subkeys and values to a new file in the standard format.
|
2005-11-12 20:12:03 +01:00
|
|
|
*
|
2000-11-30 21:31:41 +01:00
|
|
|
* PARAMS
|
2019-06-25 12:34:15 +02:00
|
|
|
* hkey [I] Handle of key where save begins
|
|
|
|
* lpFile [I] Address of filename to save to
|
|
|
|
* sa [I] Address of security structure
|
2004-07-14 01:33:14 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS
|
|
|
|
* Failure: nonzero error code from Winerror.h
|
2000-11-30 21:31:41 +01:00
|
|
|
*/
|
2019-06-25 12:34:15 +02:00
|
|
|
LSTATUS WINAPI RegSaveKeyW( HKEY hkey, LPCWSTR file, LPSECURITY_ATTRIBUTES sa )
|
2000-11-30 21:31:41 +01:00
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
return RegSaveKeyExW(hkey, file, sa, 0);
|
2000-11-30 21:31:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2019-06-25 12:34:15 +02:00
|
|
|
* RegSaveKeyA [ADVAPI32.@]
|
2004-07-14 01:33:14 +02:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* See RegSaveKeyW.
|
2000-11-30 21:31:41 +01:00
|
|
|
*/
|
2019-06-25 12:34:15 +02:00
|
|
|
LSTATUS WINAPI RegSaveKeyA( HKEY hkey, LPCSTR file, LPSECURITY_ATTRIBUTES sa )
|
|
|
|
{
|
|
|
|
return RegSaveKeyExA(hkey, file, sa, 0);
|
2000-11-30 21:31:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2019-06-25 12:34:15 +02:00
|
|
|
* RegReplaceKeyW [ADVAPI32.@]
|
2004-04-23 23:32:34 +02:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* Replace the file backing a registry key and all its subkeys with another file.
|
2000-11-30 21:31:41 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
2019-06-25 12:34:15 +02:00
|
|
|
* hkey [I] Handle of open key
|
|
|
|
* lpSubKey [I] Address of name of subkey
|
|
|
|
* lpNewFile [I] Address of filename for file with new data
|
|
|
|
* lpOldFile [I] Address of filename for backup file
|
2000-11-30 21:31:41 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
2004-07-14 01:33:14 +02:00
|
|
|
* Success: ERROR_SUCCESS
|
2019-06-25 12:34:15 +02:00
|
|
|
* Failure: nonzero error code from Winerror.h
|
2000-11-30 21:31:41 +01:00
|
|
|
*/
|
2019-06-25 12:34:15 +02:00
|
|
|
LSTATUS WINAPI RegReplaceKeyW( HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpNewFile,
|
|
|
|
LPCWSTR lpOldFile )
|
2000-11-30 21:31:41 +01:00
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
FIXME("(%p,%s,%s,%s): stub\n", hkey, debugstr_w(lpSubKey),
|
|
|
|
debugstr_w(lpNewFile),debugstr_w(lpOldFile));
|
|
|
|
return ERROR_SUCCESS;
|
2000-11-30 21:31:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-02 01:34:44 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* RegRenameKey [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
LSTATUS WINAPI RegRenameKey( HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpNewName )
|
|
|
|
{
|
|
|
|
FIXME("(%p,%s,%s): stub\n", hkey, debugstr_w(lpSubKey), debugstr_w(lpNewName));
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-30 21:31:41 +01:00
|
|
|
/******************************************************************************
|
2019-06-25 12:34:15 +02:00
|
|
|
* RegReplaceKeyA [ADVAPI32.@]
|
2000-11-30 21:31:41 +01:00
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* See RegReplaceKeyW.
|
2000-11-30 21:31:41 +01:00
|
|
|
*/
|
2019-06-25 12:34:15 +02:00
|
|
|
LSTATUS WINAPI RegReplaceKeyA( HKEY hkey, LPCSTR lpSubKey, LPCSTR lpNewFile,
|
|
|
|
LPCSTR lpOldFile )
|
2000-11-30 21:31:41 +01:00
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
UNICODE_STRING lpSubKeyW;
|
|
|
|
UNICODE_STRING lpNewFileW;
|
|
|
|
UNICODE_STRING lpOldFileW;
|
|
|
|
LONG ret;
|
2004-01-03 01:38:30 +01:00
|
|
|
|
2019-06-25 12:34:15 +02:00
|
|
|
RtlCreateUnicodeStringFromAsciiz( &lpSubKeyW, lpSubKey );
|
|
|
|
RtlCreateUnicodeStringFromAsciiz( &lpOldFileW, lpOldFile );
|
|
|
|
RtlCreateUnicodeStringFromAsciiz( &lpNewFileW, lpNewFile );
|
|
|
|
ret = RegReplaceKeyW( hkey, lpSubKeyW.Buffer, lpNewFileW.Buffer, lpOldFileW.Buffer );
|
|
|
|
RtlFreeUnicodeString( &lpOldFileW );
|
|
|
|
RtlFreeUnicodeString( &lpNewFileW );
|
|
|
|
RtlFreeUnicodeString( &lpSubKeyW );
|
|
|
|
return ret;
|
2000-11-30 21:31:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* RegConnectRegistryW [ADVAPI32.@]
|
2000-11-30 21:31:41 +01:00
|
|
|
*
|
2007-04-07 01:46:59 +02:00
|
|
|
* Establish a connection to a predefined registry key on another computer.
|
2005-11-12 20:12:03 +01:00
|
|
|
*
|
2000-11-30 21:31:41 +01:00
|
|
|
* PARAMS
|
2004-07-14 01:33:14 +02:00
|
|
|
* lpMachineName [I] Address of name of remote computer
|
|
|
|
* hHey [I] Predefined registry handle
|
|
|
|
* phkResult [I] Address of buffer for remote registry handle
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS
|
|
|
|
* Failure: nonzero error code from Winerror.h
|
2000-11-30 21:31:41 +01:00
|
|
|
*/
|
2007-09-18 00:40:48 +02:00
|
|
|
LSTATUS WINAPI RegConnectRegistryW( LPCWSTR lpMachineName, HKEY hKey,
|
2019-06-25 12:34:15 +02:00
|
|
|
PHKEY phkResult )
|
2000-11-30 21:31:41 +01:00
|
|
|
{
|
2004-03-18 02:34:23 +01:00
|
|
|
LONG ret;
|
|
|
|
|
2012-06-26 23:38:13 +02:00
|
|
|
TRACE("(%s,%p,%p)\n",debugstr_w(lpMachineName), hKey, phkResult);
|
2000-11-30 21:31:41 +01:00
|
|
|
|
|
|
|
if (!lpMachineName || !*lpMachineName) {
|
|
|
|
/* Use the local machine name */
|
2004-03-18 02:34:23 +01:00
|
|
|
ret = RegOpenKeyW( hKey, NULL, phkResult );
|
2000-11-30 21:31:41 +01:00
|
|
|
}
|
2005-09-15 11:31:05 +02:00
|
|
|
else {
|
2004-03-18 02:34:23 +01:00
|
|
|
WCHAR compName[MAX_COMPUTERNAME_LENGTH + 1];
|
2018-03-29 17:14:15 +02:00
|
|
|
DWORD len = ARRAY_SIZE( compName );
|
2000-11-30 21:31:41 +01:00
|
|
|
|
2005-09-15 11:31:05 +02:00
|
|
|
/* MSDN says lpMachineName must start with \\ : not so */
|
|
|
|
if( lpMachineName[0] == '\\' && lpMachineName[1] == '\\')
|
|
|
|
lpMachineName += 2;
|
2004-03-18 02:34:23 +01:00
|
|
|
if (GetComputerNameW(compName, &len))
|
|
|
|
{
|
2005-09-15 11:31:05 +02:00
|
|
|
if (!strcmpiW(lpMachineName, compName))
|
2004-03-18 02:34:23 +01:00
|
|
|
ret = RegOpenKeyW(hKey, NULL, phkResult);
|
|
|
|
else
|
|
|
|
{
|
2005-09-15 11:31:05 +02:00
|
|
|
FIXME("Connect to %s is not supported.\n",debugstr_w(lpMachineName));
|
2004-03-18 02:34:23 +01:00
|
|
|
ret = ERROR_BAD_NETPATH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = GetLastError();
|
|
|
|
}
|
|
|
|
return ret;
|
2000-11-30 21:31:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-02-15 00:11:17 +01:00
|
|
|
* RegConnectRegistryA [ADVAPI32.@]
|
2004-07-14 01:33:14 +02:00
|
|
|
*
|
2005-11-04 12:43:27 +01:00
|
|
|
* See RegConnectRegistryW.
|
2000-11-30 21:31:41 +01:00
|
|
|
*/
|
2007-09-18 00:40:48 +02:00
|
|
|
LSTATUS WINAPI RegConnectRegistryA( LPCSTR machine, HKEY hkey, PHKEY reskey )
|
2000-11-30 21:31:41 +01:00
|
|
|
{
|
2003-01-21 00:23:12 +01:00
|
|
|
UNICODE_STRING machineW;
|
|
|
|
LONG ret;
|
|
|
|
|
|
|
|
RtlCreateUnicodeStringFromAsciiz( &machineW, machine );
|
|
|
|
ret = RegConnectRegistryW( machineW.Buffer, hkey, reskey );
|
|
|
|
RtlFreeUnicodeString( &machineW );
|
2000-11-30 21:31:41 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-30 12:06:48 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* RegDisablePredefinedCache [ADVAPI32.@]
|
|
|
|
*
|
2019-06-25 12:34:15 +02:00
|
|
|
* Disables the caching of the HKEY_CURRENT_USER key for the process.
|
2006-06-30 12:06:48 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: ERROR_SUCCESS
|
|
|
|
* Failure: nonzero error code from Winerror.h
|
2019-06-25 12:34:15 +02:00
|
|
|
*
|
2006-06-30 12:06:48 +02:00
|
|
|
* NOTES
|
|
|
|
* This is useful for services that use impersonation.
|
|
|
|
*/
|
2007-09-18 00:40:48 +02:00
|
|
|
LSTATUS WINAPI RegDisablePredefinedCache(void)
|
2006-06-30 12:06:48 +02:00
|
|
|
{
|
2019-06-25 12:34:15 +02:00
|
|
|
return RtlNtStatusToDosError( DisablePredefinedHandleTableInternal( HKEY_CURRENT_USER ));
|
2016-02-26 17:00:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RegCopyTreeA [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
LONG WINAPI RegCopyTreeA( HKEY hsrc, const char *subkey, HKEY hdst )
|
|
|
|
{
|
|
|
|
UNICODE_STRING subkeyW;
|
|
|
|
LONG ret;
|
|
|
|
|
|
|
|
if (subkey) RtlCreateUnicodeStringFromAsciiz( &subkeyW, subkey );
|
|
|
|
else subkeyW.Buffer = NULL;
|
|
|
|
ret = RegCopyTreeW( hsrc, subkeyW.Buffer, hdst );
|
|
|
|
RtlFreeUnicodeString( &subkeyW );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-10 04:55:58 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* RegEnableReflectionKey [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
LONG WINAPI RegEnableReflectionKey(HKEY base)
|
|
|
|
{
|
|
|
|
FIXME("%p: stub\n", base);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-04 04:54:14 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* RegDisableReflectionKey [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
LONG WINAPI RegDisableReflectionKey(HKEY base)
|
|
|
|
{
|
|
|
|
FIXME("%p: stub\n", base);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|