Bitdefender Hypervisor Memory Introspection
hook_dtr.c File Reference
#include "hook_dtr.h"
#include "callbacks.h"
#include "guests.h"

Go to the source code of this file.

Functions

INTSTATUS IntHookDtrSetHook (DWORD Flags, PFUNC_DtrReadWriteHookCallback Callback, void **Hook)
 Places a descriptor table register hook. More...
 
static INTSTATUS IntHookDtrDeleteHook (HOOK_DTR *Hook)
 Permanently delete a descriptor register hook. More...
 
INTSTATUS IntHookDtrRemoveHook (HOOK_DTR *Hook)
 Remove a descriptor register hook. More...
 
static void IntHookDtrRemoveAllHooks (void)
 Remove all descriptor register hooks. More...
 
INTSTATUS IntHookDtrCommit (void)
 Commit the descriptor registers hooks. More...
 
INTSTATUS IntHookDtrInit (void)
 Initialize the descriptor registers hook state. More...
 
INTSTATUS IntHookDtrUninit (void)
 Uninit the descriptor registers hooks state. More...
 

Function Documentation

◆ IntHookDtrCommit()

INTSTATUS IntHookDtrCommit ( void  )

Commit the descriptor registers hooks.

This function will iterate the list of DTR hooks, and it will delete all the hooks that were flagged for removal.

Return values
INT_STATUS_SUCCESSOn success.
INT_STATUS_NOT_INITIALIZEDIf the DTR hooks state is not initialized.

Definition at line 165 of file hook_dtr.c.

Referenced by IntGuestPreReturnCallback().

◆ IntHookDtrDeleteHook()

static INTSTATUS IntHookDtrDeleteHook ( HOOK_DTR Hook)
static

Permanently delete a descriptor register hook.

NOTE: If this is the last descriptor register hook that is removed, Introcore will ask the HV to disable descriptor table access notifications.

Parameters
[in]HookThe DTR hook to be deleted.
Return values
INT_STATUS_SUCCESSOn success.

Definition at line 75 of file hook_dtr.c.

Referenced by IntHookDtrCommit(), and IntHookDtrRemoveHook().

◆ IntHookDtrInit()

INTSTATUS IntHookDtrInit ( void  )

Initialize the descriptor registers hook state.

Return values
INT_STATUS_SUCCESSOn success.
INT_STATUS_INSUFFICIENT_RESOURCESIf a memory alloc fails.

Definition at line 203 of file hook_dtr.c.

Referenced by IntGuestInit().

◆ IntHookDtrRemoveAllHooks()

static void IntHookDtrRemoveAllHooks ( void  )
static

Remove all descriptor register hooks.

Definition at line 146 of file hook_dtr.c.

Referenced by IntHookDtrUninit().

◆ IntHookDtrRemoveHook()

INTSTATUS IntHookDtrRemoveHook ( HOOK_DTR Hook)

Remove a descriptor register hook.

Removes a DTR hook. First of all, this function will mark the hook as being disabled (the callback will never be called again). If we are currently in the context of a DTR violation, we will wait for the commit phase to permanently delete the hook. Otherwise, the hook will be deleted immediately.

Parameters
[in]HookThe hook to be removed.
Return values
INT_STATUS_SUCCESSOn success.
INT_STATUS_INVALID_PARAMETERIf an invalid parameter is supplied.

Definition at line 106 of file hook_dtr.c.

Referenced by IntGdtrUnprotect(), IntHandleDtrViolation(), IntHookDtrRemoveAllHooks(), and IntIdtrUnprotect().

◆ IntHookDtrSetHook()

INTSTATUS IntHookDtrSetHook ( DWORD  Flags,
PFUNC_DtrReadWriteHookCallback  Callback,
void **  Hook 
)

Places a descriptor table register hook.

Establishes a hook on a descriptor table register. The Flags argument indicates which register is hooked and for what access. On each load or store on the hooked register, the callback will be called. NOTE: Make sure that the Flags contains only one of:

Parameters
[in]FlagsA combination of IG_DESC_ACCESS indicating what register & for what access the hook is set.
[in]CallbackThe callback to be called when the indicated register is loaded/stored.
[out]HookThe handle to the newly placed hook.
Return values
INT_STATUS_SUCCESSOn success.
INT_STATUS_INVALID_PARAMETERIf an invalid parameter is supplied.
INT_STATUS_INSUFFICIENT_RESOURCESIf a memory alloc fails.

Definition at line 11 of file hook_dtr.c.

Referenced by IntGdtrProtect(), and IntIdtrProtect().

◆ IntHookDtrUninit()

INTSTATUS IntHookDtrUninit ( void  )

Uninit the descriptor registers hooks state.

Return values
INT_STATUS_SUCCESSOn success.
INT_STATUS_NOT_INITIALIZED_HINTIf the DTR hooks state is not initialized.

Definition at line 226 of file hook_dtr.c.

Referenced by IntGuestUninit().