Bitdefender Hypervisor Memory Introspection
introcore.c File Reference
#include "introcore.h"
#include "debugger.h"
#include "guests.h"
#include "introapi.h"
#include "introcpu.h"
#include "gpacache.h"
#include "winprocess.h"
#include "lixprocess.h"

Go to the source code of this file.

Data Structures

struct  _MULTI_PAGE_MAP
 Holds information about page mappings that contain multiple pages. More...
 

Typedefs

typedef struct _MULTI_PAGE_MAP MULTI_PAGE_MAP
 Holds information about page mappings that contain multiple pages. More...
 
typedef struct _MULTI_PAGE_MAPPMULTI_PAGE_MAP
 

Functions

static BOOLEAN IsSse42Supported (void)
 Checks if support for SSE 4.2 is present. More...
 
void IntPreinit (void)
 Initializes the global variables used throughout the project. More...
 
INTSTATUS IntInit (GLUE_IFACE *GlueInterface, UPPER_IFACE const *UpperInterface)
 Initializes introcore. More...
 
INTSTATUS IntUninit (void)
 Disables and uninitializes Introcore. More...
 
static INTSTATUS IntVirtMemReadWrite (QWORD VirtualAddress, DWORD Length, QWORD Cr3, void *Buffer, DWORD *RetLength, BOOLEAN Write)
 Transfers memory between a guest virtual memory range and Introcore. More...
 
INTSTATUS IntVirtMemSet (QWORD VirtualAddress, DWORD Length, QWORD Cr3, BYTE Value)
 
static INTSTATUS IntPhysMemReadWriteAnySize (QWORD PhysicalAddress, DWORD Length, void *Buffer, DWORD *RetLength, BOOLEAN Write)
 Transfers memory between a guest physical memory range and Introcore. More...
 
static INTSTATUS IntPhysMemReadWrite (QWORD PhysicalAddress, DWORD Length, void *Buffer, DWORD *RetLength, BOOLEAN Write)
 Transfers memory between a guest physical memory range and Introcore, but only for a single memory page. More...
 
INTSTATUS IntVirtMemRead (QWORD Gva, DWORD Length, QWORD Cr3, void *Buffer, DWORD *RetLength)
 Reads data from a guest virtual memory range. More...
 
INTSTATUS IntVirtMemWrite (QWORD Gva, DWORD Length, QWORD Cr3, void *Buffer)
 Writes data to a guest virtual memory range. More...
 
INTSTATUS IntKernVirtMemRead (QWORD KernelGva, DWORD Length, void *Buffer, DWORD *RetLength)
 Reads data from a guest kernel virtual memory range. More...
 
INTSTATUS IntKernVirtMemWrite (QWORD KernelGva, DWORD Length, void *Buffer)
 Writes data to a guest kernel virtual memory range. More...
 
INTSTATUS IntPhysicalMemRead (QWORD PhysicalAddress, DWORD Length, void *Buffer, DWORD *RetLength)
 Reads data from a guest physical memory range, but only for a single page. More...
 
INTSTATUS IntPhysicalMemWrite (QWORD PhysicalAddress, DWORD Length, void *Buffer)
 Writes data to a guest physical memory range, but only for a single page. More...
 
INTSTATUS IntPhysicalMemReadAnySize (QWORD PhysicalAddress, DWORD Length, void *Buffer, DWORD *RetLength)
 Reads data from a guest physical memory range, regardless of how many pages it spans across. More...
 
INTSTATUS IntPhysicalMemWriteAnySize (QWORD PhysicalAddress, DWORD Length, void *Buffer)
 Writes data to a guest physical memory range, regardless of how many pages it spans across. More...
 
INTSTATUS IntKernVirtMemFetchQword (QWORD GuestVirtualAddress, QWORD *Data)
 Reads 8 bytes from the guest kernel memory. More...
 
INTSTATUS IntKernVirtMemFetchDword (QWORD GuestVirtualAddress, DWORD *Data)
 Reads 4 bytes from the guest kernel memory. More...
 
INTSTATUS IntKernVirtMemFetchWordSize (QWORD GuestVirtualAddress, void *Data)
 Reads a guest pointer from the guest kernel memory. More...
 
INTSTATUS IntVirtMemFetchQword (QWORD GuestVirtualAddress, QWORD Cr3, QWORD *Data)
 Reads 8 bytes from the guest memory. More...
 
INTSTATUS IntVirtMemFetchDword (QWORD GuestVirtualAddress, QWORD Cr3, DWORD *Data)
 Reads 4 bytes from the guest memory. More...
 
INTSTATUS IntVirtMemFetchWordSize (QWORD GuestVirtualAddress, QWORD Cr3, void *Data)
 Reads a guest pointer from the guest memory. More...
 
INTSTATUS IntKernVirtMemPatchQword (QWORD GuestVirtualAddress, QWORD Data)
 Writes 8 bytes in the guest kernel memory. More...
 
INTSTATUS IntKernVirtMemPatchDword (QWORD GuestVirtualAddress, DWORD Data)
 Writes 4 bytes in the guest kernel memory. More...
 
INTSTATUS IntKernVirtMemPatchWordSize (QWORD GuestVirtualAddress, QWORD Data)
 Writes a guest pointer inside the guest kernel memory. More...
 
INTSTATUS IntVirtMemPatchQword (QWORD GuestVirtualAddress, QWORD Cr3, QWORD Data)
 Writes 8 bytes in the guest memory. More...
 
INTSTATUS IntVirtMemPatchDword (QWORD GuestVirtualAddress, QWORD Cr3, DWORD Data)
 Writes 4 bytes in the guest memory. More...
 
INTSTATUS IntVirtMemPatchWordSize (QWORD GuestVirtualAddress, QWORD Cr3, QWORD Data)
 Writes a guest pointer inside the guest memory. More...
 
INTSTATUS IntVirtMemFetchString (QWORD Gva, DWORD MaxLength, QWORD Cr3, void *Buffer)
 Reads a NULL-terminated string from the guest. More...
 
static INTSTATUS IntMapGpaForTranslation (QWORD Gpa, void **HostPtr)
 Maps a guest physical address used for memory translation in Introcore address space. More...
 
static INTSTATUS IntUnmapGpaForTranslation (QWORD Gpa, void **HostPtr)
 Unmaps an address that was previously mapped with IntMapGpaForTranslation. More...
 
static INTSTATUS IntTranslateVa32 (UINT32 Gva, UINT32 Cr3, VA_TRANSLATION *Translation)
 Translates a guest virtual address when 32-bit paging is used. More...
 
static INTSTATUS IntTranslateVa32Pae (UINT64 Gva, UINT64 Cr3, VA_TRANSLATION *Translation)
 Translates a guest virtual address when 32-bit PAE paging is used. More...
 
static INTSTATUS IntTranslateVa64 (UINT64 Gva, UINT64 Cr3, VA_TRANSLATION *Translation)
 Translates a guest virtual address when 4-level paging is used. More...
 
static INTSTATUS IntTranslateVa64La57 (UINT64 Gva, UINT64 Cr3, VA_TRANSLATION *Translation)
 Translates a guest virtual address when 5-level paging is used. More...
 
INTSTATUS IntTranslateVirtualAddressEx (QWORD Gva, QWORD Cr3, DWORD Flags, VA_TRANSLATION *Translation)
 Translates a guest virtual address to a guest physical address. More...
 
INTSTATUS IntTranslateVirtualAddress (QWORD Gva, QWORD Cr3, QWORD *PhysicalAddress)
 Translates a guest virtual address to a guest physical address. More...
 
static INTSTATUS IntVirtMemMapMultiPage (QWORD GuestVirtualAddress, DWORD Length, QWORD Cr3, void **HostPtr)
 Maps a guest kernel virtual memory range inside Introcore virtual address space regardless of the number of pages it spans across. More...
 
__must_check INTSTATUS IntVirtMemMap (QWORD Gva, DWORD Length, QWORD Cr3, DWORD Flags, void **HostPtr)
 Maps a guest virtual memory range inside Introcore virtual address space. More...
 
static BOOLEAN IntVirtMemUnmapMultiPage (void **HostPtr)
 Unamps a memory range previously mapped with IntVirtMemMapMultiPage. More...
 
INTSTATUS IntVirtMemUnmap (void **HostPtr)
 Unmaps a memory range previously mapped with IntVirtMemMap. More...
 
INTSTATUS IntInjectExceptionInGuest (BYTE Vector, QWORD Cr2, DWORD ErrorCode, DWORD CpuNumber)
 Injects an exception inside the guest. More...
 
INTSTATUS IntPauseVcpus (void)
 Pauses all the guest VCPUs. More...
 
INTSTATUS IntResumeVcpus (void)
 Resumes the VCPUs previously paused with IntPauseVcpus. More...
 
void IntEnterDebugger2 (PCHAR File, DWORD Line)
 Traps to a debugger. More...
 
void IntDbgEnterDebugger2 (PCHAR File, DWORD Line)
 Traps to a debugger and dumps the Introcore state. More...
 
BOOLEAN IntMatchPatternUtf8 (const CHAR *Pattern, const CHAR *String, DWORD Flags)
 Matches a pattern using glob match. More...
 
BOOLEAN IntMatchPatternUtf16 (const WCHAR *Pattern, const WCHAR *String, DWORD Flags)
 Matches a pattern using glob match. More...
 
INTSTATUS IntGuestUninitOnBugcheck (void const *Detour)
 Prepares Introcore unload in case of a guest crash in order to clean up the code and data injected inside the guestIf the INTRO_OPT_BUGCHECK_CLEANUP activation flag is not set, this function does nothing. Will set BugCheckInProgress inside gGuest to True. More...
 
BOOLEAN IntPolicyProcIsBeta (const void *Process, QWORD Flag)
 Checks if a process protection policy is in log-only mode. More...
 
BOOLEAN IntPolicyCoreIsOptionBeta (QWORD Flag)
 Checks if one of the kernel protection options is in log-only mode. More...
 
BOOLEAN IntPolicyProcIsFeedback (const void *Process, QWORD Flag)
 Checks if a process protection policy is in feedback-only mode. More...
 
QWORD IntPolicyGetProcProt (const void *Process)
 Gets the protection policy for a process. More...
 
BOOLEAN IntPolicyCoreTakeAction (QWORD Flag, INTRO_ACTION *Action, INTRO_ACTION_REASON *Reason)
 Returns the action that should be taken for a core introspection option. More...
 
BOOLEAN IntPolicyProcTakeAction (QWORD Flag, void const *Process, INTRO_ACTION *Action, INTRO_ACTION_REASON *Reason)
 Returns the action that should be taken for a process protection option. More...
 
BOOLEAN IntPolicyProcForceBetaIfNeeded (QWORD Flag, void *Process, INTRO_ACTION *Action)
 Checks if a forced action should be taken even if the process log-only mode is active. More...
 
BOOLEAN IntPolicyCoreForceBetaIfNeeded (QWORD Flag, INTRO_ACTION *Action)
 Checks if a forced action should be taken even if the log-only mode is active. More...
 
BOOLEAN IntPolicyIsCoreOptionFeedback (QWORD Flag)
 Checks if a core protection option is in feedback-only mode. More...
 
char * utf16_for_log (const WCHAR *WString)
 Converts a UTF-16 to a UTF-8 string to be used inside logging macros. More...
 
INTSTATUS IntReadString (QWORD StrGva, DWORD MinimumLength, BOOLEAN AnsiOnly, char **String, DWORD *StringLength)
 Reads a string from the guest kernel memory. More...
 

Variables

void * gLock = NULL
 A lock that ensures that all the events are serialized inside introcore. More...
 
const INT_VERSION_INFO IntHviVersion
 The version of the introcore library. More...
 
INTRO_ERROR_CONTEXT gErrorContext = { 0 }
 Global storage for the error context used by GLUE_IFACE.NotifyIntrospectionErrorState. More...
 
LIST_HEAD gMultiPageMaps = LIST_HEAD_INIT(gMultiPageMaps)
 List of all the currently valid multi page maps. More...
 
BOOLEAN gAbortLoad = FALSE
 Set to True if introcore should abort the initialization process. More...
 
BOOLEAN gSse42Supported
 Set to True if support for SSE 4.2 was detected. More...
 
BOOLEAN gInsideDebugger
 Set to True when introcore is inside a debugger. More...
 
const QWORD gByteMaskToBitMask [256]
 Converts a byte number to a mask having the bits in those bytes set. More...
 

Typedef Documentation

◆ MULTI_PAGE_MAP

Holds information about page mappings that contain multiple pages.

◆ PMULTI_PAGE_MAP

typedef struct _MULTI_PAGE_MAP * PMULTI_PAGE_MAP

Function Documentation

◆ IntDbgEnterDebugger2()

void IntDbgEnterDebugger2 ( PCHAR  File,
DWORD  Line 
)

Traps to a debugger and dumps the Introcore state.

This function should not be used directly, the IntDbgEnterDebugger macro should be used instead.

Parameters
[in]FileNULL-terminated string containing the name of the file from which this function was called
[in]LineThe line number from which this function was called

Definition at line 2411 of file introcore.c.

◆ IntEnterDebugger2()

void IntEnterDebugger2 ( PCHAR  File,
DWORD  Line 
)

Traps to a debugger.

This function should not be used directly, the IntEnterDebugger macro should be used instead.

Parameters
[in]FileNULL-terminated string containing the name of the file from which this function was called
[in]LineThe line number from which this function was called

Definition at line 2388 of file introcore.c.

◆ IntInit()

INTSTATUS IntInit ( GLUE_IFACE GlueInterface,
UPPER_IFACE const *  UpperInterface 
)

Initializes introcore.

This will validate and initialize the GLUE_IFACE and UPPER_IFACE instances, as well as the gLock lock.

Parameters
[in,out]GlueInterfaceThe instance of GLUE_IFACE to be used. The part that must be implemented by the integrator must be implemented. Introcore will fill initialize the APIs it exposes.
[in]UpperInterfaceThe instance of UPPER_IFACE to be used. All the mandatory APIs must be implemented
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value
Precondition
IntPreinit was called
Postcondition
gIface, gUpIface, and gLock are fully initialized and can be used

Definition at line 186 of file introcore.c.

◆ IntInjectExceptionInGuest()

INTSTATUS IntInjectExceptionInGuest ( BYTE  Vector,
QWORD  Cr2,
DWORD  ErrorCode,
DWORD  CpuNumber 
)

Injects an exception inside the guest.

Note that even if this function exits with success, there is still no guarantee that the exception was injected inside the guest, as the hypervisor may have other exceptions to inject. In order to be sure that the exception we scheduled was injected, the IntHandleEventInjection callback registered with GLUE_IFACE.RegisterEventInjectionHandler is used.

Parameters
[in]VectorVector to be injected
[in]Cr2Cr2 value. Ignored if Vector is not 14 (page fault)
[in]ErrorCodeThe error code of the exception. Ignored for exceptions that do not have an error code
[in]CpuNumberThe CPU on which the exception should be injected. IG_CURRENT_VCPU is not a valid value
Return values
INT_STATUS_SUCCESSin case of success
INT_STATUS_INVALID_PARAMETER_4is the CPU number is not valid
INT_STATUS_ALREADY_INITIALIZEDif an exception is already scheduled on the specified CPU

Definition at line 2264 of file introcore.c.

Referenced by DbgInjectPf(), IntHandleCowOnPage(), IntHandleFetchRetryOnPageBoundary(), IntLixVmaHandlePageExecution(), IntSwapMemHandleBreakpointAgent(), IntSwapMemInjectPendingPF(), IntWinModBlockHandleExecution(), IntWinSudHandleSudExec(), and IntWinVadHandlePageExecution().

◆ IntKernVirtMemFetchDword()

INTSTATUS IntKernVirtMemFetchDword ( QWORD  GuestVirtualAddress,
DWORD Data 
)

◆ IntKernVirtMemFetchQword()

INTSTATUS IntKernVirtMemFetchQword ( QWORD  GuestVirtualAddress,
QWORD Data 
)

Reads 8 bytes from the guest kernel memory.

Parameters
[in]GuestVirtualAddressVirtual address from which to read
[out]DataData read from the guest
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 811 of file introcore.c.

Referenced by DbgDumpGuestModules(), DbgDumpVadRoot(), IntKsymRelativeFindOffsetTableEnd(), IntLixCrashDumpDmesg(), IntLixDrvIterateList(), IntLixFileGetDentry(), IntLixFileGetPath(), IntLixGetInitTask(), IntLixGuestNew(), IntLixJumpLabelHandler(), IntLixMmFindVmaInLinkedList(), IntLixMmFindVmaInRbTree(), IntLixMmGetInitMm(), IntLixMmListVmasInternal(), IntLixMmPopulateVmasInternal(), IntLixNetFileIsSocket(), IntLixNetGetConnectionFromSocket(), IntLixNetIterateTaskConnections(), IntLixStackTraceGet(), IntLixStackTraceGetReg(), IntLixTaskActivateExploitProtection(), IntLixTaskCreate(), IntLixTaskCreateInitTask(), IntLixTaskDeactivateExploitProtection(), IntLixTaskFetchMm(), IntLixTaskGetCurrentTaskStruct(), IntLixTaskGetTrapFrame(), IntLixTaskIsUserStackPivoted(), IntLixTaskIterateGuestTasks(), IntLixTaskIterateThreadGroup(), IntLixTaskIterateThreadNode(), IntLixTaskSendCredViolationEvent(), IntLixVdsoFetchAddress(), IntLixVdsoResolveDynamicOffset(), IntLixVdsoResolveImageAddress(), IntLixVmaChangeProtection(), IntLixVmaExpandDownwards(), IntLogStackTrace(), IntStackAnalyzePointer(), IntThrSafeLixGetCurrentStack(), IntThrSafeLixInspectWaitingThread(), IntVmaMarkProtection(), IntWinBcHandleBugCheck(), IntWinDrvIsListHead(), IntWinDrvIterateLoadedModules(), IntWinGetAccessTokenFromProcess(), IntWinGetAccesTokenFromThread(), IntWinGetStartUpTime(), IntWinGuestFindKernelObjects(), IntWinModFillInjectionData(), IntWinPfnIsMmPfnDatabase(), IntWinProcCreateProcessObject(), IntWinProcHandleTerminate(), IntWinReadToken(), IntWinStackTraceGet64(), and IntWinStackUserTrapFrameGetGeneric().

◆ IntKernVirtMemFetchWordSize()

INTSTATUS IntKernVirtMemFetchWordSize ( QWORD  GuestVirtualAddress,
void *  Data 
)

Reads a guest pointer from the guest kernel memory.

Parameters
[in]GuestVirtualAddressVirtual address from which to read
[out]DataData read from the guest. Must be at least 8 bytes long for 64-bit guests, and at least 4 bytes long for 32-bit guests.
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 847 of file introcore.c.

Referenced by IntWinDpiValidateThreadStart(), IntWinDrvObjCreateFromAddress(), IntWinHalFindPerformanceCounterInternal(), IntWinHalIsHalPerf(), IntWinIntObjHandleModification(), IntWinIntObjProtect(), IntWinModFillProcessInjectionData(), IntWinNetGetLocalAddr(), IntWinNetGetTcpPortPoolFromCompartment(), IntWinNetIterateLinkedList(), IntWinNetIterateSlinkedList(), IntWinNetParseTcpBitmap(), IntWinNetParseTcpPartition(), IntWinProcIsPsActiveProcessHead(), IntWinStackHandleUserStackPagedOut(), IntWinThrIterateThreads(), IntWinTokenPrivsHandleSwap(), and IntWinTokenPrivsHandleWrite().

◆ IntKernVirtMemPatchDword()

INTSTATUS IntKernVirtMemPatchDword ( QWORD  GuestVirtualAddress,
DWORD  Data 
)

Writes 4 bytes in the guest kernel memory.

Parameters
[in]GuestVirtualAddressVirtual address at which the write is done
[out]DataData to write inside the guest
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 950 of file introcore.c.

Referenced by IntPtiDeliverDriverForLoad().

◆ IntKernVirtMemPatchQword()

INTSTATUS IntKernVirtMemPatchQword ( QWORD  GuestVirtualAddress,
QWORD  Data 
)

Writes 8 bytes in the guest kernel memory.

Parameters
[in]GuestVirtualAddressVirtual address at which the write is done
[out]DataData to write inside the guest
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 932 of file introcore.c.

Referenced by IntDetDisableLixHypercall(), IntLixApiUpdateHooks(), IntLixTaskActivateExploitProtection(), IntLixTaskDeactivateExploitProtection(), IntPtiDeliverDriverForLoad(), and IntVmaMarkProtection().

◆ IntKernVirtMemPatchWordSize()

INTSTATUS IntKernVirtMemPatchWordSize ( QWORD  GuestVirtualAddress,
QWORD  Data 
)

Writes a guest pointer inside the guest kernel memory.

For 64-bit guests, this will write 8 bytes. For 32-bit guests, this will write 4 bytes.

Parameters
[in]GuestVirtualAddressVirtual address at which the write is done
[out]DataData to write inside the guest. For 32-bit guests, only the low 32-bits will be written.
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 968 of file introcore.c.

◆ IntKernVirtMemRead()

INTSTATUS IntKernVirtMemRead ( QWORD  KernelGva,
DWORD  Length,
void *  Buffer,
DWORD RetLength 
)

Reads data from a guest kernel virtual memory range.

Similar to IntVirtMemRead, but will always use the system Cr3 saved in gGuest.

Parameters
[in]KernelGvaThe start of the guest virtual memory range
[in]LengthThe size of the memory range
[out]BufferBuffer in which data will be read. Must be at least Length bytes in size.
[out]RetLengthThe size we managed to read. In case of success, it will always be equal to Length. May be NULL.
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 674 of file introcore.c.

Referenced by DbgDumpCodeblocks(), DbgDumpGuestModules(), DbgTestRead(), IntDetCallCallback(), IntDetCreateObjectLix(), IntDetGetArgumentInternal(), IntDetGetArguments(), IntDetRelocate(), IntDetSetHook(), IntDetSetLixHook(), IntExceptGetVictimEpt(), IntFindKernelPcr(), IntGuestDetectOsSysCall(), IntIdtGetEntry(), IntKernVirtMemFetchDword(), IntKernVirtMemFetchQword(), IntKernVirtMemFetchWordSize(), IntKsymFindIndexesTableStart(), IntKsymInit(), IntLixAgentFindInstruction(), IntLixDentryGetName(), IntLixDrvIsLegitimateTextPoke(), IntLixFileReadDentry(), IntLixGetInitTask(), IntLixGuestIsKptiActive(), IntLixNetFileIsSocket(), IntLixNetGetConnectionFromSocket(), IntLixPatchHandler(), IntLixPatchSwapgs(), IntLixTaskCreateInitTask(), IntLixTaskDumpTree(), IntLixTaskGetTrapFrame(), IntLogContextRecord(), IntLogExceptionRecord(), IntLogTrapFrame(), IntMtblPatchInstruction(), IntPeFindExportByName(), IntPeFindExportByOrdinal(), IntPeFindExportByRva(), IntPeFindFunctionByPattern(), IntPeGetExportNameByRva(), IntPeGetRuntimeFunction(), IntPeGetSectionHeaderByIndex(), IntPtiRemoveInstruction(), IntReadString(), IntRtlpVirtualUnwindCheckAccess(), IntSlackAllocWindows(), IntStackAnalyzePointer(), IntThrSafeWinGetCurrentStack(), IntVeDeliverDriverForLoad(), IntVeFindKernelKvaShadowAndKernelExit(), IntWinAgentActivatePendingAgent(), IntWinAgentFindInstruction(), IntWinAgentHandleDriverVmcall(), IntWinAgentHandleLoader1Hypercall(), IntWinAgentInjectTrampoline(), IntWinAgentRestoreState32(), IntWinAgentRestoreState64(), IntWinApiHookVeHandler(), IntWinCrashHandleDepViolation(), IntWinDpiGetProcessDebugFlag(), IntWinDrvCreateFromAddress(), IntWinDrvHeadersInMemory(), IntWinDrvIsListHead(), IntWinDrvObjCreateFromAddress(), IntWinGuestFindDriversNamespaceNoBuffer(), IntWinGuestFindIdleCr3(), IntWinGuestFindKernelCr3(), IntWinGuestFindKernelObjects(), IntWinGuestReadKernel(), IntWinHalHandleHalHeapExec(), IntWinHalIsIntController(), IntWinHalReadHal(), IntWinHandleException(), IntWinInfCheckCtxLoggerOnRelocation(), IntWinInfHookGetCircularCtxLogger(), IntWinInfHookGetCpuClockIntegrityCallback(), IntWinInfHookGetWmiLoggerGetCpuClock(), IntWinInfHookSiloWmiPtrIntegrityCallback(), IntWinModFillInjectionData(), IntWinNetFindTcpPartition(), IntWinNetGetAddrFam(), IntWinNetGetAddrInfo(), IntWinNetGetLocalAddr(), IntWinNetGetTcpPortPool(), IntWinNetParseTcpBitmap(), IntWinNetParseTcpPartition(), IntWinObjGetObjectNameInfo(), IntWinObjGetPoolHeaderForObject(), IntWinObjHandleRootDirTagInMemory(), IntWinObjIsTypeObject(), IntWinObjParseDriverDirectory(), IntWinPfnIsMmPfnDatabase(), IntWinPowGetRequestedPowerState(), IntWinProcCreateProcessObject(), IntWinProcDumpEgFlags(), IntWinProcEnforceProcessDep(), IntWinProcGetNameFromEprocess(), IntWinProcIsPsActiveProcessHead(), IntWinProcIterateGuestProcesses(), IntWinReadSid(), IntWinReadToken(), IntWinSDReadSecDesc(), IntWinStackUserTrapFrameGetGeneric(), IntWinSudCheckIntegrity(), IntWinSudProtectIntegrity(), IntWinThrGetCurrentThread(), IntWinThrGetCurrentTib(), IntWinThrHandleQueueApc(), IntWinThrHandleThreadHijack(), IntWinVadFetchImageName(), IntWinVadHandleProtectGeneric(), IntWinVadHandleVirtualProtect(), IntWinVadImportProcessTree(), IntWinVadProcImportMainModuleVad(), and IntWinVadRescanVad().

◆ IntKernVirtMemWrite()

INTSTATUS IntKernVirtMemWrite ( QWORD  KernelGva,
DWORD  Length,
void *  Buffer 
)

Writes data to a guest kernel virtual memory range.

Similar to IntVirtMemWrite, but will always use the system Cr3 saved in gGuest.

Parameters
[in]KernelGvaThe start of the guest virtual memory range
[in]LengthThe size of the memory range
[out]BufferBuffer with the data to be written. Must be at least Length bytes in size.
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 699 of file introcore.c.

Referenced by IntDetSetLixHook(), IntKernVirtMemPatchDword(), IntKernVirtMemPatchQword(), IntKernVirtMemPatchWordSize(), IntLixAgentActivatePendingAgent(), IntLixApiHookAll(), IntLixGuestAllocateDeploy(), IntLixPatchSwapgs(), IntLixUnpatchSwapgs(), IntMemClkUncloakRegionInternal(), IntMtblPatchInstruction(), IntPtiAllocMemtableSpace(), IntRtlpVirtualUnwindCheckAccess(), IntWinAgentRestoreState32(), IntWinAgentRestoreState64(), IntWinDrvObjHandleModification(), IntWinHalHandleDispatchTableWrite(), IntWinHalHandleHalHeapExec(), IntWinHalHandlePerfCounterModification(), IntWinIdtHandleModification(), IntWinInfCheckCtxLoggerOnRelocation(), IntWinInfHookGetCpuClockIntegrityCallback(), and IntWinSudHandleFieldModification().

◆ IntMapGpaForTranslation()

static INTSTATUS IntMapGpaForTranslation ( QWORD  Gpa,
void **  HostPtr 
)
static

Maps a guest physical address used for memory translation in Introcore address space.

IntMapGpaForTranslation should be used to free any resources allocated for this mapping.

Parameters
[in]GpaGuest physical address to map
[out]HostPtrOn success, will contain a pointer to the mapped address
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 1117 of file introcore.c.

Referenced by IntTranslateVa32(), IntTranslateVa32Pae(), IntTranslateVa64(), and IntTranslateVa64La57().

◆ IntMatchPatternUtf16()

BOOLEAN IntMatchPatternUtf16 ( const WCHAR Pattern,
const WCHAR String,
DWORD  Flags 
)

Matches a pattern using glob match.

This function simply converts the input parameters to UTF-8 and uses IntMatchPatternUtf8.

Parameters
[in]PatternA NULL-terminated string containing the pattern
[in]StringA NULL-terminated string against which the pattern is matched
[in]FlagsFlags containing the match. Can be 0, in which case a standard glob match is done, or INTRO_MATCH_TRUNCATED, in which case the match will be done up to the first "*" found inside Pattern
Return values
Trueif a match is found
Falseif a match is not found

Definition at line 2491 of file introcore.c.

Referenced by IntCamiUpdateProcessProtectionInfoWin(), IntWinProcGetProtectedInfoEx(), and IntWinProcUpdateProtectedProcess().

◆ IntMatchPatternUtf8()

BOOLEAN IntMatchPatternUtf8 ( const CHAR Pattern,
const CHAR String,
DWORD  Flags 
)

Matches a pattern using glob match.

Parameters
[in]PatternA NULL-terminated string containing the pattern
[in]StringA NULL-terminated string against which the pattern is matched
[in]FlagsFlags containing the match. Can be 0, in which case a standard glob match is done, or INTRO_MATCH_TRUNCATED, in which case the match will be done up to the first "*" found inside Pattern
Return values
Trueif a match is found
Falseif a match is not found

Definition at line 2454 of file introcore.c.

Referenced by IntCamiUpdateProcessProtectionInfoLix(), IntCamiUpdateProcessProtectionInfoWin(), IntLixProcUpdateProtectedProcess(), IntLixTaskAdjustProtections(), IntLixTaskShouldProtect(), IntMatchPatternUtf16(), IntWinProcGetProtectedInfo(), IntWinProcGetProtectedInfoEx(), and IntWinProcUpdateProtectedProcess().

◆ IntPauseVcpus()

INTSTATUS IntPauseVcpus ( void  )

Pauses all the guest VCPUs.

If gInsideDebugger is True, the function does nothing. VCPUs should be resumed using the IntResumeVcpus function. It is safe to call this multiple times in a row, but each call must match a IntResumeVcpus call.

Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value
Remarks
A failure to pause the VCPUs is considered a fatal error and introcore will try to trap to a debugger
Postcondition
All the virtual processors used by the guest are no longer scheduled and the guest is paused.

Definition at line 2320 of file introcore.c.

Referenced by IntAddRemoveProtectedProcessUtf16(), IntAddRemoveProtectedProcessUtf8(), IntAgentHandleLogGatherVmcall(), IntAgentHandleRemediationVmcall(), IntDetHandleWrite(), IntDisableIntro(), IntDispatchVeAsEpt(), IntEnginesResultCallback(), IntFlushEPTPermissions(), IntGuestDisableIntro(), IntGuestHandleCr3Write(), IntGuestUpdateCoreOptions(), IntHandleBreakpoint(), IntHandleCrWrite(), IntHandleDtrViolation(), IntHandleEptViolation(), IntHandleEventInjection(), IntHandleIntroCall(), IntHandleMsrViolation(), IntHandleTimer(), IntHandleXcrWrite(), IntHookPtsCheckIntegrity(), IntHookPtsInvokeCallbacks(), IntLixAgentActivatePendingAgent(), IntLixApiUpdateHooks(), IntLixGuestInitAgentCompletion(), IntLixGuestInitAgentHypercall(), IntMemClkCloakRegion(), IntMemClkModifyPatchedData(), IntMemClkUncloakRegionInternal(), IntMtblPatchInstruction(), IntPtiDeliverDriverForLoad(), IntPtiDeliverDriverForUnload(), IntPtiDisableFiltering(), IntPtiEnableFiltering(), IntRtlpVirtualUnwindCheckAccess(), IntSwapgsStartMitigation(), IntVasHookTables(), IntVeCompleteLoader(), IntVeDeliverDriverForLoad(), IntVeDeliverDriverForUnload(), IntVeUnhookVeAgent(), IntWinAgentActivatePendingAgent(), IntWinAgentDeployWinDriver(), IntWinAgentHandleDriverVmcall(), IntWinAgentRemove(), IntWinDrvObjHandleModification(), IntWinGuestKernelHeadersInMemory(), IntWinGuestSectionInMemory(), IntWinHalHandlePerfCounterModification(), IntWinHalSectionInMemory(), IntWinIdtHandleModification(), IntWinInfCheckCtxLoggerOnRelocation(), IntWinInfHookGetCpuClockIntegrityCallback(), IntWinIntObjHandleArrayModification(), IntWinIntObjHandleObjectModification(), IntWinPowDisableSpinWait(), IntWinPowEnableSpinWait(), IntWinProcValidateSystemCr3(), IntWinSDCheckAclIntegrity(), IntWinSDCheckSecDescIntegrity(), IntWinSudHandleFieldModification(), IntWinTokenPtrCheckIntegrityOnProcess(), and IntWinVadHandleDeleteGeneric().

◆ IntPhysicalMemRead()

INTSTATUS IntPhysicalMemRead ( QWORD  PhysicalAddress,
DWORD  Length,
void *  Buffer,
DWORD RetLength 
)

Reads data from a guest physical memory range, but only for a single page.

Parameters
[in]PhysicalAddressThe start of the guest physical memory range
[in]LengthThe size of the memory range
[out]BufferBuffer in which data will be read. Must be at least Length bytes in size.
[out]RetLengthThe size we managed to read. In case of success, it will always be equal to Length. May be NULL.
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 721 of file introcore.c.

Referenced by IntHookPtsDumpPtsEntry(), IntMemClkHashRegion(), IntShcIsSuspiciousCode(), IntWinSelfMapCheckSelfMapEntry(), and IntWinSelfMapGetAndCheckSelfMapEntry().

◆ IntPhysicalMemReadAnySize()

INTSTATUS IntPhysicalMemReadAnySize ( QWORD  PhysicalAddress,
DWORD  Length,
void *  Buffer,
DWORD RetLength 
)

Reads data from a guest physical memory range, regardless of how many pages it spans across.

This is useful when reading contents from large pages, for example.

Parameters
[in]PhysicalAddressThe start of the guest physical memory range
[in]LengthThe size of the memory range
[out]BufferBuffer in which data will be read. Must be at least Length bytes in size.
[out]RetLengthThe size we managed to read. In case of success, it will always be equal to Length. May be NULL.
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 764 of file introcore.c.

Referenced by IntSwapMemPageSwappedIn(), and IntSwapMemReadData().

◆ IntPhysicalMemWrite()

INTSTATUS IntPhysicalMemWrite ( QWORD  PhysicalAddress,
DWORD  Length,
void *  Buffer 
)

Writes data to a guest physical memory range, but only for a single page.

Parameters
[in]PhysicalAddressThe start of the guest physical memory range
[in]LengthThe size of the memory range
[out]BufferBuffer that contains the data to be written. Must be at least Length bytes in size.
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 744 of file introcore.c.

Referenced by IntMemClkHandleSwap(), and IntWinSudHandleSudExec().

◆ IntPhysicalMemWriteAnySize()

INTSTATUS IntPhysicalMemWriteAnySize ( QWORD  PhysicalAddress,
DWORD  Length,
void *  Buffer 
)

Writes data to a guest physical memory range, regardless of how many pages it spans across.

This is useful when writing to large pages, for example.

Parameters
[in]PhysicalAddressThe start of the guest physical memory range
[in]LengthThe size of the memory range
[out]BufferBuffer that contains the data to be written. Must be at least Length bytes in size.
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 789 of file introcore.c.

◆ IntPhysMemReadWrite()

static INTSTATUS IntPhysMemReadWrite ( QWORD  PhysicalAddress,
DWORD  Length,
void *  Buffer,
DWORD RetLength,
BOOLEAN  Write 
)
static

Transfers memory between a guest physical memory range and Introcore, but only for a single memory page.

This function will copy the contents of a physical memory page to a designated buffer, or a designated buffer inside a physical memory page. It will not work if the memory range spans across multiple pages. If it returns INT_STATUS_SUCCESS, for write operations, the memory range will contain Length bytes from Buffer; for read operations, Buffer will contain Length bytes from the physical address range. If RetLength is not NULL, it will contain the value Length. If it doesn't return INT_STATUS_SUCCESS, RetLength will contain the number of bytes successfully transferred (which will most likely be less than Length).

Parameters
[in]PhysicalAddressThe start of the physical memory range
[in]LengthThe size of the physical memory range
[in,out]BufferIf Write is True, the buffer from which contents will be copied inside the guest's memory. If Write is False, the buffer in which the contents of the guest memory will be copied to. Must be at least Length bytes in size.
[out]RetLengthThe actual size that we managed to transfer from the guest to Introcore. If INT_STATUS_SUCCES is returned, this will be equal to Length. May be NULL.
[in]WriteTrue for write operations, False for read operations.
Return values
INT_STATUS_SUCCESSin case of success
INT_STATUS_INVALID_PARAMETER_1if the physical memory range spans across multiple pages
INT_STATUS_INVALID_PARAMETER_2is Length is 0

Definition at line 548 of file introcore.c.

Referenced by IntPhysicalMemRead(), and IntPhysicalMemWrite().

◆ IntPhysMemReadWriteAnySize()

static INTSTATUS IntPhysMemReadWriteAnySize ( QWORD  PhysicalAddress,
DWORD  Length,
void *  Buffer,
DWORD RetLength,
BOOLEAN  Write 
)
static

Transfers memory between a guest physical memory range and Introcore.

This function will copy a physical-address range to a designated buffer, or a designated buffer inside a physical-address range. If the range spans across multiple pages, it will map each page individually, but no more than one page at a time. If it returns INT_STATUS_SUCCESS, for write operations, the memory range will contain Length bytes from Buffer; for read operations, Buffer will contain Length bytes from the physical address range. If RetLength is not NULL, it will contain the value Length. If it doesn't return INT_STATUS_SUCCESS, RetLength will contain the number of bytes successfully transferred (which will most likely be less than Length). Note that the guest physical address space is not guaranteed to be contiguous, so calling this function for a range that spans across multiple pages must be done only in very specific cases when the caller can guarantee that those pages are contiguous.

Parameters
[in]PhysicalAddressThe start of the physical memory range
[in]LengthThe size of the physical memory range
[in,out]BufferIf Write is True, the buffer from which contents will be copied inside the guest's memory. If Write is False, the buffer in which the contents of the guest memory will be copied to. Must be at least Length bytes in size.
[out]RetLengthThe actual size that we managed to transfer from the guest to introcore. If INT_STATUS_SUCCES is returned, this will be equal to Length. May be NULL.
[in]WriteTrue for write operations, False for read operations.
Return values
INT_STATUS_SUCCESSin case of success
INT_STATUS_INVALID_PARAMETER_2is Length is 0

Definition at line 462 of file introcore.c.

Referenced by IntPhysicalMemReadAnySize(), and IntPhysicalMemWriteAnySize().

◆ IntPolicyCoreForceBetaIfNeeded()

◆ IntPolicyCoreIsOptionBeta()

BOOLEAN IntPolicyCoreIsOptionBeta ( QWORD  Flag)

Checks if one of the kernel protection options is in log-only mode.

If the option is one of the POLICY_KM_BETA_FLAGS options and the INTRO_OPT_KM_BETA_DETECTIONS option was also used, the function will always return True. Otherwise the beta options from CAMI are checked.

Parameters
[in]FlagThe option to check. Must be one of the Activation and protection flags values.
Returns
True if the option is in log-only mode; False if it is not

Definition at line 2603 of file introcore.c.

Referenced by IntAlertCoreGetFlags(), IntLixProcPolicyIsBeta(), IntPolicyCoreForceBetaIfNeeded(), IntPolicyCoreTakeAction(), IntWinHalHandleDispatchTableWrite(), IntWinHalHandleHalHeapExec(), IntWinProcPolicyIsBeta(), IntWinSelfMapHandleCr3SelfMapModification(), and IntWinSelfMapHandleCr3SelfMapWrite().

◆ IntPolicyCoreTakeAction()

◆ IntPolicyGetProcProt()

QWORD IntPolicyGetProcProt ( const void *  Process)

Gets the protection policy for a process.

Parameters
[in]ProcessProcess for which the protection policy is returned. For Windows guests this is a pointer to a WIN_PROCESS_OBJECT structure; for Linux guests this is a pointer to a LIX_TASK_OBJECT structure
Returns
The process protection policy. This is a combination of Process protection options values

Definition at line 2661 of file introcore.c.

Referenced by IntAlertProcGetFlags(), and IntPolicyProcTakeAction().

◆ IntPolicyIsCoreOptionFeedback()

BOOLEAN IntPolicyIsCoreOptionFeedback ( QWORD  Flag)

Checks if a core protection option is in feedback-only mode.

Parameters
[in]FlagProtection option for which the check is done. Must be one of the Activation and protection flags values.
Returns
True if the option is in feedback-only mode

Definition at line 2829 of file introcore.c.

Referenced by IntAlertCoreGetFlags(), IntLixProcPolicyIsFeedback(), and IntWinProcPolicyIsFeedback().

◆ IntPolicyProcForceBetaIfNeeded()

BOOLEAN IntPolicyProcForceBetaIfNeeded ( QWORD  Flag,
void *  Process,
INTRO_ACTION Action 
)

Checks if a forced action should be taken even if the process log-only mode is active.

Parameters
[in]FlagProtection option for which the check is done. Must be one of the Process protection options values.
[in]ProcessProcess for which the check is done. For Windows guests this is a pointer to a WIN_PROCESS_OBJECT structure; for Linux guests this is a pointer to a LIX_TASK_OBJECT structure
[in,out]ActionAction to be taken
Returns
True if the action should be taken even if the log-only option is active

Definition at line 2773 of file introcore.c.

Referenced by IntLixAccessRemoteVmHandler(), IntLixTaskHandleInjection(), IntLixValidateProcessCreationRights(), IntLixVmaHandlePageExecution(), IntWinDagentHandleDoubleAgent(), IntWinModHandleKernelWrite(), IntWinModHandleUserWrite(), IntWinProcHandleCopyMemory(), IntWinProcHandleInstrument(), IntWinThrHandleQueueApc(), IntWinThrHandleThreadHijack(), and IntWinVadHandlePageExecution().

◆ IntPolicyProcIsBeta()

BOOLEAN IntPolicyProcIsBeta ( const void *  Process,
QWORD  Flag 
)

Checks if a process protection policy is in log-only mode.

Parameters
[in]ProcessThe process for which the check is done. For Windows guests this is a pointer to a WIN_PROCESS_OBJECT structure; for Linux guests this is a pointer to a LIX_TASK_OBJECT structure
[in]FlagProtection option to be checked. This must be one of the Process protection options values
Returns
True if the option is in log-only mode; False if it is not

Definition at line 2569 of file introcore.c.

Referenced by IntAlertProcGetFlags(), IntPolicyProcForceBetaIfNeeded(), IntPolicyProcTakeAction(), IntWinDagentSendDoubleAgentAlert(), and IntWinProcEnforceProcessDep().

◆ IntPolicyProcIsFeedback()

BOOLEAN IntPolicyProcIsFeedback ( const void *  Process,
QWORD  Flag 
)

Checks if a process protection policy is in feedback-only mode.

Parameters
[in]ProcessThe process for which the check is done. For Windows guests this is a pointer to a WIN_PROCESS_OBJECT structure; for Linux guests this is a pointer to a LIX_TASK_OBJECT structure
[in]FlagProtection option to be checked. This must be one of the Process protection options values
Returns
True if the option is in feedback-only mode; False if it is not

Definition at line 2627 of file introcore.c.

Referenced by IntAlertProcGetFlags(), and IntPolicyProcTakeAction().

◆ IntPolicyProcTakeAction()

BOOLEAN IntPolicyProcTakeAction ( QWORD  Flag,
void const *  Process,
INTRO_ACTION Action,
INTRO_ACTION_REASON Reason 
)

Returns the action that should be taken for a process protection option.

Parameters
[in]FlagProtection option for which the policy is returned. Must be one of the Process protection options values.
[in]ProcessProcess for which the protection policy is checked. For Windows guests this is a pointer to a WIN_PROCESS_OBJECT structure; for Linux guests this is a pointer to a LIX_TASK_OBJECT structure
[in,out]ActionAction to be taken
[in,out]ReasonThe reason for which Action is taken
Returns
True if an alert should be generated

Definition at line 2732 of file introcore.c.

Referenced by IntLixAccessRemoteVmHandler(), IntLixTaskHandleInjection(), IntLixValidateProcessCreationRights(), IntWinDagentHandleDoubleAgent(), IntWinModHandleKernelWrite(), IntWinModHandleUserWrite(), IntWinProcHandleCopyMemory(), IntWinProcHandleInstrument(), IntWinThrHandleQueueApc(), IntWinThrHandleThreadHijack(), and IntWinVadIsExecSuspicious().

◆ IntPreinit()

void IntPreinit ( void  )

Initializes the global variables used throughout the project.

This should be called before IntInit in order to ensure that the global state is properly zeroed before introcore starts.

Postcondition
The global introcore state is reset and zeroed.

Definition at line 166 of file introcore.c.

◆ IntReadString()

INTSTATUS IntReadString ( QWORD  StrGva,
DWORD  MinimumLength,
BOOLEAN  AnsiOnly,
char **  String,
DWORD StringLength 
)

Reads a string from the guest kernel memory.

Parameters
[in]StrGvaGuest virtual address from which to read the string
[in]MinimumLengthThe minimum length the string should have
[in]AnsiOnlyIf the string should be an ANSI string
[in,out]StringOn success, will point to the string. This will be allocated with HpAllocWithTag. The caller is responsible of freeing this memory with HpFreeAndNullWithTag.
[out]StringLengthThe length of the string. May be NULL.
Return values
INT_STATUS_SUCCESSin case of success
INT_STATUS_INVALID_PARAMETER_1if StrGva does not point inside the kernel
INT_STATUS_INVALID_PARAMETER_2is MinimumLength is 0 or more than PAGE_SIZE. Note that the string can still span across two pages
INT_STATUS_NOT_FOUNDif no valid string is found
INT_STATUS_INSUFFICIENT_RESOURCESif not enough memory could be allocated for the string

Definition at line 2880 of file introcore.c.

Referenced by IntLixTaskCreateFromBinprm(), IntLixTaskPathGetByDentry(), and IntWinGuestResolveImports().

◆ IntResumeVcpus()

INTSTATUS IntResumeVcpus ( void  )

Resumes the VCPUs previously paused with IntPauseVcpus.

If gInsideDebugger is True, the function does nothing. It is an error to call this more times than IntPauseVcpus was called.

Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value
Remarks
A failure to resume the VCPUs is considered a fatal error and introcore will try to trap to a debugger

Definition at line 2355 of file introcore.c.

Referenced by IntAddRemoveProtectedProcessUtf16(), IntAddRemoveProtectedProcessUtf8(), IntAgentHandleLogGatherVmcall(), IntAgentHandleRemediationVmcall(), IntDetHandleWrite(), IntDisableIntro(), IntDispatchVeAsEpt(), IntEnginesResultCallback(), IntFlushEPTPermissions(), IntGuestDisableIntro(), IntGuestHandleCr3Write(), IntGuestUpdateCoreOptions(), IntHandleBreakpoint(), IntHandleCrWrite(), IntHandleDtrViolation(), IntHandleEptViolation(), IntHandleEventInjection(), IntHandleIntroCall(), IntHandleMsrViolation(), IntHandleTimer(), IntHandleXcrWrite(), IntHookPtsCheckIntegrity(), IntHookPtsInvokeCallbacks(), IntLixAgentActivatePendingAgent(), IntLixApiUpdateHooks(), IntLixGuestInitAgentCompletion(), IntLixGuestInitAgentHypercall(), IntMemClkCloakRegion(), IntMemClkModifyPatchedData(), IntMemClkUncloakRegionInternal(), IntMtblPatchInstruction(), IntPtiDeliverDriverForLoad(), IntPtiDeliverDriverForUnload(), IntPtiDisableFiltering(), IntPtiEnableFiltering(), IntRtlpVirtualUnwindCheckAccess(), IntSwapgsStartMitigation(), IntVasHookTables(), IntVeCompleteLoader(), IntVeDeliverDriverForLoad(), IntVeDeliverDriverForUnload(), IntVeUnhookVeAgent(), IntWinAgentActivatePendingAgent(), IntWinAgentDeployWinDriver(), IntWinAgentHandleDriverVmcall(), IntWinAgentRemove(), IntWinDrvObjHandleModification(), IntWinGuestKernelHeadersInMemory(), IntWinGuestSectionInMemory(), IntWinHalHandlePerfCounterModification(), IntWinHalSectionInMemory(), IntWinIdtHandleModification(), IntWinInfCheckCtxLoggerOnRelocation(), IntWinInfHookGetCpuClockIntegrityCallback(), IntWinIntObjHandleArrayModification(), IntWinIntObjHandleObjectModification(), IntWinPowDisableSpinWait(), IntWinPowEnableSpinWait(), IntWinProcValidateSystemCr3(), IntWinSDCheckAclIntegrity(), IntWinSDCheckSecDescIntegrity(), IntWinSudHandleFieldModification(), IntWinTokenPtrCheckIntegrityOnProcess(), and IntWinVadHandleDeleteGeneric().

◆ IntTranslateVa32()

static INTSTATUS IntTranslateVa32 ( UINT32  Gva,
UINT32  Cr3,
VA_TRANSLATION Translation 
)
static

Translates a guest virtual address when 32-bit paging is used.

Parameters
[in]GvaGuest virtual address to translate
[in]Cr3Cr3 used for the translation
[out]TranslationTranslation information
Return values
INT_STATUS_SUCCESSin case of success. This does not guarantee that Gva is present inside the leaf page table
INT_STATUS_NO_MAPPING_STRUCTURESif at any given point, the translation fails because a mapping structure can't be accessed.

ERROR("[ERROR] Failed mapping cr3 0x%016llx (cached: %d): 0x%08x\n", Cr3, pCache != NULL, status);

Definition at line 1175 of file introcore.c.

Referenced by IntTranslateVirtualAddressEx().

◆ IntTranslateVa32Pae()

static INTSTATUS IntTranslateVa32Pae ( UINT64  Gva,
UINT64  Cr3,
VA_TRANSLATION Translation 
)
static

Translates a guest virtual address when 32-bit PAE paging is used.

Parameters
[in]GvaGuest virtual address to translate
[in]Cr3Cr3 used for the translation
[out]TranslationTranslation information
Return values
INT_STATUS_SUCCESSin case of success. This does not guarantee that Gva is present inside the leaf page table
INT_STATUS_NO_MAPPING_STRUCTURESif at any given point, the translation fails because a mapping structure can't be accessed.

ERROR("[ERROR] Failed mapping cr3 0x%016llx (cached: %d): 0x%08x\n", Cr3, pCache != NULL, status);

ERROR("[ERROR] Failed mapping pd 0x%016llx (cached: %d): 0x%08x\n", pdpe, pCache != NULL, status);

Definition at line 1295 of file introcore.c.

Referenced by IntTranslateVirtualAddressEx().

◆ IntTranslateVa64()

static INTSTATUS IntTranslateVa64 ( UINT64  Gva,
UINT64  Cr3,
VA_TRANSLATION Translation 
)
static

Translates a guest virtual address when 4-level paging is used.

Parameters
[in]GvaGuest virtual address to translate
[in]Cr3Cr3 used for the translation
[out]TranslationTranslation information
Return values
INT_STATUS_SUCCESSin case of success. This does not guarantee that Gva is present inside the leaf page table
INT_STATUS_NO_MAPPING_STRUCTURESif at any given point, the translation fails because a mapping structure can't be accessed.

ERROR("[ERROR] Failed mapping cr3 0x%016llx (cached: %d): 0x%08x\n", Cr3, pCache != NULL, status);

ERROR("[ERROR] Failed mapping pdp 0x%016llx (cached: %d): 0x%08x\n", pml4e, pCache != NULL, status);

Definition at line 1452 of file introcore.c.

Referenced by IntTranslateVirtualAddressEx().

◆ IntTranslateVa64La57()

static INTSTATUS IntTranslateVa64La57 ( UINT64  Gva,
UINT64  Cr3,
VA_TRANSLATION Translation 
)
static

Translates a guest virtual address when 5-level paging is used.

Parameters
[in]GvaGuest virtual address to translate
[in]Cr3Cr3 used for the translation
[out]TranslationTranslation information
Return values
INT_STATUS_SUCCESSin case of success. This does not guarantee that Gva is present inside the leaf page table
INT_STATUS_NO_MAPPING_STRUCTURESif at any given point, the translation fails because a mapping structure can't be accessed.

Definition at line 1646 of file introcore.c.

Referenced by IntTranslateVirtualAddressEx().

◆ IntTranslateVirtualAddress()

INTSTATUS IntTranslateVirtualAddress ( QWORD  Gva,
QWORD  Cr3,
QWORD PhysicalAddress 
)

Translates a guest virtual address to a guest physical address.

This is a wrapper over IntTranslateVirtualAddressEx, but instead of returning the entire translation information, it will return only the physical address to which Gva maps. This function will fail if Gva is not present.

Parameters
[in]GvaGuest virtual address to be translated
[in]Cr3The Cr3 to be used for the translation. If 0, the currently loaded kernel Cr3 will be used. If the current process has different page directory table base registers for user mode and kernel mode due to KPTI, the kernel Cr3 will be used even if the user mode Cr3 is currently loaded
[out]PhysicalAddressOn success, the physical address to which Gva maps.
Return values
INT_STATUS_SUCCESSin case of success
INT_STATUS_INVALID_PARAMETER_3if PhysicalAddress is NULL
INT_STATUS_PAGE_NOT_PRESENTif Gva is not present or if the paging mode is PAGING_NONE
INT_STATUS_NO_MAPPING_STRUCTURESif at any given point, the translation fails because a mapping structure can't be accessed

Definition at line 1999 of file introcore.c.

Referenced by DbgDumpPfn(), IntAlertEptFillFromVictimZone(), IntHandleDtrViolation(), IntHandleEptViolation(), IntIntegrityCheckAll(), IntLixDrvSendViolationEvent(), IntLixGuestNew(), IntLixMmListVmasInternal(), IntLixTaskFetchMm(), IntLixVdsoDynamicProtectRelocate(), IntLixVdsoFixedProtect(), IntPeFindFunctionStart(), IntVeDumpVeInfoPage(), IntVeEnableDisableDriverAccessInProtectedView(), IntVeSetVeInfoPage(), IntWinCrashHandleDepViolation(), IntWinDpiValidateThreadStart(), IntWinDrvObjCreateFromAddress(), IntWinDrvObjHandleWrite(), IntWinDrvObjRemoveFromAddress(), IntWinHalProtectHalHeapExecs(), and IntWinStackHandleUserStackPagedOut().

◆ IntTranslateVirtualAddressEx()

INTSTATUS IntTranslateVirtualAddressEx ( QWORD  Gva,
QWORD  Cr3,
DWORD  Flags,
VA_TRANSLATION Translation 
)

Translates a guest virtual address to a guest physical address.

If error is returned, an incomplete trace is stored in the translation, and the translated physical address is not valid. If success is returned, a complete trace is stored inside the translation, however, it may still be possible that the page frame is not present. The caller must check the translation flags upon successful exit.

Parameters
[in]GvaGuest virtual address to be translated
[in]Cr3The Cr3 used for the translation
[in]FlagsFlags controlling the translation. May be 0 or a combination of Translation flags values. If it does not specify a paging mode, the function will deduce it by using the memory information inside gGuest. If TRFLG_CACHING_ATTR is set, will also obtain the caching attributes using the guest's IA32_PAT MSR.
[out]TranslationTranslation information
Return values
INT_STATUS_SUCCESSin case of success. This does not guarantee that Gva is present inside the leaf page table
INT_STATUS_NO_MAPPING_STRUCTURESif at any given point, the translation fails because a mapping structure can't be accessed.

Definition at line 1863 of file introcore.c.

Referenced by DbgDumpTranslation(), IntDecEmulatePageWalk(), IntHandleCowOnPage(), IntHookPtsCheckIntegrity(), IntIcAddInvdForInstruction(), IntLixGuestAllocateFill(), IntLixGuestFindKernelVersionAndRo(), IntSwapMemInjectPendingPF(), IntSwapMemReadData(), IntTranslateVirtualAddress(), IntValidateRangeForWrite(), IntValidateTranslation(), IntVeDumpVeInfoPage(), IntVeHandleEPTViolationInProtectedView(), IntVirtMemMap(), IntVirtMemSafeWrite(), IntWinDpiValidateHeapSpray(), IntWinDrvObjIsValidDriverObject(), IntWinGuestFindSystemCr3(), IntWinGuestIsSystemCr3(), IntWinHalFindHalHeapAndInterruptController(), IntWinLogVAInfo(), IntWinPfnIsMmPfnDatabase(), IntWinPfnLockAddress(), IntWinProcValidateSystemCr3(), IntWinSDFetchSecDescAddress(), IntWinSDReadSecDesc(), and IntWinTokenFetchTokenAddress().

◆ IntUninit()

INTSTATUS IntUninit ( void  )

Disables and uninitializes Introcore.

This will disable introspection engine, remove the guest protection and uninitialize the global state. Note that if a guest is initialized, disabling the protection for it will be done using the IG_DISABLE_IGNORE_SAFENESS option. This will also unmap everything in the gMultiPageMaps list of mappings, reset the GLUE_IFACE and UPPER_IFACE instances and uninitialize the gLock lock.

Definition at line 266 of file introcore.c.

◆ IntUnmapGpaForTranslation()

static INTSTATUS IntUnmapGpaForTranslation ( QWORD  Gpa,
void **  HostPtr 
)
static

Unmaps an address that was previously mapped with IntMapGpaForTranslation.

Parameters
[in]GpaGuest physical address that was mapped
[in,out]HostPtrPointer to the allocated memory
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 1148 of file introcore.c.

Referenced by IntTranslateVa32(), IntTranslateVa32Pae(), IntTranslateVa64(), and IntTranslateVa64La57().

◆ IntVirtMemFetchDword()

INTSTATUS IntVirtMemFetchDword ( QWORD  GuestVirtualAddress,
QWORD  Cr3,
DWORD Data 
)

Reads 4 bytes from the guest memory.

Parameters
[in]GuestVirtualAddressVirtual address from which to read
[in]Cr3The Cr3 used to translate GuestVirtualAddress. If 0, the current kernel Cr3 will be used.
[out]DataData read from the guest
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 887 of file introcore.c.

Referenced by IntWinProcHandleInstrument().

◆ IntVirtMemFetchQword()

INTSTATUS IntVirtMemFetchQword ( QWORD  GuestVirtualAddress,
QWORD  Cr3,
QWORD Data 
)

Reads 8 bytes from the guest memory.

Parameters
[in]GuestVirtualAddressVirtual address from which to read
[in]Cr3The Cr3 used to translate GuestVirtualAddress. If 0, the current kernel Cr3 will be used.
[out]DataData read from the guest
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 866 of file introcore.c.

Referenced by IntLixDrvFindList(), and IntLixStackDumpUmStackTrace().

◆ IntVirtMemFetchString()

INTSTATUS IntVirtMemFetchString ( QWORD  Gva,
DWORD  MaxLength,
QWORD  Cr3,
void *  Buffer 
)

Reads a NULL-terminated string from the guest.

Parameters
[in]GvaGuest virtual address from which the read starts
[in]MaxLengthMaximum length to be read. If a NULL terminator is not found before MaxLength bytes are read, the read stops.
[in]Cr3The Cr3 used to translate Gva. If 0, the current kernel Cr3 will be used.
[out]BufferBuffer containing the data read from the guest
Return values
INT_STATUS_SUCCESSin case of success
INT_STATUS_INVALID_PARAMETER_4is Buffer is NULL
INT_STATUS_NOT_FOUNDif a NULL terminator is not found before MaxLength bytes are read

Definition at line 1053 of file introcore.c.

◆ IntVirtMemFetchWordSize()

INTSTATUS IntVirtMemFetchWordSize ( QWORD  GuestVirtualAddress,
QWORD  Cr3,
void *  Data 
)

Reads a guest pointer from the guest memory.

For 64-bit guests, this will read 8 bytes. For 32-bit guests, this will read 4 bytes.

Parameters
[in]GuestVirtualAddressVirtual address from which to read
[in]Cr3The Cr3 used to translate GuestVirtualAddress. If 0, the current kernel Cr3 will be used.
[out]DataData read from the guest. The buffer must be at least 8 bytes in size for 64-bit guests, and 4 bytes in size for 32-bit guests.
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 908 of file introcore.c.

Referenced by IntWinProcHandleInstrument().

◆ IntVirtMemMap()

__must_check INTSTATUS IntVirtMemMap ( QWORD  Gva,
DWORD  Length,
QWORD  Cr3,
DWORD  Flags,
void **  HostPtr 
)

Maps a guest virtual memory range inside Introcore virtual address space.

If the virtual range spans across multiple pages, IntVirtMemMapMultiPage will be used

Parameters
[in]GvaGuest virtual address to be mapped
[in]LengthThe length of the virtual range
[in]Cr3Cr3 used to translate Gva. If 0, the current kernel Cr3 will be used
[in]FlagsIgnored. TODO: remove
[out]HostPtrOn success, will contain a pointer to the mapped memory
Return values
INT_STATUS_SUCCESSin case of success
INT_STATUS_INVALID_PARAMETER_2if Length is 0
INT_STATUS_PAGE_NOT_PRESENTif Gva is not present or if the paging mode is PAGING_NONE
INT_STATUS_NO_MAPPING_STRUCTURESif at any given point, the translation fails because a mapping structure can't be accessed

Definition at line 2134 of file introcore.c.

Referenced by _IntLixTaskRead(), _IntLixTaskStartMap(), DbgDumpGuestModules(), DbgDumpPfn(), IntAlertFillCodeBlocks(), IntDecDecodeInstruction(), IntExceptDumpSignatures(), IntExceptGetVictimIntegrity(), IntExceptUserLogWindowsInformation(), IntExceptVerifyCodeBlocksSig(), IntExceptVerifyValueCodeSig(), IntIntegrityAddRegion(), IntIntegrityRecalculate(), IntKsymFindIndexesTableStart(), IntKsymFindMarkersReducedTableEnd(), IntKsymFindMarkersTableEnd(), IntKsymFindNamesTableEnd(), IntKsymInitAbsolute(), IntKsymRelativeFindOffsetTableEnd(), IntKsymRelativeFindOffsetTableStart(), IntLixAgentFree(), IntLixCrashDumpDmesg(), IntLixCredInitMap(), IntLixCredsDump(), IntLixDrvCreateDriverObject(), IntLixDrvFindList(), IntLixDrvValidate(), IntLixDumpStacktrace(), IntLixFsrInitMap(), IntLixFsrRead(), IntLixGetInitTask(), IntLixGuestClearGuestMemory(), IntLixGuestFindKernelBase(), IntLixMmGetInitMm(), IntLixPatchSwapgs(), IntLixStackTraceGet(), IntLixTaskCreateFromBinprm(), IntLixTaskFetchCmdLine(), IntPeFindExportByName(), IntPeFindExportByOrdinal(), IntPeFindExportByRva(), IntPeFindFunctionByPattern(), IntPeFindFunctionStart(), IntPeGetDirectory(), IntPeGetExportNameByRva(), IntPeGetRuntimeFunction(), IntPeGetSectionHeaderByIndex(), IntPeGetSectionHeaderByRva(), IntPeGetSectionHeadersByName(), IntPeListSectionsHeaders(), IntPeParseUnwindData(), IntPeValidateHeader(), IntPtiCacheAdd(), IntPtiCacheRemove(), IntPtiMonitorAllPtWriteCandidates(), IntPtiRemovePtFilter(), IntReadString(), IntSerializeExtractCodeBlocks(), IntSlackAllocLinux(), IntThrSafeIsStackPtrInIntro(), IntThrSafeMoveReturn(), IntThrSafeWinInspectWaitingThread(), IntVeRemoveAgent(), IntVeUpdateCacheEntry(), IntVirtMemReadWrite(), IntVirtMemSet(), IntWinDpiValidateHeapSpray(), IntWinDrvObjIsValidDriverObject(), IntWinDrvRemoveFromAddress(), IntWinGuestFindBuildNumber(), IntWinGuestFindDriversNamespaceNoBuffer(), IntWinGuestFindIdleCr3(), IntWinGuestFindKernel(), IntWinGuestFindKernelCr3(), IntWinGuestFindKernelObjectsInternal(), IntWinGuestReadKernel(), IntWinGuestValidateKernel(), IntWinHalFindHalHeapAndInterruptController(), IntWinHalFindInterruptController(), IntWinHalHandleDispatchTableWrite(), IntWinHalReadHal(), IntWinIntObjHandleArrayModification(), IntWinModHookPoly(), IntWinNetFillTcpStruct(), IntWinNetFindTcpBitmap(), IntWinNetFindTcpObjects(), IntWinNetFindTcpPartition(), IntWinNetSearchForAlloc(), IntWinPfnModifyRefCount(), IntWinProcMapEprocess(), IntWinStackTraceGet32(), IntWinStackTraceGet64(), IntWinStackTraceGetUser32(), IntWinStackTraceGetUser64(), IntWinStackUserTrapFrameGet32(), IntWinStackUserTrapFrameGet64(), IntWinSudHandleFieldModification(), IntWinTokenPrivsShouldHook(), and IntWinVadMapShortVad().

◆ IntVirtMemMapMultiPage()

static INTSTATUS IntVirtMemMapMultiPage ( QWORD  GuestVirtualAddress,
DWORD  Length,
QWORD  Cr3,
void **  HostPtr 
)
static

Maps a guest kernel virtual memory range inside Introcore virtual address space regardless of the number of pages it spans across.

Parameters
[in]GuestVirtualAddressThe start of the guest virtual address range
[in]LengthThe size of the memory range
[in]Cr3The Cr3 used to translate GuestVirtualAddress. If 0, the current kernel Cr3 will be used
[out]HostPtrOn success, will contain a pointer to the mapped memory
Return values
INT_STATUS_SUCCESSin case of success
INT_STATUS_INSUFFICIENT_RESOURCESif not enough memory is available
INT_STATUS_INVALID_INTERNAL_STATEis an inconsistency was detected

Definition at line 2060 of file introcore.c.

Referenced by IntVirtMemMap().

◆ IntVirtMemPatchDword()

INTSTATUS IntVirtMemPatchDword ( QWORD  GuestVirtualAddress,
QWORD  Cr3,
DWORD  Data 
)

Writes 4 bytes in the guest memory.

Parameters
[in]GuestVirtualAddressVirtual address at which the write is done
[in]Cr3The Cr3 used to translate GuestVirtualAddress. If 0, the current kernel Cr3 will be used.
[out]DataData to write inside the guest
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 1010 of file introcore.c.

◆ IntVirtMemPatchQword()

INTSTATUS IntVirtMemPatchQword ( QWORD  GuestVirtualAddress,
QWORD  Cr3,
QWORD  Data 
)

Writes 8 bytes in the guest memory.

Parameters
[in]GuestVirtualAddressVirtual address at which the write is done
[in]Cr3The Cr3 used to translate GuestVirtualAddress. If 0, the current kernel Cr3 will be used.
[out]DataData to write inside the guest
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 989 of file introcore.c.

◆ IntVirtMemPatchWordSize()

INTSTATUS IntVirtMemPatchWordSize ( QWORD  GuestVirtualAddress,
QWORD  Cr3,
QWORD  Data 
)

Writes a guest pointer inside the guest memory.

Parameters
[in]GuestVirtualAddressVirtual address at which the write is done
[in]Cr3The Cr3 used to translate GuestVirtualAddress. If 0, the current kernel Cr3 will be used.
[out]DataData to write inside the guest. For 32-bit guests, only the low 32-bits will be written.
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 1031 of file introcore.c.

◆ IntVirtMemRead()

INTSTATUS IntVirtMemRead ( QWORD  Gva,
DWORD  Length,
QWORD  Cr3,
void *  Buffer,
DWORD RetLength 
)

Reads data from a guest virtual memory range.

Parameters
[in]GvaThe start of the guest virtual memory range
[in]LengthThe size of the memory range
[in]Cr3The Cr3 used to translate Gva. If 0, the current kernel Cr3 will be used.
[out]BufferBuffer in which data will be read. Must be at least Length bytes in size.
[out]RetLengthThe size we managed to read. In case of success, it will always be equal to Length. May be NULL.
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 627 of file introcore.c.

Referenced by IntAgentHandleLogGatherVmcall(), IntAgentHandleRemediationVmcall(), IntAlertFillDpiExtraInfo(), IntAlertFillExecContext(), IntDisasmGva(), IntDumpGvaEx(), IntExceptGetVictimEpt(), IntExceptVerifyValueCodeSig(), IntExceptVerifyValueSig(), IntGetValueFromOperand(), IntHandleDtrViolation(), IntHandleFetchRetryOnPageBoundary(), IntKsymRelativeFindOffsetTableStart(), IntLixAgentFillDataFromMemory(), IntMemClkHandleRead(), IntSerializeDpiWinHeapSpray(), IntSerializeDpiWinPivotedStack(), IntSerializeDpiWinThreadStart(), IntSerializeRawDump(), IntSerializeRipCode(), IntShcIsSuspiciousCode(), IntVirtMemFetchDword(), IntVirtMemFetchQword(), IntVirtMemFetchString(), IntVirtMemFetchWordSize(), IntVirtMemMapMultiPage(), IntWinCrashHandleDepViolation(), IntWinGuestFindIdleCr3(), IntWinModBlockHandleExecution(), IntWinObjHandleDriverDirectoryEntryInMemory(), IntWinProcHandleCopyMemory(), IntWinProcHandleInstrument(), IntWinStackTraceGetUser(), IntWinStackTraceGetUser32(), IntWinStackWow64CheckIsPivoted(), IntWinThrGetCurrentStackBaseAndLimit(), IntWinThrGetUmStackBaseAndLimitFromTib(), IntWinThrHandleQueueApc(), IntWinThrHandleThreadHijack(), IntWinTokenCheckCurrentPrivileges(), and IntWinTokenPrivsProtectOnProcess().

◆ IntVirtMemReadWrite()

static INTSTATUS IntVirtMemReadWrite ( QWORD  VirtualAddress,
DWORD  Length,
QWORD  Cr3,
void *  Buffer,
DWORD RetLength,
BOOLEAN  Write 
)
static

Transfers memory between a guest virtual memory range and Introcore.

This function will copy a virtual-address range to a designated buffer, or a designated buffer inside a virtual-address range. If the range spans across multiple pages, it will map each page individually, but no more than one page at a time. If it returns INT_STATUS_SUCCESS, for write operations, the memory range will contain Length bytes from Buffer; for read operations, Buffer will contain Length bytes from the physical address range. If RetLength is not NULL, it will contain the value Length. If it doesn't return INT_STATUS_SUCCESS, RetLength will contain the number of bytes successfully transferred (which will most likely be less than Length). Note that write operations will be done even if Address is not writable inside the guest's page tables.

Parameters
[in]VirtualAddressThe start of the virtual address range
[in]LengthThe size to be read or written
[in]Cr3The Cr3 used to translate VirtualAddress to a physical address. If 0, the current Cr3 used by the guest will be used. If KPTI is enabled and the current process has different user mode and kernel mode page directory base registers, the one for the kernel will be used, even if the user mode Cr3 is loaded.
[in,out]BufferIf Write is True, the buffer from which contents will be copied inside the guest's memory. If Write is False, the buffer in which the contents of the guest memory will be copied to. Must be at least Length bytes in size.
[out]RetLengthThe actual size that we managed to transfer from the guest to introcore. If INT_STATUS_SUCCES is returned, this will be equal to Length. May be NULL.
[in]WriteTrue for write operations, False for read operations.
Return values
INT_STATUS_SUCCESSin case of success
INT_STATUS_INVALID_PARAMETER_2is Length is 0
INT_STATUS_PAGE_NOT_PRESENTif VirtualAddress is not present inside the guest page tables

Definition at line 315 of file introcore.c.

Referenced by IntKernVirtMemRead(), IntKernVirtMemWrite(), IntVirtMemRead(), and IntVirtMemWrite().

◆ IntVirtMemSet()

INTSTATUS IntVirtMemSet ( QWORD  VirtualAddress,
DWORD  Length,
QWORD  Cr3,
BYTE  Value 
)

Definition at line 414 of file introcore.c.

Referenced by IntLixGuestInitAgentCompletion().

◆ IntVirtMemUnmap()

INTSTATUS IntVirtMemUnmap ( void **  HostPtr)

Unmaps a memory range previously mapped with IntVirtMemMap.

Parameters
[in]HostPtrPoints to the memory area allocated when the map was done. After this function returns, it will point to NULL.
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 2234 of file introcore.c.

Referenced by _IntLixTaskFinishMap(), DbgDumpGuestModules(), DbgDumpPfn(), IntAlertFillCodeBlocks(), IntDecDecodeInstruction(), IntExceptDumpSignatures(), IntExceptGetVictimIntegrity(), IntExceptUserLogWindowsInformation(), IntExceptVerifyCodeBlocksSig(), IntExceptVerifyValueCodeSig(), IntIntegrityAddRegion(), IntIntegrityRecalculate(), IntKsymFindIndexesTableStart(), IntKsymFindMarkersReducedTableEnd(), IntKsymFindMarkersTableEnd(), IntKsymFindNamesTableEnd(), IntKsymInitAbsolute(), IntKsymRelativeFindOffsetTableEnd(), IntKsymRelativeFindOffsetTableStart(), IntLixAgentFree(), IntLixCrashDumpDmesg(), IntLixCredsDump(), IntLixCredUninitMap(), IntLixDrvCreateDriverObject(), IntLixDrvFindList(), IntLixDrvValidate(), IntLixDumpStacktrace(), IntLixFsrUninitMap(), IntLixGetInitTask(), IntLixGuestClearGuestMemory(), IntLixGuestFindKernelBase(), IntLixMmGetInitMm(), IntLixPatchSwapgs(), IntLixStackTraceGet(), IntLixTaskCreateFromBinprm(), IntLixTaskFetchCmdLine(), IntPeFindExportByName(), IntPeFindExportByOrdinal(), IntPeFindExportByRva(), IntPeFindFunctionByPattern(), IntPeFindFunctionStart(), IntPeGetDirectory(), IntPeGetExportNameByRva(), IntPeGetRuntimeFunction(), IntPeGetSectionHeaderByIndex(), IntPeGetSectionHeaderByRva(), IntPeGetSectionHeadersByName(), IntPeListSectionsHeaders(), IntPeParseUnwindData(), IntPeValidateHeader(), IntPhysMemReadWriteAnySize(), IntPtiCacheAdd(), IntPtiCacheRemove(), IntPtiMonitorAllPtWriteCandidates(), IntPtiRemovePtFilter(), IntReadString(), IntSerializeExtractCodeBlocks(), IntSlackAllocLinux(), IntThrSafeIsStackPtrInIntro(), IntThrSafeMoveReturn(), IntThrSafeWinInspectWaitingThread(), IntVeDeliverDriverForUnload(), IntVeHandleSwap(), IntVeRemoveAgent(), IntVirtMemReadWrite(), IntVirtMemSet(), IntWinDpiValidateHeapSpray(), IntWinDrvObjIsValidDriverObject(), IntWinDrvRemoveFromAddress(), IntWinGuestFindBuildNumber(), IntWinGuestFindDriversNamespaceNoBuffer(), IntWinGuestFindIdleCr3(), IntWinGuestFindKernel(), IntWinGuestFindKernelCr3(), IntWinGuestFindKernelObjectsInternal(), IntWinGuestReadKernel(), IntWinGuestValidateKernel(), IntWinHalFindHalHeapAndInterruptController(), IntWinHalFindInterruptController(), IntWinHalHandleDispatchTableWrite(), IntWinHalReadHal(), IntWinIntObjHandleArrayModification(), IntWinModHookPoly(), IntWinNetFillTcpStruct(), IntWinNetFindTcpBitmap(), IntWinNetFindTcpObjects(), IntWinNetFindTcpPartition(), IntWinNetSearchForAlloc(), IntWinPfnModifyRefCount(), IntWinProcAdd(), IntWinProcHandleCreateInternal(), IntWinProcSwapIn(), IntWinStackTraceGet32(), IntWinStackTraceGet64(), IntWinStackTraceGetUser32(), IntWinStackTraceGetUser64(), IntWinStackUserTrapFrameGet32(), IntWinStackUserTrapFrameGet64(), IntWinSudHandleFieldModification(), IntWinTokenPrivsShouldHook(), and IntWinVadFetchVadFromMemory().

◆ IntVirtMemUnmapMultiPage()

static BOOLEAN IntVirtMemUnmapMultiPage ( void **  HostPtr)
static

Unamps a memory range previously mapped with IntVirtMemMapMultiPage.

Parameters
[in,out]HostPtrPointer to the mapped region. On success, it will point to NULL
Returns
True if HostPtr matched any known multi map ranges; False if it did not

Definition at line 2202 of file introcore.c.

Referenced by IntVirtMemUnmap().

◆ IntVirtMemWrite()

INTSTATUS IntVirtMemWrite ( QWORD  Gva,
DWORD  Length,
QWORD  Cr3,
void *  Buffer 
)

Writes data to a guest virtual memory range.

Parameters
[in]GvaThe start of the guest virtual memory range
[in]LengthThe size of the memory range
[in]Cr3The Cr3 used to translate Gva. If 0, the current kernel Cr3 will be used.
[out]BufferBuffer with the data to be written. Must be at least Length bytes in size.
Returns
INT_STATUS_SUCCESS if successful, or an appropriate INTSTATUS error value

Definition at line 652 of file introcore.c.

Referenced by IntDetRelocate(), IntLixAgentCreateThreadHypercall(), IntMemClkCloakRegion(), IntMemClkModifyPatchedData(), IntVirtMemPatchDword(), IntVirtMemPatchQword(), IntVirtMemPatchWordSize(), and IntWinDagentHandleSlackWritable().

◆ IsSse42Supported()

static BOOLEAN IsSse42Supported ( void  )
static

Checks if support for SSE 4.2 is present.

Returns
True if support was detected, False if it was not

Definition at line 143 of file introcore.c.

Referenced by IntInit().

◆ utf16_for_log()

char* utf16_for_log ( const WCHAR WString)

Converts a UTF-16 to a UTF-8 string to be used inside logging macros.

This function should be called only from one of the log macros (TRACE, INFO. WARNING, LOG, ERROR, CRITICAL). Note that each string is limited to a size of 1KB and calling this function more than 8 times in a row (in the same logging macro) is an error. The log macros will reset the global state used for conversion. This is needed because not all logging implementations can handle wide char strings.

Parameters
[in]WStringNULL-terminated string to be converted
Returns
A pointer to a NULL-terminated string containing the converted WString. This is returned from a static array.

Definition at line 2845 of file introcore.c.

Referenced by DbgDumpGuestModules(), IntAgentHandleLogGatherVmcall(), IntAgentHandleRemediationVmcall(), IntDetSetHook(), IntDriverDump(), IntExceptKernelLogWindowsInformation(), IntExceptKernelUserLogWindowsInformation(), IntExceptUserLogWindowsInformation(), IntLogCurrentIP(), IntLogProcessInfo(), IntLogStackTrace(), IntModBlockHandleBlockModHeadersInMemory(), IntModBlockHandlePreInjection(), IntWinAgentSelectBootstrapAddress(), IntWinApiHook(), IntWinDagentCheckNativeSubsystem(), IntWinDagentHandleDoubleAgent(), IntWinDagentHandleSuspModExecution(), IntWinDrvCreateFromAddress(), IntWinDrvForceDisableReadNtEat(), IntWinDrvHeadersInMemory(), IntWinDrvObjCreateFromAddress(), IntWinDrvObjHandleWrite(), IntWinDrvObjProtect(), IntWinDrvObjProtectFastIoDispatch(), IntWinDrvObjUnprotect(), IntWinDrvObjUnprotectFastIoDispatch(), IntWinDrvObjUpdateProtection(), IntWinDrvUnprotect(), IntWinDrvUpdateProtection(), IntWinModBlockHandleExecution(), IntWinModCacheCreate(), IntWinModHandleExportsInMemory(), IntWinModHandleModulePathInMemory(), IntWinModHandlePreInjection(), IntWinModHookModule(), IntWinModulesChangeProtectionFlags(), IntWinProcAddProtectedProcess(), IntWinProcCreateProcessObject(), IntWinProcDump(), IntWinProcDumpProtected(), IntWinProcHandleCopyMemory(), IntWinProcSwapIn(), IntWinProcSwapOut(), IntWinUmModCacheFetch(), IntWinUmModCacheFillExports(), IntWinUmModCacheFillHeaders(), IntWinUmPathCreate(), and IntWinVadDump().

Variable Documentation

◆ gAbortLoad

BOOLEAN gAbortLoad = FALSE

Set to True if introcore should abort the initialization process.

Definition at line 59 of file introcore.c.

Referenced by IntAbortEnableIntro(), and IntGuestHandleCr3Write().

◆ gByteMaskToBitMask

const QWORD gByteMaskToBitMask[256]

Converts a byte number to a mask having the bits in those bytes set.

For example, for 5, will return 0x0000000000ff00ff which has bytes 0 and 1 filled.

Definition at line 73 of file introcore.c.

Referenced by IntHookPtwProcessWrite().

◆ gErrorContext

INTRO_ERROR_CONTEXT gErrorContext = { 0 }

Global storage for the error context used by GLUE_IFACE.NotifyIntrospectionErrorState.

Since API calls are serialized, all the error notifications use this as the context in order to avoid allocating extra memory when reporting an error, as some errors may be triggered by low memory conditions and we would like to avoid memory allocations in those situations.

Definition at line 43 of file introcore.c.

Referenced by IntWinProcProtect(), and IntWinProcUpdateProtection().

◆ gInsideDebugger

BOOLEAN gInsideDebugger

Set to True when introcore is inside a debugger.

This is used to avoid pausing VCPUs while trapped inside a debugger, as that can lead to deadlocks

Definition at line 28 of file debugger.c.

Referenced by IntDbgProcessCommand(), IntPauseVcpus(), and IntResumeVcpus().

◆ gLock

void* gLock = NULL

A lock that ensures that all the events are serialized inside introcore.

This essentially makes introcore act as a single threaded library, since only one callback will be executing at a time. Since events on Xen are already synchronized this is already true for VMX events even without this lock. It just ensures that this behavior is consistent across all APIs, not just event handlers. Not acquiring this lock is a fatal error as all the code in introcore assumes that this lock is held.

Definition at line 24 of file introcore.c.

Referenced by IntAddExceptionFromAlert(), IntAddRemoveProtectedProcessUtf16(), IntAddRemoveProtectedProcessUtf8(), IntDisableIntro(), IntEnginesResultCallback(), IntFlushAlertExceptions(), IntFlushGpaCache(), IntGetCurrentInstructionLength(), IntGetCurrentInstructionMnemonic(), IntGetCurrentIntroOptions(), IntGetExceptionsVersion(), IntGetGuestInfo(), IntGetSupportVersion(), IntGetVersionString(), IntHandleBreakpoint(), IntHandleCrWrite(), IntHandleDtrViolation(), IntHandleEptViolation(), IntHandleEventInjection(), IntHandleIntroCall(), IntHandleMsrViolation(), IntHandleTimer(), IntHandleXcrWrite(), IntInit(), IntInjectFileAgentInGuest(), IntInjectProcessAgentInGuest(), IntIterateVaSpace(), IntModifyDynamicOptions(), IntNewGuestNotification(), IntNotifyGuestPowerStateChange(), IntRemoveAllProtectedProcesses(), IntRemoveException(), IntSetLogLevel(), IntUninit(), IntUpdateExceptions(), and IntUpdateSupport().

◆ gMultiPageMaps

LIST_HEAD gMultiPageMaps = LIST_HEAD_INIT(gMultiPageMaps)

List of all the currently valid multi page maps.

Definition at line 56 of file introcore.c.

◆ gSse42Supported

BOOLEAN gSse42Supported

Set to True if support for SSE 4.2 was detected.

Definition at line 99 of file crc32.c.

Referenced by Crc32ComputeFast(), and IntInit().

◆ IntHviVersion

const INT_VERSION_INFO IntHviVersion
Initial value:
=
{
.VersionInfo =
{
.Build = INTRO_VERSION_BUILDNUMBER & 0xFFFF,
.Revision = INTRO_VERSION_REVISION,
.Minor = INTRO_VERSION_MINOR,
.Major = INTRO_VERSION_MAJOR
}
}

The version of the introcore library.

The HVI version. Used to check for compatibility issues with the cami version.

Definition at line 27 of file introcore.c.