Commit d68a0e65 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

kernel32/tests: Test DUPLICATE_SAME_ATTRIBUTES flag in DuplicateHandle().

parent da9210e0
......@@ -2549,6 +2549,50 @@ static void test_DuplicateHandle(void)
ok(r, "DuplicateHandle error %lu\n", GetLastError());
ok(f == out || broken(/* Win7 */ (((ULONG_PTR)f & 3) == 3) && (f != out)), "f != out\n");
CloseHandle(out);
/* Test DUPLICATE_SAME_ATTRIBUTES */
f = CreateFileA("NUL", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
ok(f != INVALID_HANDLE_VALUE, "Failed to open NUL %lu\n", GetLastError());
r = GetHandleInformation(f, &info);
ok(r && info == 0, "Unexpected info %lx\n", info);
r = DuplicateHandle(GetCurrentProcess(), f, GetCurrentProcess(), &out,
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);
r = SetHandleInformation(f, HANDLE_FLAG_INHERIT | HANDLE_FLAG_PROTECT_FROM_CLOSE,
HANDLE_FLAG_INHERIT | HANDLE_FLAG_PROTECT_FROM_CLOSE);
ok(r, "SetHandleInformation error %lu\n", GetLastError());
info = 0xdeabeef;
r = GetHandleInformation(f, &info);
ok(r && info == (HANDLE_FLAG_INHERIT | HANDLE_FLAG_PROTECT_FROM_CLOSE), "Unexpected info %lx\n", info);
ok(r, "SetHandleInformation error %lu\n", GetLastError());
r = DuplicateHandle(GetCurrentProcess(), f, GetCurrentProcess(), &out,
0, FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_SAME_ATTRIBUTES);
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());
CloseHandle(out);
r = SetHandleInformation(f, HANDLE_FLAG_INHERIT | HANDLE_FLAG_PROTECT_FROM_CLOSE, 0);
ok(r, "SetHandleInformation error %lu\n", GetLastError());
CloseHandle(f);
r = DuplicateHandle(GetCurrentProcess(), GetCurrentProcess(), GetCurrentProcess(), &out,
0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_SAME_ATTRIBUTES);
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);
}
#define test_completion(a, b, c, d, e) _test_completion(__LINE__, a, b, c, d, e)
......
......@@ -5367,6 +5367,7 @@ typedef struct _QUOTA_LIMITS_EX {
#define DUPLICATE_CLOSE_SOURCE 0x00000001
#define DUPLICATE_SAME_ACCESS 0x00000002
#define DUPLICATE_SAME_ATTRIBUTES 0x00000004
#ifdef __WINESRC__
#define DUPLICATE_MAKE_GLOBAL 0x80000000 /* Not a Windows flag */
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment