68 QWORD detourAddr, readAddr, byteAddr, cmpAddr, cmpValue;
105 byteAddr = detourAddr + 1 + (e * 10) + 1;
106 cmpAddr = detourAddr + 1 + (e * 10) + 4;
114 byteAddr = detourAddr + 1 + (e * 10ull) + 1;
115 cmpAddr = detourAddr + 1 + (e * 10ull) + 4;
123 byteAddr = detourAddr + 1 + (e * 10ull) + 1;
124 cmpAddr = detourAddr + 1 + (e * 10ull) + 4;
132 byteAddr = detourAddr + 1 + (e * 10) + 1;
133 cmpAddr = detourAddr + 1 + (e * 10) + 4;
141 byteAddr = detourAddr + 2 + (e * 16) + 9;
142 cmpAddr = detourAddr + 2 + (e * 16) + 2;
150 byteAddr = detourAddr + 1 + (e * 10) + 1;
151 cmpAddr = detourAddr + 1 + (e * 10) + 4;
159 byteAddr = detourAddr + 2 + (e * 16) + 9;
160 cmpAddr = detourAddr + 2 + (e * 16) + 2;
168 byteAddr = detourAddr + 2 + (e * 16) + 9;
169 cmpAddr = detourAddr + 2 + (e * 16) + 2;
193 ERROR(
"[ERROR] IntRipRead failed: 0x%08x\n", status);
197 if (rip >= detourAddr && rip < detourAddr + size)
205 TRACE(
"[RTLPVIRTUALUNWIND] A rip seems to be inside our relocs, bailing out for now...\n");
207 goto resume_and_exit;
214 ERROR(
"[ERROR] IntKernVirtMemRead failed for %llx: 0x%08x\n", readAddr, status);
215 goto resume_and_exit;
222 ERROR(
"[ERROR] IntKernVirtMemWrite failed for %llx: 0x%08x\n", byteAddr, status);
223 goto resume_and_exit;
230 ERROR(
"[ERROR] IntKernVirtMemWrite failed for %llx: 0x%08x\n", cmpAddr, status);
231 goto resume_and_exit;
236 TRACE(
"[RTLPVIRTUALUNWIND] Successfully patched detour with tag %d, entry %llu, IF = %d\n",
INTSTATUS IntKernVirtMemWrite(QWORD KernelGva, DWORD Length, void *Buffer)
Writes data to a guest kernel virtual memory range.
IG_ARCH_REGS Regs
The current state of the guest registers.
DWORD Index
The VCPU number.
#define INT_STATUS_SUCCESS
DWORD KernelSize
The size of the kernel.
#define INT_SUCCESS(Status)
INTSTATUS IntResumeVcpus(void)
Resumes the VCPUs previously paused with IntPauseVcpus.
#define INT_STATUS_NOT_NEEDED_HINT
int INTSTATUS
The status data type.
DWORD OSVersion
Os version.
#define INT_STATUS_NOT_FOUND
INTSTATUS IntRipRead(DWORD CpuNumber, QWORD *Rip)
Reads the value of the guest RIP.
INTSTATUS IntPauseVcpus(void)
Pauses all the guest VCPUs.
INTRO_GUEST_TYPE OSType
The type of the guest.
INTSTATUS IntDetGetAddrAndTag(QWORD Ptr, QWORD *Address, DWORD *Size, DETOUR_TAG *Tag)
Checks if Ptr is inside a detour handler and returns the detour's handler address, size and tag.
BOOLEAN Guest64
True if this is a 64-bit guest, False if it is a 32-bit guest.
INTSTATUS IntRtlpVirtualUnwindCheckAccess(void)
Check if a memory read operation was issued by RtlpVirtualUnwind or friends and update the cache...
QWORD KernelVa
The guest virtual address at which the kernel image.
BOOLEAN gRipInsideRtlpVirtualUnwindReloc
DWORD CpuCount
The number of logical CPUs.
static uint64_t __rdtsc(void)
GUEST_STATE gGuest
The current guest state.
INTSTATUS IntKernVirtMemRead(QWORD KernelGva, DWORD Length, void *Buffer, DWORD *RetLength)
Reads data from a guest kernel virtual memory range.
VCPU_STATE * gVcpu
The state of the current VCPU.
DETOUR_TAG
Unique tag used to identify a detour.
QWORD Gla
The accessed guest virtual address. Valid only for EPT exits.