Dbghelp describes the types of function arguments with a specific
[wine/wine64.git] / dlls / ntdll / reg.c
blob584c82498badb4f8e6240ac416ecfd928583c15c
1 /*
2 * Registry functions
4 * Copyright (C) 1999 Juergen Schmied
5 * Copyright (C) 2000 Alexandre Julliard
6 * Copyright 2005 Ivan Leo Puoti, Laurent Pinchart
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * NOTES:
23 * HKEY_LOCAL_MACHINE \\REGISTRY\\MACHINE
24 * HKEY_USERS \\REGISTRY\\USER
25 * HKEY_CURRENT_CONFIG \\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\HARDWARE PROFILES\\CURRENT
26 * HKEY_CLASSES \\REGISTRY\\MACHINE\\SOFTWARE\\CLASSES
29 #include "config.h"
30 #include "wine/port.h"
32 #include <stdarg.h>
33 #include <stdio.h>
34 #include <string.h>
36 #include "wine/library.h"
37 #include "ntdll_misc.h"
38 #include "wine/debug.h"
39 #include "wine/unicode.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(reg);
43 /* maximum length of a key/value name in bytes (without terminating null) */
44 #define MAX_NAME_LENGTH ((MAX_PATH-1) * sizeof(WCHAR))
46 /******************************************************************************
47 * NtCreateKey [NTDLL.@]
48 * ZwCreateKey [NTDLL.@]
50 NTSTATUS WINAPI NtCreateKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr,
51 ULONG TitleIndex, const UNICODE_STRING *class, ULONG options,
52 PULONG dispos )
54 NTSTATUS ret;
56 TRACE( "(%p,%s,%s,%lx,%lx,%p)\n", attr->RootDirectory, debugstr_us(attr->ObjectName),
57 debugstr_us(class), options, access, retkey );
59 if (attr->ObjectName->Length > MAX_NAME_LENGTH) return STATUS_BUFFER_OVERFLOW;
60 if (!retkey) return STATUS_INVALID_PARAMETER;
62 SERVER_START_REQ( create_key )
64 req->parent = attr->RootDirectory;
65 req->access = access;
66 req->options = options;
67 req->modif = 0;
68 req->namelen = attr->ObjectName->Length;
69 wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length );
70 if (class) wine_server_add_data( req, class->Buffer, class->Length );
71 if (!(ret = wine_server_call( req )))
73 *retkey = reply->hkey;
74 if (dispos) *dispos = reply->created ? REG_CREATED_NEW_KEY : REG_OPENED_EXISTING_KEY;
77 SERVER_END_REQ;
78 TRACE("<- %p\n", *retkey);
79 return ret;
82 /******************************************************************************
83 * RtlpNtCreateKey [NTDLL.@]
85 * See NtCreateKey.
87 NTSTATUS WINAPI RtlpNtCreateKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr,
88 ULONG TitleIndex, const UNICODE_STRING *class, ULONG options,
89 PULONG dispos )
91 OBJECT_ATTRIBUTES oa;
93 if (attr)
95 memcpy( &oa, attr, sizeof oa );
96 oa.Attributes &= ~(OBJ_PERMANENT|OBJ_EXCLUSIVE);
97 attr = &oa;
100 return NtCreateKey(retkey, access, attr, 0, NULL, 0, dispos);
103 /******************************************************************************
104 * NtOpenKey [NTDLL.@]
105 * ZwOpenKey [NTDLL.@]
107 * OUT HANDLE retkey (returns 0 when failure)
108 * IN ACCESS_MASK access
109 * IN POBJECT_ATTRIBUTES attr
111 NTSTATUS WINAPI NtOpenKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr )
113 NTSTATUS ret;
114 DWORD len = attr->ObjectName->Length;
116 TRACE( "(%p,%s,%lx,%p)\n", attr->RootDirectory,
117 debugstr_us(attr->ObjectName), access, retkey );
119 if (len > MAX_NAME_LENGTH) return STATUS_BUFFER_OVERFLOW;
120 if (!retkey) return STATUS_INVALID_PARAMETER;
122 SERVER_START_REQ( open_key )
124 req->parent = attr->RootDirectory;
125 req->access = access;
126 wine_server_add_data( req, attr->ObjectName->Buffer, len );
127 ret = wine_server_call( req );
128 *retkey = reply->hkey;
130 SERVER_END_REQ;
131 TRACE("<- %p\n", *retkey);
132 return ret;
135 /******************************************************************************
136 * RtlpNtOpenKey [NTDLL.@]
138 * See NtOpenKey.
140 NTSTATUS WINAPI RtlpNtOpenKey( PHANDLE retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES *attr )
142 if (attr)
143 attr->Attributes &= ~(OBJ_PERMANENT|OBJ_EXCLUSIVE);
144 return NtOpenKey(retkey, access, attr);
147 /******************************************************************************
148 * NtDeleteKey [NTDLL.@]
149 * ZwDeleteKey [NTDLL.@]
151 NTSTATUS WINAPI NtDeleteKey( HANDLE hkey )
153 NTSTATUS ret;
155 TRACE( "(%p)\n", hkey );
157 SERVER_START_REQ( delete_key )
159 req->hkey = hkey;
160 ret = wine_server_call( req );
162 SERVER_END_REQ;
163 return ret;
166 /******************************************************************************
167 * RtlpNtMakeTemporaryKey [NTDLL.@]
169 * See NtDeleteKey.
171 NTSTATUS WINAPI RtlpNtMakeTemporaryKey( HANDLE hkey )
173 return NtDeleteKey(hkey);
176 /******************************************************************************
177 * NtDeleteValueKey [NTDLL.@]
178 * ZwDeleteValueKey [NTDLL.@]
180 NTSTATUS WINAPI NtDeleteValueKey( HANDLE hkey, const UNICODE_STRING *name )
182 NTSTATUS ret;
184 TRACE( "(%p,%s)\n", hkey, debugstr_us(name) );
185 if (name->Length > MAX_NAME_LENGTH) return STATUS_BUFFER_OVERFLOW;
187 SERVER_START_REQ( delete_key_value )
189 req->hkey = hkey;
190 wine_server_add_data( req, name->Buffer, name->Length );
191 ret = wine_server_call( req );
193 SERVER_END_REQ;
194 return ret;
198 /******************************************************************************
199 * enumerate_key
201 * Implementation of NtQueryKey and NtEnumerateKey
203 static NTSTATUS enumerate_key( HANDLE handle, int index, KEY_INFORMATION_CLASS info_class,
204 void *info, DWORD length, DWORD *result_len )
207 NTSTATUS ret;
208 void *data_ptr;
209 size_t fixed_size;
211 switch(info_class)
213 case KeyBasicInformation: data_ptr = ((KEY_BASIC_INFORMATION *)info)->Name; break;
214 case KeyFullInformation: data_ptr = ((KEY_FULL_INFORMATION *)info)->Class; break;
215 case KeyNodeInformation: data_ptr = ((KEY_NODE_INFORMATION *)info)->Name; break;
216 default:
217 FIXME( "Information class %d not implemented\n", info_class );
218 return STATUS_INVALID_PARAMETER;
220 fixed_size = (char *)data_ptr - (char *)info;
222 SERVER_START_REQ( enum_key )
224 req->hkey = handle;
225 req->index = index;
226 req->info_class = info_class;
227 if (length > fixed_size) wine_server_set_reply( req, data_ptr, length - fixed_size );
228 if (!(ret = wine_server_call( req )))
230 LARGE_INTEGER modif;
232 RtlSecondsSince1970ToTime( reply->modif, &modif );
234 switch(info_class)
236 case KeyBasicInformation:
238 KEY_BASIC_INFORMATION keyinfo;
239 fixed_size = (char *)keyinfo.Name - (char *)&keyinfo;
240 keyinfo.LastWriteTime = modif;
241 keyinfo.TitleIndex = 0;
242 keyinfo.NameLength = reply->namelen;
243 memcpy( info, &keyinfo, min( length, fixed_size ) );
245 break;
246 case KeyFullInformation:
248 KEY_FULL_INFORMATION keyinfo;
249 fixed_size = (char *)keyinfo.Class - (char *)&keyinfo;
250 keyinfo.LastWriteTime = modif;
251 keyinfo.TitleIndex = 0;
252 keyinfo.ClassLength = wine_server_reply_size(reply);
253 keyinfo.ClassOffset = keyinfo.ClassLength ? fixed_size : -1;
254 keyinfo.SubKeys = reply->subkeys;
255 keyinfo.MaxNameLen = reply->max_subkey;
256 keyinfo.MaxClassLen = reply->max_class;
257 keyinfo.Values = reply->values;
258 keyinfo.MaxValueNameLen = reply->max_value;
259 keyinfo.MaxValueDataLen = reply->max_data;
260 memcpy( info, &keyinfo, min( length, fixed_size ) );
262 break;
263 case KeyNodeInformation:
265 KEY_NODE_INFORMATION keyinfo;
266 fixed_size = (char *)keyinfo.Name - (char *)&keyinfo;
267 keyinfo.LastWriteTime = modif;
268 keyinfo.TitleIndex = 0;
269 keyinfo.ClassLength = max( 0, wine_server_reply_size(reply) - reply->namelen );
270 keyinfo.ClassOffset = keyinfo.ClassLength ? fixed_size + reply->namelen : -1;
271 keyinfo.NameLength = reply->namelen;
272 memcpy( info, &keyinfo, min( length, fixed_size ) );
274 break;
276 *result_len = fixed_size + reply->total;
277 if (length < *result_len) ret = STATUS_BUFFER_OVERFLOW;
280 SERVER_END_REQ;
281 return ret;
286 /******************************************************************************
287 * NtEnumerateKey [NTDLL.@]
288 * ZwEnumerateKey [NTDLL.@]
290 * NOTES
291 * the name copied into the buffer is NOT 0-terminated
293 NTSTATUS WINAPI NtEnumerateKey( HANDLE handle, ULONG index, KEY_INFORMATION_CLASS info_class,
294 void *info, DWORD length, DWORD *result_len )
296 /* -1 means query key, so avoid it here */
297 if (index == (ULONG)-1) return STATUS_NO_MORE_ENTRIES;
298 return enumerate_key( handle, index, info_class, info, length, result_len );
302 /******************************************************************************
303 * RtlpNtEnumerateSubKey [NTDLL.@]
306 NTSTATUS WINAPI RtlpNtEnumerateSubKey( HANDLE handle, UNICODE_STRING *out, ULONG index )
308 KEY_BASIC_INFORMATION *info;
309 DWORD dwLen, dwResultLen;
310 NTSTATUS ret;
312 if (out->Length)
314 dwLen = out->Length + sizeof(KEY_BASIC_INFORMATION);
315 info = (KEY_BASIC_INFORMATION*)RtlAllocateHeap( GetProcessHeap(), 0, dwLen );
316 if (!info)
317 return STATUS_NO_MEMORY;
319 else
321 dwLen = 0;
322 info = NULL;
325 ret = NtEnumerateKey( handle, index, KeyBasicInformation, info, dwLen, &dwResultLen );
326 dwResultLen -= sizeof(KEY_BASIC_INFORMATION);
328 if (ret == STATUS_BUFFER_OVERFLOW)
329 out->Length = dwResultLen;
330 else if (!ret)
332 if (out->Length < info->NameLength)
334 out->Length = dwResultLen;
335 ret = STATUS_BUFFER_OVERFLOW;
337 else
339 out->Length = info->NameLength;
340 memcpy(out->Buffer, info->Name, info->NameLength);
344 if (info)
345 RtlFreeHeap( GetProcessHeap(), 0, info );
346 return ret;
349 /******************************************************************************
350 * NtQueryKey [NTDLL.@]
351 * ZwQueryKey [NTDLL.@]
353 NTSTATUS WINAPI NtQueryKey( HANDLE handle, KEY_INFORMATION_CLASS info_class,
354 void *info, DWORD length, DWORD *result_len )
356 return enumerate_key( handle, -1, info_class, info, length, result_len );
360 /* fill the key value info structure for a specific info class */
361 static void copy_key_value_info( KEY_VALUE_INFORMATION_CLASS info_class, void *info,
362 DWORD length, int type, int name_len, int data_len )
364 switch(info_class)
366 case KeyValueBasicInformation:
368 KEY_VALUE_BASIC_INFORMATION keyinfo;
369 keyinfo.TitleIndex = 0;
370 keyinfo.Type = type;
371 keyinfo.NameLength = name_len;
372 length = min( length, (char *)keyinfo.Name - (char *)&keyinfo );
373 memcpy( info, &keyinfo, length );
374 break;
376 case KeyValueFullInformation:
378 KEY_VALUE_FULL_INFORMATION keyinfo;
379 keyinfo.TitleIndex = 0;
380 keyinfo.Type = type;
381 keyinfo.DataOffset = (char *)keyinfo.Name - (char *)&keyinfo + name_len;
382 keyinfo.DataLength = data_len;
383 keyinfo.NameLength = name_len;
384 length = min( length, (char *)keyinfo.Name - (char *)&keyinfo );
385 memcpy( info, &keyinfo, length );
386 break;
388 case KeyValuePartialInformation:
390 KEY_VALUE_PARTIAL_INFORMATION keyinfo;
391 keyinfo.TitleIndex = 0;
392 keyinfo.Type = type;
393 keyinfo.DataLength = data_len;
394 length = min( length, (char *)keyinfo.Data - (char *)&keyinfo );
395 memcpy( info, &keyinfo, length );
396 break;
398 default:
399 break;
404 /******************************************************************************
405 * NtEnumerateValueKey [NTDLL.@]
406 * ZwEnumerateValueKey [NTDLL.@]
408 NTSTATUS WINAPI NtEnumerateValueKey( HANDLE handle, ULONG index,
409 KEY_VALUE_INFORMATION_CLASS info_class,
410 void *info, DWORD length, DWORD *result_len )
412 NTSTATUS ret;
413 void *ptr;
414 size_t fixed_size;
416 TRACE( "(%p,%lu,%d,%p,%ld)\n", handle, index, info_class, info, length );
418 /* compute the length we want to retrieve */
419 switch(info_class)
421 case KeyValueBasicInformation: ptr = ((KEY_VALUE_BASIC_INFORMATION *)info)->Name; break;
422 case KeyValueFullInformation: ptr = ((KEY_VALUE_FULL_INFORMATION *)info)->Name; break;
423 case KeyValuePartialInformation: ptr = ((KEY_VALUE_PARTIAL_INFORMATION *)info)->Data; break;
424 default:
425 FIXME( "Information class %d not implemented\n", info_class );
426 return STATUS_INVALID_PARAMETER;
428 fixed_size = (char *)ptr - (char *)info;
430 SERVER_START_REQ( enum_key_value )
432 req->hkey = handle;
433 req->index = index;
434 req->info_class = info_class;
435 if (length > fixed_size) wine_server_set_reply( req, ptr, length - fixed_size );
436 if (!(ret = wine_server_call( req )))
438 copy_key_value_info( info_class, info, length, reply->type, reply->namelen,
439 wine_server_reply_size(reply) - reply->namelen );
440 *result_len = fixed_size + reply->total;
441 if (length < *result_len) ret = STATUS_BUFFER_OVERFLOW;
444 SERVER_END_REQ;
445 return ret;
449 /******************************************************************************
450 * NtQueryValueKey [NTDLL.@]
451 * ZwQueryValueKey [NTDLL.@]
453 * NOTES
454 * the name in the KeyValueInformation is never set
456 NTSTATUS WINAPI NtQueryValueKey( HANDLE handle, const UNICODE_STRING *name,
457 KEY_VALUE_INFORMATION_CLASS info_class,
458 void *info, DWORD length, DWORD *result_len )
460 NTSTATUS ret;
461 UCHAR *data_ptr;
462 unsigned int fixed_size = 0;
464 TRACE( "(%p,%s,%d,%p,%ld)\n", handle, debugstr_us(name), info_class, info, length );
466 if (name->Length > MAX_NAME_LENGTH) return STATUS_BUFFER_OVERFLOW;
468 /* compute the length we want to retrieve */
469 switch(info_class)
471 case KeyValueBasicInformation:
472 fixed_size = (char *)((KEY_VALUE_BASIC_INFORMATION *)info)->Name - (char *)info;
473 data_ptr = NULL;
474 break;
475 case KeyValueFullInformation:
476 data_ptr = (UCHAR *)((KEY_VALUE_FULL_INFORMATION *)info)->Name;
477 fixed_size = (char *)data_ptr - (char *)info;
478 break;
479 case KeyValuePartialInformation:
480 data_ptr = ((KEY_VALUE_PARTIAL_INFORMATION *)info)->Data;
481 fixed_size = (char *)data_ptr - (char *)info;
482 break;
483 default:
484 FIXME( "Information class %d not implemented\n", info_class );
485 return STATUS_INVALID_PARAMETER;
488 SERVER_START_REQ( get_key_value )
490 req->hkey = handle;
491 wine_server_add_data( req, name->Buffer, name->Length );
492 if (length > fixed_size) wine_server_set_reply( req, data_ptr, length - fixed_size );
493 if (!(ret = wine_server_call( req )))
495 copy_key_value_info( info_class, info, length, reply->type,
496 0, wine_server_reply_size(reply) );
497 *result_len = fixed_size + reply->total;
498 if (length < *result_len) ret = STATUS_BUFFER_OVERFLOW;
501 SERVER_END_REQ;
502 return ret;
505 /******************************************************************************
506 * RtlpNtQueryValueKey [NTDLL.@]
509 NTSTATUS WINAPI RtlpNtQueryValueKey( HANDLE handle, ULONG *result_type, PBYTE dest,
510 DWORD *result_len )
512 KEY_VALUE_PARTIAL_INFORMATION *info;
513 UNICODE_STRING name;
514 NTSTATUS ret;
515 DWORD dwResultLen;
516 DWORD dwLen = sizeof (KEY_VALUE_PARTIAL_INFORMATION) + result_len ? *result_len : 0;
518 info = (KEY_VALUE_PARTIAL_INFORMATION*)RtlAllocateHeap( GetProcessHeap(), 0, dwLen );
519 if (!info)
520 return STATUS_NO_MEMORY;
522 name.Length = 0;
523 ret = NtQueryValueKey( handle, &name, KeyValuePartialInformation, info, dwLen, &dwResultLen );
525 if (!ret || ret == STATUS_BUFFER_OVERFLOW)
527 if (result_len)
528 *result_len = info->DataLength;
530 if (result_type)
531 *result_type = info->Type;
533 if (ret != STATUS_BUFFER_OVERFLOW)
534 memcpy( dest, info->Data, info->DataLength );
537 RtlFreeHeap( GetProcessHeap(), 0, info );
538 return ret;
541 /******************************************************************************
542 * NtFlushKey [NTDLL.@]
543 * ZwFlushKey [NTDLL.@]
545 NTSTATUS WINAPI NtFlushKey(HANDLE key)
547 NTSTATUS ret;
549 TRACE("key=%p\n", key);
551 SERVER_START_REQ( flush_key )
553 req->hkey = key;
554 ret = wine_server_call( req );
556 SERVER_END_REQ;
558 return ret;
561 /******************************************************************************
562 * NtLoadKey [NTDLL.@]
563 * ZwLoadKey [NTDLL.@]
565 NTSTATUS WINAPI NtLoadKey( const OBJECT_ATTRIBUTES *attr, OBJECT_ATTRIBUTES *file )
567 NTSTATUS ret;
568 HANDLE hive;
569 IO_STATUS_BLOCK io;
571 TRACE("(%p,%p)\n", attr, file);
573 ret = NtCreateFile(&hive, GENERIC_READ, file, &io, NULL, FILE_ATTRIBUTE_NORMAL, 0,
574 OPEN_EXISTING, 0, NULL, 0);
575 if (ret) return ret;
577 SERVER_START_REQ( load_registry )
579 req->hkey = attr->RootDirectory;
580 req->file = hive;
581 wine_server_add_data(req, attr->ObjectName->Buffer, attr->ObjectName->Length);
582 ret = wine_server_call( req );
584 SERVER_END_REQ;
586 NtClose(hive);
588 return ret;
591 /******************************************************************************
592 * NtNotifyChangeKey [NTDLL.@]
593 * ZwNotifyChangeKey [NTDLL.@]
595 NTSTATUS WINAPI NtNotifyChangeKey(
596 IN HANDLE KeyHandle,
597 IN HANDLE Event,
598 IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
599 IN PVOID ApcContext OPTIONAL,
600 OUT PIO_STATUS_BLOCK IoStatusBlock,
601 IN ULONG CompletionFilter,
602 IN BOOLEAN Asynchronous,
603 OUT PVOID ChangeBuffer,
604 IN ULONG Length,
605 IN BOOLEAN WatchSubtree)
607 NTSTATUS ret;
609 TRACE("(%p,%p,%p,%p,%p,0x%08lx, 0x%08x,%p,0x%08lx,0x%08x)\n",
610 KeyHandle, Event, ApcRoutine, ApcContext, IoStatusBlock, CompletionFilter,
611 Asynchronous, ChangeBuffer, Length, WatchSubtree);
613 if (ApcRoutine || ApcContext || ChangeBuffer || Length)
614 FIXME("Unimplemented optional parameter\n");
616 if (!Asynchronous)
618 OBJECT_ATTRIBUTES attr;
619 InitializeObjectAttributes( &attr, NULL, 0, NULL, NULL );
620 ret = NtCreateEvent( &Event, EVENT_ALL_ACCESS, &attr, FALSE, FALSE );
621 if (ret != STATUS_SUCCESS)
622 return ret;
625 SERVER_START_REQ( set_registry_notification )
627 req->hkey = KeyHandle;
628 req->event = Event;
629 req->subtree = WatchSubtree;
630 req->filter = CompletionFilter;
631 ret = wine_server_call( req );
633 SERVER_END_REQ;
635 if (!Asynchronous)
637 if (ret == STATUS_SUCCESS)
638 NtWaitForSingleObject( Event, FALSE, NULL );
639 NtClose( Event );
642 return STATUS_SUCCESS;
645 /******************************************************************************
646 * NtQueryMultipleValueKey [NTDLL]
647 * ZwQueryMultipleValueKey
650 NTSTATUS WINAPI NtQueryMultipleValueKey(
651 HANDLE KeyHandle,
652 PKEY_MULTIPLE_VALUE_INFORMATION ListOfValuesToQuery,
653 ULONG NumberOfItems,
654 PVOID MultipleValueInformation,
655 ULONG Length,
656 PULONG ReturnLength)
658 FIXME("(%p,%p,0x%08lx,%p,0x%08lx,%p) stub!\n",
659 KeyHandle, ListOfValuesToQuery, NumberOfItems, MultipleValueInformation,
660 Length,ReturnLength);
661 return STATUS_SUCCESS;
664 /******************************************************************************
665 * NtReplaceKey [NTDLL.@]
666 * ZwReplaceKey [NTDLL.@]
668 NTSTATUS WINAPI NtReplaceKey(
669 IN POBJECT_ATTRIBUTES ObjectAttributes,
670 IN HANDLE Key,
671 IN POBJECT_ATTRIBUTES ReplacedObjectAttributes)
673 FIXME("(%p),stub!\n", Key);
674 dump_ObjectAttributes(ObjectAttributes);
675 dump_ObjectAttributes(ReplacedObjectAttributes);
676 return STATUS_SUCCESS;
678 /******************************************************************************
679 * NtRestoreKey [NTDLL.@]
680 * ZwRestoreKey [NTDLL.@]
682 NTSTATUS WINAPI NtRestoreKey(
683 HANDLE KeyHandle,
684 HANDLE FileHandle,
685 ULONG RestoreFlags)
687 FIXME("(%p,%p,0x%08lx) stub\n",
688 KeyHandle, FileHandle, RestoreFlags);
689 return STATUS_SUCCESS;
691 /******************************************************************************
692 * NtSaveKey [NTDLL.@]
693 * ZwSaveKey [NTDLL.@]
695 NTSTATUS WINAPI NtSaveKey(IN HANDLE KeyHandle, IN HANDLE FileHandle)
697 NTSTATUS ret;
699 TRACE("(%p,%p)\n", KeyHandle, FileHandle);
701 SERVER_START_REQ( save_registry )
703 req->hkey = KeyHandle;
704 req->file = FileHandle;
705 ret = wine_server_call( req );
707 SERVER_END_REQ;
709 return ret;
711 /******************************************************************************
712 * NtSetInformationKey [NTDLL.@]
713 * ZwSetInformationKey [NTDLL.@]
715 NTSTATUS WINAPI NtSetInformationKey(
716 IN HANDLE KeyHandle,
717 IN const int KeyInformationClass,
718 IN PVOID KeyInformation,
719 IN ULONG KeyInformationLength)
721 FIXME("(%p,0x%08x,%p,0x%08lx) stub\n",
722 KeyHandle, KeyInformationClass, KeyInformation, KeyInformationLength);
723 return STATUS_SUCCESS;
727 /******************************************************************************
728 * NtSetValueKey [NTDLL.@]
729 * ZwSetValueKey [NTDLL.@]
731 * NOTES
732 * win95 does not care about count for REG_SZ and finds out the len by itself (js)
733 * NT does definitely care (aj)
735 NTSTATUS WINAPI NtSetValueKey( HANDLE hkey, const UNICODE_STRING *name, ULONG TitleIndex,
736 ULONG type, const void *data, ULONG count )
738 NTSTATUS ret;
740 TRACE( "(%p,%s,%ld,%p,%ld)\n", hkey, debugstr_us(name), type, data, count );
742 if (name->Length > MAX_NAME_LENGTH) return STATUS_BUFFER_OVERFLOW;
744 SERVER_START_REQ( set_key_value )
746 req->hkey = hkey;
747 req->type = type;
748 req->namelen = name->Length;
749 wine_server_add_data( req, name->Buffer, name->Length );
750 wine_server_add_data( req, data, count );
751 ret = wine_server_call( req );
753 SERVER_END_REQ;
754 return ret;
757 /******************************************************************************
758 * RtlpNtSetValueKey [NTDLL.@]
761 NTSTATUS WINAPI RtlpNtSetValueKey( HANDLE hkey, ULONG type, const void *data,
762 ULONG count )
764 UNICODE_STRING name;
766 name.Length = 0;
767 return NtSetValueKey( hkey, &name, 0, type, data, count );
770 /******************************************************************************
771 * NtUnloadKey [NTDLL.@]
772 * ZwUnloadKey [NTDLL.@]
774 NTSTATUS WINAPI NtUnloadKey(IN HANDLE KeyHandle)
776 NTSTATUS ret;
778 TRACE("(%p)\n", KeyHandle);
780 SERVER_START_REQ( unload_registry )
782 req->hkey = KeyHandle;
783 ret = wine_server_call(req);
785 SERVER_END_REQ;
787 return ret;
790 /******************************************************************************
791 * RtlFormatCurrentUserKeyPath [NTDLL.@]
794 NTSTATUS WINAPI RtlFormatCurrentUserKeyPath( IN OUT PUNICODE_STRING KeyPath)
796 static const WCHAR pathW[] = {'\\','R','e','g','i','s','t','r','y','\\','U','s','e','r','\\'};
797 HANDLE token;
798 NTSTATUS status;
800 status = NtOpenThreadToken(GetCurrentThread(), TOKEN_READ, TRUE, &token);
801 if (status == STATUS_NO_TOKEN)
802 status = NtOpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token);
803 if (status == STATUS_SUCCESS)
805 char buffer[sizeof(TOKEN_USER) + sizeof(SID) + sizeof(DWORD)*SID_MAX_SUB_AUTHORITIES];
806 DWORD len = sizeof(buffer);
808 status = NtQueryInformationToken(token, TokenUser, buffer, len, &len);
809 if (status == STATUS_SUCCESS)
811 KeyPath->MaximumLength = 0;
812 status = RtlConvertSidToUnicodeString(KeyPath, ((TOKEN_USER *)buffer)->User.Sid, FALSE);
813 if (status == STATUS_BUFFER_OVERFLOW)
815 PWCHAR buf = RtlAllocateHeap(GetProcessHeap(), 0,
816 sizeof(pathW) + KeyPath->Length + sizeof(WCHAR));
817 if (buf)
819 memcpy(buf, pathW, sizeof(pathW));
820 KeyPath->MaximumLength = KeyPath->Length + sizeof(WCHAR);
821 KeyPath->Buffer = (PWCHAR)((LPBYTE)buf + sizeof(pathW));
822 status = RtlConvertSidToUnicodeString(KeyPath,
823 ((TOKEN_USER *)buffer)->User.Sid, FALSE);
824 KeyPath->Buffer = (PWCHAR)buf;
825 KeyPath->Length += sizeof(pathW);
826 KeyPath->MaximumLength += sizeof(pathW);
828 else
829 status = STATUS_NO_MEMORY;
832 NtClose(token);
834 return status;
837 /******************************************************************************
838 * RtlOpenCurrentUser [NTDLL.@]
840 * NOTES
841 * If we return just HKEY_CURRENT_USER the advapi tries to find a remote
842 * registry (odd handle) and fails.
844 DWORD WINAPI RtlOpenCurrentUser(
845 IN ACCESS_MASK DesiredAccess, /* [in] */
846 OUT PHANDLE KeyHandle) /* [out] handle of HKEY_CURRENT_USER */
848 OBJECT_ATTRIBUTES ObjectAttributes;
849 UNICODE_STRING ObjectName;
850 NTSTATUS ret;
852 TRACE("(0x%08lx, %p)\n",DesiredAccess, KeyHandle);
854 RtlFormatCurrentUserKeyPath(&ObjectName);
855 InitializeObjectAttributes(&ObjectAttributes,&ObjectName,OBJ_CASE_INSENSITIVE,0, NULL);
856 ret = NtCreateKey(KeyHandle, DesiredAccess, &ObjectAttributes, 0, NULL, 0, NULL);
857 RtlFreeUnicodeString(&ObjectName);
858 return ret;
862 static NTSTATUS RTL_ReportRegistryValue(PKEY_VALUE_FULL_INFORMATION pInfo,
863 PRTL_QUERY_REGISTRY_TABLE pQuery, PVOID pContext, PVOID pEnvironment)
865 PUNICODE_STRING str;
866 UNICODE_STRING src, dst;
867 LONG *bin;
868 ULONG offset;
869 PWSTR wstr;
870 DWORD res;
871 NTSTATUS status = STATUS_SUCCESS;
872 ULONG len;
873 LPWSTR String;
874 INT count = 0;
876 if (pInfo == NULL)
878 if (pQuery->Flags & RTL_QUERY_REGISTRY_DIRECT)
879 return STATUS_INVALID_PARAMETER;
880 else
882 status = pQuery->QueryRoutine(pQuery->Name, pQuery->DefaultType, pQuery->DefaultData,
883 pQuery->DefaultLength, pContext, pQuery->EntryContext);
885 return status;
887 len = pInfo->DataLength;
889 if (pQuery->Flags & RTL_QUERY_REGISTRY_DIRECT)
891 str = (PUNICODE_STRING)pQuery->EntryContext;
893 switch(pInfo->Type)
895 case REG_EXPAND_SZ:
896 if (!(pQuery->Flags & RTL_QUERY_REGISTRY_NOEXPAND))
898 RtlInitUnicodeString(&src, (WCHAR*)(((CHAR*)pInfo) + pInfo->DataOffset));
899 res = 0;
900 dst.MaximumLength = 0;
901 RtlExpandEnvironmentStrings_U(pEnvironment, &src, &dst, &res);
902 dst.Length = 0;
903 dst.MaximumLength = res;
904 dst.Buffer = RtlAllocateHeap(GetProcessHeap(), 0, res * sizeof(WCHAR));
905 RtlExpandEnvironmentStrings_U(pEnvironment, &src, &dst, &res);
906 status = pQuery->QueryRoutine(pQuery->Name, pInfo->Type, dst.Buffer,
907 dst.Length, pContext, pQuery->EntryContext);
908 RtlFreeHeap(GetProcessHeap(), 0, dst.Buffer);
911 case REG_SZ:
912 case REG_LINK:
913 if (str->Buffer == NULL)
914 RtlCreateUnicodeString(str, (WCHAR*)(((CHAR*)pInfo) + pInfo->DataOffset));
915 else
916 RtlAppendUnicodeToString(str, (WCHAR*)(((CHAR*)pInfo) + pInfo->DataOffset));
917 break;
919 case REG_MULTI_SZ:
920 if (!(pQuery->Flags & RTL_QUERY_REGISTRY_NOEXPAND))
921 return STATUS_INVALID_PARAMETER;
923 if (str->Buffer == NULL)
925 str->Buffer = RtlAllocateHeap(GetProcessHeap(), 0, len);
926 str->MaximumLength = len;
928 len = min(len, str->MaximumLength);
929 memcpy(str->Buffer, ((CHAR*)pInfo) + pInfo->DataOffset, len);
930 str->Length = len;
931 break;
933 default:
934 bin = (LONG*)pQuery->EntryContext;
935 if (pInfo->DataLength <= sizeof(ULONG))
936 memcpy(bin, ((CHAR*)pInfo) + pInfo->DataOffset,
937 pInfo->DataLength);
938 else
940 if (bin[0] <= sizeof(ULONG))
942 memcpy(&bin[1], ((CHAR*)pInfo) + pInfo->DataOffset,
943 min(-bin[0], pInfo->DataLength));
945 else
947 len = min(bin[0], pInfo->DataLength);
948 bin[1] = len;
949 bin[2] = pInfo->Type;
950 memcpy(&bin[3], ((CHAR*)pInfo) + pInfo->DataOffset, len);
953 break;
956 else
958 if((pQuery->Flags & RTL_QUERY_REGISTRY_NOEXPAND) ||
959 (pInfo->Type != REG_EXPAND_SZ && pInfo->Type != REG_MULTI_SZ))
961 status = pQuery->QueryRoutine(pInfo->Name, pInfo->Type,
962 ((CHAR*)pInfo) + pInfo->DataOffset, pInfo->DataLength,
963 pContext, pQuery->EntryContext);
965 else if (pInfo->Type == REG_EXPAND_SZ)
967 RtlInitUnicodeString(&src, (WCHAR*)(((CHAR*)pInfo) + pInfo->DataOffset));
968 res = 0;
969 dst.MaximumLength = 0;
970 RtlExpandEnvironmentStrings_U(pEnvironment, &src, &dst, &res);
971 dst.Length = 0;
972 dst.MaximumLength = res;
973 dst.Buffer = RtlAllocateHeap(GetProcessHeap(), 0, res * sizeof(WCHAR));
974 RtlExpandEnvironmentStrings_U(pEnvironment, &src, &dst, &res);
975 status = pQuery->QueryRoutine(pQuery->Name, pInfo->Type, dst.Buffer,
976 dst.Length, pContext, pQuery->EntryContext);
977 RtlFreeHeap(GetProcessHeap(), 0, dst.Buffer);
979 else /* REG_MULTI_SZ */
981 if(pQuery->Flags & RTL_QUERY_REGISTRY_NOEXPAND)
983 for (offset = 0; offset <= pInfo->DataLength; offset += len + sizeof(WCHAR))
985 wstr = (WCHAR*)(((CHAR*)pInfo) + offset);
986 len = strlenW(wstr) * sizeof(WCHAR);
987 status = pQuery->QueryRoutine(pQuery->Name, pInfo->Type, wstr, len,
988 pContext, pQuery->EntryContext);
989 if(status != STATUS_SUCCESS && status != STATUS_BUFFER_TOO_SMALL)
990 return status;
993 else
995 while(count<=pInfo->DataLength)
997 String = (WCHAR*)(((CHAR*)pInfo) + pInfo->DataOffset)+count;
998 count+=strlenW(String)+1;
999 RtlInitUnicodeString(&src, (WCHAR*)(((CHAR*)pInfo) + pInfo->DataOffset));
1000 res = 0;
1001 dst.MaximumLength = 0;
1002 RtlExpandEnvironmentStrings_U(pEnvironment, &src, &dst, &res);
1003 dst.Length = 0;
1004 dst.MaximumLength = res;
1005 dst.Buffer = RtlAllocateHeap(GetProcessHeap(), 0, res * sizeof(WCHAR));
1006 RtlExpandEnvironmentStrings_U(pEnvironment, &src, &dst, &res);
1007 status = pQuery->QueryRoutine(pQuery->Name, pInfo->Type, dst.Buffer,
1008 dst.Length, pContext, pQuery->EntryContext);
1009 RtlFreeHeap(GetProcessHeap(), 0, dst.Buffer);
1010 if(status != STATUS_SUCCESS && status != STATUS_BUFFER_TOO_SMALL)
1011 return status;
1016 return status;
1020 static NTSTATUS RTL_GetKeyHandle(ULONG RelativeTo, PCWSTR Path, PHANDLE handle)
1022 UNICODE_STRING KeyString;
1023 OBJECT_ATTRIBUTES regkey;
1024 PCWSTR base;
1025 INT len;
1026 NTSTATUS status;
1028 static const WCHAR empty[] = {0};
1029 static const WCHAR control[] = {'\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e',
1030 '\\','S','y','s','t','e','m','\\','C','u','r','r','e','n','t',' ','C','o','n','t','r','o','l','S','e','t','\\',
1031 'C','o','n','t','r','o','l','\\',0};
1033 static const WCHAR devicemap[] = {'\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e','\\',
1034 'H','a','r','d','w','a','r','e','\\','D','e','v','i','c','e','M','a','p','\\',0};
1036 static const WCHAR services[] = {'\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e','\\',
1037 'S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
1038 'S','e','r','v','i','c','e','s','\\',0};
1040 static const WCHAR user[] = {'\\','R','e','g','i','s','t','r','y','\\','U','s','e','r','\\',
1041 'C','u','r','r','e','n','t','U','s','e','r','\\',0};
1043 static const WCHAR windows_nt[] = {'\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e','\\',
1044 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
1045 'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',0};
1047 switch (RelativeTo & 0xff)
1049 case RTL_REGISTRY_ABSOLUTE:
1050 base = empty;
1051 break;
1053 case RTL_REGISTRY_CONTROL:
1054 base = control;
1055 break;
1057 case RTL_REGISTRY_DEVICEMAP:
1058 base = devicemap;
1059 break;
1061 case RTL_REGISTRY_SERVICES:
1062 base = services;
1063 break;
1065 case RTL_REGISTRY_USER:
1066 base = user;
1067 break;
1069 case RTL_REGISTRY_WINDOWS_NT:
1070 base = windows_nt;
1071 break;
1073 default:
1074 return STATUS_INVALID_PARAMETER;
1077 len = (strlenW(base) + strlenW(Path) + 1) * sizeof(WCHAR);
1078 KeyString.Buffer = RtlAllocateHeap(GetProcessHeap(), 0, len);
1079 if (KeyString.Buffer == NULL)
1080 return STATUS_NO_MEMORY;
1082 strcpyW(KeyString.Buffer, base);
1083 strcatW(KeyString.Buffer, Path);
1084 KeyString.Length = len - sizeof(WCHAR);
1085 KeyString.MaximumLength = len;
1086 InitializeObjectAttributes(&regkey, &KeyString, OBJ_CASE_INSENSITIVE, NULL, NULL);
1087 status = NtOpenKey(handle, KEY_ALL_ACCESS, &regkey);
1088 RtlFreeHeap(GetProcessHeap(), 0, KeyString.Buffer);
1089 return status;
1092 /*************************************************************************
1093 * RtlQueryRegistryValues [NTDLL.@]
1095 * Query multiple registry values with a signle call.
1097 * PARAMS
1098 * RelativeTo [I] Registry path that Path refers to
1099 * Path [I] Path to key
1100 * QueryTable [I] Table of key values to query
1101 * Context [I] Paremeter to pass to the application defined QueryRoutine function
1102 * Environment [I] Optional parameter to use when performing expantion
1104 * RETURNS
1105 * STATUS_SUCCESS or an appropriate NTSTATUS error code.
1107 NTSTATUS WINAPI RtlQueryRegistryValues(IN ULONG RelativeTo, IN PCWSTR Path,
1108 IN PRTL_QUERY_REGISTRY_TABLE QueryTable, IN PVOID Context,
1109 IN PVOID Environment OPTIONAL)
1111 UNICODE_STRING Value;
1112 HANDLE handle, topkey;
1113 PKEY_VALUE_FULL_INFORMATION pInfo = NULL;
1114 ULONG len, buflen = 0;
1115 NTSTATUS status=STATUS_SUCCESS, ret = STATUS_SUCCESS;
1116 INT i;
1118 TRACE("(%ld, %s, %p, %p, %p)\n", RelativeTo, debugstr_w(Path), QueryTable, Context, Environment);
1120 if(Path == NULL)
1121 return STATUS_INVALID_PARAMETER;
1123 /* get a valid handle */
1124 if (RelativeTo & RTL_REGISTRY_HANDLE)
1125 topkey = handle = (HANDLE)Path;
1126 else
1128 status = RTL_GetKeyHandle(RelativeTo, Path, &topkey);
1129 handle = topkey;
1131 if(status != STATUS_SUCCESS)
1132 return status;
1134 /* Process query table entries */
1135 for (; QueryTable->QueryRoutine != NULL || QueryTable->Name != NULL; ++QueryTable)
1137 if (QueryTable->Flags &
1138 (RTL_QUERY_REGISTRY_SUBKEY | RTL_QUERY_REGISTRY_TOPKEY))
1140 /* topkey must be kept open just in case we will reuse it later */
1141 if (handle != topkey)
1142 NtClose(handle);
1144 if (QueryTable->Flags & RTL_QUERY_REGISTRY_SUBKEY)
1146 handle = 0;
1147 status = RTL_GetKeyHandle((ULONG)QueryTable->Name, Path, &handle);
1148 if(status != STATUS_SUCCESS)
1150 ret = status;
1151 goto out;
1154 else
1155 handle = topkey;
1158 if (QueryTable->Flags & RTL_QUERY_REGISTRY_NOVALUE)
1160 QueryTable->QueryRoutine(QueryTable->Name, REG_NONE, NULL, 0,
1161 Context, QueryTable->EntryContext);
1162 continue;
1165 if (!handle)
1167 if (QueryTable->Flags & RTL_QUERY_REGISTRY_REQUIRED)
1169 ret = STATUS_OBJECT_NAME_NOT_FOUND;
1170 goto out;
1172 continue;
1175 if (QueryTable->Name == NULL)
1177 if (QueryTable->Flags & RTL_QUERY_REGISTRY_DIRECT)
1179 ret = STATUS_INVALID_PARAMETER;
1180 goto out;
1183 /* Report all subkeys */
1184 for (i = 0;; ++i)
1186 status = NtEnumerateValueKey(handle, i,
1187 KeyValueFullInformation, pInfo, buflen, &len);
1188 if (status == STATUS_NO_MORE_ENTRIES)
1189 break;
1190 if (status == STATUS_BUFFER_OVERFLOW ||
1191 status == STATUS_BUFFER_TOO_SMALL)
1193 buflen = len;
1194 RtlFreeHeap(GetProcessHeap(), 0, pInfo);
1195 pInfo = (KEY_VALUE_FULL_INFORMATION*)RtlAllocateHeap(
1196 GetProcessHeap(), 0, buflen);
1197 NtEnumerateValueKey(handle, i, KeyValueFullInformation,
1198 pInfo, buflen, &len);
1201 status = RTL_ReportRegistryValue(pInfo, QueryTable, Context, Environment);
1202 if(status != STATUS_SUCCESS && status != STATUS_BUFFER_TOO_SMALL)
1204 ret = status;
1205 goto out;
1207 if (QueryTable->Flags & RTL_QUERY_REGISTRY_DELETE)
1209 RtlInitUnicodeString(&Value, pInfo->Name);
1210 NtDeleteValueKey(handle, &Value);
1214 if (i == 0 && (QueryTable->Flags & RTL_QUERY_REGISTRY_REQUIRED))
1216 ret = STATUS_OBJECT_NAME_NOT_FOUND;
1217 goto out;
1220 else
1222 RtlInitUnicodeString(&Value, QueryTable->Name);
1223 status = NtQueryValueKey(handle, &Value, KeyValueFullInformation,
1224 pInfo, buflen, &len);
1225 if (status == STATUS_BUFFER_OVERFLOW ||
1226 status == STATUS_BUFFER_TOO_SMALL)
1228 buflen = len;
1229 RtlFreeHeap(GetProcessHeap(), 0, pInfo);
1230 pInfo = (KEY_VALUE_FULL_INFORMATION*)RtlAllocateHeap(
1231 GetProcessHeap(), 0, buflen);
1232 status = NtQueryValueKey(handle, &Value,
1233 KeyValueFullInformation, pInfo, buflen, &len);
1235 if (status != STATUS_SUCCESS)
1237 if (QueryTable->Flags & RTL_QUERY_REGISTRY_REQUIRED)
1239 ret = STATUS_OBJECT_NAME_NOT_FOUND;
1240 goto out;
1242 status = RTL_ReportRegistryValue(NULL, QueryTable, Context, Environment);
1243 if(status != STATUS_SUCCESS && status != STATUS_BUFFER_TOO_SMALL)
1245 ret = status;
1246 goto out;
1249 else
1251 status = RTL_ReportRegistryValue(pInfo, QueryTable, Context, Environment);
1252 if(status != STATUS_SUCCESS && status != STATUS_BUFFER_TOO_SMALL)
1254 ret = status;
1255 goto out;
1257 if (QueryTable->Flags & RTL_QUERY_REGISTRY_DELETE)
1258 NtDeleteValueKey(handle, &Value);
1263 out:
1264 RtlFreeHeap(GetProcessHeap(), 0, pInfo);
1265 if (handle != topkey)
1266 NtClose(handle);
1267 NtClose(topkey);
1268 return ret;
1271 /*************************************************************************
1272 * RtlCheckRegistryKey [NTDLL.@]
1274 * Query multiple registry values with a signle call.
1276 * PARAMS
1277 * RelativeTo [I] Registry path that Path refers to
1278 * Path [I] Path to key
1280 * RETURNS
1281 * STATUS_SUCCESS if the specified key exists, or an NTSTATUS error code.
1283 NTSTATUS WINAPI RtlCheckRegistryKey(IN ULONG RelativeTo, IN PWSTR Path)
1285 HANDLE handle;
1286 NTSTATUS status;
1288 TRACE("(%ld, %s)\n", RelativeTo, debugstr_w(Path));
1290 if((!RelativeTo) && Path == NULL)
1291 return STATUS_OBJECT_PATH_SYNTAX_BAD;
1292 if(RelativeTo & RTL_REGISTRY_HANDLE)
1293 return STATUS_SUCCESS;
1295 status = RTL_GetKeyHandle(RelativeTo, Path, &handle);
1296 if (handle) NtClose(handle);
1297 if (status == STATUS_INVALID_HANDLE) status = STATUS_OBJECT_NAME_NOT_FOUND;
1298 return status;
1301 /*************************************************************************
1302 * RtlDeleteRegistryValue [NTDLL.@]
1304 * Query multiple registry values with a signle call.
1306 * PARAMS
1307 * RelativeTo [I] Registry path that Path refers to
1308 * Path [I] Path to key
1309 * ValueName [I] Name of the value to delete
1311 * RETURNS
1312 * STATUS_SUCCESS if the specified key is successfully deleted, or an NTSTATUS error code.
1314 NTSTATUS WINAPI RtlDeleteRegistryValue(IN ULONG RelativeTo, IN PCWSTR Path, IN PCWSTR ValueName)
1316 NTSTATUS status;
1317 HANDLE handle;
1318 UNICODE_STRING Value;
1320 TRACE("(%ld, %s, %s)\n", RelativeTo, debugstr_w(Path), debugstr_w(ValueName));
1322 RtlInitUnicodeString(&Value, ValueName);
1323 if(RelativeTo == RTL_REGISTRY_HANDLE)
1325 return NtDeleteValueKey((HANDLE)Path, &Value);
1327 status = RTL_GetKeyHandle(RelativeTo, Path, &handle);
1328 if (status) return status;
1329 status = NtDeleteValueKey(handle, &Value);
1330 NtClose(handle);
1331 return status;