From a891f907f199fd203c1cfddd1b55a45cc2158460 Mon Sep 17 00:00:00 2001 From: _xeroxz Date: Mon, 15 Feb 2021 01:28:25 -0800 Subject: [PATCH] added div error ISR... --- drv_entry.cpp | 1 + idt.hpp | 1 + idt_handlers.asm | 2 ++ vmcs.cpp | 2 -- vmxlaunch.cpp | 4 ++++ 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drv_entry.cpp b/drv_entry.cpp index b5e1039..e91989e 100644 --- a/drv_entry.cpp +++ b/drv_entry.cpp @@ -49,6 +49,7 @@ auto drv_entry(PDRIVER_OBJECT driver_object, PUNICODE_STRING registry_path) -> N // change gp, pf, and de to vmxroot handlers... idt::table[general_protection] = idt::create_entry(hv::idt_addr_t{ __gp_handler }, idt::ist_idx::gp); idt::table[page_fault] = idt::create_entry(hv::idt_addr_t{ __pf_handler }, idt::ist_idx::pf); + idt::table[divide_error] = idt::create_entry(hv::idt_addr_t{ __de_handler }, idt::ist_idx::de); // used for SEH in vmxroot fault handler... idt::image_base = driver_object->DriverStart; diff --git a/idt.hpp b/idt.hpp index bfab4af..8b60ac1 100644 --- a/idt.hpp +++ b/idt.hpp @@ -6,6 +6,7 @@ #pragma section(".idt", read, write) extern "C" void __gp_handler(void); extern "C" void __pf_handler(void); +extern "C" void __de_handler(void); extern "C" void seh_handler(hv::pidt_regs_t regs); namespace idt diff --git a/idt_handlers.asm b/idt_handlers.asm index d9e86d6..8c5079e 100644 --- a/idt_handlers.asm +++ b/idt_handlers.asm @@ -1,6 +1,7 @@ extern seh_handler : proc .code +__de_handler proc __pf_handler proc __gp_handler proc push rax @@ -80,4 +81,5 @@ __gp_handler proc iretq __gp_handler endp __pf_handler endp +__de_handler endp end \ No newline at end of file diff --git a/vmcs.cpp b/vmcs.cpp index 39755cf..6bc8697 100644 --- a/vmcs.cpp +++ b/vmcs.cpp @@ -50,8 +50,6 @@ namespace vmcs tr.request_privilege_level = NULL; tr.table = NULL; __vmx_vmwrite(VMCS_HOST_TR_SELECTOR, tr.flags); - - } auto setup_guest() -> void diff --git a/vmxlaunch.cpp b/vmxlaunch.cpp index 873a42c..52f22f3 100644 --- a/vmxlaunch.cpp +++ b/vmxlaunch.cpp @@ -29,6 +29,10 @@ auto vmxlaunch::init_vmcs(cr3 cr3_value) -> void reinterpret_cast(ExAllocatePool(NonPagedPool, PAGE_SIZE * HOST_STACK_PAGES)) + (PAGE_SIZE * HOST_STACK_PAGES); + vcpu->tss.interrupt_stack_table[idt::ist_idx::de] = + reinterpret_cast(ExAllocatePool(NonPagedPool, + PAGE_SIZE * HOST_STACK_PAGES)) + (PAGE_SIZE * HOST_STACK_PAGES); + vcpu->gdt[segment_selector{ readtr() }.idx].base_address_upper = tss.upper; vcpu->gdt[segment_selector{ readtr() }.idx].base_address_high = tss.high; vcpu->gdt[segment_selector{ readtr() }.idx].base_address_middle = tss.middle;