Module: wine Branch: master Commit: d6d99e59e350de4c7a545059b925acbc33660998 URL: https://source.winehq.org/git/wine.git/?a=commit;h=d6d99e59e350de4c7a545059b...
Author: Akihiro Sagawa sagawa.aki@gmail.com Date: Fri Feb 12 20:30:12 2021 +0900
ntdll: ObjectName should also be used in NtUnloadKey.
Signed-off-by: Akihiro Sagawa sagawa.aki@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/kernelbase/registry.c | 14 +++----------- dlls/ntdll/unix/registry.c | 8 +++++++- include/wine/server_protocol.h | 7 +++++-- server/protocol.def | 4 +++- server/registry.c | 17 +++++++++++++---- server/request.h | 5 +++-- server/trace.c | 4 +++- 7 files changed, 37 insertions(+), 22 deletions(-)
diff --git a/dlls/kernelbase/registry.c b/dlls/kernelbase/registry.c index 574bf2f56b7..2ed5e268119 100644 --- a/dlls/kernelbase/registry.c +++ b/dlls/kernelbase/registry.c @@ -2349,24 +2349,16 @@ LSTATUS WINAPI RegRestoreKeyA( HKEY hkey, LPCSTR lpFile, DWORD dwFlags ) */ LSTATUS WINAPI RegUnLoadKeyW( HKEY hkey, LPCWSTR lpSubKey ) { - DWORD ret; - HKEY shkey; OBJECT_ATTRIBUTES attr; UNICODE_STRING subkey;
TRACE("(%p,%s)\n",hkey, debugstr_w(lpSubKey));
- ret = RegOpenKeyExW( hkey, lpSubKey, 0, MAXIMUM_ALLOWED, &shkey ); - if( ret ) - return ERROR_INVALID_PARAMETER; + if (!(hkey = get_special_root_hkey( hkey, 0 ))) return ERROR_INVALID_HANDLE;
RtlInitUnicodeString(&subkey, lpSubKey); - InitializeObjectAttributes(&attr, &subkey, OBJ_CASE_INSENSITIVE, shkey, NULL); - ret = RtlNtStatusToDosError(NtUnloadKey(&attr)); - - RegCloseKey(shkey); - - return ret; + InitializeObjectAttributes(&attr, &subkey, OBJ_CASE_INSENSITIVE, hkey, NULL); + return RtlNtStatusToDosError( NtUnloadKey(&attr) ); }
diff --git a/dlls/ntdll/unix/registry.c b/dlls/ntdll/unix/registry.c index c0897033609..b52811b05e7 100644 --- a/dlls/ntdll/unix/registry.c +++ b/dlls/ntdll/unix/registry.c @@ -677,9 +677,15 @@ NTSTATUS WINAPI NtUnloadKey( OBJECT_ATTRIBUTES *attr )
TRACE( "(%p)\n", attr );
+ if (!attr || !attr->ObjectName) return STATUS_ACCESS_VIOLATION; + if (attr->Length != sizeof(*attr)) return STATUS_INVALID_PARAMETER; + if (attr->ObjectName->Length & 1) return STATUS_OBJECT_NAME_INVALID; + SERVER_START_REQ( unload_registry ) { - req->hkey = wine_server_obj_handle( attr->RootDirectory ); + req->parent = wine_server_obj_handle( attr->RootDirectory ); + req->attributes = attr->Attributes; + wine_server_add_data( req, attr->ObjectName->Buffer, attr->ObjectName->Length ); ret = wine_server_call(req); } SERVER_END_REQ; diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index bd231c54e74..277b1a1c33a 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -2356,7 +2356,10 @@ struct load_registry_reply struct unload_registry_request { struct request_header __header; - obj_handle_t hkey; + obj_handle_t parent; + unsigned int attributes; + /* VARARG(name,unicode_str); */ + char __pad_20[4]; }; struct unload_registry_reply { @@ -6223,7 +6226,7 @@ union generic_reply
/* ### protocol_version begin ### */
-#define SERVER_PROTOCOL_VERSION 681 +#define SERVER_PROTOCOL_VERSION 682
/* ### protocol_version end ### */
diff --git a/server/protocol.def b/server/protocol.def index c56c3ee7b2d..fa19bb41bb4 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1812,7 +1812,9 @@ struct process_info
/* UnLoad a registry branch from a file */ @REQ(unload_registry) - obj_handle_t hkey; /* root key to unload to */ + obj_handle_t parent; /* handle to the parent key */ + unsigned int attributes; /* object attributes */ + VARARG(name,unicode_str); /* key name */ @END
diff --git a/server/registry.c b/server/registry.c index 76ef7aeb65d..9b9295b1b68 100644 --- a/server/registry.c +++ b/server/registry.c @@ -2244,7 +2244,9 @@ DECL_HANDLER(load_registry)
DECL_HANDLER(unload_registry) { - struct key *key; + struct key *key, *parent; + struct unicode_str name; + unsigned int access = 0;
if (!thread_single_check_privilege( current, &SeRestorePrivilege )) { @@ -2252,10 +2254,17 @@ DECL_HANDLER(unload_registry) return; }
- if ((key = get_hkey_obj( req->hkey, 0 ))) + if (!is_wow64_thread( current )) access = (access & ~KEY_WOW64_32KEY) | KEY_WOW64_64KEY; + + if ((parent = get_parent_hkey_obj( req->parent ))) { - delete_key( key, 1 ); /* FIXME */ - release_object( key ); + get_req_path( &name, !req->parent ); + if ((key = open_key( parent, &name, access, req->attributes ))) + { + delete_key( key, 1 ); /* FIXME */ + release_object( key ); + } + release_object( parent ); } }
diff --git a/server/request.h b/server/request.h index ef5b16d2722..23308ed49e6 100644 --- a/server/request.h +++ b/server/request.h @@ -1231,8 +1231,9 @@ C_ASSERT( FIELD_OFFSET(struct delete_key_value_request, hkey) == 12 ); C_ASSERT( sizeof(struct delete_key_value_request) == 16 ); C_ASSERT( FIELD_OFFSET(struct load_registry_request, file) == 12 ); C_ASSERT( sizeof(struct load_registry_request) == 16 ); -C_ASSERT( FIELD_OFFSET(struct unload_registry_request, hkey) == 12 ); -C_ASSERT( sizeof(struct unload_registry_request) == 16 ); +C_ASSERT( FIELD_OFFSET(struct unload_registry_request, parent) == 12 ); +C_ASSERT( FIELD_OFFSET(struct unload_registry_request, attributes) == 16 ); +C_ASSERT( sizeof(struct unload_registry_request) == 24 ); C_ASSERT( FIELD_OFFSET(struct save_registry_request, hkey) == 12 ); C_ASSERT( FIELD_OFFSET(struct save_registry_request, file) == 16 ); C_ASSERT( sizeof(struct save_registry_request) == 24 ); diff --git a/server/trace.c b/server/trace.c index 031237429ca..2737cb16499 100644 --- a/server/trace.c +++ b/server/trace.c @@ -2417,7 +2417,9 @@ static void dump_load_registry_request( const struct load_registry_request *req
static void dump_unload_registry_request( const struct unload_registry_request *req ) { - fprintf( stderr, " hkey=%04x", req->hkey ); + fprintf( stderr, " parent=%04x", req->parent ); + fprintf( stderr, ", attributes=%08x", req->attributes ); + dump_varargs_unicode_str( ", name=", cur_size ); }
static void dump_save_registry_request( const struct save_registry_request *req )