- LIB: Windows 9X doesn't like it when you specify a security descriptor, so

special case Win9X so that it'll pass a NULL to CreateFileMapping.
    
    lib/
        shmem.C

svn path=/trunk/boinc/; revision=15152
This commit is contained in:
Rom Walton 2008-05-08 20:10:20 +00:00
parent a0be700d20
commit fd5d31ff71
2 changed files with 104 additions and 80 deletions

View File

@ -3716,3 +3716,12 @@ David May 8 2008
edf_sim.C
sched_array.C
sched_config.C,h
Rom May 8 2008
- LIB: Windows 9X doesn't like it when you specify a security descriptor, so
special case Win9X so that it'll pass a NULL to CreateFileMapping.
lib/
shmem.C

View File

@ -80,8 +80,20 @@ HANDLE create_shmem(LPCTSTR seg_name, int size, void** pp, bool disable_mapview)
EXPLICIT_ACCESS ea;
SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;
SECURITY_ATTRIBUTES sa;
OSVERSIONINFO osvi;
char global_seg_name[256];
// Win9X doesn't like any reference to a security descriptor. So if we
// detect that we are running on the Win9X platform pass a NULL value
// for it.
osvi.dwOSVersionInfoSize = sizeof(osvi);
GetVersionEx(&osvi);
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
hMap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, size, seg_name);
dwError = GetLastError();
} else {
// Create a well-known SID for the Everyone group.
if(!AllocateAndInitializeSid(&SIDAuthWorld, 1,
SECURITY_WORLD_RID,
@ -159,6 +171,7 @@ HANDLE create_shmem(LPCTSTR seg_name, int size, void** pp, bool disable_mapview)
hMap = CreateFileMapping(INVALID_HANDLE_VALUE, &sa, PAGE_READWRITE, 0, size, seg_name);
dwError = GetLastError();
}
}
if (disable_mapview && (NULL != hMap) && (ERROR_ALREADY_EXISTS == dwError)) {
CloseHandle(hMap);
@ -171,12 +184,14 @@ HANDLE create_shmem(LPCTSTR seg_name, int size, void** pp, bool disable_mapview)
Cleanup:
if (osvi.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) {
if (pEveryoneSID)
FreeSid(pEveryoneSID);
if (pACL)
LocalFree(pACL);
if (pSD)
LocalFree(pSD);
}
return hMap;
}