kernel32: File mapping names are case sensitive.

This commit is contained in:
Alexandre Julliard 2008-05-21 20:45:11 +02:00
parent b62f3dee2d
commit 9f76085c06
2 changed files with 42 additions and 3 deletions

View File

@ -622,6 +622,45 @@ static void test_NtMapViewOfSection(void)
CloseHandle(hProcess); 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) static void test_BadPtr(void)
{ {
void *ptr = (void*)1; void *ptr = (void*)1;
@ -667,5 +706,6 @@ START_TEST(virtual)
test_VirtualAlloc(); test_VirtualAlloc();
test_MapViewOfFile(); test_MapViewOfFile();
test_NtMapViewOfSection(); test_NtMapViewOfSection();
test_CreateFileMapping();
test_BadPtr(); test_BadPtr();
} }

View File

@ -347,8 +347,7 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa,
attr.Length = sizeof(attr); attr.Length = sizeof(attr);
attr.RootDirectory = 0; attr.RootDirectory = 0;
attr.ObjectName = NULL; attr.ObjectName = NULL;
attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_OPENIF | attr.Attributes = OBJ_OPENIF | ((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL; attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL;
attr.SecurityQualityOfService = NULL; attr.SecurityQualityOfService = NULL;
@ -451,7 +450,7 @@ HANDLE WINAPI OpenFileMappingW( DWORD access, BOOL inherit, LPCWSTR name)
attr.Length = sizeof(attr); attr.Length = sizeof(attr);
attr.RootDirectory = get_BaseNamedObjects_handle(); attr.RootDirectory = get_BaseNamedObjects_handle();
attr.ObjectName = &nameW; attr.ObjectName = &nameW;
attr.Attributes = OBJ_CASE_INSENSITIVE | (inherit ? OBJ_INHERIT : 0); attr.Attributes = inherit ? OBJ_INHERIT : 0;
attr.SecurityDescriptor = NULL; attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL; attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, name ); RtlInitUnicodeString( &nameW, name );