summaryrefslogtreecommitdiffhomepage
path: root/opentrack-compat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-11-05 06:02:54 +0100
committerStanislaw Halik <sthalik@misaki.pl>2015-11-05 06:02:54 +0100
commitae71a80a7b84899fd9d8c64265a7509e71f2c380 (patch)
treec4f1b14e5e33f81bd1d21ce0b23004f675ae5009 /opentrack-compat
parent9da1484e6c1bbd130a6b618f72efb0acf222e548 (diff)
shm: set right permissions for the mapping
Fix a copy-paste error.
Diffstat (limited to 'opentrack-compat')
-rw-r--r--opentrack-compat/shm.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/opentrack-compat/shm.cpp b/opentrack-compat/shm.cpp
index a26b808b..fffb3709 100644
--- a/opentrack-compat/shm.cpp
+++ b/opentrack-compat/shm.cpp
@@ -36,7 +36,7 @@ struct secattr
pACL = nullptr;
}
- secattr() : success(true), pSD(nullptr), pEveryoneSID(nullptr), pACL(nullptr)
+ secattr(DWORD perms) : success(true), pSD(nullptr), pEveryoneSID(nullptr), pACL(nullptr)
{
SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;
EXPLICIT_ACCESS ea;
@@ -52,7 +52,7 @@ struct secattr
memset(&ea, 0, sizeof(ea));
- ea.grfAccessPermissions = KEY_READ;
+ ea.grfAccessPermissions = perms;
ea.grfAccessMode = SET_ACCESS;
ea.grfInheritance = NO_INHERITANCE;
ea.Trustee.TrusteeForm = TRUSTEE_IS_SID;
@@ -109,9 +109,14 @@ cleanup:
PortableLockedShm::PortableLockedShm(const char* shmName, const char* mutexName, int mapSize)
{
- secattr sa;
+ secattr sa(GENERIC_ALL|SYNCHRONIZE);
hMutex = CreateMutexA(sa.success ? &sa.attrs : nullptr, false, mutexName);
+ if (!hMutex)
+ {
+ fprintf(stderr, "CreateMutexA: %d\n", (int) GetLastError());
+ fflush(stderr);
+ }
hMapFile = CreateFileMappingA(
INVALID_HANDLE_VALUE,
sa.success ? &sa.attrs : nullptr,
@@ -119,11 +124,21 @@ PortableLockedShm::PortableLockedShm(const char* shmName, const char* mutexName,
0,
mapSize,
shmName);
+ if (!hMapFile)
+ {
+ fprintf(stderr, "CreateFileMappingA: %d\n", (int) GetLastError());
+ fflush(stderr);
+ }
mem = MapViewOfFile(hMapFile,
FILE_MAP_WRITE,
0,
0,
mapSize);
+ if (!mem)
+ {
+ fprintf(stderr, "MapViewOfFile: %d\n", (int) GetLastError());
+ fflush(stderr);
+ }
}
PortableLockedShm::~PortableLockedShm()