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_NODE
|
|
|
|
{
|
|
|
|
struct _QUEUE_NODE* next;
|
|
|
|
PVOID data;
|
|
|
|
|
2023-10-05 08:27:17 +02:00
|
|
|
}QUEUE_NODE, * PQUEUE_NODE;
|
2023-08-20 16:12:04 +02:00
|
|
|
|
|
|
|
typedef struct QUEUE_HEAD
|
|
|
|
{
|
|
|
|
struct _QUEUE_NODE* start;
|
|
|
|
struct _QUEUE_NODE* end;
|
2023-10-11 08:35:20 +02:00
|
|
|
KGUARDED_MUTEX lock;
|
2023-08-20 17:04:53 +02:00
|
|
|
INT entries;
|
2023-08-20 16:12:04 +02:00
|
|
|
|
2023-10-05 08:27:17 +02:00
|
|
|
}QUEUE_HEAD, * PQUEUE_HEAD;
|
2023-08-20 16:12:04 +02:00
|
|
|
|
2023-09-02 10:54:04 +02:00
|
|
|
typedef struct _GLOBAL_REPORT_QUEUE_HEADER
|
|
|
|
{
|
|
|
|
INT count;
|
|
|
|
|
|
|
|
}GLOBAL_REPORT_QUEUE_HEADER, * PGLOBAL_REPORT_QUEUE_HEADER;
|
|
|
|
|
2023-09-02 15:47:15 +02:00
|
|
|
typedef struct _REPORT_HEADER
|
|
|
|
{
|
|
|
|
INT report_id;
|
|
|
|
|
|
|
|
}REPORT_HEADER, * PREPORT_HEADER;
|
|
|
|
|
2023-09-25 17:41:38 +02:00
|
|
|
#define LIST_POOL_TAG 'list'
|
|
|
|
|
2023-10-11 18:05:29 +02:00
|
|
|
_IRQL_requires_max_(APC_LEVEL)
|
2023-10-11 08:35:20 +02:00
|
|
|
_Acquires_lock_(_Lock_kind_mutex_)
|
|
|
|
_Releases_lock_(_Lock_kind_mutex_)
|
2023-10-05 08:27:17 +02:00
|
|
|
VOID
|
2023-09-27 06:22:14 +02:00
|
|
|
QueuePush(
|
2023-10-07 17:37:47 +02:00
|
|
|
_Inout_ PQUEUE_HEAD Head,
|
2023-08-20 16:12:04 +02:00
|
|
|
_In_ PVOID Data
|
|
|
|
);
|
|
|
|
|
2023-10-11 18:05:29 +02:00
|
|
|
_IRQL_requires_max_(APC_LEVEL)
|
2023-10-11 08:35:20 +02:00
|
|
|
_Acquires_lock_(_Lock_kind_mutex_)
|
|
|
|
_Releases_lock_(_Lock_kind_mutex_)
|
2023-10-05 08:27:17 +02:00
|
|
|
PVOID
|
|
|
|
QueuePop(
|
2023-10-07 17:37:47 +02:00
|
|
|
_Inout_ PQUEUE_HEAD Head
|
2023-08-20 16:12:04 +02:00
|
|
|
);
|
|
|
|
|
2023-10-05 08:27:17 +02:00
|
|
|
VOID
|
2023-09-27 06:22:14 +02:00
|
|
|
InitialiseGlobalReportQueue(
|
2023-10-07 17:37:47 +02:00
|
|
|
_Out_ PBOOLEAN Status
|
2023-09-02 10:54:04 +02:00
|
|
|
);
|
|
|
|
|
2023-10-10 15:52:42 +02:00
|
|
|
_IRQL_requires_max_(APC_LEVEL)
|
|
|
|
_Acquires_lock_(_Lock_kind_mutex_)
|
|
|
|
_Releases_lock_(_Lock_kind_mutex_)
|
2023-10-05 08:27:17 +02:00
|
|
|
VOID
|
2023-09-27 06:22:14 +02:00
|
|
|
InsertReportToQueue(
|
2023-09-02 10:54:04 +02:00
|
|
|
_In_ PVOID Report
|
|
|
|
);
|
|
|
|
|
2023-10-10 15:52:42 +02:00
|
|
|
_IRQL_requires_max_(APC_LEVEL)
|
|
|
|
_Acquires_lock_(_Lock_kind_mutex_)
|
|
|
|
_Releases_lock_(_Lock_kind_mutex_)
|
2023-10-05 08:27:17 +02:00
|
|
|
NTSTATUS
|
2023-09-27 06:22:14 +02:00
|
|
|
HandlePeriodicGlobalReportQueueQuery(
|
2023-10-07 17:37:47 +02:00
|
|
|
_Inout_ PIRP Irp
|
2023-09-02 10:54:04 +02:00
|
|
|
);
|
2023-08-20 16:12:04 +02:00
|
|
|
|
2023-10-10 15:52:42 +02:00
|
|
|
_IRQL_requires_max_(APC_LEVEL)
|
|
|
|
_Acquires_lock_(_Lock_kind_mutex_)
|
|
|
|
_Releases_lock_(_Lock_kind_mutex_)
|
2023-10-05 08:27:17 +02:00
|
|
|
VOID
|
2023-09-27 06:22:14 +02:00
|
|
|
FreeGlobalReportQueueObjects();
|
2023-08-20 16:12:04 +02:00
|
|
|
|
2023-10-05 08:27:17 +02:00
|
|
|
VOID
|
2023-09-27 06:22:14 +02:00
|
|
|
ListInit(
|
2023-10-08 16:07:49 +02:00
|
|
|
_Inout_ PSINGLE_LIST_ENTRY Head,
|
2023-10-11 08:35:20 +02:00
|
|
|
_Inout_ PKGUARDED_MUTEX Lock
|
2023-09-25 17:41:38 +02:00
|
|
|
);
|
|
|
|
|
2023-10-11 08:35:20 +02:00
|
|
|
_Acquires_lock_(_Lock_kind_mutex_)
|
|
|
|
_Releases_lock_(_Lock_kind_mutex_)
|
2023-10-08 16:07:49 +02:00
|
|
|
VOID
|
2023-09-27 06:22:14 +02:00
|
|
|
ListInsert(
|
2023-10-08 16:07:49 +02:00
|
|
|
_Inout_ PSINGLE_LIST_ENTRY Head,
|
|
|
|
_Inout_ PSINGLE_LIST_ENTRY NewEntry,
|
2023-10-11 08:35:20 +02:00
|
|
|
_In_ PKGUARDED_MUTEX Lock
|
2023-09-25 17:41:38 +02:00
|
|
|
);
|
|
|
|
|
2023-10-11 08:35:20 +02:00
|
|
|
_Acquires_lock_(_Lock_kind_mutex_)
|
|
|
|
_Releases_lock_(_Lock_kind_mutex_)
|
2023-10-08 16:07:49 +02:00
|
|
|
BOOLEAN
|
|
|
|
ListFreeFirstEntry(
|
|
|
|
_Inout_ PSINGLE_LIST_ENTRY Head,
|
2023-10-12 13:27:40 +02:00
|
|
|
_In_ PKGUARDED_MUTEX Lock,
|
|
|
|
_In_opt_ PVOID CallbackRoutine
|
2023-09-25 17:41:38 +02:00
|
|
|
);
|
|
|
|
|
2023-10-11 08:35:20 +02:00
|
|
|
_Acquires_lock_(_Lock_kind_mutex_)
|
|
|
|
_Releases_lock_(_Lock_kind_mutex_)
|
2023-10-08 16:07:49 +02:00
|
|
|
VOID
|
|
|
|
ListRemoveEntry(
|
|
|
|
_Inout_ PSINGLE_LIST_ENTRY Head,
|
|
|
|
_Inout_ PSINGLE_LIST_ENTRY Entry,
|
2023-10-11 08:35:20 +02:00
|
|
|
_In_ PKGUARDED_MUTEX Lock
|
2023-10-08 16:07:49 +02:00
|
|
|
);
|
|
|
|
|
2023-08-20 16:12:04 +02:00
|
|
|
#endif
|