Module: wine Branch: master Commit: 1c7e1f1fc6b62c247ae6e3da226d3c976f323800 URL: https://gitlab.winehq.org/wine/wine/-/commit/1c7e1f1fc6b62c247ae6e3da226d3c9...
Author: Eric Pouech epouech@codeweavers.com Date: Sat Nov 18 11:59:29 2023 +0100
server: Implement support for DUPLICATE_SAME_ATTRIBUTES in DuplicateHandle().
This flag is documented on MSDN in ZwDuplicateObject() but not in DuplicateHandle(). Yet functional on both.
Signed-off-by: Eric Pouech epouech@codeweavers.com
---
dlls/kernel32/tests/process.c | 3 --- server/handle.c | 6 +++++- 2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index a7fef049c8e..ed291d071cc 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -2560,7 +2560,6 @@ static void test_DuplicateHandle(void) 0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_SAME_ATTRIBUTES); ok(r, "DuplicateHandle error %lu\n", GetLastError()); r = GetHandleInformation(out, &info); - todo_wine ok(r && info == 0, "Unexpected info %lx\n", info); CloseHandle(out);
@@ -2576,7 +2575,6 @@ static void test_DuplicateHandle(void) ok(r, "DuplicateHandle error %lu\n", GetLastError()); info = 0xdeabeef; r = GetHandleInformation(out, &info); - todo_wine ok(r && info == (HANDLE_FLAG_INHERIT | HANDLE_FLAG_PROTECT_FROM_CLOSE), "Unexpected info %lx\n", info); r = SetHandleInformation(out, HANDLE_FLAG_PROTECT_FROM_CLOSE, 0); ok(r, "SetHandleInformation error %lu\n", GetLastError()); @@ -2590,7 +2588,6 @@ static void test_DuplicateHandle(void) ok(r, "DuplicateHandle error %lu\n", GetLastError()); info = 0xdeabeef; r = GetHandleInformation(out, &info); - todo_wine ok(r && info == 0, "Unexpected info %lx\n", info); CloseHandle(out); } diff --git a/server/handle.c b/server/handle.c index 0595fdb403b..71cdd2e328c 100644 --- a/server/handle.c +++ b/server/handle.c @@ -566,7 +566,7 @@ obj_handle_t duplicate_handle( struct process *src, obj_handle_t src_handle, str { obj_handle_t res; struct handle_entry *entry; - unsigned int src_access; + unsigned int src_access, src_flags; struct object *obj = get_handle_obj( src, src_handle, 0, NULL );
if (!obj) return 0; @@ -574,6 +574,7 @@ obj_handle_t duplicate_handle( struct process *src, obj_handle_t src_handle, str src_access = entry->access; else /* pseudo-handle, give it full access */ src_access = obj->ops->map_access( obj, GENERIC_ALL ); + src_flags = (src_access & RESERVED_ALL) >> RESERVED_SHIFT; src_access &= ~RESERVED_ALL;
if (options & DUPLICATE_SAME_ACCESS) @@ -611,6 +612,9 @@ obj_handle_t duplicate_handle( struct process *src, obj_handle_t src_handle, str res = alloc_handle_entry( dst, obj, access, attr ); }
+ if (res && (options & DUPLICATE_SAME_ATTRIBUTES)) + set_handle_flags( dst, res, ~0u, src_flags ); + release_object( obj ); return res; }