1
0
Fork 0

Source and DLL are consistent. Painfull error!!!

This commit is contained in:
= 2014-04-25 08:46:57 +02:00
parent 19ae56009d
commit 066816ae82
2 changed files with 20 additions and 6 deletions

View File

@ -121,9 +121,11 @@ PUBLIC_FUNCTION(CreateSharedMemory)
if (pBuf == NULL) if (pBuf == NULL)
{ {
CloseHandle(hMapFile);
hMapFile = NULL;
PushReturnValue(GetLastError()); // Could not map view of file PushReturnValue(GetLastError()); // Could not map view of file
CloseHandle(hMapFile);
hMapFile = NULL;
} }
@ -162,7 +164,7 @@ PUBLIC_FUNCTION(WriteIntoSharedMem)
} }
pBuf = (LPTSTR)MapViewOfFile(hMapFile, // handle to map object pBuf = (LPTSTR)MapViewOfFile(hMapFile, // handle to map object
FILE_MAP_ALL_ACCESS, // read/write permission FILE_MAP_WRITE, // read/write permission
0, 0,
0, 0,
BUF_SIZE); BUF_SIZE);
@ -182,6 +184,9 @@ PUBLIC_FUNCTION(WriteIntoSharedMem)
// read name for mem segment from stack // read name for mem segment from stack
popstring(szMsg); popstring(szMsg);
CopyMemory((PVOID)pBuf, szMsg, (_tcslen(szMsg) * sizeof(TCHAR))); CopyMemory((PVOID)pBuf, szMsg, (_tcslen(szMsg) * sizeof(TCHAR)));
CloseHandle(hMapFile);
PushReturnValue(0); PushReturnValue(0);
} }
PUBLIC_FUNCTION_END PUBLIC_FUNCTION_END
@ -204,6 +209,9 @@ PUBLIC_FUNCTION(ReadIntoSharedMem)
if (hMapFile == NULL) if (hMapFile == NULL)
{ {
pushstring(TEXT("Could not open file mapping object"));
PushReturnValue(GetLastError()); PushReturnValue(GetLastError());
// _tprintf(TEXT("Could not open file mapping object (%d).\n"), // _tprintf(TEXT("Could not open file mapping object (%d).\n"),
// GetLastError()); // GetLastError());
@ -220,6 +228,7 @@ PUBLIC_FUNCTION(ReadIntoSharedMem)
{ {
// _tprintf(TEXT("Could not map view of file (%d).\n"), // _tprintf(TEXT("Could not map view of file (%d).\n"),
// GetLastError()); // GetLastError());
pushstring(TEXT("Could not map view of file"));
PushReturnValue(GetLastError()); PushReturnValue(GetLastError());
@ -229,13 +238,14 @@ PUBLIC_FUNCTION(ReadIntoSharedMem)
} }
pushstring(TEXT(pBuf));
PushReturnValue(0);
UnmapViewOfFile(pBuf); UnmapViewOfFile(pBuf);
CloseHandle(hMapFile); CloseHandle(hMapFile);
PushReturnValue(0);
pushstring(TEXT(pBuf));
} }
PUBLIC_FUNCTION_END PUBLIC_FUNCTION_END
@ -255,6 +265,10 @@ PUBLIC_FUNCTION(ExistsSharedMem)
// GetLastError()); // GetLastError());
return; return;
} }
CloseHandle(hMapFile);
PushReturnValue(1);
} }
PUBLIC_FUNCTION_END PUBLIC_FUNCTION_END