Bitdefender Hypervisor Memory Introspection
windriver.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Bitdefender
3  * SPDX-License-Identifier: Apache-2.0
4  */
12 
13 #ifndef _WINDRIVER_H_
14 #define _WINDRIVER_H_
15 
16 #include "windrvobj.h"
17 
18 //
19 // Internal definition of a loaded kernel driver.
20 //
21 typedef struct _WIN_KERNEL_DRIVER
22 {
24 
27 
29 
32  void *EpHookObject;
33 
35 
37 
39 
40  void *EatReadHook;
41 
44 
46 
47 
49 
52 #define DRIVER_MAX_ITERATIONS 4096
53 
54 
55 //
56 // Loaded drivers specific API
57 //
60  _In_ QWORD PsLoadedModuleListGva,
61  _In_ void *PsLoadedModuleList,
62  _In_ QWORD KernelLdr
63  );
64 
68  _In_ QWORD Aux
69  );
70 
73  _In_ QWORD ModuleInfo,
74  _In_ QWORD Flags
75  );
76 
79  _In_ QWORD ModuleInfo
80  );
81 
84  _In_ KERNEL_DRIVER *Driver,
86  );
87 
90  _In_ KERNEL_DRIVER *Driver
91  );
92 
95  _In_opt_ void *Context,
96  _In_ void *Hook,
97  _In_ QWORD Address,
98  _Out_ INTRO_ACTION *Action
99  );
100 
101 INTSTATUS
103  _In_ void *Context,
104  _In_ void *Hook,
105  _In_ QWORD Address,
106  _Out_ INTRO_ACTION *Action
107  );
108 
109 INTSTATUS
111  _In_ void *Context,
112  _In_ void *Hook,
113  _In_ QWORD Address,
114  _Out_ INTRO_ACTION *Action
115  );
116 
117 INTSTATUS
119  void
120  );
121 
122 INTSTATUS
124  void
125  );
126 
127 INTSTATUS
129  _In_ KERNEL_DRIVER *Driver
130  );
131 
132 INTSTATUS
134  void
135  );
136 
137 #endif // _WINDRIVER_H_
uint16_t * PWCHAR
Definition: intro_types.h:63
#define _In_opt_
Definition: intro_sal.h:16
INTSTATUS IntWinDrvHandleRead(void *Context, void *Hook, QWORD Address, INTRO_ACTION *Action)
Used to notify the introspection engine when a read took place on a protected driver (used only for n...
Definition: windriver.c:1483
#define _Out_
Definition: intro_sal.h:22
INTSTATUS IntWinDrvUpdateProtection(void)
Used to update the protection for all the loaded modules (gKernelDrivers).
Definition: windriver.c:1751
QWORD EatReadCount
The number of EAT reads that took place from withing known drivers.
Definition: windriver.h:43
#define _In_
Definition: intro_sal.h:21
DWORD PathLength
The driver`s path length (number of WCHARS).
Definition: windriver.h:26
struct _WIN_KERNEL_DRIVER * PWIN_KERNEL_DRIVER
PBYTE MzPeHeaders
The driver`s MZ/PE headers (cached internally).
Definition: windriver.h:34
int INTSTATUS
The status data type.
Definition: introstatus.h:24
void * HeadersSwapHandle
The swap handle used to read the driver`s headers.
Definition: windriver.h:38
INTSTATUS IntWinDrvCreateFromAddress(QWORD ModuleInfo, QWORD Flags)
Adds a driver to introspection's LoadedModuleList (gKernelDrivers). This way we avoid lots of mapping...
Definition: windriver.c:305
DWORD TimeDateStamp
The driver`s internal timestamp (from the _IMAGE_FILE_HEADER).
Definition: windriver.h:23
Describes a kernel driver.
Definition: drivers.h:30
INTSTATUS IntWinUnprotectReadNtEat(void)
Used to remove the EAT read hook from ntoskrnl.exe.
Definition: windriver.c:690
INTSTATUS IntWinDrvHandleDriverEntry(void *Context, void *Hook, QWORD Address, INTRO_ACTION *Action)
Used to notify the introspection engine when the DriverEntry of a module starts executing.
Definition: windriver.c:1152
INTSTATUS IntWinDrvProtect(KERNEL_DRIVER *Driver, QWORD ProtectionFlag)
Used to enable protection for the given driver.
Definition: windriver.c:1069
uint8_t * PBYTE
Definition: intro_types.h:47
Holds information about a driver object.
Definition: windrvobj.h:13
unsigned long long QWORD
Definition: intro_types.h:53
struct _WIN_KERNEL_DRIVER WIN_KERNEL_DRIVER
INTSTATUS(* PFUNC_IterateListCallback)(QWORD Node, QWORD Aux)
Definition: introtypes.h:71
INTSTATUS IntWinDrvRemoveEntry(KERNEL_DRIVER *Driver)
Removes the KERNEL_DRIVER from the internal structures.
Definition: windriver.c:1696
INTSTATUS IntWinDrvIsListHead(QWORD PsLoadedModuleListGva, void *PsLoadedModuleList, QWORD KernelLdr)
Used to identify WINDOWS_GUEST::PsLoadedModuleList.
Definition: windriver.c:67
PWCHAR Path
The driver`s path.
Definition: windriver.h:28
void * EatReadHook
The read hook placed on the driver`s EAT.
Definition: windriver.h:40
uint32_t DWORD
Definition: intro_types.h:49
QWORD ProtectionFlag
The introcore option that decided that this driver must be protected.
Definition: drivers.h:49
INTSTATUS IntWinProtectReadNtEat(void)
Used to place a read hook on the ntoskrnl.exe EAT.
Definition: windriver.c:622
enum _INTRO_ACTION INTRO_ACTION
Event actions.
INTSTATUS IntWinDrvRemoveFromAddress(QWORD ModuleInfo)
Removes a driver from the introspection's loaded modules list (gKernelDrivers).
Definition: windriver.c:522
INTSTATUS IntWinDrvIterateLoadedModules(PFUNC_IterateListCallback Callback, QWORD Aux)
Used to iterate trough the WINDOWS_GUEST::PsLoadedModuleList.
Definition: windriver.c:227
void * EpHookObject
The EP hook placed on the driver (we will be notified when the execution began) - useful to obtain th...
Definition: windriver.h:32
INTSTATUS IntWinDrvUnprotect(KERNEL_DRIVER *Driver)
Used to disable protection for the given driver.
Definition: windriver.c:1103
PWIN_DRIVER_OBJECT DriverObject
The driver object.
Definition: windriver.h:36
DWORD PathHash
CRC32 hash value for the driver`s path.
Definition: windriver.h:25
INTSTATUS IntWinDrvHandleWrite(void *Context, void *Hook, QWORD Address, INTRO_ACTION *Action)
Used to notify the introspection engine when a write took place on a protected driver.
Definition: windriver.c:1315
struct _KERNEL_DRIVER * PKERNEL_DRIVER
Definition: windriver.h:48