mirror-ac/driver/integrity.h

137 lines
3.5 KiB
C
Raw Normal View History

2023-08-22 19:32:25 +02:00
#ifndef INTEGRITY_H
#define INTEGRITY_H
#include <ntifs.h>
2023-09-02 15:47:15 +02:00
#include "common.h"
2023-08-22 19:32:25 +02:00
typedef struct _MODULE_DISPATCHER_HEADER {
2024-04-13 10:23:14 +02:00
volatile UINT32 validated; // if this is > 0, a thread is already using it
UINT8 result;
2023-12-31 15:06:24 +01:00
} MODULE_DISPATCHER_HEADER, *PMODULE_DISPATCHER_HEADER;
typedef struct _SYSTEM_MODULE_INFORMATION {
2024-04-13 10:23:14 +02:00
MODULE_DISPATCHER_HEADER dispatcher_header;
RTL_MODULE_EXTENDED_INFO module_information;
2023-12-31 15:06:24 +01:00
} SYSTEM_MODULE_INFORMATION, *PSYSTEM_MODULE_INFORMATION;
#define VERIFICATION_THREAD_COUNT 4
typedef struct _SYS_MODULE_VAL_CONTEXT {
2024-04-13 10:23:14 +02:00
/* Stores the number of actively executing worker threads */
volatile LONG active_thread_count;
2023-12-31 15:06:24 +01:00
2024-04-13 10:23:14 +02:00
/* determines whether a validation is in progress */
volatile LONG active;
2023-12-31 15:06:24 +01:00
2024-04-13 10:23:14 +02:00
/* determines whether a validation is complete */
volatile LONG complete;
2023-12-31 15:06:24 +01:00
2024-04-13 10:23:14 +02:00
/* current count of validated modules */
volatile LONG current_count;
2023-12-31 15:06:24 +01:00
2024-04-13 10:23:14 +02:00
/* total count of modules */
UINT32 total_count;
2023-12-31 15:06:24 +01:00
2024-04-13 10:23:14 +02:00
/* number of modules to validate in a single sweep */
UINT32 block_size;
2023-12-31 15:06:24 +01:00
2024-04-13 10:23:14 +02:00
/* pointer to the buffer containing the system module information */
PRTL_MODULE_EXTENDED_INFO module_info;
2023-12-31 15:06:24 +01:00
2024-04-13 10:23:14 +02:00
/* pointer to the array of dispatcher info used to synchonize threads */
PMODULE_DISPATCHER_HEADER dispatcher_info;
2023-12-31 15:06:24 +01:00
2024-04-13 10:23:14 +02:00
/* array of pointers to work items, used to free work items when
* complete */
PIO_WORKITEM work_items[VERIFICATION_THREAD_COUNT];
2023-12-31 15:06:24 +01:00
} SYS_MODULE_VAL_CONTEXT, *PSYS_MODULE_VAL_CONTEXT;
typedef enum _SMBIOS_TABLE_INDEX {
2024-04-13 10:23:14 +02:00
SmbiosInformation = 0,
SystemInformation,
VendorSpecificInformation,
ChassisInformation
} SMBIOS_TABLE_INDEX;
#define SMBIOS_VMWARE_SERIAL_NUMBER_SUB_INDEX 3
2023-12-31 15:06:24 +01:00
#define SMBIOS_NATIVE_SERIAL_NUMBER_SUB_INDEX 4
#define SMBIOS_VENDOR_STRING_SUB_INDEX 1
2023-10-05 08:27:17 +02:00
NTSTATUS
2023-12-13 05:06:27 +01:00
GetDriverImageSize(_Inout_ PIRP Irp);
2023-08-22 19:32:25 +02:00
2023-10-05 08:27:17 +02:00
NTSTATUS
2023-12-13 05:06:27 +01:00
RetrieveInMemoryModuleExecutableSections(_Inout_ PIRP Irp);
2023-10-05 08:27:17 +02:00
NTSTATUS
2023-12-13 05:06:27 +01:00
ValidateProcessLoadedModule(_Inout_ PIRP Irp);
2023-09-04 17:00:36 +02:00
2023-10-05 08:27:17 +02:00
NTSTATUS
GetHardDiskDriveSerialNumber(_Inout_ PVOID ConfigDrive0Serial,
_In_ SIZE_T ConfigDrive0MaxSize);
2023-09-06 17:33:08 +02:00
2023-09-27 06:22:14 +02:00
NTSTATUS
2024-05-04 17:43:01 +02:00
ParseSMBIOSTable(_Out_ PVOID Buffer,
_In_ SIZE_T BufferSize,
_In_ SMBIOS_TABLE_INDEX TableIndex,
_In_ ULONG TableSubIndex);
2023-09-27 06:22:14 +02:00
2023-10-02 16:31:30 +02:00
NTSTATUS
2023-10-03 14:31:30 +02:00
DetectEptHooksInKeyFunctions();
2023-10-02 16:31:30 +02:00
2023-10-07 17:37:47 +02:00
PVOID
2023-12-13 05:06:27 +01:00
ScanForSignature(_In_ PVOID BaseAddress,
_In_ SIZE_T MaxLength,
_In_ LPCSTR Signature,
_In_ SIZE_T SignatureLength);
2023-10-07 17:37:47 +02:00
NTSTATUS
GetOsVersionInformation(_Out_ PRTL_OSVERSIONINFOW VersionInfo);
2023-12-31 15:06:24 +01:00
NTSTATUS
SystemModuleVerificationDispatcher();
2024-01-02 23:29:23 +01:00
NTSTATUS
ValidateOurDriverImage();
VOID
CleanupValidationContextOnUnload(_In_ PSYS_MODULE_VAL_CONTEXT Context);
UINT32
CalculateCpuCoreUsage(_In_ UINT32 Core);
NTSTATUS
HashModule(_In_ PRTL_MODULE_EXTENDED_INFO Module, _Out_ PVOID Hash);
VOID
ValidateSystemModule(_In_ PRTL_MODULE_EXTENDED_INFO Module);
2024-01-12 06:40:33 +01:00
BOOLEAN
ValidateOurDriversDispatchRoutines();
2024-02-11 15:34:28 +01:00
VOID
2024-05-11 14:54:58 +02:00
DeferredModuleHashingCallback(_In_ PDEVICE_OBJECT DeviceObject,
_In_opt_ PVOID Context);
2024-02-11 15:34:28 +01:00
2024-05-04 17:43:01 +02:00
VOID
FindWinLogonProcess(_In_ PPROCESS_LIST_ENTRY Node, _In_opt_ PVOID Context);
2024-05-04 17:43:01 +02:00
NTSTATUS
InitialiseHeartbeatConfiguration(
2024-05-15 11:48:09 +02:00
_Out_ PHEARTBEAT_CONFIGURATION Configuration);
2024-05-04 17:43:01 +02:00
VOID
FreeHeartbeatConfiguration(_Inout_ PHEARTBEAT_CONFIGURATION Configuration);
NTSTATUS
HashUserModule(_In_ PPROCESS_MAP_MODULE_ENTRY Entry,
_Out_ PVOID OutBuffer,
_In_ UINT32 OutBufferSize);
#endif