mirror of
https://github.com/momo5502/hypervisor.git
synced 2025-04-19 21:52:55 +00:00
More cleanup
This commit is contained in:
parent
4f2b1e79a7
commit
d317a308c5
@ -7,6 +7,7 @@
|
||||
#include "memory.hpp"
|
||||
#include "thread.hpp"
|
||||
#include "assembly.hpp"
|
||||
#include "string.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -53,8 +54,8 @@ namespace
|
||||
special_registers.debug_control = __readmsr(IA32_DEBUGCTL);
|
||||
special_registers.msr_gs_base = __readmsr(IA32_GS_BASE);
|
||||
special_registers.kernel_dr7 = __readdr(7);
|
||||
_sgdt(&special_registers.gdtr.limit);
|
||||
__sidt(&special_registers.idtr.limit);
|
||||
_sgdt(&special_registers.gdtr);
|
||||
__sidt(&special_registers.idtr);
|
||||
_str(&special_registers.tr);
|
||||
_sldt(&special_registers.ldtr);
|
||||
}
|
||||
@ -68,8 +69,8 @@ namespace
|
||||
|
||||
void restore_descriptor_tables(vmx::launch_context& launch_context)
|
||||
{
|
||||
__lgdt(&launch_context.special_registers.gdtr.limit);
|
||||
__lidt(&launch_context.special_registers.idtr.limit);
|
||||
__lgdt(&launch_context.special_registers.gdtr);
|
||||
__lidt(&launch_context.special_registers.idtr);
|
||||
}
|
||||
|
||||
vmx::state* resolve_vm_state_from_context(CONTEXT& context)
|
||||
@ -1056,7 +1057,7 @@ INT32 ShvVmxLaunchOnVp(vmx::state* VpData)
|
||||
// back to the caller on failure.
|
||||
//
|
||||
auto error_code = launch_vmx();
|
||||
throw std::runtime_error("Failed to launch vmx");
|
||||
throw std::runtime_error(string::va("Failed to launch vmx: %X", error_code));
|
||||
}
|
||||
|
||||
|
||||
@ -1068,7 +1069,9 @@ void hypervisor::enable_core(const uint64_t system_directory_table_base)
|
||||
vm_state->launch_context.system_directory_table_base = system_directory_table_base;
|
||||
|
||||
capture_cpu_context(vm_state->launch_context);
|
||||
if ((__readeflags() & EFLAGS_ALIGNMENT_CHECK_FLAG_FLAG) == 0)
|
||||
|
||||
const rflags rflags{.flags = __readeflags()};
|
||||
if (!rflags.alignment_check_flag)
|
||||
{
|
||||
ShvVmxLaunchOnVp(vm_state);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "std_include.hpp"
|
||||
#include "irp.hpp"
|
||||
#include "finally.hpp"
|
||||
#include "logging.hpp"
|
||||
#include "exception.hpp"
|
||||
#include "string.hpp"
|
||||
#include "memory.hpp"
|
||||
|
||||
@ -68,7 +68,7 @@ namespace
|
||||
debug_log("Hello from the Driver!\n");
|
||||
break;
|
||||
case HOOK_DRV_IOCTL:
|
||||
apply_hook(static_cast<hook_request*>(irp_sp->Parameters.DeviceIoControl.Type3InputBuffer));
|
||||
//apply_hook(static_cast<hook_request*>(irp_sp->Parameters.DeviceIoControl.Type3InputBuffer));
|
||||
break;
|
||||
default:
|
||||
debug_log("Invalid IOCTL Code: 0x%X\n", ioctr_code);
|
||||
@ -128,12 +128,18 @@ irp::irp(const PDRIVER_OBJECT driver_object, const wchar_t* device_name, const w
|
||||
|
||||
irp::~irp()
|
||||
{
|
||||
PAGED_CODE()
|
||||
|
||||
if (this->device_object_)
|
||||
try
|
||||
{
|
||||
PAGED_CODE()
|
||||
|
||||
if (this->device_object_)
|
||||
{
|
||||
IoDeleteSymbolicLink(&this->dos_device_name_);
|
||||
IoDeleteDevice(this->device_object_);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
IoDeleteSymbolicLink(&this->dos_device_name_);
|
||||
IoDeleteDevice(this->device_object_);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user