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>
This commit is contained in:
parent
d68a0e650a
commit
1c7e1f1fc6
2 changed files with 5 additions and 4 deletions
|
@ -2560,7 +2560,6 @@ static void test_DuplicateHandle(void)
|
||||||
0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_SAME_ATTRIBUTES);
|
0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_SAME_ATTRIBUTES);
|
||||||
ok(r, "DuplicateHandle error %lu\n", GetLastError());
|
ok(r, "DuplicateHandle error %lu\n", GetLastError());
|
||||||
r = GetHandleInformation(out, &info);
|
r = GetHandleInformation(out, &info);
|
||||||
todo_wine
|
|
||||||
ok(r && info == 0, "Unexpected info %lx\n", info);
|
ok(r && info == 0, "Unexpected info %lx\n", info);
|
||||||
CloseHandle(out);
|
CloseHandle(out);
|
||||||
|
|
||||||
|
@ -2576,7 +2575,6 @@ static void test_DuplicateHandle(void)
|
||||||
ok(r, "DuplicateHandle error %lu\n", GetLastError());
|
ok(r, "DuplicateHandle error %lu\n", GetLastError());
|
||||||
info = 0xdeabeef;
|
info = 0xdeabeef;
|
||||||
r = GetHandleInformation(out, &info);
|
r = GetHandleInformation(out, &info);
|
||||||
todo_wine
|
|
||||||
ok(r && info == (HANDLE_FLAG_INHERIT | HANDLE_FLAG_PROTECT_FROM_CLOSE), "Unexpected info %lx\n", info);
|
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);
|
r = SetHandleInformation(out, HANDLE_FLAG_PROTECT_FROM_CLOSE, 0);
|
||||||
ok(r, "SetHandleInformation error %lu\n", GetLastError());
|
ok(r, "SetHandleInformation error %lu\n", GetLastError());
|
||||||
|
@ -2590,7 +2588,6 @@ static void test_DuplicateHandle(void)
|
||||||
ok(r, "DuplicateHandle error %lu\n", GetLastError());
|
ok(r, "DuplicateHandle error %lu\n", GetLastError());
|
||||||
info = 0xdeabeef;
|
info = 0xdeabeef;
|
||||||
r = GetHandleInformation(out, &info);
|
r = GetHandleInformation(out, &info);
|
||||||
todo_wine
|
|
||||||
ok(r && info == 0, "Unexpected info %lx\n", info);
|
ok(r && info == 0, "Unexpected info %lx\n", info);
|
||||||
CloseHandle(out);
|
CloseHandle(out);
|
||||||
}
|
}
|
||||||
|
|
|
@ -566,7 +566,7 @@ obj_handle_t duplicate_handle( struct process *src, obj_handle_t src_handle, str
|
||||||
{
|
{
|
||||||
obj_handle_t res;
|
obj_handle_t res;
|
||||||
struct handle_entry *entry;
|
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 );
|
struct object *obj = get_handle_obj( src, src_handle, 0, NULL );
|
||||||
|
|
||||||
if (!obj) return 0;
|
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;
|
src_access = entry->access;
|
||||||
else /* pseudo-handle, give it full access */
|
else /* pseudo-handle, give it full access */
|
||||||
src_access = obj->ops->map_access( obj, GENERIC_ALL );
|
src_access = obj->ops->map_access( obj, GENERIC_ALL );
|
||||||
|
src_flags = (src_access & RESERVED_ALL) >> RESERVED_SHIFT;
|
||||||
src_access &= ~RESERVED_ALL;
|
src_access &= ~RESERVED_ALL;
|
||||||
|
|
||||||
if (options & DUPLICATE_SAME_ACCESS)
|
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 );
|
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 );
|
release_object( obj );
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue