Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
mutex.hpp File Reference
#include <Windows.h>
#include "error_message.h"

Go to the source code of this file.

Functions

ERRORCODE SetEnvironmentMutex ()
ERRORCODE MutexExist ()
ERRORCODE DestroyMutex ()

Function Documentation

◆ DestroyMutex()

ERRORCODE DestroyMutex ( )

Definition at line 35 of file mutex.cpp.

35 {
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 CLEAN_HANDLE
HANDLE g_mutex
Definition mutex.cpp:3

References CLEAN_HANDLE, ERRORCODE, g_mutex, and PANO_SUCCESS.

◆ MutexExist()

ERRORCODE MutexExist ( )

Definition at line 19 of file mutex.cpp.

19 {
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}
#define MUTEX_NOT_SET
#define SERVICE_MUTEX

References ERRORCODE, g_mutex, MUTEX_NOT_SET, PANO_SUCCESS, and SERVICE_MUTEX.

Referenced by WinMain().

◆ SetEnvironmentMutex()

ERRORCODE SetEnvironmentMutex ( )

Definition at line 5 of file mutex.cpp.

5 {
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}
#define INVALID_INPUT

References ERRORCODE, g_mutex, INVALID_INPUT, PANO_SUCCESS, and SERVICE_MUTEX.

Referenced by WinMain().