Bitdefender Hypervisor Memory Introspection
|
#include "thread_safeness.h"
Go to the source code of this file.
Data Structures | |
struct | _MEM_TABLE_RELOC |
Macros | |
#define | MAX_MEM_TABLE_SIZE 256 |
#define | MEM_TABLE_HEADER_SIZE 47 |
#define | MEM_TABLE_ENTRY_SIZE 11u |
#define | MAX_MEM_TABLE_SLACK_SIZE ((MEM_TABLE_HEADER_SIZE) + (MEM_TABLE_ENTRY_SIZE) * (MAX_MEM_TABLE_SIZE)) |
Typedefs | |
typedef struct _MEM_TABLE_RELOC | MEM_TABLE_RELOC |
typedef struct _MEM_TABLE_RELOC * | PMEM_TABLE_RELOC |
Functions | |
BOOLEAN | IntMtblIsPtrInReloc (QWORD Ptr, THS_PTR_TYPE Type, QWORD *Table) |
Check if the given pointer is inside a mem-table relocation handler. More... | |
INTSTATUS | IntMtblCheckAccess (void) |
Check if the current instruction is like a switch-case table access instruction. More... | |
void | IntMtblDisable (void) |
Disables mem-table instructions instrumentation. More... | |
INTSTATUS | IntMtblRemoveAgentEntries (void) |
Removes only the mem-table entries that were relocated inside the PT filter. More... | |
BOOLEAN | IntMtblInsRelocated (QWORD Rip) |
Check if the instruction at the provided RIP is instrumented. More... | |
INTSTATUS | IntMtblUninit (void) |
Completely uninit the mem-tables, removing all the handlers from the NT slack space. More... | |
#define MAX_MEM_TABLE_SIZE 256 |
Definition at line 11 of file memtables.h.
Referenced by IntMtblCheckAccess(), and IntMtblPatchInstruction().
#define MAX_MEM_TABLE_SLACK_SIZE ((MEM_TABLE_HEADER_SIZE) + (MEM_TABLE_ENTRY_SIZE) * (MAX_MEM_TABLE_SIZE)) |
Definition at line 27 of file memtables.h.
Referenced by IntMtblPatchInstruction().
#define MEM_TABLE_ENTRY_SIZE 11u |
Definition at line 26 of file memtables.h.
Referenced by IntMtblPatchInstruction().
#define MEM_TABLE_HEADER_SIZE 47 |
Definition at line 25 of file memtables.h.
Referenced by IntMtblPatchInstruction().
typedef struct _MEM_TABLE_RELOC MEM_TABLE_RELOC |
Describes a relocated mem-table instruction.
typedef struct _MEM_TABLE_RELOC * PMEM_TABLE_RELOC |
INTSTATUS IntMtblCheckAccess | ( | void | ) |
Check if the current instruction is like a switch-case table access instruction.
This function checks if the current instruction (pointed by the RIP on the current VCPU) looks like an instruction which loads switch-case offset from a code-page. We look after the following features: 0. The instruction must be a MOV instruction;
INT_STATUS_SUCCESS | On success. |
INT_STATUS_NOT_NEEDED_HINT | If there's no need to instrument the instruction. |
INT_STATUS_INSUFFICIENT_RESOURCES | If a memory alloc fails. |
Definition at line 401 of file memtables.c.
Referenced by IntHandleMemAccess().
void IntMtblDisable | ( | void | ) |
Disables mem-table instructions instrumentation.
This function will remove all the hooks placed on mem-table like instructions, thus disabling the instrumentation. Note that the handlers will still remain, and if we have pointers still pointing there, nothing bad will happen. This function should be called only when preparing for uninit.
Definition at line 644 of file memtables.c.
Referenced by IntGuestPrepareUninit().
Check if the instruction at the provided RIP is instrumented.
[in] | Rip | The RIP to be checked. |
TRUE | if the RIP contains an instrumented instruction, FALSE otherwise. |
Definition at line 677 of file memtables.c.
Referenced by IntHandleEptViolation().
BOOLEAN IntMtblIsPtrInReloc | ( | QWORD | Ptr, |
THS_PTR_TYPE | Type, | ||
QWORD * | Table | ||
) |
Check if the given pointer is inside a mem-table relocation handler.
[in] | Ptr | The pointer to be checked. |
[in] | Type | Pointer type - stack value or live RIP. |
[out] | Table | Optional address to the relocation table, if any is found. |
TRUE | If the pointer points within a relocation handler, FALSE otherwise. |
Definition at line 596 of file memtables.c.
Referenced by IntThrSafeIsLiveRIPInIntro(), and IntThrSafeIsStackPtrInIntro().
INTSTATUS IntMtblRemoveAgentEntries | ( | void | ) |
Removes only the mem-table entries that were relocated inside the PT filter.
When using the PT filter, many mem-table instructions may need to be instrumented. Since the NT sections slack space is very scarce, we will use, in that case, the PT filter itself in order to accommodate the relocated instructions. However, when the PT filter is unloaded, we also must stop instrumenting the instructions that were relocated inside of it.
INT_STATUS_SUCCESS | On success. |
Definition at line 707 of file memtables.c.
Referenced by IntPtiDisableFiltering().
INTSTATUS IntMtblUninit | ( | void | ) |
Completely uninit the mem-tables, removing all the handlers from the NT slack space.
This function must be called only during uninit, and only after thread-safeness was employed, in order to make sure no live RIPs or saved RIPs point inside a handler.
INT_STATUS_SUCCESS | On success. |
Definition at line 745 of file memtables.c.
Referenced by IntGuestUninit().