Shared memory with services

Hi,

I have two applications, one 32 bits and one 64 bits talking through a dll which I made in 32 and 64 bits and use shared memory.

It communicates perfectly as long as I launch my applications with the .exe. But when I use it as a service, it does'nt work.

I've made some researches and I found things like "Global\\" and DACL but I don't really understand how it works.
I tried this but it doesn't work :

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;


Sorry for my bad english :)
Thank you.
Last edited on
Topic archived. No new replies allowed.