Bitdefender Hypervisor Memory Introspection
lixmodule.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Bitdefender
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #ifndef _LIXMODULE_H_
6 #define _LIXMODULE_H_
7 
8 #include "introtypes.h"
9 
10 
11 #define LIX_MODULE_NAME_LEN 56
12 #define LIX_ACTIVE_PATCH_SIZE 27
13 
14 typedef struct _LIX_MODULE_LAYOUT
18 {
24 
25 
29 typedef struct _LIX_KERNEL_MODULE
30 {
31  void *InitSwapHook;
32 
35 
38 
41 
44 
47 
48 
51 
55 typedef struct _LIX_KERNEL_PATCH
56 {
58 
62 
64 
67 
68 
71  _Out_ QWORD *Drivers
72  );
73 
76  _In_ KERNEL_DRIVER *Driver
77  );
78 
79 void
81  _In_ KERNEL_DRIVER *Driver,
82  _In_ QWORD Gva,
83  _Out_writes_(8) CHAR *SectionName
84  );
85 
88  _In_ void *Hook,
89  _In_ QWORD Address,
90  _In_ LIX_ACTIVE_PATCH *ActivePatch,
91  _Out_ INTRO_ACTION *Action
92  );
93 
96  _In_opt_ void *Context,
97  _In_ void *Hook,
98  _In_ QWORD Address,
99  _Out_ INTRO_ACTION *Action
100  );
101 
102 INTSTATUS
105  _In_ QWORD Aux
106  );
107 
108 INTSTATUS
110  _In_ QWORD DriverGva,
111  _In_ QWORD StaticDetected
112  );
113 
114 INTSTATUS
116  _In_ QWORD DriverGva
117  );
118 
119 INTSTATUS
121  void
122  );
123 
124 void
126  void
127  );
128 
129 #endif // _LIXMODULE_H_
#define _In_opt_
Definition: intro_sal.h:16
WORD Length
The patch length.
Definition: lixmodule.h:60
#define _Out_
Definition: intro_sal.h:22
_Bool BOOLEAN
Definition: intro_types.h:58
Describes the information about a Linux active-patch.
Definition: lixguest.h:461
DWORD GplSymbolsCount
The number of GPL-exported symbols (num_gpl_syms).
Definition: lixmodule.h:34
INTSTATUS IntLixDrvCreateKernel(void)
Create the KERNEL_DRIVER object for the operating system kernel and activate the protection for it...
Definition: lixmodule.c:1452
uint8_t BYTE
Definition: intro_types.h:47
INTSTATUS IntLixDrvRemoveEntry(KERNEL_DRIVER *Driver)
Disable protection and frees the driver structure from our internal list.
Definition: lixmodule.c:828
DWORD RoSize
The size of the .rodata (read-only).
Definition: lixmodule.h:22
#define _In_
Definition: intro_sal.h:21
uint16_t WORD
Definition: intro_types.h:48
INTSTATUS IntLixDrvRemoveFromAddress(QWORD DriverGva)
Disable protection and remove the driver structure from our internal list.
Definition: lixmodule.c:866
INTSTATUS IntLixDrvFindList(QWORD *Drivers)
Searches the Linux kernel for the 'modules' variable.
Definition: lixmodule.c:244
int INTSTATUS
The status data type.
Definition: introstatus.h:24
LIX_MODULE_LAYOUT CoreLayout
The layout of the core section.
Definition: lixmodule.h:40
LIX_MODULE_LAYOUT InitLayout
The layout of the init section.
Definition: lixmodule.h:39
void * InitSwapHook
The hook on the init section.
Definition: lixmodule.h:31
#define _Out_writes_(expr)
Definition: intro_sal.h:28
#define LIX_ACTIVE_PATCH_SIZE
The maximum size of the active-patch data.
Definition: lixmodule.h:12
void IntLixDrvUpdateProtection(void)
Update Linux drivers protection according to the new core options.
Definition: lixmodule.c:487
QWORD GplSymbols
The GVA of the exported gpl symbols (gpl_syms).
Definition: lixmodule.h:37
Describes a kernel driver.
Definition: drivers.h:30
void * HookObjectRead
The hook object used to protect this driver against read. NULL if the driver is not protected...
Definition: lixmodule.h:43
DWORD Size
The total size of the section.
Definition: lixmodule.h:20
INTSTATUS IntLixDrvHandleWrite(void *Context, void *Hook, QWORD Address, INTRO_ACTION *Action)
Called if an write occurs on the protected memory zone.
Definition: lixmodule.c:1236
unsigned long long QWORD
Definition: intro_types.h:53
struct _KERNEL_DRIVER * PKERNEL_DRIVER
Definition: lixmodule.h:49
INTSTATUS(* PFUNC_IterateListCallback)(QWORD Node, QWORD Aux)
Definition: introtypes.h:71
struct _LIX_KERNEL_PATCH LIX_KERNEL_PATCH
The internal structure of the Linux active-patch.
void IntLixDrvGetSecName(KERNEL_DRIVER *Driver, QWORD Gva, CHAR *SectionName)
Get the section of the driver that contains the provided guest virtual address.
Definition: lixmodule.c:913
struct _LIX_ACTIVE_PATCH * PLIX_ACTIVE_PATCH
Definition: lixmodule.h:50
uint32_t DWORD
Definition: intro_types.h:49
INTSTATUS IntLixDrvCreateFromAddress(QWORD DriverGva, QWORD StaticDetected)
Create the KERNEL_DRIVER object from the provided 'module struct' address and activate the protection...
Definition: lixmodule.c:696
QWORD KernelSymbols
The GVA of the exported symbols (syms).
Definition: lixmodule.h:36
enum _INTRO_ACTION INTRO_ACTION
Event actions.
INTSTATUS IntLixDrvIterateList(PFUNC_IterateListCallback Callback, QWORD Aux)
Iterates the 'modules' list form the guest and activate protection for each driver that is initialize...
Definition: lixmodule.c:1364
The internal structure of the Linux active-patch.
Definition: lixmodule.h:55
INTSTATUS IntLixDrvIsLegitimateTextPoke(void *Hook, QWORD Address, LIX_ACTIVE_PATCH *ActivePatch, INTRO_ACTION *Action)
This function checks if the modified zone by the current instruction is a 'text_poke'.
Definition: lixmodule.c:980
struct _LIX_MODULE_LAYOUT LIX_MODULE_LAYOUT
The layout of the core/init sections.
struct _LIX_KERNEL_PATCH * PLIX_KERNEL_PATCH
LIST_ENTRY Link
List entry element.
Definition: lixmodule.h:57
struct _LIX_KERNEL_MODULE * PLIX_KERNEL_MODULE
struct _LIX_KERNEL_MODULE LIX_KERNEL_MODULE
The internal structure of the Linux-driver.
The layout of the core/init sections.
Definition: lixmodule.h:17
BOOLEAN Initialized
This means that the init section is discarded.
Definition: lixmodule.h:45
QWORD Base
The base GVA of the section.
Definition: lixmodule.h:19
struct _LIX_MODULE_LAYOUT * PLIX_MODULE_LAYOUT
WORD PatchedLength
The size of the already patched area.
Definition: lixmodule.h:61
QWORD Gva
The start of the region which follows to be patched.
Definition: lixmodule.h:59
char CHAR
Definition: intro_types.h:56
DWORD SymbolsCount
The number of symbols (num_syms).
Definition: lixmodule.h:33
BOOLEAN CodeValid
Definition: lixmodule.h:65
The internal structure of the Linux-driver.
Definition: lixmodule.h:29
DWORD TextSize
The size of the .text (code usually).
Definition: lixmodule.h:21