/* INCLUDES *****************************************************************/
-#include "advapi32.h"
+#include <advapi32.h>
#define NDEBUG
-#include <debug.h>
+#include <wine/debug.h>
/* DEFINES ******************************************************************/
BOOL
RegInitialize (VOID)
{
- DPRINT("RegInitialize()\n");
+ TRACE("RegInitialize()\n");
ProcessHeap = RtlGetProcessHeap();
RtlZeroMemory (DefaultHandleTable,
BOOL
RegCleanup (VOID)
{
- DPRINT("RegCleanup()\n");
+ TRACE("RegCleanup()\n");
CloseDefaultKeys ();
RtlDeleteCriticalSection (&HandleTableCS);
ULONG Index;
NTSTATUS Status = STATUS_SUCCESS;
- DPRINT("MapDefaultKey (Key %x)\n", Key);
+ TRACE("MapDefaultKey (Key %x)\n", Key);
if (((ULONG)Key & 0xF0000000) != 0x80000000)
{
break;
default:
- DPRINT("MapDefaultHandle() no handle creator\n");
+ WARN("MapDefaultHandle() no handle creator\n");
Status = STATUS_INVALID_PARAMETER;
}
}
OpenClassesRootKey (PHANDLE KeyHandle)
{
OBJECT_ATTRIBUTES Attributes;
- UNICODE_STRING KeyName = ROS_STRING_INITIALIZER(L"\\Registry\\Machine\\Software\\CLASSES");
+ UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software\\CLASSES");
- DPRINT("OpenClassesRootKey()\n");
+ TRACE("OpenClassesRootKey()\n");
InitializeObjectAttributes (&Attributes,
&KeyName,
OpenLocalMachineKey (PHANDLE KeyHandle)
{
OBJECT_ATTRIBUTES Attributes;
- UNICODE_STRING KeyName = ROS_STRING_INITIALIZER(L"\\Registry\\Machine");
+ UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine");
NTSTATUS Status;
- DPRINT("OpenLocalMachineKey()\n");
+ TRACE("OpenLocalMachineKey()\n");
InitializeObjectAttributes (&Attributes,
&KeyName,
MAXIMUM_ALLOWED,
&Attributes);
- DPRINT("NtOpenKey(%wZ) => %08x\n", &KeyName, Status);
+ TRACE("NtOpenKey(%wZ) => %08x\n", &KeyName, Status);
return Status;
}
OpenUsersKey (PHANDLE KeyHandle)
{
OBJECT_ATTRIBUTES Attributes;
- UNICODE_STRING KeyName = ROS_STRING_INITIALIZER(L"\\Registry\\User");
+ UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\User");
- DPRINT("OpenUsersKey()\n");
+ TRACE("OpenUsersKey()\n");
InitializeObjectAttributes (&Attributes,
&KeyName,
{
OBJECT_ATTRIBUTES Attributes;
UNICODE_STRING KeyName =
- ROS_STRING_INITIALIZER(L"\\Registry\\Machine\\System\\CurrentControlSet\\Hardware Profiles\\Current");
+ RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Hardware Profiles\\Current");
- DPRINT("OpenCurrentConfigKey()\n");
+ TRACE("OpenCurrentConfigKey()\n");
InitializeObjectAttributes (&Attributes,
&KeyName,
LONG STDCALL
RegCloseKey (HKEY hKey)
{
- LONG ErrorCode;
NTSTATUS Status;
/* don't close null handle or a pseudo handle */
Status = NtClose (hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
}
+/************************************************************************
+ * RegCopyTreeW
+ *
+ * @unimplemented
+ */
+LONG STDCALL
+RegCopyTreeW(IN HKEY hKeySrc,
+ IN LPCWSTR lpSubKey OPTIONAL,
+ IN HKEY hKeyDest)
+{
+ HANDLE DestKeyHandle, KeyHandle, SubKeyHandle = NULL;
+ NTSTATUS Status;
+
+ Status = MapDefaultKey(&KeyHandle,
+ hKeySrc);
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+
+ Status = MapDefaultKey(&DestKeyHandle,
+ hKeyDest);
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+
+ if (lpSubKey != NULL)
+ {
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING SubKeyName;
+
+ RtlInitUnicodeString(&SubKeyName,
+ (LPWSTR)lpSubKey);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &SubKeyName,
+ OBJ_CASE_INSENSITIVE,
+ KeyHandle,
+ NULL);
+
+ Status = NtOpenKey(&SubKeyHandle,
+ KEY_READ,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+ }
+
+ /* FIXME - copy all keys and values recursively */
+ Status = STATUS_NOT_IMPLEMENTED;
+
+ if (SubKeyHandle != NULL)
+ {
+ NtClose(SubKeyHandle);
+ }
+
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+
+ return ERROR_SUCCESS;
+}
+
+
+/************************************************************************
+ * RegCopyTreeA
+ *
+ * @implemented
+ */
+LONG STDCALL
+RegCopyTreeA(IN HKEY hKeySrc,
+ IN LPCSTR lpSubKey OPTIONAL,
+ IN HKEY hKeyDest)
+{
+ UNICODE_STRING SubKeyName;
+ LONG Ret;
+
+ if (lpSubKey != NULL)
+ {
+ if (!RtlCreateUnicodeStringFromAsciiz(&SubKeyName,
+ (LPSTR)lpSubKey))
+ {
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+ }
+ else
+ RtlInitUnicodeString(&SubKeyName,
+ NULL);
+
+ Ret = RegCopyTreeW(hKeySrc,
+ SubKeyName.Buffer,
+ hKeyDest);
+
+ RtlFreeUnicodeString(&SubKeyName);
+
+ return Ret;
+}
+
+
/************************************************************************
* RegConnectRegistryW
*
ClassString,
dwOptions,
(PULONG)lpdwDisposition);
- DPRINT("NtCreateKey(%wZ) called (Status %lx)\n", ObjectAttributes->ObjectName, Status);
+ TRACE("NtCreateKey(%wZ) called (Status %lx)\n", ObjectAttributes->ObjectName, Status);
if (Status != STATUS_OBJECT_NAME_NOT_FOUND)
return Status;
NULL,
0,
&Disposition);
- DPRINT("NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName, Status);
+ TRACE("NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName, Status);
}
if (!NT_SUCCESS(Status))
NULL,
0,
&Disposition);
- DPRINT("NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName, Status);
+ TRACE("NtCreateKey(%wZ) called (Status %lx)\n", &LocalKeyName, Status);
if (!NT_SUCCESS(Status))
break;
}
UNICODE_STRING ClassString;
OBJECT_ATTRIBUTES Attributes;
HANDLE ParentKey;
- LONG ErrorCode;
NTSTATUS Status;
- DPRINT("RegCreateKeyExA() called\n");
+ TRACE("RegCreateKeyExA() called\n");
/* get the real parent key */
Status = MapDefaultKey (&ParentKey,
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
- DPRINT("ParentKey %x\n", (ULONG)ParentKey);
+ TRACE("ParentKey %x\n", (ULONG)ParentKey);
if (lpClass != NULL)
{
RtlFreeUnicodeString (&ClassString);
}
- DPRINT("Status %x\n", Status);
+ TRACE("Status %x\n", Status);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
UNICODE_STRING ClassString;
OBJECT_ATTRIBUTES Attributes;
HANDLE ParentKey;
- LONG ErrorCode;
NTSTATUS Status;
- DPRINT("RegCreateKeyExW() called\n");
+ TRACE("RegCreateKeyExW() called\n");
/* get the real parent key */
Status = MapDefaultKey (&ParentKey,
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError(Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError(Status);
}
- DPRINT("ParentKey %x\n", (ULONG)ParentKey);
+ TRACE("ParentKey %x\n", (ULONG)ParentKey);
RtlInitUnicodeString (&ClassString,
lpClass);
dwOptions,
samDesired,
lpdwDisposition);
- DPRINT("Status %x\n", Status);
+ TRACE("Status %x\n", Status);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
HANDLE ParentKey;
HANDLE TargetKey;
NTSTATUS Status;
- LONG ErrorCode;
Status = MapDefaultKey (&ParentKey,
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
RtlCreateUnicodeStringFromAsciiz (&SubKeyName,
InitializeObjectAttributes(&ObjectAttributes,
&SubKeyName,
OBJ_CASE_INSENSITIVE,
- (HANDLE)ParentKey,
+ ParentKey,
NULL);
Status = NtOpenKey (&TargetKey,
RtlFreeUnicodeString (&SubKeyName);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
Status = NtDeleteKey (TargetKey);
NtClose (TargetKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError(Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError(Status);
}
return ERROR_SUCCESS;
HANDLE ParentKey;
HANDLE TargetKey;
NTSTATUS Status;
- LONG ErrorCode;
Status = MapDefaultKey (&ParentKey,
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
RtlInitUnicodeString (&SubKeyName,
InitializeObjectAttributes (&ObjectAttributes,
&SubKeyName,
OBJ_CASE_INSENSITIVE,
- (HANDLE)ParentKey,
+ ParentKey,
NULL);
Status = NtOpenKey (&TargetKey,
DELETE,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
Status = NtDeleteKey (TargetKey);
NtClose (TargetKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
}
+/************************************************************************
+ * RegDeleteKeyValueW
+ *
+ * @implemented
+ */
+LONG STDCALL
+RegDeleteKeyValueW(IN HKEY hKey,
+ IN LPCWSTR lpSubKey OPTIONAL,
+ IN LPCWSTR lpValueName OPTIONAL)
+{
+ UNICODE_STRING ValueName;
+ HANDLE KeyHandle, SubKeyHandle = NULL;
+ NTSTATUS Status;
+
+ Status = MapDefaultKey(&KeyHandle,
+ hKey);
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+
+ if (lpSubKey != NULL)
+ {
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING SubKeyName;
+
+ RtlInitUnicodeString(&SubKeyName,
+ (LPWSTR)lpSubKey);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &SubKeyName,
+ OBJ_CASE_INSENSITIVE,
+ KeyHandle,
+ NULL);
+
+ Status = NtOpenKey(&SubKeyHandle,
+ KEY_SET_VALUE,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+ }
+
+ RtlInitUnicodeString(&ValueName,
+ (LPWSTR)lpValueName);
+
+ Status = NtDeleteValueKey((SubKeyHandle != NULL) ? SubKeyHandle : KeyHandle,
+ &ValueName);
+
+ if (SubKeyHandle != NULL)
+ {
+ NtClose(SubKeyHandle);
+ }
+
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+
+ return ERROR_SUCCESS;
+}
+
+
+/************************************************************************
+ * RegDeleteKeyValueA
+ *
+ * @implemented
+ */
+LONG STDCALL
+RegDeleteKeyValueA(IN HKEY hKey,
+ IN LPCSTR lpSubKey OPTIONAL,
+ IN LPCSTR lpValueName OPTIONAL)
+{
+ UNICODE_STRING SubKey, ValueName;
+ LONG Ret;
+
+ if (lpSubKey != NULL)
+ {
+ if (!RtlCreateUnicodeStringFromAsciiz(&SubKey,
+ (LPSTR)lpSubKey))
+ {
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+ }
+ else
+ RtlInitUnicodeString(&SubKey,
+ NULL);
+
+ if (lpValueName != NULL)
+ {
+ if (!RtlCreateUnicodeStringFromAsciiz(&ValueName,
+ (LPSTR)lpValueName))
+ {
+ RtlFreeUnicodeString(&SubKey);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+ }
+ else
+ RtlInitUnicodeString(&ValueName,
+ NULL);
+
+ Ret = RegDeleteKeyValueW(hKey,
+ SubKey.Buffer,
+ SubKey.Buffer);
+
+ RtlFreeUnicodeString(&SubKey);
+ RtlFreeUnicodeString(&ValueName);
+
+ return Ret;
+}
+
+
+/************************************************************************
+ * RegDeleteTreeW
+ *
+ * @unimplemented
+ */
+LONG STDCALL
+RegDeleteTreeW(IN HKEY hKey,
+ IN LPCWSTR lpSubKey OPTIONAL)
+{
+ HANDLE KeyHandle, SubKeyHandle = NULL;
+ NTSTATUS Status;
+
+ Status = MapDefaultKey(&KeyHandle,
+ hKey);
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+
+ if (lpSubKey != NULL)
+ {
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING SubKeyName;
+
+ RtlInitUnicodeString(&SubKeyName,
+ (LPWSTR)lpSubKey);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &SubKeyName,
+ OBJ_CASE_INSENSITIVE,
+ KeyHandle,
+ NULL);
+
+ Status = NtOpenKey(&SubKeyHandle,
+ DELETE | KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+ }
+
+ /* FIXME - delete all keys recursively */
+ Status = STATUS_NOT_IMPLEMENTED;
+
+ if (SubKeyHandle != NULL)
+ {
+ NtClose(SubKeyHandle);
+ }
+
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+
+ return ERROR_SUCCESS;
+}
+
+
+/************************************************************************
+ * RegDeleteTreeA
+ *
+ * @implemented
+ */
+LONG STDCALL
+RegDeleteTreeA(IN HKEY hKey,
+ IN LPCSTR lpSubKey OPTIONAL)
+{
+ UNICODE_STRING SubKeyName;
+ LONG Ret;
+
+ if (lpSubKey != NULL)
+ {
+ if (!RtlCreateUnicodeStringFromAsciiz(&SubKeyName,
+ (LPSTR)lpSubKey))
+ {
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+ }
+ else
+ RtlInitUnicodeString(&SubKeyName,
+ NULL);
+
+ Ret = RegDeleteTreeW(hKey,
+ SubKeyName.Buffer);
+
+ RtlFreeUnicodeString(&SubKeyName);
+
+ return Ret;
+}
+
+
+/************************************************************************
+ * RegSetKeyValueW
+ *
+ * @implemented
+ */
+LONG STDCALL
+RegSetKeyValueW(IN HKEY hKey,
+ IN LPCWSTR lpSubKey OPTIONAL,
+ IN LPCWSTR lpValueName OPTIONAL,
+ IN DWORD dwType,
+ IN LPCVOID lpData OPTIONAL,
+ IN DWORD cbData)
+{
+ HANDLE KeyHandle, SubKeyHandle = NULL;
+ NTSTATUS Status;
+ LONG Ret;
+
+ Status = MapDefaultKey(&KeyHandle,
+ hKey);
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+
+ if (lpSubKey != NULL)
+ {
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING SubKeyName;
+
+ RtlInitUnicodeString(&SubKeyName,
+ (LPWSTR)lpSubKey);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &SubKeyName,
+ OBJ_CASE_INSENSITIVE,
+ KeyHandle,
+ NULL);
+
+ Status = NtOpenKey(&SubKeyHandle,
+ KEY_SET_VALUE,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+ }
+
+ Ret = RegSetValueExW((SubKeyHandle != NULL) ? SubKeyHandle : KeyHandle,
+ lpValueName,
+ 0,
+ dwType,
+ lpData,
+ cbData);
+
+ if (SubKeyHandle != NULL)
+ {
+ NtClose(SubKeyHandle);
+ }
+
+ return Ret;
+}
+
+
+/************************************************************************
+ * RegSetKeyValueA
+ *
+ * @implemented
+ */
+LONG STDCALL
+RegSetKeyValueA(IN HKEY hKey,
+ IN LPCSTR lpSubKey OPTIONAL,
+ IN LPCSTR lpValueName OPTIONAL,
+ IN DWORD dwType,
+ IN LPCVOID lpData OPTIONAL,
+ IN DWORD cbData)
+{
+ HANDLE KeyHandle, SubKeyHandle = NULL;
+ NTSTATUS Status;
+ LONG Ret;
+
+ Status = MapDefaultKey(&KeyHandle,
+ hKey);
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+
+ if (lpSubKey != NULL)
+ {
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING SubKeyName;
+
+ if (!RtlCreateUnicodeStringFromAsciiz(&SubKeyName,
+ (LPSTR)lpSubKey))
+ {
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &SubKeyName,
+ OBJ_CASE_INSENSITIVE,
+ KeyHandle,
+ NULL);
+
+ Status = NtOpenKey(&SubKeyHandle,
+ KEY_SET_VALUE,
+ &ObjectAttributes);
+
+ RtlFreeUnicodeString(&SubKeyName);
+
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError(Status);
+ }
+ }
+
+ Ret = RegSetValueExA((SubKeyHandle != NULL) ? SubKeyHandle : KeyHandle,
+ lpValueName,
+ 0,
+ dwType,
+ lpData,
+ cbData);
+
+ if (SubKeyHandle != NULL)
+ {
+ NtClose(SubKeyHandle);
+ }
+
+ return Ret;
+}
+
+
/************************************************************************
* RegDeleteValueA
*
{
UNICODE_STRING ValueName;
HANDLE KeyHandle;
- LONG ErrorCode;
NTSTATUS Status;
Status = MapDefaultKey (&KeyHandle,
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
RtlCreateUnicodeStringFromAsciiz (&ValueName,
RtlFreeUnicodeString (&ValueName);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
{
UNICODE_STRING ValueName;
NTSTATUS Status;
- LONG ErrorCode;
HANDLE KeyHandle;
Status = MapDefaultKey (&KeyHandle,
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
RtlInitUnicodeString (&ValueName,
&ValueName);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
HANDLE KeyHandle;
NTSTATUS Status;
- DPRINT("RegEnumKeyExA(hKey 0x%x, dwIndex %d, lpName 0x%x, *lpcbName %d, lpClass 0x%x, lpcbClass %d)\n",
+ TRACE("RegEnumKeyExA(hKey 0x%x, dwIndex %d, lpName 0x%x, *lpcbName %d, lpClass 0x%x, lpcbClass %d)\n",
hKey, dwIndex, lpName, *lpcbName, lpClass, lpcbClass ? *lpcbClass : 0);
if ((lpClass) && (!lpcbClass))
{
- SetLastError (ERROR_INVALID_PARAMETER);
return ERROR_INVALID_PARAMETER;
}
Status = MapDefaultKey(&KeyHandle, hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
if (*lpcbName > 0)
KeyInfo = RtlAllocateHeap (ProcessHeap, 0, BufferSize);
if (KeyInfo == NULL)
{
- SetLastError (ERROR_OUTOFMEMORY);
return ERROR_OUTOFMEMORY;
}
KeyInfo,
BufferSize,
&ResultSize);
- DPRINT("NtEnumerateKey() returned status 0x%X\n", Status);
+ TRACE("NtEnumerateKey() returned status 0x%X\n", Status);
if (!NT_SUCCESS(Status))
{
ErrorCode = RtlNtStatusToDosError (Status);
}
}
- DPRINT("Key Namea0 Length %d\n", StringU.Length);
- DPRINT("Key Namea1 Length %d\n", NameLength);
- DPRINT("Key Namea Length %d\n", *lpcbName);
- DPRINT("Key Namea %s\n", lpName);
+ TRACE("Key Namea0 Length %d\n", StringU.Length);
+ TRACE("Key Namea1 Length %d\n", NameLength);
+ TRACE("Key Namea Length %d\n", *lpcbName);
+ TRACE("Key Namea %s\n", lpName);
RtlFreeHeap (ProcessHeap,
0,
KeyInfo);
- if (ErrorCode != ERROR_SUCCESS)
- {
- SetLastError(ErrorCode);
- }
-
return ErrorCode;
}
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
if (*lpcbName > 0)
BufferSize);
if (KeyInfo == NULL)
{
- SetLastError (ERROR_OUTOFMEMORY);
return ERROR_OUTOFMEMORY;
}
KeyInfo,
BufferSize,
&ResultSize);
- DPRINT("NtEnumerateKey() returned status 0x%X\n", Status);
+ TRACE("NtEnumerateKey() returned status 0x%X\n", Status);
if (!NT_SUCCESS(Status))
{
ErrorCode = RtlNtStatusToDosError (Status);
0,
KeyInfo);
- if (ErrorCode != ERROR_SUCCESS)
- {
- SetLastError(ErrorCode);
- }
-
return ErrorCode;
}
status = MapDefaultKey (&KeyHandle, hKey);
if (!NT_SUCCESS(status))
{
- LONG ErrorCode;
- ErrorCode = RtlNtStatusToDosError (status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (status);
}
total_size = info_size + (MAX_PATH + 1) * sizeof(WCHAR);
if (len > *count) status = STATUS_BUFFER_OVERFLOW;
else
{
- RtlUnicodeToMultiByteN( data, len, NULL, (WCHAR *)(buf_ptr + info->DataOffset),
+ RtlUnicodeToMultiByteN( (PCHAR)data, len, NULL, (WCHAR *)(buf_ptr + info->DataOffset),
total_size - info->DataOffset );
/* if the type is REG_SZ and data is not 0-terminated
* and there is enough space in the buffer NT appends a \0 */
/******************************************************************************
* RegEnumValueW [ADVAPI32.@]
* @implemented
- *
+ *
* PARAMS
* hkey [I] Handle to key to query
* index [I] Index of value to query
/* NT only checks count, not val_count */
if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER;
-
+
status = MapDefaultKey (&KeyHandle, hKey);
if (!NT_SUCCESS(status))
{
- LONG ErrorCode;
- ErrorCode = RtlNtStatusToDosError (status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (status);
}
total_size = info_size + (MAX_PATH + 1) * sizeof(WCHAR);
RegFlushKey(HKEY hKey)
{
HANDLE KeyHandle;
- LONG ErrorCode;
NTSTATUS Status;
if (hKey == HKEY_PERFORMANCE_DATA)
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
Status = NtFlushKey (KeyHandle);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
LPDWORD lpcbSecurityDescriptor)
{
HANDLE KeyHandle;
- LONG ErrorCode;
NTSTATUS Status;
if (hKey == HKEY_PERFORMANCE_DATA)
{
- SetLastError(ERROR_INVALID_HANDLE);
return ERROR_INVALID_HANDLE;
}
hKey);
if (!NT_SUCCESS(Status))
{
- DPRINT("MapDefaultKey() failed (Status %lx)\n", Status);
- ErrorCode = RtlNtStatusToDosError(Status);
- SetLastError(ErrorCode);
- return ErrorCode;
+ TRACE("MapDefaultKey() failed (Status %lx)\n", Status);
+ return RtlNtStatusToDosError (Status);
}
Status = NtQuerySecurityObject(KeyHandle,
lpcbSecurityDescriptor);
if (!NT_SUCCESS(Status))
{
- DPRINT("NtQuerySecurityObject() failed (Status %lx)\n", Status);
- ErrorCode = RtlNtStatusToDosError(Status);
- SetLastError(ErrorCode);
- return ErrorCode;
+ WARN("NtQuerySecurityObject() failed (Status %lx)\n", Status);
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
UNICODE_STRING FileName;
UNICODE_STRING KeyName;
HANDLE KeyHandle;
- LONG ErrorCode;
NTSTATUS Status;
if (hKey == HKEY_PERFORMANCE_DATA)
{
- SetLastError(ERROR_INVALID_HANDLE);
return ERROR_INVALID_HANDLE;
}
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpFile,
NULL,
NULL))
{
- SetLastError (ERROR_BAD_PATHNAME);
return ERROR_BAD_PATHNAME;
}
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
}
+/************************************************************************
+ * RegOpenCurrentUser
+ *
+ * @implemented
+ */
+LONG STDCALL
+RegOpenCurrentUser (IN REGSAM samDesired,
+ OUT PHKEY phkResult)
+{
+ NTSTATUS Status;
+
+ Status = RtlOpenCurrentUser((ACCESS_MASK)samDesired,
+ (PHANDLE)phkResult);
+ if (!NT_SUCCESS(Status))
+ {
+ /* NOTE - don't set the last error code! just return the error! */
+ return RtlNtStatusToDosError(Status);
+ }
+
+ return ERROR_SUCCESS;
+}
+
+
/************************************************************************
* RegOpenKeyA
*
LPCSTR lpSubKey,
PHKEY phkResult)
{
- DPRINT("RegOpenKeyA hKey 0x%x lpSubKey %s phkResult %p\n", hKey, lpSubKey, phkResult);
+ TRACE("RegOpenKeyA hKey 0x%x lpSubKey %s phkResult %p\n", hKey, lpSubKey, phkResult);
if (!lpSubKey || !*lpSubKey)
{
LPCWSTR lpSubKey,
PHKEY phkResult)
{
- DPRINT("RegOpenKeyW hKey 0x%x lpSubKey %S phkResult %p\n", hKey, lpSubKey, phkResult);
+ TRACE("RegOpenKeyW hKey 0x%x lpSubKey %S phkResult %p\n", hKey, lpSubKey, phkResult);
if (!lpSubKey || !*lpSubKey)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING SubKeyString;
HANDLE KeyHandle;
- LONG ErrorCode;
NTSTATUS Status;
- DPRINT("RegOpenKeyExA hKey 0x%x lpSubKey %s ulOptions 0x%x samDesired 0x%x phkResult %p\n",
+ TRACE("RegOpenKeyExA hKey 0x%x lpSubKey %s ulOptions 0x%x samDesired 0x%x phkResult %p\n",
hKey, lpSubKey, ulOptions, samDesired, phkResult);
Status = MapDefaultKey (&KeyHandle, hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
RtlCreateUnicodeStringFromAsciiz (&SubKeyString, (LPSTR)lpSubKey);
RtlFreeUnicodeString (&SubKeyString);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING SubKeyString;
HANDLE KeyHandle;
- LONG ErrorCode;
NTSTATUS Status;
- DPRINT("RegOpenKeyExW hKey 0x%x lpSubKey %S ulOptions 0x%x samDesired 0x%x phkResult %p\n",
+ TRACE("RegOpenKeyExW hKey 0x%x lpSubKey %S ulOptions 0x%x samDesired 0x%x phkResult %p\n",
hKey, lpSubKey, ulOptions, samDesired, phkResult);
-
+
Status = MapDefaultKey (&KeyHandle, hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
if (lpSubKey != NULL)
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
}
+/************************************************************************
+ * RegOpenUserClassesRoot
+ *
+ * @implemented
+ */
+LONG STDCALL
+RegOpenUserClassesRoot (IN HANDLE hToken,
+ IN DWORD dwOptions,
+ IN REGSAM samDesired,
+ OUT PHKEY phkResult)
+{
+ const WCHAR UserClassesKeyPrefix[] = L"\\Registry\\User\\";
+ const WCHAR UserClassesKeySuffix[] = L"_Classes";
+ PTOKEN_USER TokenUserData;
+ ULONG RequiredLength;
+ UNICODE_STRING UserSidString, UserClassesKeyRoot;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ LONG ErrorCode;
+ NTSTATUS Status;
+
+ /* check parameters */
+ if (hToken == NULL || dwOptions != 0 || phkResult == NULL)
+ {
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ /*
+ * Get the user sid from the token
+ */
+
+ReadTokenSid:
+ /* determine how much memory we need */
+ Status = NtQueryInformationToken(hToken,
+ TokenUser,
+ NULL,
+ 0,
+ &RequiredLength);
+ if (!NT_SUCCESS(Status) && (Status != STATUS_BUFFER_TOO_SMALL))
+ {
+ /* NOTE - as opposed to all other registry functions windows does indeed
+ change the last error code in case the caller supplied a invalid
+ handle for example! */
+ ErrorCode = RtlNtStatusToDosError (Status);
+ return ErrorCode;
+ }
+
+ TokenUserData = RtlAllocateHeap(ProcessHeap,
+ 0,
+ RequiredLength);
+ if (TokenUserData == NULL)
+ {
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+ /* attempt to read the information */
+ Status = NtQueryInformationToken(hToken,
+ TokenUser,
+ TokenUserData,
+ RequiredLength,
+ &RequiredLength);
+ if (!NT_SUCCESS(Status))
+ {
+ RtlFreeHeap(ProcessHeap,
+ 0,
+ TokenUserData);
+ if (Status == STATUS_BUFFER_TOO_SMALL)
+ {
+ /* the information appears to have changed?! try again */
+ goto ReadTokenSid;
+ }
+
+ /* NOTE - as opposed to all other registry functions windows does indeed
+ change the last error code in case the caller supplied a invalid
+ handle for example! */
+ ErrorCode = RtlNtStatusToDosError (Status);
+ return ErrorCode;
+ }
+
+ /*
+ * Build the absolute path for the user's registry in the form
+ * "\Registry\User\<SID>_Classes"
+ */
+ Status = RtlConvertSidToUnicodeString(&UserSidString,
+ TokenUserData->User.Sid,
+ TRUE);
+
+ /* we don't need the user data anymore, free it */
+ RtlFreeHeap(ProcessHeap,
+ 0,
+ TokenUserData);
+
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError (Status);
+ }
+
+ /* allocate enough memory for the entire key string */
+ UserClassesKeyRoot.Length = 0;
+ UserClassesKeyRoot.MaximumLength = UserSidString.Length +
+ sizeof(UserClassesKeyPrefix) +
+ sizeof(UserClassesKeySuffix);
+ UserClassesKeyRoot.Buffer = RtlAllocateHeap(ProcessHeap,
+ 0,
+ UserClassesKeyRoot.MaximumLength);
+ if (UserClassesKeyRoot.Buffer == NULL)
+ {
+ RtlFreeUnicodeString(&UserSidString);
+ return RtlNtStatusToDosError (Status);
+ }
+
+ /* build the string */
+ RtlAppendUnicodeToString(&UserClassesKeyRoot,
+ UserClassesKeyPrefix);
+ RtlAppendUnicodeStringToString(&UserClassesKeyRoot,
+ &UserSidString);
+ RtlAppendUnicodeToString(&UserClassesKeyRoot,
+ UserClassesKeySuffix);
+
+ TRACE("RegOpenUserClassesRoot: Absolute path: %wZ\n", &UserClassesKeyRoot);
+
+ /*
+ * Open the key
+ */
+
+ InitializeObjectAttributes (&ObjectAttributes,
+ &UserClassesKeyRoot,
+ OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
+
+ Status = NtOpenKey((PHANDLE)phkResult,
+ samDesired,
+ &ObjectAttributes);
+
+ RtlFreeUnicodeString(&UserSidString);
+ RtlFreeUnicodeString(&UserClassesKeyRoot);
+
+ if (!NT_SUCCESS(Status))
+ {
+ return RtlNtStatusToDosError (Status);
+ }
+
+ return ERROR_SUCCESS;
+}
+
+
/************************************************************************
* RegQueryInfoKeyA
*
ULONG ClassLength = 0;
HANDLE KeyHandle;
NTSTATUS Status;
- LONG ErrorCode = ERROR_SUCCESS;
ULONG Length;
+ LONG ErrorCode = ERROR_SUCCESS;
if ((lpClass) && (!lpcbClass))
{
- SetLastError(ERROR_INVALID_PARAMETER);
return ERROR_INVALID_PARAMETER;
}
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
if (lpClass != NULL)
FullInfoSize);
if (FullInfo == NULL)
{
- SetLastError (ERROR_OUTOFMEMORY);
return ERROR_OUTOFMEMORY;
}
FullInfo,
FullInfoSize,
&Length);
- DPRINT("NtQueryKey() returned status 0x%X\n", Status);
+ TRACE("NtQueryKey() returned status 0x%X\n", Status);
if (!NT_SUCCESS(Status))
{
if (lpClass != NULL)
FullInfo);
}
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
- DPRINT("SubKeys %d\n", FullInfo->SubKeys);
+ TRACE("SubKeys %d\n", FullInfo->SubKeys);
if (lpcSubKeys != NULL)
{
*lpcSubKeys = FullInfo->SubKeys;
}
- DPRINT("MaxNameLen %lu\n", FullInfo->MaxNameLen);
+ TRACE("MaxNameLen %lu\n", FullInfo->MaxNameLen);
if (lpcbMaxSubKeyLen != NULL)
{
*lpcbMaxSubKeyLen = FullInfo->MaxNameLen / sizeof(WCHAR) + 1;
}
- DPRINT("MaxClassLen %lu\n", FullInfo->MaxClassLen);
+ TRACE("MaxClassLen %lu\n", FullInfo->MaxClassLen);
if (lpcbMaxClassLen != NULL)
{
*lpcbMaxClassLen = FullInfo->MaxClassLen / sizeof(WCHAR) + 1;
}
- DPRINT("Values %lu\n", FullInfo->Values);
+ TRACE("Values %lu\n", FullInfo->Values);
if (lpcValues != NULL)
{
*lpcValues = FullInfo->Values;
}
- DPRINT("MaxValueNameLen %lu\n", FullInfo->MaxValueNameLen);
+ TRACE("MaxValueNameLen %lu\n", FullInfo->MaxValueNameLen);
if (lpcbMaxValueNameLen != NULL)
{
*lpcbMaxValueNameLen = FullInfo->MaxValueNameLen / sizeof(WCHAR) + 1;
}
- DPRINT("MaxValueDataLen %lu\n", FullInfo->MaxValueDataLen);
+ TRACE("MaxValueDataLen %lu\n", FullInfo->MaxValueDataLen);
if (lpcbMaxValueLen != NULL)
{
*lpcbMaxValueLen = FullInfo->MaxValueDataLen;
FullInfo);
}
- ErrorCode = RtlNtStatusToDosError(Status);
- SetLastError(ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
}
FullInfo);
}
- if (ErrorCode != ERROR_SUCCESS)
- {
- SetLastError (ErrorCode);
- }
-
return ErrorCode;
}
*ldwTotsize = 0;
- DPRINT ("RegQueryMultipleValuesA(%p,%p,%ld,%p,%p=%ld)\n",
+ TRACE("RegQueryMultipleValuesA(%p,%p,%ld,%p,%p=%ld)\n",
hKey, val_list, num_vals, lpValueBuf, ldwTotsize, *ldwTotsize);
for (i = 0; i < num_vals; i++)
*ldwTotsize = 0;
- DPRINT ("RegQueryMultipleValuesW(%p,%p,%ld,%p,%p=%ld)\n",
+ TRACE ("RegQueryMultipleValuesW(%p,%p,%ld,%p,%p=%ld)\n",
hKey, val_list, num_vals, lpValueBuf, ldwTotsize, *ldwTotsize);
for (i = 0; i < num_vals; i++)
PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
UNICODE_STRING ValueName;
NTSTATUS Status;
- LONG ErrorCode = ERROR_SUCCESS;
ULONG BufferSize;
ULONG ResultSize;
HANDLE KeyHandle;
+ LONG ErrorCode = ERROR_SUCCESS;
ULONG MaxCopy = lpcbData != NULL && lpData != NULL ? *lpcbData : 0;
- DPRINT("hKey 0x%X lpValueName %S lpData 0x%X lpcbData %d\n",
+ TRACE("hKey 0x%X lpValueName %S lpData 0x%X lpcbData %d\n",
hKey, lpValueName, lpData, lpcbData ? *lpcbData : 0);
Status = MapDefaultKey (&KeyHandle,
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
if (lpData != NULL && lpcbData == NULL)
{
- SetLastError (ERROR_INVALID_PARAMETER);
return ERROR_INVALID_PARAMETER;
}
BufferSize);
if (ValueInfo == NULL)
{
- SetLastError(ERROR_OUTOFMEMORY);
return ERROR_OUTOFMEMORY;
}
ValueInfo,
BufferSize,
&ResultSize);
- DPRINT("Status 0x%X\n", Status);
+ TRACE("Status 0x%X\n", Status);
if (Status == STATUS_BUFFER_OVERFLOW)
{
/* Return ERROR_SUCCESS and the buffer space needed for a successful call */
else if (!NT_SUCCESS(Status))
{
ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
MaxCopy = 0;
if (lpcbData != NULL)
{
if (lpcbData != NULL)
{
*lpcbData = (ResultSize - FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[0]));
- DPRINT("(string) Returning Size: %lu\n", *lpcbData);
+ TRACE("(string) Returning Size: %lu\n", *lpcbData);
}
}
else
if (lpcbData != NULL)
{
*lpcbData = ResultSize - FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[0]);
- DPRINT("(other) Returning Size: %lu\n", *lpcbData);
+ TRACE("(other) Returning Size: %lu\n", *lpcbData);
}
}
- DPRINT("Type %d Size %d\n", ValueInfo->Type, ValueInfo->DataLength);
+ TRACE("Type %d Size %d\n", ValueInfo->Type, ValueInfo->DataLength);
RtlFreeHeap (ProcessHeap,
0,
DWORD Length;
DWORD Type;
- DPRINT("hKey 0x%X lpValueName %s lpData 0x%X lpcbData %d\n",
+ TRACE("hKey 0x%X lpValueName %s lpData 0x%X lpcbData %d\n",
hKey, lpValueName, lpData, lpcbData ? *lpcbData : 0);
if (lpData != NULL && lpcbData == NULL)
{
- SetLastError(ERROR_INVALID_PARAMETER);
return ERROR_INVALID_PARAMETER;
}
ValueData.MaximumLength);
if (!ValueData.Buffer)
{
- SetLastError(ERROR_OUTOFMEMORY);
return ERROR_OUTOFMEMORY;
}
}
&Type,
(lpData == NULL) ? NULL : (LPBYTE)ValueData.Buffer,
&Length);
- DPRINT("ErrorCode %lu\n", ErrorCode);
+ TRACE("ErrorCode %lu\n", ErrorCode);
RtlFreeUnicodeString(&ValueName);
if (ErrorCode == ERROR_SUCCESS ||
LONG ValueSize;
LONG ErrorCode;
- DPRINT("hKey 0x%X lpSubKey %s lpValue %p lpcbValue %d\n",
+ TRACE("hKey 0x%X lpSubKey %s lpValue %p lpcbValue %d\n",
hKey, lpSubKey, lpValue, lpcbValue ? *lpcbValue : 0);
if (lpValue != NULL &&
lpcbValue == NULL)
{
- SetLastError(ERROR_INVALID_PARAMETER);
return ERROR_INVALID_PARAMETER;
}
ValueSize);
if (Value.Buffer == NULL)
{
- SetLastError(ERROR_OUTOFMEMORY);
return ERROR_OUTOFMEMORY;
}
}
BOOL CloseRealKey;
NTSTATUS Status;
- DPRINT("hKey 0x%X lpSubKey %S lpValue %p lpcbValue %d\n",
+ TRACE("hKey 0x%X lpSubKey %S lpValue %p lpcbValue %d\n",
hKey, lpSubKey, lpValue, lpcbValue ? *lpcbValue : 0);
Status = MapDefaultKey (&KeyHandle,
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
if (lpSubKey != NULL &&
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
CloseRealKey = TRUE;
}
BOOLEAN CloseRealKey;
HANDLE RealKeyHandle;
HANDLE KeyHandle;
- LONG ErrorCode;
NTSTATUS Status;
if (hKey == HKEY_PERFORMANCE_DATA)
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
/* Open the real key */
&KeyObjectAttributes);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
CloseRealKey = TRUE;
}
{
NtClose (RealKeyHandle);
}
- SetLastError (ERROR_INVALID_PARAMETER);
return ERROR_INVALID_PARAMETER;
}
{
NtClose (RealKeyHandle);
}
- SetLastError (ERROR_INVALID_PARAMETER);
return ERROR_INVALID_PARAMETER;
}
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
UNICODE_STRING FileName;
HANDLE FileHandle;
HANDLE KeyHandle;
- LONG ErrorCode;
NTSTATUS Status;
if (hKey == HKEY_PERFORMANCE_DATA)
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpFile,
NULL,
NULL))
{
- SetLastError (ERROR_INVALID_PARAMETER);
return ERROR_INVALID_PARAMETER;
}
RtlFreeUnicodeString (&FileName);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
Status = NtRestoreKey (KeyHandle,
NtClose (FileHandle);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
HANDLE FileHandle;
HANDLE KeyHandle;
NTSTATUS Status;
- LONG ErrorCode;
Status = MapDefaultKey (&KeyHandle,
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
if (!RtlDosPathNameToNtPathName_U ((PWSTR)lpFile,
NULL,
NULL))
{
- SetLastError (ERROR_INVALID_PARAMETER);
return ERROR_INVALID_PARAMETER;
}
RtlFreeUnicodeString (&FileName);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
Status = NtSaveKey (KeyHandle,
NtClose (FileHandle);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
PSECURITY_DESCRIPTOR pSecurityDescriptor)
{
HANDLE KeyHandle;
- LONG ErrorCode;
NTSTATUS Status;
if (hKey == HKEY_PERFORMANCE_DATA)
{
- SetLastError(ERROR_INVALID_HANDLE);
return ERROR_INVALID_HANDLE;
}
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
Status = NtSetSecurityObject (KeyHandle,
pSecurityDescriptor);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
{
cbData++;
}
-
+
RtlInitAnsiString (&AnsiString,
NULL);
AnsiString.Buffer = (PSTR)lpData;
PUNICODE_STRING pValueName;
HANDLE KeyHandle;
NTSTATUS Status;
- LONG ErrorCode;
Status = MapDefaultKey (&KeyHandle,
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
if (lpValueName != NULL)
RtlInitUnicodeString (&ValueName, L"");
}
pValueName = &ValueName;
-
+
if (((dwType == REG_SZ) ||
(dwType == REG_MULTI_SZ) ||
(dwType == REG_EXPAND_SZ)) &&
(ULONG)cbData);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;
{
LONG ret;
HKEY hSubKey;
-
+
if (dwType != REG_SZ)
{
return ERROR_INVALID_PARAMETER;
}
-
+
if (lpSubKey != NULL && lpSubKey[0] != '\0')
{
ret = RegCreateKeyA(hKey,
}
else
hSubKey = hKey;
-
+
ret = RegSetValueExA(hSubKey,
NULL,
0,
REG_SZ,
- lpData,
+ (CONST BYTE*)lpData,
strlen(lpData) + 1);
-
+
if (hSubKey != hKey)
{
RegCloseKey(hSubKey);
UNICODE_STRING SubKeyString;
HANDLE KeyHandle;
HANDLE RealKey;
- LONG ErrorCode;
BOOL CloseRealKey;
NTSTATUS Status;
+ LONG ErrorCode;
Status = MapDefaultKey (&KeyHandle,
hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
if ((lpSubKey) && (wcslen(lpSubKey) != 0))
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
CloseRealKey = TRUE;
}
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
HANDLE KeyHandle;
- DWORD ErrorCode;
NTSTATUS Status;
if (hKey == HKEY_PERFORMANCE_DATA)
{
- SetLastError(ERROR_INVALID_HANDLE);
return ERROR_INVALID_HANDLE;
}
Status = MapDefaultKey (&KeyHandle, hKey);
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
RtlInitUnicodeString (&KeyName,
if (!NT_SUCCESS(Status))
{
- ErrorCode = RtlNtStatusToDosError (Status);
- SetLastError (ErrorCode);
- return ErrorCode;
+ return RtlNtStatusToDosError (Status);
}
return ERROR_SUCCESS;