diff --git a/dlls/kernel32/tests/sync.c b/dlls/kernel32/tests/sync.c index 3965458e5c6de84e0d77a33283686becb3f8353e..d4f6cf75bacfa075d9eb9e71022337f4fcaff66a 100644 --- a/dlls/kernel32/tests/sync.c +++ b/dlls/kernel32/tests/sync.c @@ -133,12 +133,23 @@ static void test_mutex(void) int i; DWORD failed = 0; + SetLastError(0xdeadbeef); + hOpened = OpenMutex(0, FALSE, "WineTestMutex"); + ok(hOpened == NULL, "OpenMutex succeeded\n"); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError()); + + SetLastError(0xdeadbeef); hCreated = CreateMutex(NULL, FALSE, "WineTestMutex"); ok(hCreated != NULL, "CreateMutex failed with error %d\n", GetLastError()); + SetLastError(0xdeadbeef); hOpened = OpenMutex(0, FALSE, "WineTestMutex"); +todo_wine ok(hOpened == NULL, "OpenMutex succeeded\n"); +todo_wine + ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError()); + SetLastError(0xdeadbeef); hOpened = OpenMutex(GENERIC_EXECUTE, FALSE, "WineTestMutex"); ok(hOpened != NULL, "OpenMutex failed with error %d\n", GetLastError()); wait_ret = WaitForSingleObject(hOpened, INFINITE); @@ -151,6 +162,7 @@ static void test_mutex(void) ok(wait_ret == WAIT_OBJECT_0, "WaitForSingleObject failed with error 0x%08x\n", wait_ret); } + SetLastError(0xdeadbeef); hOpened = OpenMutex(GENERIC_READ | GENERIC_WRITE, FALSE, "WineTestMutex"); ok(hOpened != NULL, "OpenMutex failed with error %d\n", GetLastError()); wait_ret = WaitForSingleObject(hOpened, INFINITE); @@ -159,22 +171,30 @@ static void test_mutex(void) for (i = 0; i < 32; i++) { + SetLastError(0xdeadbeef); hOpened = OpenMutex(0x1 << i, FALSE, "WineTestMutex"); if(hOpened != NULL) { + SetLastError(0xdeadbeef); ret = ReleaseMutex(hOpened); ok(ret, "ReleaseMutex failed with error %d, access %x\n", GetLastError(), 1 << i); CloseHandle(hOpened); } else { + if ((1 << i) == ACCESS_SYSTEM_SECURITY) + todo_wine ok(GetLastError() == ERROR_PRIVILEGE_NOT_HELD, "wrong error %u, access %x\n", GetLastError(), 1 << i); + else + todo_wine ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u, , access %x\n", GetLastError(), 1 << i); ReleaseMutex(hCreated); failed |=0x1 << i; } } +todo_wine ok( failed == 0x0de0fffe, "open succeeded when it shouldn't: %x\n", failed); + SetLastError(0xdeadbeef); ret = ReleaseMutex(hCreated); ok(!ret && (GetLastError() == ERROR_NOT_OWNER), "ReleaseMutex should have failed with ERROR_NOT_OWNER instead of %d\n", GetLastError()); diff --git a/server/mutex.c b/server/mutex.c index 7c9700d0347324a16d611e5f2e25afb332a3a921..75142755ad46154ae6c939771e15291da5596f30 100644 --- a/server/mutex.c +++ b/server/mutex.c @@ -238,14 +238,6 @@ DECL_HANDLER(open_mutex) struct directory *root = NULL; struct mutex *mutex; - if ((req->access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL | - MUTEX_ALL_ACCESS | STANDARD_RIGHTS_ALL | MAXIMUM_ALLOWED)) || - !req->access) - { - set_error(STATUS_INVALID_PARAMETER); - return; - } - get_req_unicode_str( &name ); if (req->rootdir && !(root = get_directory_obj( current->process, req->rootdir, 0 ))) return;