![]() |
Panoptes 1.0.0
Endpoint Detection and Response
|
#include "event_queue.h"Go to the source code of this file.
Classes | |
| struct | _PANO_EVENT_NODE |
Macros | |
| #define | PANO_EVENT_POOL_TAG 'vEoP' |
| #define | PANO_CONSUMER_MARK ((PVOID)(ULONG_PTR)0x50414E4F) |
Typedefs | |
| typedef struct _PANO_EVENT_NODE | PANO_EVENT_NODE |
| typedef struct _PANO_EVENT_NODE * | PPANO_EVENT_NODE |
Functions | |
| _IRQL_raises_ (DISPATCH_LEVEL) _Acquires_lock_(g_IrpLock) static VOID CsqAcquireLock(PIO_CSQ Csq | |
| _Releases_lock_ (g_IrpLock) static VOID CsqReleaseLock(PIO_CSQ Csq | |
| 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, const void *Payload, UINT32 PayloadSize) |
| NTSTATUS | PanoReportFileEvent (PANO_EVENT_TYPE Type, UINT64 ProcessId, UINT64 ThreadId, INT64 FileOffset, UINT32 Length, UINT32 Flags, const WCHAR *FileName, UINT32 NameLength) |
| NTSTATUS | PanoReportFileModifiedEvent (UINT64 ProcessId, UINT64 ThreadId, UINT64 Writes, UINT64 Bytes, INT64 FirstWriteTime, UINT32 Flags, const WCHAR *FileName, UINT32 NameLength) |
| NTSTATUS | PanoReportRenameEvent (UINT64 ProcessId, UINT64 ThreadId, UINT32 Flags, const WCHAR *SourceName, UINT32 SourceNameLength, const WCHAR *DestinationName, UINT32 DestinationNameLength) |
| NTSTATUS | PanoReportProcessEvent (PANO_EVENT_TYPE Type, UINT64 ProcessId, UINT64 ParentProcessId, UINT64 CreatingProcessId, UINT64 CreatingThreadId, const WCHAR *ImageName, UINT32 ImageNameLength, const WCHAR *CommandLine, UINT32 CommandLineLength) |
| NTSTATUS | PanoReportRegistryEvent (PANO_EVENT_TYPE Type, UINT64 ProcessId, UINT64 ThreadId, UINT32 Flags, UINT32 Detail, UINT32 DataSize, const WCHAR *KeyName, UINT32 KeyNameLength, const WCHAR *SecondName, UINT32 SecondNameLength, const void *Data, UINT32 DataLength) |
Variables | |
| PKIRQL | Irql |
| #define PANO_CONSUMER_MARK ((PVOID)(ULONG_PTR)0x50414E4F) |
Definition at line 31 of file event_queue.cpp.
Referenced by EventQueueCleanupFile(), and EventQueueReceiveRequest().
| #define PANO_EVENT_POOL_TAG 'vEoP' |
Definition at line 3 of file event_queue.cpp.
Referenced by EventQueueCleanup(), and EventQueueCleanupFile().
| typedef struct _PANO_EVENT_NODE PANO_EVENT_NODE |
| typedef struct _PANO_EVENT_NODE * PPANO_EVENT_NODE |
| _IRQL_raises_ | ( | DISPATCH_LEVEL | ) |
| _Releases_lock_ | ( | g_IrpLock | ) |
References Irql.
| 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, |
| const void * | Payload, | ||
| UINT32 | PayloadSize ) |
Definition at line 398 of file event_queue.cpp.
| NTSTATUS PanoReportFileEvent | ( | PANO_EVENT_TYPE | Type, |
| UINT64 | ProcessId, | ||
| UINT64 | ThreadId, | ||
| INT64 | FileOffset, | ||
| UINT32 | Length, | ||
| UINT32 | Flags, | ||
| const WCHAR * | FileName, | ||
| UINT32 | NameLength ) |
Definition at line 414 of file event_queue.cpp.
References _PANO_FILE_EVENT_DATA::FileName, _PANO_FILE_EVENT_DATA::FileOffset, _PANO_FILE_EVENT_DATA::Flags, _PANO_FILE_EVENT_DATA::Length, _PANO_FILE_EVENT_DATA::NameLength, PANO_FLAG_NAME_TRUNCATED, PANO_MAX_FILE_NAME_LENGTH, _PANO_FILE_EVENT_DATA::ProcessId, and _PANO_FILE_EVENT_DATA::ThreadId.
| NTSTATUS PanoReportFileModifiedEvent | ( | UINT64 | ProcessId, |
| UINT64 | ThreadId, | ||
| UINT64 | Writes, | ||
| UINT64 | Bytes, | ||
| INT64 | FirstWriteTime, | ||
| UINT32 | Flags, | ||
| const WCHAR * | FileName, | ||
| UINT32 | NameLength ) |
Definition at line 456 of file event_queue.cpp.
References _PANO_FILE_MODIFIED_EVENT_DATA::Bytes, _PANO_FILE_MODIFIED_EVENT_DATA::FileName, _PANO_FILE_MODIFIED_EVENT_DATA::FirstWriteTime, _PANO_FILE_MODIFIED_EVENT_DATA::Flags, _PANO_FILE_MODIFIED_EVENT_DATA::NameLength, PANO_EVENT_FILE_MODIFIED, PANO_FLAG_NAME_TRUNCATED, PANO_MAX_MODIFIED_FILE_NAME_LENGTH, _PANO_FILE_MODIFIED_EVENT_DATA::ProcessId, _PANO_FILE_MODIFIED_EVENT_DATA::ThreadId, and _PANO_FILE_MODIFIED_EVENT_DATA::Writes.
| NTSTATUS PanoReportProcessEvent | ( | PANO_EVENT_TYPE | Type, |
| UINT64 | ProcessId, | ||
| UINT64 | ParentProcessId, | ||
| UINT64 | CreatingProcessId, | ||
| UINT64 | CreatingThreadId, | ||
| const WCHAR * | ImageName, | ||
| UINT32 | ImageNameLength, | ||
| const WCHAR * | CommandLine, | ||
| UINT32 | CommandLineLength ) |
Definition at line 575 of file event_queue.cpp.
References _PANO_PROCESS_EVENT_DATA::CommandLineLength, _PANO_PROCESS_EVENT_DATA::CreatingProcessId, _PANO_PROCESS_EVENT_DATA::CreatingThreadId, _PANO_PROCESS_EVENT_DATA::Flags, _PANO_PROCESS_EVENT_DATA::ImageNameLength, PANO_FLAG_COMMAND_LINE_TRUNCATED, PANO_FLAG_NAME_TRUNCATED, PANO_MAX_PROCESS_STRINGS_LENGTH, _PANO_PROCESS_EVENT_DATA::ParentProcessId, _PANO_PROCESS_EVENT_DATA::ProcessId, and _PANO_PROCESS_EVENT_DATA::Strings.
| NTSTATUS PanoReportRegistryEvent | ( | PANO_EVENT_TYPE | Type, |
| UINT64 | ProcessId, | ||
| UINT64 | ThreadId, | ||
| UINT32 | Flags, | ||
| UINT32 | Detail, | ||
| UINT32 | DataSize, | ||
| const WCHAR * | KeyName, | ||
| UINT32 | KeyNameLength, | ||
| const WCHAR * | SecondName, | ||
| UINT32 | SecondNameLength, | ||
| const void * | Data, | ||
| UINT32 | DataLength ) |
Definition at line 631 of file event_queue.cpp.
References _PANO_REGISTRY_EVENT_DATA::DataLength, _PANO_REGISTRY_EVENT_DATA::DataSize, _PANO_REGISTRY_EVENT_DATA::Detail, _PANO_REGISTRY_EVENT_DATA::Flags, _PANO_REGISTRY_EVENT_DATA::KeyNameLength, PANO_FLAG_DATA_TRUNCATED, PANO_FLAG_NAME_TRUNCATED, PANO_MAX_REGISTRY_DATA_SIZE, PANO_MAX_REGISTRY_NAMES_LENGTH, _PANO_REGISTRY_EVENT_DATA::ProcessId, _PANO_REGISTRY_EVENT_DATA::SecondNameLength, _PANO_REGISTRY_EVENT_DATA::Strings, and _PANO_REGISTRY_EVENT_DATA::ThreadId.
| NTSTATUS PanoReportRenameEvent | ( | UINT64 | ProcessId, |
| UINT64 | ThreadId, | ||
| UINT32 | Flags, | ||
| const WCHAR * | SourceName, | ||
| UINT32 | SourceNameLength, | ||
| const WCHAR * | DestinationName, | ||
| UINT32 | DestinationNameLength ) |
Definition at line 527 of file event_queue.cpp.
References _PANO_RENAME_EVENT_DATA::DestinationNameLength, _PANO_RENAME_EVENT_DATA::Flags, _PANO_RENAME_EVENT_DATA::Names, PANO_EVENT_FILE_RENAME, PANO_FLAG_NAME_TRUNCATED, PANO_MAX_RENAME_NAMES_LENGTH, _PANO_RENAME_EVENT_DATA::ProcessId, _PANO_RENAME_EVENT_DATA::SourceNameLength, and _PANO_RENAME_EVENT_DATA::ThreadId.
| KIRQL Irql |
Definition at line 158 of file event_queue.cpp.
Referenced by _Releases_lock_().