From: Eric Pouech epouech@codeweavers.com
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 | 7 ++++++- 2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index 9ac5688e903..432d770d7b7 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -2559,7 +2559,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);
@@ -2575,7 +2574,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()); @@ -2589,7 +2587,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..69f42970912 100644 --- a/server/handle.c +++ b/server/handle.c @@ -32,6 +32,7 @@ #define WIN32_NO_STATUS #include "windef.h" #include "winternl.h" +#include "ddk/wdm.h"
#include "handle.h" #include "process.h" @@ -566,7 +567,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 +575,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_SHIFT; src_access &= ~RESERVED_ALL;
if (options & DUPLICATE_SAME_ACCESS) @@ -611,6 +613,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; }