![]() |
Panoptes 1.0.0
Endpoint Detection and Response
|
Go to the source code of this file.
Macros | |
| #define | PANO_MAX_QUEUED_EVENTS 2048 |
| Maximum number of events buffered while no GET_EVENT request is pending. Older buffered events are not discarded; new events are dropped once the FIFO is full. | |
Functions | |
| NTSTATUS | EventQueueInit () |
| Initializes the event queue. Call once from DriverEntry before any producer can run and before the device is exposed. | |
| void | EventQueueCleanup () |
| Cancels every pending GET_EVENT request and frees all buffered events. Call from the unload path after all producers have been stopped. | |
| BOOLEAN | EventQueueReceiveRequest (PIRP Irp, NTSTATUS *Status) |
| Queues a GET_EVENT request. Call from the IOCTL dispatch routine. On success the IRP is either completed immediately (an event was waiting) or marked pending and parked in the cancel-safe queue; in both cases the dispatch routine must return the value written to *Status and must not touch the IRP again. | |
| BOOLEAN | EventQueueIsConsumerProcess (UINT64 ProcessId) |
| Checks whether a process is the one reading events (the service). The filter does not report that process's own file activity: its log writes, database and scans would otherwise each produce more events for it to read, and it discards them anyway. Tracks the process of the handle that most recently became a consumer. Safe at any IRQL <= DISPATCH_LEVEL. | |
| void | EventQueueCleanupFile (PFILE_OBJECT FileObject) |
| Handles IRP_MJ_CLEANUP for a handle to the device: cancels the GET_EVENT requests still parked for it and, if it was the last consumer, drops the buffered events. Call from the IRP_MJ_CLEANUP dispatch routine. | |
| NTSTATUS | PanoReportEvent (PANO_EVENT_TYPE Type, _In_reads_bytes_(PayloadSize) const void *Payload, UINT32 PayloadSize) |
| Reports one event. Delivers it to a pending GET_EVENT request if one is waiting, otherwise buffers it. Safe to call at IRQL <= DISPATCH_LEVEL. | |
| NTSTATUS | PanoReportFileEvent (PANO_EVENT_TYPE Type, UINT64 ProcessId, UINT64 ThreadId, INT64 FileOffset, UINT32 Length, UINT32 Flags, _In_reads_opt_(NameLength) const WCHAR *FileName, UINT32 NameLength) |
| Convenience wrapper that builds a PANO_FILE_EVENT_DATA event. FileName is copied and truncated to PANO_MAX_FILE_NAME_LENGTH (PANO_FLAG_NAME_TRUNCATED is set in Flags when truncation occurs). Pass NameLength in WCHARs. | |
| NTSTATUS | PanoReportFileModifiedEvent (UINT64 ProcessId, UINT64 ThreadId, UINT64 Writes, UINT64 Bytes, INT64 FirstWriteTime, UINT32 Flags, _In_reads_opt_(NameLength) const WCHAR *FileName, UINT32 NameLength) |
| Convenience wrapper that builds a PANO_EVENT_FILE_MODIFIED event. FileName is copied and truncated to PANO_MAX_MODIFIED_FILE_NAME_LENGTH (PANO_FLAG_NAME_TRUNCATED is set when truncation occurs). Pass NameLength in WCHARs. | |
| NTSTATUS | PanoReportRenameEvent (UINT64 ProcessId, UINT64 ThreadId, UINT32 Flags, _In_reads_opt_(SourceNameLength) const WCHAR *SourceName, UINT32 SourceNameLength, _In_reads_opt_(DestinationNameLength) const WCHAR *DestinationName, UINT32 DestinationNameLength) |
| Convenience wrapper that builds a PANO_RENAME_EVENT_DATA event. If the two names together exceed PANO_MAX_RENAME_NAMES_LENGTH they are truncated (the longer one first) and PANO_FLAG_NAME_TRUNCATED is set. Pass lengths in WCHARs. | |
| NTSTATUS | PanoReportRegistryEvent (PANO_EVENT_TYPE Type, UINT64 ProcessId, UINT64 ThreadId, UINT32 Flags, UINT32 Detail, UINT32 DataSize, _In_reads_opt_(KeyNameLength) const WCHAR *KeyName, UINT32 KeyNameLength, _In_reads_opt_(SecondNameLength) const WCHAR *SecondName, UINT32 SecondNameLength, _In_reads_bytes_opt_(DataLength) const void *Data, UINT32 DataLength) |
| Convenience wrapper that builds a PANO_REGISTRY_EVENT_DATA event. Every buffer must be kernel memory: the caller captures anything from user mode first. Data is cut to PANO_MAX_REGISTRY_DATA_SIZE bytes (PANO_FLAG_DATA_TRUNCATED is set). If the two names together exceed PANO_MAX_REGISTRY_NAMES_LENGTH they are truncated (the longer one first) and PANO_FLAG_NAME_TRUNCATED is set. Pass name lengths in WCHARs and DataLength in bytes. | |
| NTSTATUS | PanoReportProcessEvent (PANO_EVENT_TYPE Type, UINT64 ProcessId, UINT64 ParentProcessId, UINT64 CreatingProcessId, UINT64 CreatingThreadId, _In_reads_opt_(ImageNameLength) const WCHAR *ImageName, UINT32 ImageNameLength, _In_reads_opt_(CommandLineLength) const WCHAR *CommandLine, UINT32 CommandLineLength) |
| Convenience wrapper that builds a PANO_PROCESS_EVENT_DATA event. If the image name and command line together exceed PANO_MAX_PROCESS_STRINGS_LENGTH they are truncated (the longer one first) and PANO_FLAG_NAME_TRUNCATED / PANO_FLAG_COMMAND_LINE_TRUNCATED are set for whichever was cut. Pass lengths in WCHARs. | |
| #define PANO_MAX_QUEUED_EVENTS 2048 |
Maximum number of events buffered while no GET_EVENT request is pending. Older buffered events are not discarded; new events are dropped once the FIFO is full.
Definition at line 25 of file event_queue.h.
| void EventQueueCleanup | ( | ) |
Cancels every pending GET_EVENT request and frees all buffered events. Call from the unload path after all producers have been stopped.
Definition at line 202 of file event_queue.cpp.
References PANO_EVENT_POOL_TAG.
Referenced by DriverEntry(), and UnloadPanoptes().
| void EventQueueCleanupFile | ( | PFILE_OBJECT | FileObject | ) |
Handles IRP_MJ_CLEANUP for a handle to the device: cancels the GET_EVENT requests still parked for it and, if it was the last consumer, drops the buffered events. Call from the IRP_MJ_CLEANUP dispatch routine.
| FileObject | The file object being cleaned up. |
Definition at line 277 of file event_queue.cpp.
References PANO_CONSUMER_MARK, and PANO_EVENT_POOL_TAG.
| NTSTATUS EventQueueInit | ( | ) |
Initializes the event queue. Call once from DriverEntry before any producer can run and before the device is exposed.
Definition at line 181 of file event_queue.cpp.
Referenced by DriverEntry().
| BOOLEAN EventQueueIsConsumerProcess | ( | UINT64 | ProcessId | ) |
Checks whether a process is the one reading events (the service). The filter does not report that process's own file activity: its log writes, database and scans would otherwise each produce more events for it to read, and it discards them anyway. Tracks the process of the handle that most recently became a consumer. Safe at any IRQL <= DISPATCH_LEVEL.
Definition at line 270 of file event_queue.cpp.
| BOOLEAN EventQueueReceiveRequest | ( | PIRP | Irp, |
| NTSTATUS * | Status ) |
Queues a GET_EVENT request. Call from the IOCTL dispatch routine. On success the IRP is either completed immediately (an event was waiting) or marked pending and parked in the cancel-safe queue; in both cases the dispatch routine must return the value written to *Status and must not touch the IRP again.
| Irp | The IOCTL_PANOPTES_GET_EVENT request (METHOD_BUFFERED). |
| Status | Receives the status the dispatch routine should return. |
Definition at line 219 of file event_queue.cpp.
References PANO_CONSUMER_MARK, and PANO_MAX_EVENT_SIZE.
| NTSTATUS PanoReportEvent | ( | PANO_EVENT_TYPE | Type, |
| _In_reads_bytes_(PayloadSize) const void * | Payload, | ||
| UINT32 | PayloadSize ) |
Reports one event. Delivers it to a pending GET_EVENT request if one is waiting, otherwise buffers it. Safe to call at IRQL <= DISPATCH_LEVEL.
| Type | A PANO_EVENT_TYPE. |
| Payload | The event body that follows the header (e.g. a PANO_FILE_EVENT_DATA). |
| PayloadSize | Size of Payload in bytes. |
| NTSTATUS PanoReportFileEvent | ( | PANO_EVENT_TYPE | Type, |
| UINT64 | ProcessId, | ||
| UINT64 | ThreadId, | ||
| INT64 | FileOffset, | ||
| UINT32 | Length, | ||
| UINT32 | Flags, | ||
| _In_reads_opt_(NameLength) const WCHAR * | FileName, | ||
| UINT32 | NameLength ) |
Convenience wrapper that builds a PANO_FILE_EVENT_DATA event. FileName is copied and truncated to PANO_MAX_FILE_NAME_LENGTH (PANO_FLAG_NAME_TRUNCATED is set in Flags when truncation occurs). Pass NameLength in WCHARs.
| NTSTATUS PanoReportFileModifiedEvent | ( | UINT64 | ProcessId, |
| UINT64 | ThreadId, | ||
| UINT64 | Writes, | ||
| UINT64 | Bytes, | ||
| INT64 | FirstWriteTime, | ||
| UINT32 | Flags, | ||
| _In_reads_opt_(NameLength) const WCHAR * | FileName, | ||
| UINT32 | NameLength ) |
Convenience wrapper that builds a PANO_EVENT_FILE_MODIFIED event. FileName is copied and truncated to PANO_MAX_MODIFIED_FILE_NAME_LENGTH (PANO_FLAG_NAME_TRUNCATED is set when truncation occurs). Pass NameLength in WCHARs.
| NTSTATUS PanoReportProcessEvent | ( | PANO_EVENT_TYPE | Type, |
| UINT64 | ProcessId, | ||
| UINT64 | ParentProcessId, | ||
| UINT64 | CreatingProcessId, | ||
| UINT64 | CreatingThreadId, | ||
| _In_reads_opt_(ImageNameLength) const WCHAR * | ImageName, | ||
| UINT32 | ImageNameLength, | ||
| _In_reads_opt_(CommandLineLength) const WCHAR * | CommandLine, | ||
| UINT32 | CommandLineLength ) |
Convenience wrapper that builds a PANO_PROCESS_EVENT_DATA event. If the image name and command line together exceed PANO_MAX_PROCESS_STRINGS_LENGTH they are truncated (the longer one first) and PANO_FLAG_NAME_TRUNCATED / PANO_FLAG_COMMAND_LINE_TRUNCATED are set for whichever was cut. Pass lengths in WCHARs.
Referenced by ProcessCreateCallback().
| NTSTATUS PanoReportRegistryEvent | ( | PANO_EVENT_TYPE | Type, |
| UINT64 | ProcessId, | ||
| UINT64 | ThreadId, | ||
| UINT32 | Flags, | ||
| UINT32 | Detail, | ||
| UINT32 | DataSize, | ||
| _In_reads_opt_(KeyNameLength) const WCHAR * | KeyName, | ||
| UINT32 | KeyNameLength, | ||
| _In_reads_opt_(SecondNameLength) const WCHAR * | SecondName, | ||
| UINT32 | SecondNameLength, | ||
| _In_reads_bytes_opt_(DataLength) const void * | Data, | ||
| UINT32 | DataLength ) |
Convenience wrapper that builds a PANO_REGISTRY_EVENT_DATA event. Every buffer must be kernel memory: the caller captures anything from user mode first. Data is cut to PANO_MAX_REGISTRY_DATA_SIZE bytes (PANO_FLAG_DATA_TRUNCATED is set). If the two names together exceed PANO_MAX_REGISTRY_NAMES_LENGTH they are truncated (the longer one first) and PANO_FLAG_NAME_TRUNCATED is set. Pass name lengths in WCHARs and DataLength in bytes.
| NTSTATUS PanoReportRenameEvent | ( | UINT64 | ProcessId, |
| UINT64 | ThreadId, | ||
| UINT32 | Flags, | ||
| _In_reads_opt_(SourceNameLength) const WCHAR * | SourceName, | ||
| UINT32 | SourceNameLength, | ||
| _In_reads_opt_(DestinationNameLength) const WCHAR * | DestinationName, | ||
| UINT32 | DestinationNameLength ) |
Convenience wrapper that builds a PANO_RENAME_EVENT_DATA event. If the two names together exceed PANO_MAX_RENAME_NAMES_LENGTH they are truncated (the longer one first) and PANO_FLAG_NAME_TRUNCATED is set. Pass lengths in WCHARs.
Referenced by PostSetInformationCallback().