creating shared memory mutex in dll
This commit is contained in:
parent
86c16a7197
commit
88c28ec995
2 changed files with 2 additions and 26 deletions
|
|
@ -44,19 +44,6 @@ typedef struct _nfs41_process_thread {
|
||||||
uint32_t tid;
|
uint32_t tid;
|
||||||
} nfs41_process_thread;
|
} nfs41_process_thread;
|
||||||
|
|
||||||
DWORD InitSharedMemory(
|
|
||||||
OUT PHANDLE phMutex)
|
|
||||||
{
|
|
||||||
DWORD status = NO_ERROR;
|
|
||||||
|
|
||||||
*phMutex = CreateMutex(NULL, FALSE, TEXT(NFS41NP_MUTEX_NAME));
|
|
||||||
if (*phMutex == NULL) {
|
|
||||||
status = GetLastError();
|
|
||||||
eprintf("CreateMutex failed with %d\n", status);
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int WINAPI thread_main(void *args)
|
static unsigned int WINAPI thread_main(void *args)
|
||||||
{
|
{
|
||||||
DWORD status = 0;
|
DWORD status = 0;
|
||||||
|
|
@ -147,8 +134,6 @@ write_downcall:
|
||||||
void __cdecl _tmain(int argc, TCHAR *argv[])
|
void __cdecl _tmain(int argc, TCHAR *argv[])
|
||||||
{
|
{
|
||||||
DWORD status = 0, len;
|
DWORD status = 0, len;
|
||||||
// handles related to shared memory
|
|
||||||
HANDLE hSharedMemoryMutex;
|
|
||||||
// handle to our drivers
|
// handle to our drivers
|
||||||
HANDLE pipe;
|
HANDLE pipe;
|
||||||
nfs41_process_thread tids[MAX_NUM_THREADS];
|
nfs41_process_thread tids[MAX_NUM_THREADS];
|
||||||
|
|
@ -181,10 +166,6 @@ void __cdecl _tmain(int argc, TCHAR *argv[])
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = InitSharedMemory(&hSharedMemoryMutex);
|
|
||||||
if (status)
|
|
||||||
goto quit_pipe;
|
|
||||||
|
|
||||||
dprintf(1, "starting nfs41 mini redirector\n");
|
dprintf(1, "starting nfs41 mini redirector\n");
|
||||||
status = DeviceIoControl(pipe, IOCTL_NFS41_START,
|
status = DeviceIoControl(pipe, IOCTL_NFS41_START,
|
||||||
NULL, 0, NULL, 0, (LPDWORD)&len, NULL);
|
NULL, 0, NULL, 0, (LPDWORD)&len, NULL);
|
||||||
|
|
@ -200,7 +181,7 @@ void __cdecl _tmain(int argc, TCHAR *argv[])
|
||||||
if (tids[i].handle == INVALID_HANDLE_VALUE) {
|
if (tids[i].handle == INVALID_HANDLE_VALUE) {
|
||||||
status = GetLastError();
|
status = GetLastError();
|
||||||
eprintf("_beginthreadex failed %d\n", status);
|
eprintf("_beginthreadex failed %d\n", status);
|
||||||
goto quit_pipe;
|
goto quit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//This can be changed to waiting on an array of handles and using waitformultipleobjects
|
//This can be changed to waiting on an array of handles and using waitformultipleobjects
|
||||||
|
|
@ -210,8 +191,6 @@ void __cdecl _tmain(int argc, TCHAR *argv[])
|
||||||
dprintf(1, "Parent woke up!!!!\n");
|
dprintf(1, "Parent woke up!!!!\n");
|
||||||
|
|
||||||
quit:
|
quit:
|
||||||
CloseHandle(hSharedMemoryMutex);
|
|
||||||
quit_pipe:
|
|
||||||
CloseHandle(pipe);
|
CloseHandle(pipe);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,10 +95,7 @@ Return Value:
|
||||||
*phMemory = 0;
|
*phMemory = 0;
|
||||||
*pMemory = NULL;
|
*pMemory = NULL;
|
||||||
|
|
||||||
*phMutex = OpenMutex(SYNCHRONIZE,
|
*phMutex = CreateMutex(NULL, FALSE, TEXT(NFS41NP_MUTEX_NAME));
|
||||||
FALSE,
|
|
||||||
TEXT(NFS41NP_MUTEX_NAME));
|
|
||||||
|
|
||||||
if (*phMutex == NULL)
|
if (*phMutex == NULL)
|
||||||
{
|
{
|
||||||
dwStatus = GetLastError();
|
dwStatus = GetLastError();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue