diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index dad82f6612a..fc70a76fe02 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -622,6 +622,45 @@ static void test_NtMapViewOfSection(void) CloseHandle(hProcess); } +static void test_CreateFileMapping(void) +{ + HANDLE handle, handle2; + + /* test case sensitivity */ + + SetLastError(0xdeadbeef); + handle = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, SEC_COMMIT | PAGE_READWRITE, 0, 0x1000, + __FILE__ ": Test Mapping"); + ok( handle != NULL, "CreateFileMapping failed with error %u\n", GetLastError()); + ok( GetLastError() == 0, "wrong error %u\n", GetLastError()); + + SetLastError(0xdeadbeef); + handle2 = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, SEC_COMMIT | PAGE_READWRITE, 0, 0x1000, + __FILE__ ": Test Mapping"); + ok( handle2 != NULL, "CreateFileMapping failed with error %d\n", GetLastError()); + ok( GetLastError() == ERROR_ALREADY_EXISTS, "wrong error %u\n", GetLastError()); + CloseHandle( handle2 ); + + SetLastError(0xdeadbeef); + handle2 = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, SEC_COMMIT | PAGE_READWRITE, 0, 0x1000, + __FILE__ ": TEST MAPPING"); + ok( handle2 != NULL, "CreateFileMapping failed with error %d\n", GetLastError()); + ok( GetLastError() == 0, "wrong error %u\n", GetLastError()); + CloseHandle( handle2 ); + + SetLastError(0xdeadbeef); + handle2 = OpenFileMappingA( FILE_MAP_ALL_ACCESS, FALSE, __FILE__ ": Test Mapping"); + ok( handle2 != NULL, "OpenFileMapping failed with error %d\n", GetLastError()); + CloseHandle( handle2 ); + + SetLastError(0xdeadbeef); + handle2 = OpenFileMappingA( FILE_MAP_ALL_ACCESS, FALSE, __FILE__ ": TEST MAPPING"); + ok( !handle2, "OpenFileMapping succeeded\n"); + ok( GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %u\n", GetLastError()); + + CloseHandle( handle ); +} + static void test_BadPtr(void) { void *ptr = (void*)1; @@ -667,5 +706,6 @@ START_TEST(virtual) test_VirtualAlloc(); test_MapViewOfFile(); test_NtMapViewOfSection(); + test_CreateFileMapping(); test_BadPtr(); } diff --git a/dlls/kernel32/virtual.c b/dlls/kernel32/virtual.c index 9bb13f123ac..a338a9d4067 100644 --- a/dlls/kernel32/virtual.c +++ b/dlls/kernel32/virtual.c @@ -347,8 +347,7 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa, attr.Length = sizeof(attr); attr.RootDirectory = 0; attr.ObjectName = NULL; - attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF | - ((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0); + attr.Attributes = OBJ_OPENIF | ((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0); attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL; attr.SecurityQualityOfService = NULL; @@ -451,7 +450,7 @@ HANDLE WINAPI OpenFileMappingW( DWORD access, BOOL inherit, LPCWSTR name) attr.Length = sizeof(attr); attr.RootDirectory = get_BaseNamedObjects_handle(); attr.ObjectName = &nameW; - attr.Attributes = OBJ_CASE_INSENSITIVE | (inherit ? OBJ_INHERIT : 0); + attr.Attributes = inherit ? OBJ_INHERIT : 0; attr.SecurityDescriptor = NULL; attr.SecurityQualityOfService = NULL; RtlInitUnicodeString( &nameW, name );