Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
driver.cpp
Go to the documentation of this file.
1#include "driver_constants.h"
2#include "callbacks.h"
3#include "ioctl.h"
4#include "trace.h"
5#include "pano_filter.h"
6#include "event_queue.h"
7#include "inject_exclusions.h"
8
9void UnloadPanoptes(PDRIVER_OBJECT DriverObject)
10{
11 PAGED_CODE();
12 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[+] Panoptes: Driver Exit\n");
13 Log_DriverExit(DriverObject);
17 // Producers are stopped and the device is gone; drain any remaining requests/events.
19 // The image load callback and the device are gone, so nothing reads or replaces the list
22}
23
24NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject,PUNICODE_STRING RegistryPath)
25{
26 PAGED_CODE();
27 DriverObject->DriverUnload = UnloadPanoptes;
28
29 TraceInit();
30 // Before the device exists, since an IOCTL can replace the list as soon as it does. Every
31 // DriverEntry failure path below runs before then, so none needs to free the list
33
34 NTSTATUS status = EventQueueInit();
35 if (!NT_SUCCESS(status)) {
36 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[!] Panoptes: Failed to initialize the event queue\n");
38 return status;
39 }
40
41 status = FilterInit(&DriverObject);
42 if (!NT_SUCCESS(status)) {
43 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[!] Panoptes: An error occured when attempting to initialized filter\n");
46 return status;
47 }
48
49 status = InitializeDriverLink(DriverObject);
50 if (!NT_SUCCESS(status)) {
51 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[!] Panoptes: An error occured when attempting to initialize the driver link\n");
55 return status;
56 }
57
59 if (!NT_SUCCESS(status))
60 {
61 DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "[!] Panoptes: An error occured when attempting to initialized kernel callbacks\n");
66 return status;
67 }
68
69 return STATUS_SUCCESS;
70}
NTSTATUS InitializeKernelCallbacks()
VOID RemoveCallbacks()
void UnloadPanoptes(PDRIVER_OBJECT DriverObject)
Definition driver.cpp:9
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
Definition driver.cpp:24
NTSTATUS EventQueueInit()
Initializes the event queue. Call once from DriverEntry before any producer can run and before the de...
void EventQueueCleanup()
Cancels every pending GET_EVENT request and frees all buffered events. Call from the unload path afte...
void InjectExclusionsInit()
Initializes the (empty) list of image names the hook DLL is not injected into. Call before the device...
void InjectExclusionsCleanup()
Frees the list. Call once the device and the image load callback are gone.
void RemoveDriverLink()
Deletes the device and symbolic link created by InitializeDriverLink.
Definition ioctl.cpp:161
NTSTATUS InitializeDriverLink(PDRIVER_OBJECT DriverObject)
Creates the \Device\Panoptes device and symbolic link and registers the IOCTL dispatch routines.
Definition ioctl.cpp:124
void FilterUninit()
Unregisters the minifilter if FilterInit registered it.
NTSTATUS FilterInit(PDRIVER_OBJECT *DriverObject)
void Log_DriverExit(PDRIVER_OBJECT DriverObject)
Definition trace.cpp:34
void TraceUninit()
Definition trace.cpp:15
void TraceInit()
Definition trace.cpp:10