Module: wine Branch: master Commit: 68a69b51bb82541f57b83e7674341a1417f1e8e5 URL: https://source.winehq.org/git/wine.git/?a=commit;h=68a69b51bb82541f57b83e767...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Jul 5 14:18:26 2022 +0200
server: Return the standard status code when the key exists in NtCreateKey.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/unix/registry.c | 12 +++++++++++- include/wine/server_protocol.h | 4 ++-- server/protocol.def | 1 - server/registry.c | 10 ++++------ server/request.h | 1 - server/trace.c | 1 - 6 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/dlls/ntdll/unix/registry.c b/dlls/ntdll/unix/registry.c index 47547d42f09..9c98bf48399 100644 --- a/dlls/ntdll/unix/registry.c +++ b/dlls/ntdll/unix/registry.c @@ -95,10 +95,19 @@ NTSTATUS WINAPI NtCreateKey( HANDLE *key, ACCESS_MASK access, const OBJECT_ATTRI if (class) wine_server_add_data( req, class->Buffer, class->Length ); ret = wine_server_call( req ); *key = wine_server_ptr_handle( reply->hkey ); - if (dispos && !ret) *dispos = reply->created ? REG_CREATED_NEW_KEY : REG_OPENED_EXISTING_KEY; } SERVER_END_REQ;
+ if (ret == STATUS_OBJECT_NAME_EXISTS) + { + if (dispos) *dispos = REG_OPENED_EXISTING_KEY; + ret = STATUS_SUCCESS; + } + else if (ret == STATUS_SUCCESS) + { + if (dispos) *dispos = REG_CREATED_NEW_KEY; + } + TRACE( "<- %p\n", *key ); free( objattr ); return ret; @@ -700,6 +709,7 @@ NTSTATUS WINAPI NtLoadKey( const OBJECT_ATTRIBUTES *attr, OBJECT_ATTRIBUTES *fil req->file = wine_server_obj_handle( key ); wine_server_add_data( req, objattr, len ); ret = wine_server_call( req ); + if (ret == STATUS_OBJECT_NAME_EXISTS) ret = STATUS_SUCCESS; } SERVER_END_REQ;
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index ce1b2630f53..0f39333919b 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -2191,7 +2191,7 @@ struct create_key_reply { struct reply_header __header; obj_handle_t hkey; - int created; + char __pad_12[4]; };
@@ -6304,7 +6304,7 @@ union generic_reply
/* ### protocol_version begin ### */
-#define SERVER_PROTOCOL_VERSION 752 +#define SERVER_PROTOCOL_VERSION 753
/* ### protocol_version end ### */
diff --git a/server/protocol.def b/server/protocol.def index a8beccaf468..6cb6275f2f2 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1718,7 +1718,6 @@ struct process_info VARARG(class,unicode_str); /* class name */ @REPLY obj_handle_t hkey; /* handle to the created key */ - int created; /* has it been newly created? */ @END
/* Open a registry key */ diff --git a/server/registry.c b/server/registry.c index 70a304a4c86..d3c1e5e7ad1 100644 --- a/server/registry.c +++ b/server/registry.c @@ -803,12 +803,11 @@ static struct key *open_key( struct key *key, const struct unicode_str *name, un static struct key *create_key( struct key *key, const struct unicode_str *name, const struct unicode_str *class, unsigned int options, unsigned int access, unsigned int attributes, - const struct security_descriptor *sd, int *created ) + const struct security_descriptor *sd ) { int index; struct unicode_str token, next;
- *created = 0; if (!(key = open_key_prefix( key, name, access, &token, &index ))) return NULL;
if (!token.len) /* the key already exists */ @@ -827,6 +826,7 @@ static struct key *create_key( struct key *key, const struct unicode_str *name, if (debug_level > 1) dump_operation( key, NULL, "Open" ); if (key->flags & KEY_PREDEF) set_error( STATUS_PREDEFINED_HANDLE ); grab_object( key ); + set_error( STATUS_OBJECT_NAME_EXISTS ); return key; }
@@ -844,7 +844,6 @@ static struct key *create_key( struct key *key, const struct unicode_str *name, set_error( STATUS_CHILD_MUST_BE_VOLATILE ); return NULL; } - *created = 1; make_dirty( key ); if (!(key = alloc_subkey( key, &token, index, current_time ))) return NULL;
@@ -2212,7 +2211,7 @@ DECL_HANDLER(create_key) if ((parent = get_parent_hkey_obj( objattr->rootdir ))) { if ((key = create_key( parent, &name, &class, req->options, access, - objattr->attributes, sd, &reply->created ))) + objattr->attributes, sd ))) { reply->hkey = alloc_handle( current->process, key, access, objattr->attributes ); release_object( key ); @@ -2367,8 +2366,7 @@ DECL_HANDLER(load_registry)
if ((parent = get_parent_hkey_obj( objattr->rootdir ))) { - int dummy; - if ((key = create_key( parent, &name, NULL, 0, KEY_WOW64_64KEY, 0, sd, &dummy ))) + if ((key = create_key( parent, &name, NULL, 0, KEY_WOW64_64KEY, 0, sd ))) { load_registry( key, req->file ); release_object( key ); diff --git a/server/request.h b/server/request.h index cbb4c5d7a01..dc9c4e82029 100644 --- a/server/request.h +++ b/server/request.h @@ -1174,7 +1174,6 @@ C_ASSERT( FIELD_OFFSET(struct create_key_request, access) == 12 ); C_ASSERT( FIELD_OFFSET(struct create_key_request, options) == 16 ); C_ASSERT( sizeof(struct create_key_request) == 24 ); C_ASSERT( FIELD_OFFSET(struct create_key_reply, hkey) == 8 ); -C_ASSERT( FIELD_OFFSET(struct create_key_reply, created) == 12 ); C_ASSERT( sizeof(struct create_key_reply) == 16 ); C_ASSERT( FIELD_OFFSET(struct open_key_request, parent) == 12 ); C_ASSERT( FIELD_OFFSET(struct open_key_request, access) == 16 ); diff --git a/server/trace.c b/server/trace.c index 4d4789d050a..c3dd1199f06 100644 --- a/server/trace.c +++ b/server/trace.c @@ -2295,7 +2295,6 @@ static void dump_create_key_request( const struct create_key_request *req ) static void dump_create_key_reply( const struct create_key_reply *req ) { fprintf( stderr, " hkey=%04x", req->hkey ); - fprintf( stderr, ", created=%d", req->created ); }
static void dump_open_key_request( const struct open_key_request *req )