2023-08-20 16:12:04 +02:00
|
|
|
#ifndef QUEUE_H
|
|
|
|
#define QUEUE_H
|
|
|
|
|
|
|
|
#include <ntifs.h>
|
2023-09-02 15:47:15 +02:00
|
|
|
#include "common.h"
|
2023-09-02 10:54:04 +02:00
|
|
|
|
|
|
|
#define MAX_REPORTS_PER_IRP 20
|
2023-08-20 16:12:04 +02:00
|
|
|
|
|
|
|
typedef struct QUEUE_HEAD
|
|
|
|
{
|
2023-12-13 05:06:27 +01:00
|
|
|
struct _QUEUE_NODE* start;
|
|
|
|
struct _QUEUE_NODE* end;
|
|
|
|
KGUARDED_MUTEX lock;
|
|
|
|
INT entries;
|
2023-08-20 16:12:04 +02:00
|
|
|
|
2023-12-13 05:06:27 +01:00
|
|
|
} QUEUE_HEAD, *PQUEUE_HEAD;
|
2023-08-20 16:12:04 +02:00
|
|
|
|
2024-01-13 22:33:57 +01:00
|
|
|
/*
|
|
|
|
* This mutex is to prevent a new item being pushed to the queue
|
|
|
|
* while the HandlePeriodicCallbackReportQueue is iterating through
|
|
|
|
* the objects. This can be an issue because the spinlock is released
|
|
|
|
* after each report is placed in the IRP buffer which means a new report
|
|
|
|
* can be pushed into the queue before the next iteration can take ownership
|
|
|
|
* of the spinlock.
|
|
|
|
*/
|
|
|
|
typedef struct _REPORT_QUEUE_HEAD
|
|
|
|
{
|
|
|
|
QUEUE_HEAD head;
|
|
|
|
volatile BOOLEAN is_driver_unloading;
|
|
|
|
KGUARDED_MUTEX lock;
|
|
|
|
|
|
|
|
} REPORT_QUEUE_HEAD, *PREPORT_QUEUE_HEAD;
|
|
|
|
|
|
|
|
typedef struct _QUEUE_NODE
|
|
|
|
{
|
|
|
|
struct _QUEUE_NODE* next;
|
|
|
|
PVOID data;
|
|
|
|
|
|
|
|
} QUEUE_NODE, *PQUEUE_NODE;
|
|
|
|
|
2023-09-02 10:54:04 +02:00
|
|
|
typedef struct _GLOBAL_REPORT_QUEUE_HEADER
|
|
|
|
{
|
2023-12-13 05:06:27 +01:00
|
|
|
INT count;
|
2023-09-02 10:54:04 +02:00
|
|
|
|
2023-12-13 05:06:27 +01:00
|
|
|
} GLOBAL_REPORT_QUEUE_HEADER, *PGLOBAL_REPORT_QUEUE_HEADER;
|
2023-09-02 10:54:04 +02:00
|
|
|
|
2023-09-02 15:47:15 +02:00
|
|
|
typedef struct _REPORT_HEADER
|
|
|
|
{
|
2023-12-13 05:06:27 +01:00
|
|
|
INT report_id;
|
2023-09-02 15:47:15 +02:00
|
|
|
|
2023-12-13 05:06:27 +01:00
|
|
|
} REPORT_HEADER, *PREPORT_HEADER;
|
2023-09-02 15:47:15 +02:00
|
|
|
|
2023-10-05 08:27:17 +02:00
|
|
|
VOID
|
2023-12-13 05:06:27 +01:00
|
|
|
QueuePush(_Inout_ PQUEUE_HEAD Head, _In_ PVOID Data);
|
2023-08-20 16:12:04 +02:00
|
|
|
|
2023-10-05 08:27:17 +02:00
|
|
|
PVOID
|
2023-12-13 05:06:27 +01:00
|
|
|
QueuePop(_Inout_ PQUEUE_HEAD Head);
|
2023-08-20 16:12:04 +02:00
|
|
|
|
2023-10-05 08:27:17 +02:00
|
|
|
VOID
|
2024-01-13 22:33:57 +01:00
|
|
|
InitialiseGlobalReportQueue();
|
2023-09-02 10:54:04 +02:00
|
|
|
|
2023-10-05 08:27:17 +02:00
|
|
|
VOID
|
2023-12-13 05:06:27 +01:00
|
|
|
InsertReportToQueue(_In_ PVOID Report);
|
2023-09-02 10:54:04 +02:00
|
|
|
|
2023-10-05 08:27:17 +02:00
|
|
|
NTSTATUS
|
2024-01-13 22:33:57 +01:00
|
|
|
HandlePeriodicGlobalReportQueueQuery(_Out_ PIRP Irp);
|
2023-08-20 16:12:04 +02:00
|
|
|
|
2024-01-13 22:33:57 +01:00
|
|
|
NTSTATUS
|
|
|
|
HandlePeriodicGlobalReportQueueQuery(_Out_ PIRP Irp);
|
2023-08-20 16:12:04 +02:00
|
|
|
|
2024-01-13 22:33:57 +01:00
|
|
|
VOID
|
|
|
|
FreeGlobalReportQueueObjects();
|
|
|
|
|
2023-08-20 16:12:04 +02:00
|
|
|
#endif
|