The functions for emulating counters.  
More...
#include "pch.h"
The functions for emulating counters. 
- Author
- Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
- Version
- 0.1 
- Date
- 2020-06-14
- Copyright
- This project is released under the GNU Public License v3. 
◆ CounterClearPreemptionTimer()
      
        
          | VOID CounterClearPreemptionTimer | ( |  | ) |  | 
      
 
Clears the preemption timer. 
- Returns
- VOID 
   95{
   96    
   97    
   98    
  100}
#define NULL64_ZERO
Definition BasicTypes.h:52
UCHAR VmxVmwrite64(size_t Field, UINT64 FieldValue)
VMX VMWRITE instruction (64-bit)
Definition Vmx.c:122
 
 
◆ CounterEmulateRdpmc()
Emulate RDPMC. 
- Parameters
- 
  
    | VCpu | The virtual processor's state |  
 
- Returns
- VOID 
   63{
   66 
   67    EcxReg         = GuestRegs->
rcx & 0xffffffff;
 
   68    UINT64 Pmc     = __readpmc(EcxReg);
 
   69    GuestRegs->
rax = 0x00000000ffffffff & Pmc;
 
   70    GuestRegs->
rdx = 0x00000000ffffffff & (Pmc >> 32);
 
   71}
unsigned __int64 UINT64
Definition BasicTypes.h:21
unsigned int UINT32
Definition BasicTypes.h:48
GUEST_REGS * Regs
Definition State.h:305
Definition BasicTypes.h:70
UINT64 rax
Definition BasicTypes.h:75
UINT64 rcx
Definition BasicTypes.h:76
UINT64 rdx
Definition BasicTypes.h:77
 
 
◆ CounterEmulateRdtsc()
Emulate RDTSC. 
- Parameters
- 
  
    | VCpu | The virtual processor's state |  
 
- Returns
- VOID 
   22{
   23    
   24    
   25    
   26    
   27    
   28    
   31 
   32    GuestRegs->
rax = 0x00000000ffffffff & Tsc;
 
   33    GuestRegs->
rdx = 0x00000000ffffffff & (Tsc >> 32);
 
   34}
 
 
◆ CounterEmulateRdtscp()
Emulate RDTSCP. 
- Parameters
- 
  
    | VCpu | The virtual processor's state |  
 
- Returns
- VOID 
   44{
   46    UINT64      Tsc       = __rdtscp(&Aux);
 
   48 
   49    GuestRegs->
rax = 0x00000000ffffffff & Tsc;
 
   50    GuestRegs->
rdx = 0x00000000ffffffff & (Tsc >> 32);
 
   51 
   52    GuestRegs->
rcx = 0x00000000ffffffff & Aux;
 
   53}
 
 
◆ CounterSetPreemptionTimer()
      
        
          | VOID CounterSetPreemptionTimer | ( | UINT32 | TimerValue | ) |  | 
      
 
Set the timer value for preemption timer. 
- Parameters
- 
  
    | TimerValue | Value of the timer |  
 
- Returns
- VOID 
   81{
   82    
   83    
   84    
   85    VmxVmwrite64(VMCS_GUEST_VMX_PREEMPTION_TIMER_VALUE, TimerValue);
 
   86}