42 *Efer = readMsr.
Value;
90 ERROR(
"[ERROR] : IntGetGprs, status = 0x%08x\n", status);
129 ERROR(
"[ERROR] IntGetAllRegisters failed: 0x%08x\n", status);
172 ERROR(
"[ERROR] IntIdtFindBase failed: 0x%08x\n", status);
180 status =
IntKernVirtMemRead(idtBase + Entry *
sizeof(gate),
sizeof(gate), &gate, NULL);
192 status =
IntKernVirtMemRead(idtBase + Entry *
sizeof(gate),
sizeof(gate), &gate, NULL);
231 (
void *)(
size_t)CpuNumber,
236 ERROR(
"[ERROR] : IntQueryGuestInfo failed for IG_QUERY_INFO_CLASS_REGISTER_STATE, status = 0x%08x\n", status);
242 if (NULL != GdtLimit)
282 *FsValue = readMsr.
Value;
319 *GsValue = readMsr.
Value;
356 *GsValue = readMsr.
Value;
381 if (Cr0Value == NULL)
403 ERROR(
"[ERROR] IntGetGprs failed: 0x%08x\n", status);
407 *Cr0Value = regs.
Cr0;
433 if (Cr3Value == NULL)
455 ERROR(
"[ERROR] IntGetGprs failed: 0x%08x\n", status);
459 *Cr3Value = regs.
Cr3;
485 if (Cr4Value == NULL)
507 ERROR(
"[ERROR] IntGetGprs failed: 0x%08x\n", status);
511 *Cr4Value = regs.
Cr4;
537 if (Cr8Value == NULL)
559 ERROR(
"[ERROR] IntGetGprs failed: 0x%08x\n", status);
563 *Cr8Value = regs.
Cr8;
601 *SysCs = readMsr.
Value;
614 *SysEip = readMsr.
Value;
627 *SysEsp = readMsr.
Value;
663 *SysStar = readMsr.
Value;
666 if (SysLstar != NULL)
676 *SysLstar = readMsr.
Value;
700 if (DebugCtl == NULL)
713 *DebugCtl = readMsr.
Value;
747 if (BuffersSize == 0)
766 LbrFrom[i] =
__readmsr(cFrom[msrLbrTos]);
862 (
void *)(
size_t)CpuNumber,
867 CRITICAL(
"[ERROR] IntQueryGuestInfo failed: 0x%08x\n", status);
897 memcpy(Regs, pRegs,
sizeof(*Regs));
934 memcpy(&
gVcpu->
Regs, Regs,
sizeof(*Regs));
938 ERROR(
"[ERROR] Modifying the GPRs from #VE context, but the registers are not cached!\n");
952 (
void *)(
size_t)CpuNumber,
1072 ERROR(
"[ERROR] IntGetXsaveAreaSize failed: 0x%08x\n", status);
1090 XsaveArea->Size = size;
1091 XsaveArea->XsaveArea = xsave;
1111 (
PBYTE)XsaveArea->XsaveArea, XsaveArea->Size);
1140 ERROR(
"[ERROR] IntEferRead failed: 0x%08x\n", status);
1153 ERROR(
"[ERROR] IntGsRead failed: 0x%08x\n", status);
1158 if (0 == (gsbase & 0x8000000000000000))
1160 WARNING(
"[WARNING][CPU %d] IA32_GS_BASE MSR does not point inside kernel (%llx)\n",
1166 ERROR(
"[ERROR] IntKernelGsRead failed: 0x%08x\n", status);
1171 if (0 == (gsbase & 0x8000000000000000))
1173 ERROR(
"[ERROR][CPU %d] IA32_KERNEL_GS_BASE MSR does not point inside kernel (%llx)\n",
1191 ERROR(
"[ERROR] IntGdtFindBase failed: 0x%08x\n", status);
1196 if (0x30 + 8 > gdtlimit)
1198 ERROR(
"[ERROR] Kernel FS points outside the GDT 0x%016llx:%x\n", gdtbase, gdtlimit);
1206 ERROR(
"[ERROR] IntKernVirtMemRead failed: 0x%08x\n", status);
1210 *Pcr = fsdesc.
Base1 | (fsdesc.
Base << 24);
1253 if (NULL == EptpIndex)
1259 (
void *)EptpIndex,
sizeof(
DWORD));
INTSTATUS IntGetXcr0(DWORD CpuNumber, QWORD *Xcr0Value)
Get the value of the guest XCR0 register.
Get the guest XCR0 value for a VCPU.
#define IG_IA32_SYSENTER_ESP
INTSTATUS IntGetMaxGpfn(QWORD *MaxGpfn)
Get the last physical page frame number accessible by the guest.
QWORD Value
The value of the MSR.
static INTSTATUS IntKernelGsRead(DWORD CpuNumber, QWORD *GsValue)
Reads the IA32_KERNEL_GS_BASE guest MSR.
Describes an XSAVE area format.
INTSTATUS IntSetXsaveArea(DWORD CpuNumber, XSAVE_AREA *XsaveArea)
Sets the contents of the guest XSAVE area.
#define MSR_LBR_6_FROM_IP
#define MSR_LBR_C_FROM_IP
Segment descriptor for 32-bit systems.
INTSTATUS IntGetGprs(DWORD CpuNumber, PIG_ARCH_REGS Regs)
Get the current guest GPR state.
IG_ARCH_REGS Regs
The current state of the guest registers.
DWORD Index
The VCPU number.
INTSTATUS IntCr8Read(DWORD CpuNumber, QWORD *Cr8Value)
Reads the value of the guest CR8.
#define INT_STATUS_SUCCESS
DWORD IntGetCurrentCpu(void)
Returns the current CPU number.
INTSTATUS IntGetXsaveArea(DWORD CpuNumber, XSAVE_AREA *XsaveArea)
Get the contents of the guest XSAVE area.
#define IntEnterDebugger()
#define INT_SUCCESS(Status)
Holds segment register state.
#define IG_IA32_SYSENTER_EIP
Get the current privilege level for a VCPU. Buffer points to a IG_CS_RING enum.
#define HpAllocWithTag(Len, Tag)
int INTSTATUS
The status data type.
QWORD gEventId
The ID of the current event.
INTSTATUS IntCr0Read(DWORD CpuNumber, QWORD *Cr0Value)
Reads the value of the guest CR0.
#define INT_STATUS_NOT_FOUND
INTSTATUS IntQueryGuestInfo(DWORD InfoClass, void *InfoParam, void *Buffer, DWORD BufferLength)
INTSTATUS IntIdtGetEntry(DWORD CpuNumber, DWORD Entry, QWORD *Handler)
Get the handler of an interrupt from the IDT.
#define MSR_LBR_3_FROM_IP
INTRO_GUEST_TYPE OSType
The type of the guest.
INTSTATUS IntSysenterRead(DWORD CpuNumber, QWORD *SysCs, QWORD *SysEip, QWORD *SysEsp)
Queries the IA32_SYSENTER_CS, IA32_SYSENTER_EIP, and IA32_SYSENTER_ESP guest MSRs.
#define INT_STATUS_BUFFER_OVERFLOW
#define _Out_writes_(expr)
INTSTATUS IntGsRead(DWORD CpuNumber, QWORD *GsValue)
Reads the IA32_GS_BASE guest MSR.
#define MSR_LBR_4_FROM_IP
INTSTATUS IntLerRead(QWORD *LerFrom, QWORD *LerTo)
static uint64_t __readmsr(uint32_t reg)
#define MSR_LBR_5_FROM_IP
BOOLEAN KptiActive
True if KPTI is enabled on this guest, False if it is not.
QWORD Cr3
Process PDBR. Includes PCID.
#define MSR_LBR_1_FROM_IP
INTSTATUS IntLbrRead(DWORD BuffersSize, QWORD *LbrFrom, QWORD *LbrTo)
INTSTATUS IntCr3Read(DWORD CpuNumber, QWORD *Cr3Value)
Reads the value of the guest CR3.
#define MSR_LBR_8_FROM_IP
#define IG_IA32_KERNEL_GS_BASE
Get the guest XSAVE area for a VCPU.
#define IG_CURRENT_VCPU
For APIs that take a VCPU number as a parameter, this can be used to specify that the current VCPU sh...
__noreturn void IntBugCheck(void)
#define MSR_LBR_7_FROM_IP
#define MSR_LBR_F_FROM_IP
An 32-bit interrupt gate as defined by the Intel docs.
INTSTATUS IntSetGprs(DWORD CpuNumber, PIG_ARCH_REGS Regs)
Sets the values of the guest GPRs.
BOOLEAN Guest64
True if this is a 64-bit guest, False if it is a 32-bit guest.
#define MSR_LBR_B_FROM_IP
#define MSR_LBR_A_FROM_IP
QWORD IntLixGetKernelCr3(QWORD Cr3)
Transforms an user CR3 into a kernel CR3 on systems with KPTI enabled and active. ...
INTSTATUS IntFsRead(DWORD CpuNumber, QWORD *FsValue)
Reads the IA32_FS_BASE guest MSR.
DWORD MsrId
The ID of the MSR, as defined by Intel.
INTSTATUS IntSyscallRead(DWORD CpuNumber, QWORD *SysStar, QWORD *SysLstar)
Queries the IA32_STAR, and IA32_LSTAR guest MSRs.
#define HpFreeAndNullWithTag(Add, Tag)
Get the current VCPU number.
An 64-bit interrupt gate as defined by the Intel docs.
INTSTATUS IntGetXsaveAreaSize(DWORD *Size)
Get the size of the guest XSAVE area on the current CPU.
#define INT_STATUS_DATA_BUFFER_TOO_SMALL
INTSTATUS IntDebugCtlRead(DWORD CpuNumber, QWORD *DebugCtl)
Queries the IA32_DEBUGCTL guest MSR.
Get the segment registers for the current VCPU. Buffer points to a IG_SEG_REGS structure.
INTSTATUS IntCr4Read(DWORD CpuNumber, QWORD *Cr4Value)
Reads the value of the guest CR4.
INTSTATUS IntRipRead(DWORD CpuNumber, QWORD *Rip)
Reads the value of the guest RIP.
INTSTATUS IntGetAllRegisters(DWORD CpuNumber, PIG_ARCH_REGS Regs)
Returns the entire guest register state. This will return the GPRs, control registers, and IDT and GDT base and limit. This also bypasses the cache used by IntGetGprs.
#define MSR_LBR_E_FROM_IP
INTSTATUS IntEferRead(QWORD CpuNumber, QWORD *Efer)
Reads the value of the guest IA32 EFER MSR.
PWIN_PROCESS_OBJECT IntWinProcFindObjectByUserCr3(QWORD Cr3)
Finds a process by its user CR3.
GUEST_STATE gGuest
The current guest state.
BOOLEAN VeContext
Set to True if we are in the context of the #VE agent.
INTSTATUS IntGetCurrentRing(DWORD CpuNumber, DWORD *Ring)
Read the current protection level.
Set the guest XSAVE area for a VCPU. This query is optional.
Similar to IG_QUERY_INFO_CLASS_REGISTER_STATE, but will get only the general purpose registers...
#define MSR_LBR_9_FROM_IP
Get the size of the guest XSAVE area for a VCPU.
INTSTATUS IntIdtFindBase(DWORD CpuNumber, QWORD *Base, WORD *Limit)
Returns the IDT base and limit for a guest CPU.
INTSTATUS IntKernVirtMemRead(QWORD KernelGva, DWORD Length, void *Buffer, DWORD *RetLength)
Reads data from a guest kernel virtual memory range.
#define INT_STATUS_OPERATION_NOT_SUPPORTED
#define MSR_LBR_D_FROM_IP
Get the guest register state for a VCPU. Buffer points to a IG_ARCH_REGS structure.
#define MSR_LBR_0_FROM_IP
INTSTATUS IntGetCurrentEptIndex(DWORD CpuNumber, DWORD *EptpIndex)
Get the EPTP index of the currently loaded EPT.
#define INT_STATUS_INVALID_PARAMETER_1
VCPU_STATE * gVcpu
The state of the current VCPU.
INTSTATUS IntFindKernelPcr(DWORD CpuNumber, QWORD *Pcr)
Finds the address of the Windows kernel _KPCR.
#define CRITICAL(fmt,...)
Get the value of a MSR for a VCPU. Buffer points to a IG_QUERY_MSR structure.
INTSTATUS IntGdtFindBase(DWORD CpuNumber, QWORD *GdtBase, WORD *GdtLimit)
Returns the GDT base and limit for a guest CPU.
INTSTATUS IntGetSegs(DWORD CpuNumber, PIG_SEG_REGS Regs)
Read the guest segment registers.
Get the current EPTP index for the current VCPU.
#define INT_STATUS_INVALID_PARAMETER_2
#define IG_IA32_SYSENTER_CS
QWORD EventId
EventId for which VCPU_STATE.Regs is valid.
Get the code segment type for a VCPU. Buffer points to a IG_CS_TYPE enum.
#define MSR_LBR_2_FROM_IP
This structure describes a running process inside the guest.
#define INT_STATUS_INSUFFICIENT_RESOURCES
INTSTATUS IntGetCurrentMode(DWORD CpuNumber, DWORD *Mode)
Read the current CS type.
#define INT_STATUS_INVALID_PARAMETER_3