Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
ResourceCore.cpp
Go to the documentation of this file.
1#define RESOURCES_EXPORTS
2#include "ResourceCore.h"
3#include <string>
4#include <unordered_map>
5
6// Define the error code mappings
7static const std::unordered_map<std::string, int> errorCodeMap = {
8 {"NOT_SET", NOT_SET},
9 {"PANO_SUCCESS", PANO_SUCCESS},
10 {"FILE_NOT_FOUND", FILE_NOT_FOUND},
11 {"PERMISSION_DENIED", PERMISSION_DENIED},
12 {"INVALID_INPUT", INVALID_INPUT},
13 {"MUTEX_NOT_SET", MUTEX_NOT_SET},
14 {"MUTEX_SET", MUTEX_SET},
15 {"DB_INITIALIZATION", DB_INITIALIZATION},
16 {"DB_DELETE", DB_DELETE},
17 {"CONTAINER_START", CONTAINER_START},
18 {"WINDOWS_ERR", WINDOWS_ERR},
19 {"INVALID_HANDLE", INVALID_HANDLE},
20 {"IOCTL_FAILED", IOCTL_FAILED},
21 {"EVENT_CREATE", EVENT_CREATE},
22 {"NAMED_PIPE_CREATE", NAMED_PIPE_CREATE},
23 {"KERNEL_PIPE", KERNEL_PIPE},
24 {"NOT_INSTALLED", NOT_INSTALLED},
25 {"CONTROL_SERVICE", CONTROL_SERVICE},
26 {"PANO_SERVICE_RUNNING", PANO_SERVICE_RUNNING},
27 {"PANO_SERVICE_STOPPED", PANO_SERVICE_STOPPED},
28 {"ERROR_STARTING_SERVICE", ERROR_STARTING_SERVICE},
29 {"ERROR_STOPPING_SERVICE", ERROR_STOPPING_SERVICE},
30 {"CLEAN_HANDLE", CLEAN_HANDLE},
31 {"NOT_ADMIN", NOT_ADMIN},
32 {"NO_CONFIG", NO_CONFIG},
33 {"GRPC_SERVER_ERROR", GRPC_SERVER_ERROR},
34 {"EXT_INVALID", EXT_INVALID},
35 {"DEBUGGER", DEBUGGER}
36};
37
38static const std::unordered_map<int, const char*> errorStringMap = {
39 {NOT_SET, "Not Set"},
40 {PANO_SUCCESS, "Operation successful"},
41 {FILE_NOT_FOUND, "File not found"},
42 {PERMISSION_DENIED, "Permission denied"},
43 {INVALID_INPUT, "Invalid input"},
44 {MUTEX_NOT_SET, "Mutex was not set"},
45 {MUTEX_SET, "Could not set service mutex"},
46 {DB_INITIALIZATION, "Cant initialize database"},
47 {DB_DELETE, "Unable to delete database"},
48 {CONTAINER_START, "Unable to start container instances"},
49 {WINDOWS_ERR, "Windows Internal Error"},
50 {INVALID_HANDLE, "Invalid Handle"},
51 {IOCTL_FAILED, "An invalid IOCTL"},
52 {EVENT_CREATE, "An error occured when attempting to create an event"},
53 {NAMED_PIPE_CREATE, "An error occured when attempting to create a named pipe"},
54 {KERNEL_PIPE, "An error occured when attempting to connect to kernel pipe."},
55 {NOT_INSTALLED, "The Panoptes driver is not installed. Reinstall Panoptes."},
56 {CONTROL_SERVICE, "Can't control the supplied service"},
57 {PANO_SERVICE_RUNNING, "The service is running"},
58 {PANO_SERVICE_STOPPED, "The Panoptes driver is not running and could not be started. Check that test signing is on (bcdedit /set testsigning on, then reboot)."},
59 {ERROR_STARTING_SERVICE, "Failed to start service"},
60 {ERROR_STOPPING_SERVICE, "Failed to stop service"},
61 {CLEAN_HANDLE, "An error occured when attempting to clean up handles"},
62 {NOT_ADMIN, "The program is not running as administrator"},
63 {NO_CONFIG, "Not config file was provided"},
64 {GRPC_SERVER_ERROR, "An error occured attempting to start local server"},
65 {EXT_INVALID, "An invalid extensibility was selected"},
66 {DEBUGGER, "Debugger Detected"}
67};
68
69extern "C" {
70
71RESOURCES_API int GetResourceErrorCode(const char* errorName) {
72 auto it = errorCodeMap.find(errorName);
73 return (it != errorCodeMap.end()) ? it->second : NOT_SET;
74}
75
76RESOURCES_API const char* GetResourceErrorString(int errorCode) {
77 auto it = errorStringMap.find(errorCode);
78 return (it != errorStringMap.end()) ? it->second : "Unknown error code";
79}
80
81}
RESOURCES_API int GetResourceErrorCode(const char *errorName)
RESOURCES_API const char * GetResourceErrorString(int errorCode)
#define ERROR_STARTING_SERVICE
#define PANO_SUCCESS
#define DEBUGGER
#define CONTAINER_START
#define INVALID_INPUT
#define PANO_SERVICE_STOPPED
#define RESOURCES_API
Definition ResourceCore.h:6
#define NOT_ADMIN
#define PANO_SERVICE_RUNNING
#define NOT_SET
#define ERROR_STOPPING_SERVICE
#define CONTROL_SERVICE
#define IOCTL_FAILED
#define INVALID_HANDLE
#define FILE_NOT_FOUND
#define KERNEL_PIPE
#define WINDOWS_ERR
#define DB_DELETE
#define PERMISSION_DENIED
#define NO_CONFIG
#define MUTEX_SET
#define DB_INITIALIZATION
#define EVENT_CREATE
#define GRPC_SERVER_ERROR
#define EXT_INVALID
#define NAMED_PIPE_CREATE
#define NOT_INSTALLED
#define CLEAN_HANDLE
#define MUTEX_NOT_SET