Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
mutex.cpp
Go to the documentation of this file.
1#include "mutex.hpp"
2
3HANDLE g_mutex;
4
6 g_mutex = CreateMutexA(
7 NULL,
8 FALSE,
10 );
11 if (g_mutex == NULL)
12 {
13 return INVALID_INPUT;
14 }
15
16 return PANO_SUCCESS;
17}
18
20 g_mutex = OpenMutexA(
21 SYNCHRONIZE, // Request full access
22 FALSE, // Do not inherit handle
23 SERVICE_MUTEX // Name of the mutex
24 );
25 if (g_mutex == NULL)
26 {
27 return MUTEX_NOT_SET;
28 }
29
30 return PANO_SUCCESS;
31}
32
33// The mutex is created unowned and only its name marks the service as running, so it is
34// closed rather than released. Safe to call more than once
36 if (g_mutex == NULL)
37 return PANO_SUCCESS;
38
39 BOOL closed = CloseHandle(g_mutex);
40 g_mutex = NULL;
41 if (!closed)
42 return CLEAN_HANDLE;
43
44 return PANO_SUCCESS;
45}
#define PANO_SUCCESS
#define INVALID_INPUT
#define CLEAN_HANDLE
#define MUTEX_NOT_SET
ERRORCODE DestroyMutex()
Definition mutex.cpp:35
HANDLE g_mutex
Definition mutex.cpp:3
ERRORCODE SetEnvironmentMutex()
Definition mutex.cpp:5
ERRORCODE MutexExist()
Definition mutex.cpp:19
#define ERRORCODE
#define SERVICE_MUTEX