1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
DWORD lastError;
char szNomMapping[LG_NOM+10];
SECURITY_DESCRIPTOR SD;
SECURITY_ATTRIBUTES sa;
InitializeSecurityDescriptor(&SD, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&SD, TRUE, NULL, FALSE);
memset(szNomMapping, 0, LG_NOM+10);
strcpy(szNomMapping, "Global\\");
strcat(szNomMapping, szNom);
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = &SD;
sa.bInheritHandle = TRUE;
*hMem = CreateFileMapping ((HANDLE) INVALID_HANDLE_VALUE,
&sa,
PAGE_READWRITE,
0,
TAILLE_BUFF_IO,
szNomMapping
);
lastError = GetLastError();
if ((*hMem)==NULL)
{
return IO_ERR_GENERAL;
}
else
{
if (lastError == ERROR_ALREADY_EXISTS)
{
return IO_ERR_ALREADY_OPEN;
}
*pszAdresse = (unsigned char*)MapViewOfFile( *hMem,
FILE_MAP_WRITE,
0,
0,
0
);
if (pszAdresse == NULL)
{
return IO_ERR_GENERAL;
}
}
return IO_NO_ERROR;
|