diff --git a/driver/driver.c b/driver/driver.c
index 278b7fd..39cedd4 100644
--- a/driver/driver.c
+++ b/driver/driver.c
@@ -4,6 +4,9 @@
#include "ioctl.h"
#include "callbacks.h"
+#include "hv.h"
+
+
PVOID callback_registration_handle;
LONG protected_process_id;
diff --git a/driver/driver.vcxproj b/driver/driver.vcxproj
index 791c378..4ccb1fc 100644
--- a/driver/driver.vcxproj
+++ b/driver/driver.vcxproj
@@ -127,6 +127,7 @@
+
@@ -136,6 +137,7 @@
+
diff --git a/driver/driver.vcxproj.filters b/driver/driver.vcxproj.filters
index 0d49a77..1cc244a 100644
--- a/driver/driver.vcxproj.filters
+++ b/driver/driver.vcxproj.filters
@@ -42,6 +42,9 @@
Source Files
+
+ Source Files
+
@@ -65,5 +68,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/driver/hv.c b/driver/hv.c
new file mode 100644
index 0000000..793662a
--- /dev/null
+++ b/driver/hv.c
@@ -0,0 +1,43 @@
+#include "hv.h"
+
+#include
+
+#include "common.h"
+
+#define TOTAL_ITERATION_COUNT 20
+
+#define IA32_APERF_MSR 0x000000E8
+
+/*
+* 1. Bind thread to a single core
+* 2. Raise the IRQL to HIGH_LEVEL
+* 3. disable interrupts
+*/
+VOID APERFMsrTimingCheck()
+{
+ ULONG64 old_irql;
+ INT cpuid_result[ 4 ];
+
+ old_irql = __readcr8();
+
+ __writecr8( HIGH_LEVEL );
+
+ _disable();
+
+ UINT64 aperf_before = __readmsr( IA32_APERF_MSR ) << 32;
+
+ __cpuid( cpuid_result, 1 );
+
+ UINT64 aperf_after = __readmsr( IA32_APERF_MSR ) << 32;
+
+ _enable();
+
+ __writecr8( old_irql );
+
+ UINT64 aperf_delta = aperf_after - aperf_before;
+
+ _enable();
+
+ DEBUG_LOG( "delta: %llx", aperf_delta );
+
+}
\ No newline at end of file
diff --git a/driver/hv.h b/driver/hv.h
new file mode 100644
index 0000000..e30ae70
--- /dev/null
+++ b/driver/hv.h
@@ -0,0 +1,8 @@
+#ifndef HV_H
+#define HV_H
+
+#include
+
+VOID APERFMsrTimingCheck();
+
+#endif
\ No newline at end of file
diff --git a/driver/ioctl.c b/driver/ioctl.c
index f1fa2bb..86bd574 100644
--- a/driver/ioctl.c
+++ b/driver/ioctl.c
@@ -7,6 +7,8 @@
#include "driver.h"
#include "callbacks.h"
+#include "hv.h"
+
NTSTATUS DeviceControl(
_In_ PDRIVER_OBJECT DriverObject,
_In_ PIRP Irp
@@ -40,8 +42,6 @@ NTSTATUS DeviceControl(
* it will issue a bug check under windows driver verifier.
*/
- DEBUG_LOG( "irp addr: %p", ( void* )Irp );
-
status = PsCreateSystemThread(
&handle,
PROCESS_ALL_ACCESS,
@@ -98,6 +98,8 @@ NTSTATUS DeviceControl(
case IOCTL_HANDLE_REPORTS_IN_CALLBACK_QUEUE:
+ APERFMsrTimingCheck();
+
status = HandlePeriodicCallbackReportQueue(Irp);
if ( !NT_SUCCESS( status ) )