diff --git a/bluepill.vcxproj b/bluepill.vcxproj
index e716e20..9dc78fe 100644
--- a/bluepill.vcxproj
+++ b/bluepill.vcxproj
@@ -85,6 +85,7 @@
+
@@ -93,6 +94,7 @@
+
@@ -102,6 +104,7 @@
+
diff --git a/bluepill.vcxproj.filters b/bluepill.vcxproj.filters
index cab2d58..f4b14c8 100644
--- a/bluepill.vcxproj.filters
+++ b/bluepill.vcxproj.filters
@@ -32,6 +32,9 @@
Source Files
+
+ Source Files
+
@@ -58,6 +61,9 @@
Header Files
+
+ Header Files
+
@@ -66,5 +72,8 @@
Source Files
+
+ Source Files
+
\ No newline at end of file
diff --git a/hv_types.hpp b/hv_types.hpp
index c3e1edb..6baf6dd 100644
--- a/hv_types.hpp
+++ b/hv_types.hpp
@@ -79,6 +79,35 @@ namespace hv
};
};
+ typedef union _idt_entry_t
+ {
+ u128 flags;
+ struct
+ {
+ u64 offset_low : 16;
+ u64 segment_selector : 16;
+ u64 reserved_0 : 8;
+ u64 gate_type : 4;
+ u64 storage_segment : 1;
+ u64 dpl : 2;
+ u64 present : 1;
+ u64 offset_middle : 16;
+ u64 offset_high : 32;
+ u64 reserved_1 : 32;
+ };
+ } idt_entry_t, *pidt_entry_t;
+
+ union idt_addr_t
+ {
+ u64 addr;
+ struct
+ {
+ u64 offset_low : 16;
+ u64 offset_middle : 16;
+ u64 offset_high : 32;
+ };
+ };
+
union ia32_efer_t
{
unsigned __int64 control;
diff --git a/idt.cpp b/idt.cpp
new file mode 100644
index 0000000..a54bf22
--- /dev/null
+++ b/idt.cpp
@@ -0,0 +1,20 @@
+#include "idt.hpp"
+
+namespace idt
+{
+ auto create_entry(void* address) -> hv::idt_entry_t
+ {
+ hv::idt_addr_t idt_addr{ (u64) address };
+ hv::idt_entry_t result{};
+
+ result.dpl = 0;
+ result.storage_segment = 0;
+ result.segment_selector = readcs();
+ result.gate_type = SEGMENT_DESCRIPTOR_TYPE_INTERRUPT_GATE;
+ result.present = 1;
+ result.offset_high = idt_addr.offset_high;
+ result.offset_middle = idt_addr.offset_middle;
+ result.offset_low = idt_addr.offset_low;
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/idt.hpp b/idt.hpp
new file mode 100644
index 0000000..b4a1575
--- /dev/null
+++ b/idt.hpp
@@ -0,0 +1,10 @@
+#pragma once
+#include "hv_types.hpp"
+#include "segment_intrin.h"
+#pragma section(".idt", read, write)
+
+namespace idt
+{
+ __declspec(allocate(".idt")) inline hv::idt_entry_t table[256];
+ auto create_entry(void* address) -> hv::idt_entry_t;
+}
\ No newline at end of file
diff --git a/idt_handler.asm b/idt_handler.asm
new file mode 100644
index 0000000..e69de29
diff --git a/mm.hpp b/mm.hpp
index c12bb4c..b117685 100644
--- a/mm.hpp
+++ b/mm.hpp
@@ -1,7 +1,5 @@
#pragma once
#include "hv_types.hpp"
-
-// the pml4 itself is inside of the HV...
#pragma section(".pml4", read, write)
namespace mm