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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
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
30 #include "wine/port.h"
37 #define WIN32_NO_STATUS
38 #include "wine/library.h"
39 #include "ntdll_misc.h"
40 #include "wine/debug.h"
41 #include "wine/unicode.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(reg
);
45 /* maximum length of a key/value name in bytes (without terminating null) */
46 #define MAX_NAME_LENGTH ((MAX_PATH-1) * sizeof(WCHAR))
48 /******************************************************************************
49 * NtCreateKey [NTDLL.@]
50 * ZwCreateKey [NTDLL.@]
52 NTSTATUS WINAPI
NtCreateKey( PHANDLE retkey
, ACCESS_MASK access
, const OBJECT_ATTRIBUTES
*attr
,
53 ULONG TitleIndex
, const UNICODE_STRING
*class, ULONG options
,
58 if (!retkey
|| !attr
) return STATUS_ACCESS_VIOLATION
;
59 if (attr
->Length
> sizeof(OBJECT_ATTRIBUTES
)) return STATUS_INVALID_PARAMETER
;
60 if (attr
->ObjectName
->Length
> MAX_NAME_LENGTH
) return STATUS_BUFFER_OVERFLOW
;
62 TRACE( "(%p,%s,%s,%x,%x,%p)\n", attr
->RootDirectory
, debugstr_us(attr
->ObjectName
),
63 debugstr_us(class), options
, access
, retkey
);
65 SERVER_START_REQ( create_key
)
67 req
->parent
= attr
->RootDirectory
;
69 req
->attributes
= attr
->Attributes
;
70 req
->options
= options
;
72 req
->namelen
= attr
->ObjectName
->Length
;
73 wine_server_add_data( req
, attr
->ObjectName
->Buffer
, attr
->ObjectName
->Length
);
74 if (class) wine_server_add_data( req
, class->Buffer
, class->Length
);
75 if (!(ret
= wine_server_call( req
)))
77 *retkey
= reply
->hkey
;
78 if (dispos
) *dispos
= reply
->created
? REG_CREATED_NEW_KEY
: REG_OPENED_EXISTING_KEY
;
82 TRACE("<- %p\n", *retkey
);
86 /******************************************************************************
87 * RtlpNtCreateKey [NTDLL.@]
91 NTSTATUS WINAPI
RtlpNtCreateKey( PHANDLE retkey
, ACCESS_MASK access
, const OBJECT_ATTRIBUTES
*attr
,
92 ULONG TitleIndex
, const UNICODE_STRING
*class, ULONG options
,
100 oa
.Attributes
&= ~(OBJ_PERMANENT
|OBJ_EXCLUSIVE
);
104 return NtCreateKey(retkey
, access
, attr
, 0, NULL
, 0, dispos
);
107 /******************************************************************************
108 * NtOpenKey [NTDLL.@]
109 * ZwOpenKey [NTDLL.@]
111 * OUT HANDLE retkey (returns 0 when failure)
112 * IN ACCESS_MASK access
113 * IN POBJECT_ATTRIBUTES attr
115 NTSTATUS WINAPI
NtOpenKey( PHANDLE retkey
, ACCESS_MASK access
, const OBJECT_ATTRIBUTES
*attr
)
118 DWORD len
= attr
->ObjectName
->Length
;
120 TRACE( "(%p,%s,%x,%p)\n", attr
->RootDirectory
,
121 debugstr_us(attr
->ObjectName
), access
, retkey
);
123 if (len
> MAX_NAME_LENGTH
) return STATUS_BUFFER_OVERFLOW
;
124 if (!retkey
) return STATUS_INVALID_PARAMETER
;
126 SERVER_START_REQ( open_key
)
128 req
->parent
= attr
->RootDirectory
;
129 req
->access
= access
;
130 req
->attributes
= attr
->Attributes
;
131 wine_server_add_data( req
, attr
->ObjectName
->Buffer
, len
);
132 ret
= wine_server_call( req
);
133 *retkey
= reply
->hkey
;
136 TRACE("<- %p\n", *retkey
);
140 /******************************************************************************
141 * RtlpNtOpenKey [NTDLL.@]
145 NTSTATUS WINAPI
RtlpNtOpenKey( PHANDLE retkey
, ACCESS_MASK access
, OBJECT_ATTRIBUTES
*attr
)
148 attr
->Attributes
&= ~(OBJ_PERMANENT
|OBJ_EXCLUSIVE
);
149 return NtOpenKey(retkey
, access
, attr
);
152 /******************************************************************************
153 * NtDeleteKey [NTDLL.@]
154 * ZwDeleteKey [NTDLL.@]
156 NTSTATUS WINAPI
NtDeleteKey( HANDLE hkey
)
160 TRACE( "(%p)\n", hkey
);
162 SERVER_START_REQ( delete_key
)
165 ret
= wine_server_call( req
);
171 /******************************************************************************
172 * RtlpNtMakeTemporaryKey [NTDLL.@]
176 NTSTATUS WINAPI
RtlpNtMakeTemporaryKey( HANDLE hkey
)
178 return NtDeleteKey(hkey
);
181 /******************************************************************************
182 * NtDeleteValueKey [NTDLL.@]
183 * ZwDeleteValueKey [NTDLL.@]
185 NTSTATUS WINAPI
NtDeleteValueKey( HANDLE hkey
, const UNICODE_STRING
*name
)
189 TRACE( "(%p,%s)\n", hkey
, debugstr_us(name
) );
190 if (name
->Length
> MAX_NAME_LENGTH
) return STATUS_BUFFER_OVERFLOW
;
192 SERVER_START_REQ( delete_key_value
)
195 wine_server_add_data( req
, name
->Buffer
, name
->Length
);
196 ret
= wine_server_call( req
);
203 /******************************************************************************
206 * Implementation of NtQueryKey and NtEnumerateKey
208 static NTSTATUS
enumerate_key( HANDLE handle
, int index
, KEY_INFORMATION_CLASS info_class
,
209 void *info
, DWORD length
, DWORD
*result_len
)
218 case KeyBasicInformation
: data_ptr
= ((KEY_BASIC_INFORMATION
*)info
)->Name
; break;
219 case KeyFullInformation
: data_ptr
= ((KEY_FULL_INFORMATION
*)info
)->Class
; break;
220 case KeyNodeInformation
: data_ptr
= ((KEY_NODE_INFORMATION
*)info
)->Name
; break;
222 FIXME( "Information class %d not implemented\n", info_class
);
223 return STATUS_INVALID_PARAMETER
;
225 fixed_size
= (char *)data_ptr
- (char *)info
;
227 SERVER_START_REQ( enum_key
)
231 req
->info_class
= info_class
;
232 if (length
> fixed_size
) wine_server_set_reply( req
, data_ptr
, length
- fixed_size
);
233 if (!(ret
= wine_server_call( req
)))
237 RtlSecondsSince1970ToTime( reply
->modif
, &modif
);
241 case KeyBasicInformation
:
243 KEY_BASIC_INFORMATION keyinfo
;
244 fixed_size
= (char *)keyinfo
.Name
- (char *)&keyinfo
;
245 keyinfo
.LastWriteTime
= modif
;
246 keyinfo
.TitleIndex
= 0;
247 keyinfo
.NameLength
= reply
->namelen
;
248 memcpy( info
, &keyinfo
, min( length
, fixed_size
) );
251 case KeyFullInformation
:
253 KEY_FULL_INFORMATION keyinfo
;
254 fixed_size
= (char *)keyinfo
.Class
- (char *)&keyinfo
;
255 keyinfo
.LastWriteTime
= modif
;
256 keyinfo
.TitleIndex
= 0;
257 keyinfo
.ClassLength
= wine_server_reply_size(reply
);
258 keyinfo
.ClassOffset
= keyinfo
.ClassLength
? fixed_size
: -1;
259 keyinfo
.SubKeys
= reply
->subkeys
;
260 keyinfo
.MaxNameLen
= reply
->max_subkey
;
261 keyinfo
.MaxClassLen
= reply
->max_class
;
262 keyinfo
.Values
= reply
->values
;
263 keyinfo
.MaxValueNameLen
= reply
->max_value
;
264 keyinfo
.MaxValueDataLen
= reply
->max_data
;
265 memcpy( info
, &keyinfo
, min( length
, fixed_size
) );
268 case KeyNodeInformation
:
270 KEY_NODE_INFORMATION keyinfo
;
271 fixed_size
= (char *)keyinfo
.Name
- (char *)&keyinfo
;
272 keyinfo
.LastWriteTime
= modif
;
273 keyinfo
.TitleIndex
= 0;
274 if (reply
->namelen
< wine_server_reply_size(reply
))
276 keyinfo
.ClassLength
= wine_server_reply_size(reply
) - reply
->namelen
;
277 keyinfo
.ClassOffset
= fixed_size
+ reply
->namelen
;
281 keyinfo
.ClassLength
= 0;
282 keyinfo
.ClassOffset
= -1;
284 keyinfo
.NameLength
= reply
->namelen
;
285 memcpy( info
, &keyinfo
, min( length
, fixed_size
) );
289 *result_len
= fixed_size
+ reply
->total
;
290 if (length
< *result_len
) ret
= STATUS_BUFFER_OVERFLOW
;
299 /******************************************************************************
300 * NtEnumerateKey [NTDLL.@]
301 * ZwEnumerateKey [NTDLL.@]
304 * the name copied into the buffer is NOT 0-terminated
306 NTSTATUS WINAPI
NtEnumerateKey( HANDLE handle
, ULONG index
, KEY_INFORMATION_CLASS info_class
,
307 void *info
, DWORD length
, DWORD
*result_len
)
309 /* -1 means query key, so avoid it here */
310 if (index
== (ULONG
)-1) return STATUS_NO_MORE_ENTRIES
;
311 return enumerate_key( handle
, index
, info_class
, info
, length
, result_len
);
315 /******************************************************************************
316 * RtlpNtEnumerateSubKey [NTDLL.@]
319 NTSTATUS WINAPI
RtlpNtEnumerateSubKey( HANDLE handle
, UNICODE_STRING
*out
, ULONG index
)
321 KEY_BASIC_INFORMATION
*info
;
322 DWORD dwLen
, dwResultLen
;
327 dwLen
= out
->Length
+ sizeof(KEY_BASIC_INFORMATION
);
328 info
= (KEY_BASIC_INFORMATION
*)RtlAllocateHeap( GetProcessHeap(), 0, dwLen
);
330 return STATUS_NO_MEMORY
;
338 ret
= NtEnumerateKey( handle
, index
, KeyBasicInformation
, info
, dwLen
, &dwResultLen
);
339 dwResultLen
-= sizeof(KEY_BASIC_INFORMATION
);
341 if (ret
== STATUS_BUFFER_OVERFLOW
)
342 out
->Length
= dwResultLen
;
345 if (out
->Length
< info
->NameLength
)
347 out
->Length
= dwResultLen
;
348 ret
= STATUS_BUFFER_OVERFLOW
;
352 out
->Length
= info
->NameLength
;
353 memcpy(out
->Buffer
, info
->Name
, info
->NameLength
);
357 RtlFreeHeap( GetProcessHeap(), 0, info
);
361 /******************************************************************************
362 * NtQueryKey [NTDLL.@]
363 * ZwQueryKey [NTDLL.@]
365 NTSTATUS WINAPI
NtQueryKey( HANDLE handle
, KEY_INFORMATION_CLASS info_class
,
366 void *info
, DWORD length
, DWORD
*result_len
)
368 return enumerate_key( handle
, -1, info_class
, info
, length
, result_len
);
372 /* fill the key value info structure for a specific info class */
373 static void copy_key_value_info( KEY_VALUE_INFORMATION_CLASS info_class
, void *info
,
374 DWORD length
, int type
, int name_len
, int data_len
)
378 case KeyValueBasicInformation
:
380 KEY_VALUE_BASIC_INFORMATION keyinfo
;
381 keyinfo
.TitleIndex
= 0;
383 keyinfo
.NameLength
= name_len
;
384 length
= min( length
, (char *)keyinfo
.Name
- (char *)&keyinfo
);
385 memcpy( info
, &keyinfo
, length
);
388 case KeyValueFullInformation
:
390 KEY_VALUE_FULL_INFORMATION keyinfo
;
391 keyinfo
.TitleIndex
= 0;
393 keyinfo
.DataOffset
= (char *)keyinfo
.Name
- (char *)&keyinfo
+ name_len
;
394 keyinfo
.DataLength
= data_len
;
395 keyinfo
.NameLength
= name_len
;
396 length
= min( length
, (char *)keyinfo
.Name
- (char *)&keyinfo
);
397 memcpy( info
, &keyinfo
, length
);
400 case KeyValuePartialInformation
:
402 KEY_VALUE_PARTIAL_INFORMATION keyinfo
;
403 keyinfo
.TitleIndex
= 0;
405 keyinfo
.DataLength
= data_len
;
406 length
= min( length
, (char *)keyinfo
.Data
- (char *)&keyinfo
);
407 memcpy( info
, &keyinfo
, length
);
416 /******************************************************************************
417 * NtEnumerateValueKey [NTDLL.@]
418 * ZwEnumerateValueKey [NTDLL.@]
420 NTSTATUS WINAPI
NtEnumerateValueKey( HANDLE handle
, ULONG index
,
421 KEY_VALUE_INFORMATION_CLASS info_class
,
422 void *info
, DWORD length
, DWORD
*result_len
)
428 TRACE( "(%p,%u,%d,%p,%d)\n", handle
, index
, info_class
, info
, length
);
430 /* compute the length we want to retrieve */
433 case KeyValueBasicInformation
: ptr
= ((KEY_VALUE_BASIC_INFORMATION
*)info
)->Name
; break;
434 case KeyValueFullInformation
: ptr
= ((KEY_VALUE_FULL_INFORMATION
*)info
)->Name
; break;
435 case KeyValuePartialInformation
: ptr
= ((KEY_VALUE_PARTIAL_INFORMATION
*)info
)->Data
; break;
437 FIXME( "Information class %d not implemented\n", info_class
);
438 return STATUS_INVALID_PARAMETER
;
440 fixed_size
= (char *)ptr
- (char *)info
;
442 SERVER_START_REQ( enum_key_value
)
446 req
->info_class
= info_class
;
447 if (length
> fixed_size
) wine_server_set_reply( req
, ptr
, length
- fixed_size
);
448 if (!(ret
= wine_server_call( req
)))
450 copy_key_value_info( info_class
, info
, length
, reply
->type
, reply
->namelen
,
451 wine_server_reply_size(reply
) - reply
->namelen
);
452 *result_len
= fixed_size
+ reply
->total
;
453 if (length
< *result_len
) ret
= STATUS_BUFFER_OVERFLOW
;
461 /******************************************************************************
462 * NtQueryValueKey [NTDLL.@]
463 * ZwQueryValueKey [NTDLL.@]
466 * the name in the KeyValueInformation is never set
468 NTSTATUS WINAPI
NtQueryValueKey( HANDLE handle
, const UNICODE_STRING
*name
,
469 KEY_VALUE_INFORMATION_CLASS info_class
,
470 void *info
, DWORD length
, DWORD
*result_len
)
474 unsigned int fixed_size
= 0;
476 TRACE( "(%p,%s,%d,%p,%d)\n", handle
, debugstr_us(name
), info_class
, info
, length
);
478 if (name
->Length
> MAX_NAME_LENGTH
) return STATUS_BUFFER_OVERFLOW
;
480 /* compute the length we want to retrieve */
483 case KeyValueBasicInformation
:
485 KEY_VALUE_BASIC_INFORMATION
*basic_info
= info
;
486 if (FIELD_OFFSET(KEY_VALUE_BASIC_INFORMATION
, Name
) < length
)
488 memcpy(basic_info
->Name
, name
->Buffer
,
489 min(length
- FIELD_OFFSET(KEY_VALUE_BASIC_INFORMATION
, Name
), name
->Length
));
491 fixed_size
= FIELD_OFFSET(KEY_VALUE_BASIC_INFORMATION
, Name
) + name
->Length
;
495 case KeyValueFullInformation
:
497 KEY_VALUE_FULL_INFORMATION
*full_info
= info
;
498 if (FIELD_OFFSET(KEY_VALUE_FULL_INFORMATION
, Name
) < length
)
500 memcpy(full_info
->Name
, name
->Buffer
,
501 min(length
- FIELD_OFFSET(KEY_VALUE_FULL_INFORMATION
, Name
), name
->Length
));
503 data_ptr
= (UCHAR
*)full_info
->Name
+ name
->Length
;
504 fixed_size
= (char *)data_ptr
- (char *)info
;
507 case KeyValuePartialInformation
:
508 data_ptr
= ((KEY_VALUE_PARTIAL_INFORMATION
*)info
)->Data
;
509 fixed_size
= (char *)data_ptr
- (char *)info
;
512 FIXME( "Information class %d not implemented\n", info_class
);
513 return STATUS_INVALID_PARAMETER
;
516 SERVER_START_REQ( get_key_value
)
519 wine_server_add_data( req
, name
->Buffer
, name
->Length
);
520 if (length
> fixed_size
&& data_ptr
) wine_server_set_reply( req
, data_ptr
, length
- fixed_size
);
521 if (!(ret
= wine_server_call( req
)))
523 copy_key_value_info( info_class
, info
, length
, reply
->type
,
524 name
->Length
, reply
->total
);
525 *result_len
= fixed_size
+ (info_class
== KeyValueBasicInformation
? 0 : reply
->total
);
526 if (length
< *result_len
) ret
= STATUS_BUFFER_OVERFLOW
;
533 /******************************************************************************
534 * RtlpNtQueryValueKey [NTDLL.@]
537 NTSTATUS WINAPI
RtlpNtQueryValueKey( HANDLE handle
, ULONG
*result_type
, PBYTE dest
,
540 KEY_VALUE_PARTIAL_INFORMATION
*info
;
544 DWORD dwLen
= sizeof (KEY_VALUE_PARTIAL_INFORMATION
) + (result_len
? *result_len
: 0);
546 info
= (KEY_VALUE_PARTIAL_INFORMATION
*)RtlAllocateHeap( GetProcessHeap(), 0, dwLen
);
548 return STATUS_NO_MEMORY
;
551 ret
= NtQueryValueKey( handle
, &name
, KeyValuePartialInformation
, info
, dwLen
, &dwResultLen
);
553 if (!ret
|| ret
== STATUS_BUFFER_OVERFLOW
)
556 *result_len
= info
->DataLength
;
559 *result_type
= info
->Type
;
561 if (ret
!= STATUS_BUFFER_OVERFLOW
)
562 memcpy( dest
, info
->Data
, info
->DataLength
);
565 RtlFreeHeap( GetProcessHeap(), 0, info
);
569 /******************************************************************************
570 * NtFlushKey [NTDLL.@]
571 * ZwFlushKey [NTDLL.@]
573 NTSTATUS WINAPI
NtFlushKey(HANDLE key
)
577 TRACE("key=%p\n", key
);
579 SERVER_START_REQ( flush_key
)
582 ret
= wine_server_call( req
);
589 /******************************************************************************
590 * NtLoadKey [NTDLL.@]
591 * ZwLoadKey [NTDLL.@]
593 NTSTATUS WINAPI
NtLoadKey( const OBJECT_ATTRIBUTES
*attr
, OBJECT_ATTRIBUTES
*file
)
599 TRACE("(%p,%p)\n", attr
, file
);
601 ret
= NtCreateFile(&hive
, GENERIC_READ
, file
, &io
, NULL
, FILE_ATTRIBUTE_NORMAL
, 0,
602 FILE_OPEN
, 0, NULL
, 0);
605 SERVER_START_REQ( load_registry
)
607 req
->hkey
= attr
->RootDirectory
;
609 wine_server_add_data(req
, attr
->ObjectName
->Buffer
, attr
->ObjectName
->Length
);
610 ret
= wine_server_call( req
);
619 /******************************************************************************
620 * NtNotifyChangeKey [NTDLL.@]
621 * ZwNotifyChangeKey [NTDLL.@]
623 NTSTATUS WINAPI
NtNotifyChangeKey(
626 IN PIO_APC_ROUTINE ApcRoutine OPTIONAL
,
627 IN PVOID ApcContext OPTIONAL
,
628 OUT PIO_STATUS_BLOCK IoStatusBlock
,
629 IN ULONG CompletionFilter
,
630 IN BOOLEAN Asynchronous
,
631 OUT PVOID ChangeBuffer
,
633 IN BOOLEAN WatchSubtree
)
637 TRACE("(%p,%p,%p,%p,%p,0x%08x, 0x%08x,%p,0x%08x,0x%08x)\n",
638 KeyHandle
, Event
, ApcRoutine
, ApcContext
, IoStatusBlock
, CompletionFilter
,
639 Asynchronous
, ChangeBuffer
, Length
, WatchSubtree
);
641 if (ApcRoutine
|| ApcContext
|| ChangeBuffer
|| Length
)
642 FIXME("Unimplemented optional parameter\n");
646 OBJECT_ATTRIBUTES attr
;
647 InitializeObjectAttributes( &attr
, NULL
, 0, NULL
, NULL
);
648 ret
= NtCreateEvent( &Event
, EVENT_ALL_ACCESS
, &attr
, FALSE
, FALSE
);
649 if (ret
!= STATUS_SUCCESS
)
653 SERVER_START_REQ( set_registry_notification
)
655 req
->hkey
= KeyHandle
;
657 req
->subtree
= WatchSubtree
;
658 req
->filter
= CompletionFilter
;
659 ret
= wine_server_call( req
);
665 if (ret
== STATUS_SUCCESS
)
666 NtWaitForSingleObject( Event
, FALSE
, NULL
);
670 return STATUS_SUCCESS
;
673 /******************************************************************************
674 * NtQueryMultipleValueKey [NTDLL]
675 * ZwQueryMultipleValueKey
678 NTSTATUS WINAPI
NtQueryMultipleValueKey(
680 PKEY_MULTIPLE_VALUE_INFORMATION ListOfValuesToQuery
,
682 PVOID MultipleValueInformation
,
686 FIXME("(%p,%p,0x%08x,%p,0x%08x,%p) stub!\n",
687 KeyHandle
, ListOfValuesToQuery
, NumberOfItems
, MultipleValueInformation
,
688 Length
,ReturnLength
);
689 return STATUS_SUCCESS
;
692 /******************************************************************************
693 * NtReplaceKey [NTDLL.@]
694 * ZwReplaceKey [NTDLL.@]
696 NTSTATUS WINAPI
NtReplaceKey(
697 IN POBJECT_ATTRIBUTES ObjectAttributes
,
699 IN POBJECT_ATTRIBUTES ReplacedObjectAttributes
)
701 FIXME("(%p),stub!\n", Key
);
702 dump_ObjectAttributes(ObjectAttributes
);
703 dump_ObjectAttributes(ReplacedObjectAttributes
);
704 return STATUS_SUCCESS
;
706 /******************************************************************************
707 * NtRestoreKey [NTDLL.@]
708 * ZwRestoreKey [NTDLL.@]
710 NTSTATUS WINAPI
NtRestoreKey(
715 FIXME("(%p,%p,0x%08x) stub\n",
716 KeyHandle
, FileHandle
, RestoreFlags
);
717 return STATUS_SUCCESS
;
719 /******************************************************************************
720 * NtSaveKey [NTDLL.@]
721 * ZwSaveKey [NTDLL.@]
723 NTSTATUS WINAPI
NtSaveKey(IN HANDLE KeyHandle
, IN HANDLE FileHandle
)
727 TRACE("(%p,%p)\n", KeyHandle
, FileHandle
);
729 SERVER_START_REQ( save_registry
)
731 req
->hkey
= KeyHandle
;
732 req
->file
= FileHandle
;
733 ret
= wine_server_call( req
);
739 /******************************************************************************
740 * NtSetInformationKey [NTDLL.@]
741 * ZwSetInformationKey [NTDLL.@]
743 NTSTATUS WINAPI
NtSetInformationKey(
745 IN
const int KeyInformationClass
,
746 IN PVOID KeyInformation
,
747 IN ULONG KeyInformationLength
)
749 FIXME("(%p,0x%08x,%p,0x%08x) stub\n",
750 KeyHandle
, KeyInformationClass
, KeyInformation
, KeyInformationLength
);
751 return STATUS_SUCCESS
;
755 /******************************************************************************
756 * NtSetValueKey [NTDLL.@]
757 * ZwSetValueKey [NTDLL.@]
760 * win95 does not care about count for REG_SZ and finds out the len by itself (js)
761 * NT does definitely care (aj)
763 NTSTATUS WINAPI
NtSetValueKey( HANDLE hkey
, const UNICODE_STRING
*name
, ULONG TitleIndex
,
764 ULONG type
, const void *data
, ULONG count
)
768 TRACE( "(%p,%s,%d,%p,%d)\n", hkey
, debugstr_us(name
), type
, data
, count
);
770 if (name
->Length
> MAX_NAME_LENGTH
) return STATUS_BUFFER_OVERFLOW
;
772 SERVER_START_REQ( set_key_value
)
776 req
->namelen
= name
->Length
;
777 wine_server_add_data( req
, name
->Buffer
, name
->Length
);
778 wine_server_add_data( req
, data
, count
);
779 ret
= wine_server_call( req
);
785 /******************************************************************************
786 * RtlpNtSetValueKey [NTDLL.@]
789 NTSTATUS WINAPI
RtlpNtSetValueKey( HANDLE hkey
, ULONG type
, const void *data
,
795 return NtSetValueKey( hkey
, &name
, 0, type
, data
, count
);
798 /******************************************************************************
799 * NtUnloadKey [NTDLL.@]
800 * ZwUnloadKey [NTDLL.@]
802 NTSTATUS WINAPI
NtUnloadKey(IN POBJECT_ATTRIBUTES attr
)
806 TRACE("(%p)\n", attr
);
808 SERVER_START_REQ( unload_registry
)
810 req
->hkey
= attr
->RootDirectory
;
811 ret
= wine_server_call(req
);
818 /******************************************************************************
819 * RtlFormatCurrentUserKeyPath [NTDLL.@]
822 NTSTATUS WINAPI
RtlFormatCurrentUserKeyPath( IN OUT PUNICODE_STRING KeyPath
)
824 static const WCHAR pathW
[] = {'\\','R','e','g','i','s','t','r','y','\\','U','s','e','r','\\'};
828 status
= NtOpenThreadToken(GetCurrentThread(), TOKEN_READ
, TRUE
, &token
);
829 if (status
== STATUS_NO_TOKEN
)
830 status
= NtOpenProcessToken(GetCurrentProcess(), TOKEN_READ
, &token
);
831 if (status
== STATUS_SUCCESS
)
833 char buffer
[sizeof(TOKEN_USER
) + sizeof(SID
) + sizeof(DWORD
)*SID_MAX_SUB_AUTHORITIES
];
834 DWORD len
= sizeof(buffer
);
836 status
= NtQueryInformationToken(token
, TokenUser
, buffer
, len
, &len
);
837 if (status
== STATUS_SUCCESS
)
839 KeyPath
->MaximumLength
= 0;
840 status
= RtlConvertSidToUnicodeString(KeyPath
, ((TOKEN_USER
*)buffer
)->User
.Sid
, FALSE
);
841 if (status
== STATUS_BUFFER_OVERFLOW
)
843 PWCHAR buf
= RtlAllocateHeap(GetProcessHeap(), 0,
844 sizeof(pathW
) + KeyPath
->Length
+ sizeof(WCHAR
));
847 memcpy(buf
, pathW
, sizeof(pathW
));
848 KeyPath
->MaximumLength
= KeyPath
->Length
+ sizeof(WCHAR
);
849 KeyPath
->Buffer
= (PWCHAR
)((LPBYTE
)buf
+ sizeof(pathW
));
850 status
= RtlConvertSidToUnicodeString(KeyPath
,
851 ((TOKEN_USER
*)buffer
)->User
.Sid
, FALSE
);
852 KeyPath
->Buffer
= buf
;
853 KeyPath
->Length
+= sizeof(pathW
);
854 KeyPath
->MaximumLength
+= sizeof(pathW
);
857 status
= STATUS_NO_MEMORY
;
865 /******************************************************************************
866 * RtlOpenCurrentUser [NTDLL.@]
869 * If we return just HKEY_CURRENT_USER the advapi tries to find a remote
870 * registry (odd handle) and fails.
872 NTSTATUS WINAPI
RtlOpenCurrentUser(
873 IN ACCESS_MASK DesiredAccess
, /* [in] */
874 OUT PHANDLE KeyHandle
) /* [out] handle of HKEY_CURRENT_USER */
876 OBJECT_ATTRIBUTES ObjectAttributes
;
877 UNICODE_STRING ObjectName
;
880 TRACE("(0x%08x, %p)\n",DesiredAccess
, KeyHandle
);
882 if ((ret
= RtlFormatCurrentUserKeyPath(&ObjectName
))) return ret
;
883 InitializeObjectAttributes(&ObjectAttributes
,&ObjectName
,OBJ_CASE_INSENSITIVE
,0, NULL
);
884 ret
= NtCreateKey(KeyHandle
, DesiredAccess
, &ObjectAttributes
, 0, NULL
, 0, NULL
);
885 RtlFreeUnicodeString(&ObjectName
);
890 static NTSTATUS
RTL_ReportRegistryValue(PKEY_VALUE_FULL_INFORMATION pInfo
,
891 PRTL_QUERY_REGISTRY_TABLE pQuery
, PVOID pContext
, PVOID pEnvironment
)
894 UNICODE_STRING src
, dst
;
899 NTSTATUS status
= STATUS_SUCCESS
;
906 if (pQuery
->Flags
& RTL_QUERY_REGISTRY_DIRECT
)
907 return STATUS_INVALID_PARAMETER
;
910 status
= pQuery
->QueryRoutine(pQuery
->Name
, pQuery
->DefaultType
, pQuery
->DefaultData
,
911 pQuery
->DefaultLength
, pContext
, pQuery
->EntryContext
);
915 len
= pInfo
->DataLength
;
917 if (pQuery
->Flags
& RTL_QUERY_REGISTRY_DIRECT
)
919 str
= (PUNICODE_STRING
)pQuery
->EntryContext
;
924 if (!(pQuery
->Flags
& RTL_QUERY_REGISTRY_NOEXPAND
))
926 RtlInitUnicodeString(&src
, (WCHAR
*)(((CHAR
*)pInfo
) + pInfo
->DataOffset
));
928 dst
.MaximumLength
= 0;
929 RtlExpandEnvironmentStrings_U(pEnvironment
, &src
, &dst
, &res
);
931 dst
.MaximumLength
= res
;
932 dst
.Buffer
= RtlAllocateHeap(GetProcessHeap(), 0, res
* sizeof(WCHAR
));
933 RtlExpandEnvironmentStrings_U(pEnvironment
, &src
, &dst
, &res
);
934 status
= pQuery
->QueryRoutine(pQuery
->Name
, pInfo
->Type
, dst
.Buffer
,
935 dst
.Length
, pContext
, pQuery
->EntryContext
);
936 RtlFreeHeap(GetProcessHeap(), 0, dst
.Buffer
);
941 if (str
->Buffer
== NULL
)
942 RtlCreateUnicodeString(str
, (WCHAR
*)(((CHAR
*)pInfo
) + pInfo
->DataOffset
));
944 RtlAppendUnicodeToString(str
, (WCHAR
*)(((CHAR
*)pInfo
) + pInfo
->DataOffset
));
948 if (!(pQuery
->Flags
& RTL_QUERY_REGISTRY_NOEXPAND
))
949 return STATUS_INVALID_PARAMETER
;
951 if (str
->Buffer
== NULL
)
953 str
->Buffer
= RtlAllocateHeap(GetProcessHeap(), 0, len
);
954 str
->MaximumLength
= len
;
956 len
= min(len
, str
->MaximumLength
);
957 memcpy(str
->Buffer
, ((CHAR
*)pInfo
) + pInfo
->DataOffset
, len
);
962 bin
= (LONG
*)pQuery
->EntryContext
;
963 if (pInfo
->DataLength
<= sizeof(ULONG
))
964 memcpy(bin
, ((CHAR
*)pInfo
) + pInfo
->DataOffset
,
968 if (bin
[0] <= sizeof(ULONG
))
970 memcpy(&bin
[1], ((CHAR
*)pInfo
) + pInfo
->DataOffset
,
971 min(-bin
[0], pInfo
->DataLength
));
975 len
= min(bin
[0], pInfo
->DataLength
);
977 bin
[2] = pInfo
->Type
;
978 memcpy(&bin
[3], ((CHAR
*)pInfo
) + pInfo
->DataOffset
, len
);
986 if((pQuery
->Flags
& RTL_QUERY_REGISTRY_NOEXPAND
) ||
987 (pInfo
->Type
!= REG_EXPAND_SZ
&& pInfo
->Type
!= REG_MULTI_SZ
))
989 status
= pQuery
->QueryRoutine(pInfo
->Name
, pInfo
->Type
,
990 ((CHAR
*)pInfo
) + pInfo
->DataOffset
, pInfo
->DataLength
,
991 pContext
, pQuery
->EntryContext
);
993 else if (pInfo
->Type
== REG_EXPAND_SZ
)
995 RtlInitUnicodeString(&src
, (WCHAR
*)(((CHAR
*)pInfo
) + pInfo
->DataOffset
));
997 dst
.MaximumLength
= 0;
998 RtlExpandEnvironmentStrings_U(pEnvironment
, &src
, &dst
, &res
);
1000 dst
.MaximumLength
= res
;
1001 dst
.Buffer
= RtlAllocateHeap(GetProcessHeap(), 0, res
* sizeof(WCHAR
));
1002 RtlExpandEnvironmentStrings_U(pEnvironment
, &src
, &dst
, &res
);
1003 status
= pQuery
->QueryRoutine(pQuery
->Name
, pInfo
->Type
, dst
.Buffer
,
1004 dst
.Length
, pContext
, pQuery
->EntryContext
);
1005 RtlFreeHeap(GetProcessHeap(), 0, dst
.Buffer
);
1007 else /* REG_MULTI_SZ */
1009 if(pQuery
->Flags
& RTL_QUERY_REGISTRY_NOEXPAND
)
1011 for (offset
= 0; offset
<= pInfo
->DataLength
; offset
+= len
+ sizeof(WCHAR
))
1013 wstr
= (WCHAR
*)(((CHAR
*)pInfo
) + offset
);
1014 len
= strlenW(wstr
) * sizeof(WCHAR
);
1015 status
= pQuery
->QueryRoutine(pQuery
->Name
, pInfo
->Type
, wstr
, len
,
1016 pContext
, pQuery
->EntryContext
);
1017 if(status
!= STATUS_SUCCESS
&& status
!= STATUS_BUFFER_TOO_SMALL
)
1023 while(count
<=pInfo
->DataLength
)
1025 String
= (WCHAR
*)(((CHAR
*)pInfo
) + pInfo
->DataOffset
)+count
;
1026 count
+=strlenW(String
)+1;
1027 RtlInitUnicodeString(&src
, (WCHAR
*)(((CHAR
*)pInfo
) + pInfo
->DataOffset
));
1029 dst
.MaximumLength
= 0;
1030 RtlExpandEnvironmentStrings_U(pEnvironment
, &src
, &dst
, &res
);
1032 dst
.MaximumLength
= res
;
1033 dst
.Buffer
= RtlAllocateHeap(GetProcessHeap(), 0, res
* sizeof(WCHAR
));
1034 RtlExpandEnvironmentStrings_U(pEnvironment
, &src
, &dst
, &res
);
1035 status
= pQuery
->QueryRoutine(pQuery
->Name
, pInfo
->Type
, dst
.Buffer
,
1036 dst
.Length
, pContext
, pQuery
->EntryContext
);
1037 RtlFreeHeap(GetProcessHeap(), 0, dst
.Buffer
);
1038 if(status
!= STATUS_SUCCESS
&& status
!= STATUS_BUFFER_TOO_SMALL
)
1048 static NTSTATUS
RTL_GetKeyHandle(ULONG RelativeTo
, PCWSTR Path
, PHANDLE handle
)
1050 UNICODE_STRING KeyString
;
1051 OBJECT_ATTRIBUTES regkey
;
1056 static const WCHAR empty
[] = {0};
1057 static const WCHAR control
[] = {'\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e',
1058 '\\','S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
1059 'C','o','n','t','r','o','l','\\',0};
1061 static const WCHAR devicemap
[] = {'\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e','\\',
1062 'H','a','r','d','w','a','r','e','\\','D','e','v','i','c','e','M','a','p','\\',0};
1064 static const WCHAR services
[] = {'\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e','\\',
1065 'S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
1066 'S','e','r','v','i','c','e','s','\\',0};
1068 static const WCHAR user
[] = {'\\','R','e','g','i','s','t','r','y','\\','U','s','e','r','\\',
1069 'C','u','r','r','e','n','t','U','s','e','r','\\',0};
1071 static const WCHAR windows_nt
[] = {'\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e','\\',
1072 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
1073 'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',0};
1075 switch (RelativeTo
& 0xff)
1077 case RTL_REGISTRY_ABSOLUTE
:
1081 case RTL_REGISTRY_CONTROL
:
1085 case RTL_REGISTRY_DEVICEMAP
:
1089 case RTL_REGISTRY_SERVICES
:
1093 case RTL_REGISTRY_USER
:
1097 case RTL_REGISTRY_WINDOWS_NT
:
1102 return STATUS_INVALID_PARAMETER
;
1105 len
= (strlenW(base
) + strlenW(Path
) + 1) * sizeof(WCHAR
);
1106 KeyString
.Buffer
= RtlAllocateHeap(GetProcessHeap(), 0, len
);
1107 if (KeyString
.Buffer
== NULL
)
1108 return STATUS_NO_MEMORY
;
1110 strcpyW(KeyString
.Buffer
, base
);
1111 strcatW(KeyString
.Buffer
, Path
);
1112 KeyString
.Length
= len
- sizeof(WCHAR
);
1113 KeyString
.MaximumLength
= len
;
1114 InitializeObjectAttributes(®key
, &KeyString
, OBJ_CASE_INSENSITIVE
, NULL
, NULL
);
1115 status
= NtOpenKey(handle
, KEY_ALL_ACCESS
, ®key
);
1116 RtlFreeHeap(GetProcessHeap(), 0, KeyString
.Buffer
);
1120 /*************************************************************************
1121 * RtlQueryRegistryValues [NTDLL.@]
1123 * Query multiple registry values with a signle call.
1126 * RelativeTo [I] Registry path that Path refers to
1127 * Path [I] Path to key
1128 * QueryTable [I] Table of key values to query
1129 * Context [I] Parameter to pass to the application defined QueryRoutine function
1130 * Environment [I] Optional parameter to use when performing expansion
1133 * STATUS_SUCCESS or an appropriate NTSTATUS error code.
1135 NTSTATUS WINAPI
RtlQueryRegistryValues(IN ULONG RelativeTo
, IN PCWSTR Path
,
1136 IN PRTL_QUERY_REGISTRY_TABLE QueryTable
, IN PVOID Context
,
1137 IN PVOID Environment OPTIONAL
)
1139 UNICODE_STRING Value
;
1140 HANDLE handle
, topkey
;
1141 PKEY_VALUE_FULL_INFORMATION pInfo
= NULL
;
1142 ULONG len
, buflen
= 0;
1143 NTSTATUS status
=STATUS_SUCCESS
, ret
= STATUS_SUCCESS
;
1146 TRACE("(%d, %s, %p, %p, %p)\n", RelativeTo
, debugstr_w(Path
), QueryTable
, Context
, Environment
);
1149 return STATUS_INVALID_PARAMETER
;
1151 /* get a valid handle */
1152 if (RelativeTo
& RTL_REGISTRY_HANDLE
)
1153 topkey
= handle
= (HANDLE
)Path
;
1156 status
= RTL_GetKeyHandle(RelativeTo
, Path
, &topkey
);
1159 if(status
!= STATUS_SUCCESS
)
1162 /* Process query table entries */
1163 for (; QueryTable
->QueryRoutine
!= NULL
|| QueryTable
->Name
!= NULL
; ++QueryTable
)
1165 if (QueryTable
->Flags
&
1166 (RTL_QUERY_REGISTRY_SUBKEY
| RTL_QUERY_REGISTRY_TOPKEY
))
1168 /* topkey must be kept open just in case we will reuse it later */
1169 if (handle
!= topkey
)
1172 if (QueryTable
->Flags
& RTL_QUERY_REGISTRY_SUBKEY
)
1175 status
= RTL_GetKeyHandle(PtrToUlong(QueryTable
->Name
), Path
, &handle
);
1176 if(status
!= STATUS_SUCCESS
)
1186 if (QueryTable
->Flags
& RTL_QUERY_REGISTRY_NOVALUE
)
1188 QueryTable
->QueryRoutine(QueryTable
->Name
, REG_NONE
, NULL
, 0,
1189 Context
, QueryTable
->EntryContext
);
1195 if (QueryTable
->Flags
& RTL_QUERY_REGISTRY_REQUIRED
)
1197 ret
= STATUS_OBJECT_NAME_NOT_FOUND
;
1203 if (QueryTable
->Name
== NULL
)
1205 if (QueryTable
->Flags
& RTL_QUERY_REGISTRY_DIRECT
)
1207 ret
= STATUS_INVALID_PARAMETER
;
1211 /* Report all subkeys */
1214 status
= NtEnumerateValueKey(handle
, i
,
1215 KeyValueFullInformation
, pInfo
, buflen
, &len
);
1216 if (status
== STATUS_NO_MORE_ENTRIES
)
1218 if (status
== STATUS_BUFFER_OVERFLOW
||
1219 status
== STATUS_BUFFER_TOO_SMALL
)
1222 RtlFreeHeap(GetProcessHeap(), 0, pInfo
);
1223 pInfo
= (KEY_VALUE_FULL_INFORMATION
*)RtlAllocateHeap(
1224 GetProcessHeap(), 0, buflen
);
1225 NtEnumerateValueKey(handle
, i
, KeyValueFullInformation
,
1226 pInfo
, buflen
, &len
);
1229 status
= RTL_ReportRegistryValue(pInfo
, QueryTable
, Context
, Environment
);
1230 if(status
!= STATUS_SUCCESS
&& status
!= STATUS_BUFFER_TOO_SMALL
)
1235 if (QueryTable
->Flags
& RTL_QUERY_REGISTRY_DELETE
)
1237 RtlInitUnicodeString(&Value
, pInfo
->Name
);
1238 NtDeleteValueKey(handle
, &Value
);
1242 if (i
== 0 && (QueryTable
->Flags
& RTL_QUERY_REGISTRY_REQUIRED
))
1244 ret
= STATUS_OBJECT_NAME_NOT_FOUND
;
1250 RtlInitUnicodeString(&Value
, QueryTable
->Name
);
1251 status
= NtQueryValueKey(handle
, &Value
, KeyValueFullInformation
,
1252 pInfo
, buflen
, &len
);
1253 if (status
== STATUS_BUFFER_OVERFLOW
||
1254 status
== STATUS_BUFFER_TOO_SMALL
)
1257 RtlFreeHeap(GetProcessHeap(), 0, pInfo
);
1258 pInfo
= (KEY_VALUE_FULL_INFORMATION
*)RtlAllocateHeap(
1259 GetProcessHeap(), 0, buflen
);
1260 status
= NtQueryValueKey(handle
, &Value
,
1261 KeyValueFullInformation
, pInfo
, buflen
, &len
);
1263 if (status
!= STATUS_SUCCESS
)
1265 if (QueryTable
->Flags
& RTL_QUERY_REGISTRY_REQUIRED
)
1267 ret
= STATUS_OBJECT_NAME_NOT_FOUND
;
1270 status
= RTL_ReportRegistryValue(NULL
, QueryTable
, Context
, Environment
);
1271 if(status
!= STATUS_SUCCESS
&& status
!= STATUS_BUFFER_TOO_SMALL
)
1279 status
= RTL_ReportRegistryValue(pInfo
, QueryTable
, Context
, Environment
);
1280 if(status
!= STATUS_SUCCESS
&& status
!= STATUS_BUFFER_TOO_SMALL
)
1285 if (QueryTable
->Flags
& RTL_QUERY_REGISTRY_DELETE
)
1286 NtDeleteValueKey(handle
, &Value
);
1292 RtlFreeHeap(GetProcessHeap(), 0, pInfo
);
1293 if (handle
!= topkey
)
1299 /*************************************************************************
1300 * RtlCheckRegistryKey [NTDLL.@]
1302 * Query multiple registry values with a signle call.
1305 * RelativeTo [I] Registry path that Path refers to
1306 * Path [I] Path to key
1309 * STATUS_SUCCESS if the specified key exists, or an NTSTATUS error code.
1311 NTSTATUS WINAPI
RtlCheckRegistryKey(IN ULONG RelativeTo
, IN PWSTR Path
)
1316 TRACE("(%d, %s)\n", RelativeTo
, debugstr_w(Path
));
1318 if((!RelativeTo
) && Path
== NULL
)
1319 return STATUS_OBJECT_PATH_SYNTAX_BAD
;
1320 if(RelativeTo
& RTL_REGISTRY_HANDLE
)
1321 return STATUS_SUCCESS
;
1323 status
= RTL_GetKeyHandle(RelativeTo
, Path
, &handle
);
1324 if (handle
) NtClose(handle
);
1325 if (status
== STATUS_INVALID_HANDLE
) status
= STATUS_OBJECT_NAME_NOT_FOUND
;
1329 /*************************************************************************
1330 * RtlDeleteRegistryValue [NTDLL.@]
1332 * Query multiple registry values with a signle call.
1335 * RelativeTo [I] Registry path that Path refers to
1336 * Path [I] Path to key
1337 * ValueName [I] Name of the value to delete
1340 * STATUS_SUCCESS if the specified key is successfully deleted, or an NTSTATUS error code.
1342 NTSTATUS WINAPI
RtlDeleteRegistryValue(IN ULONG RelativeTo
, IN PCWSTR Path
, IN PCWSTR ValueName
)
1346 UNICODE_STRING Value
;
1348 TRACE("(%d, %s, %s)\n", RelativeTo
, debugstr_w(Path
), debugstr_w(ValueName
));
1350 RtlInitUnicodeString(&Value
, ValueName
);
1351 if(RelativeTo
== RTL_REGISTRY_HANDLE
)
1353 return NtDeleteValueKey((HANDLE
)Path
, &Value
);
1355 status
= RTL_GetKeyHandle(RelativeTo
, Path
, &handle
);
1356 if (status
) return status
;
1357 status
= NtDeleteValueKey(handle
, &Value
);
1362 /*************************************************************************
1363 * RtlWriteRegistryValue [NTDLL.@]
1365 * Sets the registry value with provided data.
1368 * RelativeTo [I] Registry path that path parameter refers to
1369 * path [I] Path to the key (or handle - see RTL_GetKeyHandle)
1370 * name [I] Name of the registry value to set
1371 * type [I] Type of the registry key to set
1372 * data [I] Pointer to the user data to be set
1373 * length [I] Length of the user data pointed by data
1376 * STATUS_SUCCESS if the specified key is successfully set,
1377 * or an NTSTATUS error code.
1379 NTSTATUS WINAPI
RtlWriteRegistryValue( ULONG RelativeTo
, PCWSTR path
, PCWSTR name
,
1380 ULONG type
, PVOID data
, ULONG length
)
1386 TRACE( "(%d, %s, %s) -> %d: %p [%d]\n", RelativeTo
, debugstr_w(path
), debugstr_w(name
),
1387 type
, data
, length
);
1389 RtlInitUnicodeString( &str
, name
);
1391 if (RelativeTo
== RTL_REGISTRY_HANDLE
)
1392 return NtSetValueKey( (HANDLE
)path
, &str
, 0, type
, data
, length
);
1394 status
= RTL_GetKeyHandle( RelativeTo
, path
, &hkey
);
1395 if (status
!= STATUS_SUCCESS
) return status
;
1397 status
= NtSetValueKey( hkey
, &str
, 0, type
, data
, length
);