21 #define for_each_driver(_var_name) list_for_each (gKernelDrivers, KERNEL_DRIVER, _var_name) 24 #define MAX_DRIVER_EXPORT_CACHE_ENTRIES 10 46 _In_ void const *Detour
71 ERROR(
"[ERROR] IntLixDrvCreateFromAddress failed for module 0x%016llx: 0x%08x\n", pRegs->
Rdi, status);
84 ERROR(
"[ERROR] IntDetGetArguments failed: 0x%08x\n", status);
89 load = (args[1] & 0xFFFFFFFF) > 0;
100 ERROR(
"[ERROR] IntWinDrvCreateFromAddress failed for GVA 0x%016llx: 0x%08x\n", ldrAddress, status);
111 _In_ void const *Detour
136 ERROR(
"[ERROR] IntLixDrvRemoveFromAddress failed for GVA 0x%016llx: 0x%08x\n", pRegs->
Rdi, status);
142 QWORD ldrAddress = 0;
147 ERROR(
"[ERROR] IntDetGetArgument failed: 0x%08x\n", status);
154 ERROR(
"[ERROR] IntWinDrvRemoveFromAddress failed for GVA 0x%016llx: 0x%08x\n", ldrAddress, status);
182 if (pDriver->BaseVa <= Gva && pDriver->BaseVa + pDriver->Size > Gva)
195 if (pDriver->Lix.Initialized)
200 if (
IN_RANGE_LEN(Gva, pDriver->Lix.InitLayout.Base, pDriver->Lix.InitLayout.Size))
224 if (pDriver->BaseVa == Gva)
249 DWORD currentPosition = 0;
253 if (LoadOrder == currentPosition)
267 _In_ const void *Name
287 if (NULL == pDriver->Name)
298 cmp = strcmp(pDriver->Name, Name);
338 if (NULL == pDriver->Win.Path)
375 ERROR(
"[ERROR] IntLixDrvRemoveEntry failed: 0x%08x\n", status);
383 ERROR(
"[ERROR] IntWinDrvRemoveEntry failed: 0x%08x\n", status);
404 LOG(
" #%03d I: %d, Core: 0x%016llx, CoreSize: 0x%08llx, CoreTextSize: 0x%08x, " 405 "CoreRoSize: 0x%08x, Name: '%s'\n",
407 pDriver->Lix.Initialized,
410 pDriver->Lix.CoreLayout.TextSize,
411 pDriver->Lix.CoreLayout.RoSize,
412 (
char *)pDriver->Name);
416 LOG(
" #%03d Base: 0x%016llx, Size: 0x%08llx, PathHash: 0x%08x, NameHash: 0x%08x, Name: '%s'\n",
417 i++, pDriver->BaseVa, pDriver->Size, pDriver->Win.PathHash,
420 if (pDriver->Win.DriverObject)
422 LOG(
"------> 0x%016llx : %s\n",
423 pDriver->Win.DriverObject->DriverObjectGva,
497 if (Rip == gDriverExportCache.
Entry[index].
Rip)
499 return &gDriverExportCache.
Entry[index];
BYTE Unknown
Set if the function at this RIP is not exported.
struct _DRIVER_EXPORT_CACHE * PDRIVER_EXPORT_CACHE
INTSTATUS IntLixDrvRemoveEntry(KERNEL_DRIVER *Driver)
Disable protection and frees the driver structure from our internal list.
IG_ARCH_REGS Regs
The current state of the guest registers.
DRIVER_EXPORT_CACHE_ENTRY * IntDriverCacheExportFind(const QWORD Rip)
Finds an entry inside the gDriverExportCache.
#define INT_STATUS_SUCCESS
void IntDriverCacheInv(const QWORD BaseAddress, const QWORD Length)
Invalidates all cache entries for a given guest memory range.
INTSTATUS IntLixDrvRemoveFromAddress(QWORD DriverGva)
Disable protection and remove the driver structure from our internal list.
#define INT_SUCCESS(Status)
INTSTATUS IntDriverUnloadHandler(void const *Detour)
The detour handler that will be invoked when a guest driver is unloaded.This handles driver unloading...
int INTSTATUS
The status data type.
#define INT_STATUS_NOT_FOUND
DRIVER_EXPORT_CACHE_ENTRY Entry[MAX_DRIVER_EXPORT_CACHE_ENTRIES]
The cache entries.
INTRO_GUEST_TYPE OSType
The type of the guest.
struct _DRIVER_EXPORT_CACHE DRIVER_EXPORT_CACHE
Driver export cache.
struct _DRIVER_EXPORT_CACHE_ENTRY::@23 Type
INTSTATUS IntWinDrvCreateFromAddress(QWORD ModuleInfo, QWORD Flags)
Adds a driver to introspection's LoadedModuleList (gKernelDrivers). This way we avoid lots of mapping...
BYTE Export
Set if the function at this RIP is exported.
Describes a kernel driver.
static DRIVER_EXPORT_CACHE gDriverExportCache
The driver exports cache.
INTSTATUS IntDriverLoadHandler(void const *Detour)
The detour handler that will be invoked when a guest loads a new driver.This handles driver loading i...
LIST_HEAD gKernelDrivers
List of all the drivers currently loaded inside the guest.
void IntDriverCacheCreateUnknown(const QWORD Rip)
Adds a new entry to the gDriverExportCache.
void IntDriverDump(void)
Prints all the currently loaded drivers.
QWORD Rip
The guest RIP for which this entry exists.
static BOOLEAN RemoveEntryList(LIST_ENTRY *Entry)
Holds information about a driver object.
void IntDriverUninit(void)
Uninitializes the drivers submodule.
#define IN_RANGE_LEN(x, start, len)
KERNEL_DRIVER * IntDriverFindByPath(const WCHAR *Path)
Searches for a driver by its module path.
INTSTATUS IntWinDrvRemoveEntry(KERNEL_DRIVER *Driver)
Removes the KERNEL_DRIVER from the internal structures.
KERNEL_DRIVER * IntDriverFindByName(const void *Name)
Searches for a driver by its name.
KERNEL_DRIVER * IntDriverFindByLoadOrder(DWORD LoadOrder)
Searches a driver by its module load order.
INTSTATUS IntDetGetArgument(void const *Detour, DWORD Index, BYTE const *StackBuffer, DWORD StackBufferSize, QWORD *Value)
Reads the specified argument for a detour.
#define UNREFERENCED_PARAMETER(P)
KERNEL_DRIVER * IntDriverFindByAddress(QWORD Gva)
Returns the driver in which Gva resides.
INTSTATUS IntDetGetArguments(void const *Detour, DWORD Argc, QWORD *Argv)
Reads multiple arguments from a detour.
WORD CurrentEntry
The number of valid entries inside the Entry array.
INTSTATUS IntLixDrvCreateFromAddress(QWORD DriverGva, QWORD StaticDetected)
Create the KERNEL_DRIVER object from the provided 'module struct' address and activate the protection...
INTSTATUS IntWinDrvRemoveFromAddress(QWORD ModuleInfo)
Removes a driver from the introspection's loaded modules list (gKernelDrivers).
#define IntDbgEnterDebugger()
#define MAX_DRIVER_EXPORT_CACHE_ENTRIES
Maximum entries inside the DRIVER_EXPORT_CACHE.
GUEST_STATE gGuest
The current guest state.
void IntDriverCacheCreateExport(const QWORD Rip)
Adds a new export entry to the gDriverExportCache.
int wstrcasecmp(const WCHAR *buf1, const WCHAR *buf2)
#define LIST_HEAD_INIT(Name)
The object was detected when it was created.
char * utf16_for_log(const WCHAR *WString)
Converts a UTF-16 to a UTF-8 string to be used inside logging macros.
VCPU_STATE * gVcpu
The state of the current VCPU.
Describes an entry in the gDriverExportCache.
KERNEL_DRIVER * IntDriverFindByBase(QWORD Gva)
Searches a driver object by its module base.
#define for_each_driver(_var_name)
Iterates the gKernelDrivers linked list.