2023-08-20 16:12:04 +02:00
|
|
|
#ifndef CALLBACKS_H
|
|
|
|
#define CALLBACKS_H
|
2024-01-15 02:01:14 +01:00
|
|
|
|
2024-01-12 06:40:33 +01:00
|
|
|
#include "driver.h"
|
2024-01-15 02:01:14 +01:00
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
#include <wdf.h>
|
|
|
|
|
2024-04-13 06:40:51 +02:00
|
|
|
typedef void (*THREADLIST_CALLBACK_ROUTINE)(
|
|
|
|
_In_ PTHREAD_LIST_ENTRY ThreadListEntry, _In_opt_ PVOID Context);
|
2024-01-15 02:01:14 +01:00
|
|
|
|
2024-01-08 04:57:07 +01:00
|
|
|
#define DRIVER_PATH_LENGTH 0x100
|
2024-01-07 05:42:40 +01:00
|
|
|
#define SHA_256_HASH_LENGTH 32
|
|
|
|
|
2024-04-13 06:40:51 +02:00
|
|
|
typedef struct _DRIVER_LIST_ENTRY {
|
2024-06-16 11:21:37 +02:00
|
|
|
LIST_ENTRY list_entry;
|
|
|
|
PVOID ImageBase;
|
|
|
|
ULONG ImageSize;
|
|
|
|
BOOLEAN hashed;
|
|
|
|
BOOLEAN x86;
|
|
|
|
CHAR path[DRIVER_PATH_LENGTH];
|
|
|
|
CHAR text_hash[SHA_256_HASH_LENGTH];
|
2024-04-13 10:23:14 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This LIST_ENTRY is to be used for modules where the hashing needs to
|
|
|
|
* be deferred. For example, when x86 modules can't be hashed on driver
|
|
|
|
* load.
|
|
|
|
*/
|
|
|
|
LIST_ENTRY deferred_entry;
|
2024-02-11 15:34:28 +01:00
|
|
|
|
2024-01-07 05:13:41 +01:00
|
|
|
} DRIVER_LIST_ENTRY, *PDRIVER_LIST_ENTRY;
|
|
|
|
|
2024-04-13 06:40:51 +02:00
|
|
|
typedef void (*DRIVERLIST_CALLBACK_ROUTINE)(
|
|
|
|
_In_ PDRIVER_LIST_ENTRY DriverListEntry, _In_opt_ PVOID Context);
|
2024-02-11 15:34:28 +01:00
|
|
|
|
2024-06-09 09:22:22 +02:00
|
|
|
typedef BOOLEAN (*PROCESS_MODULE_CALLBACK)(_In_ PPROCESS_MAP_MODULE_ENTRY Entry,
|
|
|
|
_In_opt_ PVOID Context);
|
|
|
|
|
2024-01-07 05:13:41 +01:00
|
|
|
NTSTATUS
|
|
|
|
InitialiseDriverList();
|
|
|
|
|
2023-12-13 05:06:27 +01:00
|
|
|
VOID NTAPI
|
2024-04-13 06:40:51 +02:00
|
|
|
ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable,
|
|
|
|
IN PHANDLE_TABLE_ENTRY HandleTableEntry);
|
2023-08-29 19:36:58 +02:00
|
|
|
|
2023-10-05 08:27:17 +02:00
|
|
|
VOID
|
2024-04-13 06:40:51 +02:00
|
|
|
ObPostOpCallbackRoutine(_In_ PVOID RegistrationContext,
|
|
|
|
_In_ POB_POST_OPERATION_INFORMATION
|
|
|
|
OperationInformation);
|
2023-08-20 16:12:04 +02:00
|
|
|
|
2023-10-05 08:27:17 +02:00
|
|
|
OB_PREOP_CALLBACK_STATUS
|
2023-12-13 05:06:27 +01:00
|
|
|
ObPreOpCallbackRoutine(_In_ PVOID RegistrationContext,
|
|
|
|
_In_ POB_PRE_OPERATION_INFORMATION OperationInformation);
|
2023-08-20 16:12:04 +02:00
|
|
|
|
2024-01-14 05:31:19 +01:00
|
|
|
NTSTATUS
|
2023-10-08 16:07:49 +02:00
|
|
|
InitialiseThreadList();
|
|
|
|
|
|
|
|
VOID
|
2024-04-13 06:40:51 +02:00
|
|
|
ThreadCreateNotifyRoutine(_In_ HANDLE ProcessId,
|
|
|
|
_In_ HANDLE ThreadId,
|
|
|
|
_In_ BOOLEAN Create);
|
2023-10-08 16:07:49 +02:00
|
|
|
|
2023-10-10 19:49:17 +02:00
|
|
|
VOID
|
2024-04-13 06:40:51 +02:00
|
|
|
ProcessCreateNotifyRoutine(_In_ HANDLE ParentId,
|
|
|
|
_In_ HANDLE ProcessId,
|
|
|
|
_In_ BOOLEAN Create);
|
2023-10-10 19:49:17 +02:00
|
|
|
|
2023-10-08 16:07:49 +02:00
|
|
|
VOID
|
|
|
|
CleanupThreadListOnDriverUnload();
|
|
|
|
|
2023-10-09 09:34:30 +02:00
|
|
|
VOID
|
2024-06-16 10:04:28 +02:00
|
|
|
FindThreadListEntryByThreadAddress(_In_ HANDLE ThreadId,
|
2024-05-11 14:54:58 +02:00
|
|
|
_Out_ PTHREAD_LIST_ENTRY* Entry);
|
2023-10-09 09:34:30 +02:00
|
|
|
|
2024-01-07 05:13:41 +01:00
|
|
|
VOID
|
2024-04-13 06:40:51 +02:00
|
|
|
FindDriverEntryByBaseAddress(_In_ PVOID ImageBase,
|
|
|
|
_Out_ PDRIVER_LIST_ENTRY* Entry);
|
2024-01-07 05:13:41 +01:00
|
|
|
|
|
|
|
VOID
|
|
|
|
CleanupDriverListOnDriverUnload();
|
|
|
|
|
|
|
|
VOID
|
|
|
|
ImageLoadNotifyRoutineCallback(_In_opt_ PUNICODE_STRING FullImageName,
|
|
|
|
_In_ HANDLE ProcessId,
|
|
|
|
_In_ PIMAGE_INFO ImageInfo);
|
|
|
|
|
2024-01-12 06:40:33 +01:00
|
|
|
NTSTATUS
|
|
|
|
InitialiseTimerObject(_Out_ PTIMER_OBJECT Timer);
|
|
|
|
|
|
|
|
VOID
|
2024-05-11 14:54:58 +02:00
|
|
|
CleanupDriverTimerObjects(_Inout_ PTIMER_OBJECT Timer);
|
2024-01-12 06:40:33 +01:00
|
|
|
|
2024-01-14 05:31:19 +01:00
|
|
|
VOID
|
|
|
|
UnregisterProcessCreateNotifyRoutine();
|
|
|
|
|
|
|
|
VOID
|
|
|
|
UnregisterImageLoadNotifyRoutine();
|
|
|
|
|
|
|
|
VOID
|
|
|
|
UnregisterThreadCreateNotifyRoutine();
|
|
|
|
|
2024-01-15 02:01:14 +01:00
|
|
|
VOID
|
|
|
|
UnregisterProcessObCallbacks();
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
RegisterProcessObCallbacks();
|
|
|
|
|
|
|
|
VOID
|
2024-01-31 08:32:13 +01:00
|
|
|
InitialiseObCallbacksConfiguration(_Out_ PACTIVE_SESSION ProcessConfig);
|
2024-01-15 02:01:14 +01:00
|
|
|
|
2024-02-11 15:34:28 +01:00
|
|
|
VOID
|
2024-04-13 06:40:51 +02:00
|
|
|
EnumerateDriverListWithCallbackRoutine(
|
|
|
|
_In_ DRIVERLIST_CALLBACK_ROUTINE CallbackRoutine, _In_opt_ PVOID Context);
|
2024-02-11 15:34:28 +01:00
|
|
|
|
|
|
|
VOID
|
|
|
|
DriverListEntryToExtendedModuleInfo(_In_ PDRIVER_LIST_ENTRY Entry,
|
|
|
|
_Out_ PRTL_MODULE_EXTENDED_INFO Extended);
|
|
|
|
|
2024-06-09 09:22:22 +02:00
|
|
|
NTSTATUS
|
|
|
|
InitialiseProcessHashmap();
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
EnumerateProcessHandles(_In_ PPROCESS_LIST_ENTRY Entry, _In_opt_ PVOID Context);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EnumerateAndPrintProcessHashmap();
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CleanupProcessHashmap();
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EnumerateProcessModuleList(_In_ HANDLE ProcessId,
|
|
|
|
_In_ PROCESS_MODULE_CALLBACK Callback,
|
|
|
|
_In_opt_ PVOID Context);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
FindOurUserModeModuleEntry(_In_ PROCESS_MODULE_CALLBACK Callback,
|
|
|
|
_In_opt_ PVOID Context);
|
|
|
|
|
2023-08-20 16:12:04 +02:00
|
|
|
#endif
|