From 311c001654b31a8031a4cccfa9675b94c44a3334 Mon Sep 17 00:00:00 2001 From: Vitaliy Margolen Date: Sat, 19 May 2007 10:56:51 -0600 Subject: [PATCH] ntdll: Implement RtlWriteRegistryValue and forward ntoskrnl to it. --- dlls/ntdll/ntdll.spec | 2 +- dlls/ntdll/reg.c | 41 +++++++++++++++++++++++++++++ dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 2 +- include/winternl.h | 1 + 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 3b268803f1e..535f375c4a5 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -910,7 +910,7 @@ @ stub RtlWalkFrameChain @ stdcall RtlWalkHeap(long ptr) @ stub RtlWriteMemoryStream -@ stub RtlWriteRegistryValue +@ stdcall RtlWriteRegistryValue(long ptr ptr long ptr long) @ stub RtlZeroHeap @ stdcall RtlZeroMemory(ptr long) # @ stub RtlZombifyActivationContext diff --git a/dlls/ntdll/reg.c b/dlls/ntdll/reg.c index 99a46c018d7..2127888d579 100644 --- a/dlls/ntdll/reg.c +++ b/dlls/ntdll/reg.c @@ -1334,3 +1334,44 @@ NTSTATUS WINAPI RtlDeleteRegistryValue(IN ULONG RelativeTo, IN PCWSTR Path, IN P NtClose(handle); return status; } + +/************************************************************************* + * RtlWriteRegistryValue [NTDLL.@] + * + * Sets the registry value with provided data. + * + * PARAMS + * RelativeTo [I] Registry path that path parameter refers to + * path [I] Path to the key (or handle - see RTL_GetKeyHandle) + * name [I] Name of the registry value to set + * type [I] Type of the registry key to set + * data [I] Pointer to the user data to be set + * length [I] Length of the user data pointed by data + * + * RETURNS + * STATUS_SUCCESS if the specified key is successfully set, + * or an NTSTATUS error code. + */ +NTSTATUS WINAPI RtlWriteRegistryValue( ULONG RelativeTo, PCWSTR path, PCWSTR name, + ULONG type, PVOID data, ULONG length ) +{ + HANDLE hkey; + NTSTATUS status; + UNICODE_STRING str; + + TRACE( "(%d, %s, %s) -> %d: %p [%d]\n", RelativeTo, debugstr_w(path), debugstr_w(name), + type, data, length ); + + RtlInitUnicodeString( &str, name ); + + if (RelativeTo == RTL_REGISTRY_HANDLE) + return NtSetValueKey( (HANDLE)path, &str, 0, type, data, length ); + + status = RTL_GetKeyHandle( RelativeTo, path, &hkey ); + if (status != STATUS_SUCCESS) return status; + + status = NtSetValueKey( hkey, &str, 0, type, data, length ); + NtClose( hkey ); + + return status; +} diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec index f1996020e64..192e2558d4d 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec @@ -1197,7 +1197,7 @@ @ stdcall RtlVerifyVersionInfo(ptr long double) ntdll.RtlVerifyVersionInfo @ stub RtlVolumeDeviceToDosName @ stub RtlWalkFrameChain -@ stub RtlWriteRegistryValue +@ stdcall RtlWriteRegistryValue(long ptr ptr long ptr long) ntdll.RtlWriteRegistryValue @ stub RtlZeroHeap @ stdcall RtlZeroMemory(ptr long) ntdll.RtlZeroMemory @ stdcall RtlxAnsiStringToUnicodeSize(ptr) ntdll.RtlxAnsiStringToUnicodeSize diff --git a/include/winternl.h b/include/winternl.h index 8b650a9972b..1580535258b 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -2240,6 +2240,7 @@ BOOLEAN WINAPI RtlValidateHeap(HANDLE,ULONG,LPCVOID); NTSTATUS WINAPI RtlVerifyVersionInfo(const RTL_OSVERSIONINFOEXW*,DWORD,DWORDLONG); NTSTATUS WINAPI RtlWalkHeap(HANDLE,PVOID); +NTSTATUS WINAPI RtlWriteRegistryValue(ULONG,PCWSTR,PCWSTR,ULONG,PVOID,ULONG); NTSTATUS WINAPI RtlpNtCreateKey(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,const UNICODE_STRING*,ULONG,PULONG); NTSTATUS WINAPI RtlpWaitForCriticalSection(RTL_CRITICAL_SECTION *);