mirror of
https://github.com/momo5502/hypervisor.git
synced 2025-04-18 21:22:54 +00:00
More cleanup and readme
This commit is contained in:
parent
1d25ce3a94
commit
c6b6e1eba9
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
||||
build/
|
||||
build/
|
||||
*.aps
|
12
README.md
12
README.md
@ -1 +1,11 @@
|
||||
# secret
|
||||
# secret
|
||||
|
||||
Hypervisor experiments.
|
||||
Nothing serious. Yet.
|
||||
|
||||
## Credits
|
||||
|
||||
<a href="https://github.com/ionescu007/SimpleVisor">SimpleVisor</a>
|
||||
<a href="https://github.com/Gbps/gbhv/tree/master/gbhv">gbhv</a>
|
||||
|
||||
<a href="https://www.flaticon.com/free-icon/cyber-security_2092663?related_id=2092663&origin=tag" title="cyber security icons">Icon</a>
|
@ -1,4 +1,3 @@
|
||||
add_subdirectory(shared)
|
||||
add_subdirectory(driver)
|
||||
add_subdirectory(driver_file)
|
||||
add_subdirectory(runner)
|
@ -28,3 +28,18 @@ target_link_libraries(driver
|
||||
ia32_doc
|
||||
shared
|
||||
)
|
||||
|
||||
################################################
|
||||
|
||||
set(DRIVER_FILE "$<TARGET_FILE:driver>")
|
||||
|
||||
file (GENERATE
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>/driver_file.h"
|
||||
CONTENT "#define DRIVER_FILE \"${DRIVER_FILE}\"\n"
|
||||
)
|
||||
|
||||
add_library(driver_file INTERFACE)
|
||||
|
||||
target_include_directories(driver_file INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>)
|
||||
|
||||
add_dependencies(driver_file driver)
|
||||
|
@ -9,6 +9,9 @@
|
||||
#include "assembly.hpp"
|
||||
#include "string.hpp"
|
||||
|
||||
#define DPL_USER 3
|
||||
#define DPL_SYSTEM 0
|
||||
|
||||
namespace
|
||||
{
|
||||
hypervisor* instance{nullptr};
|
||||
@ -163,7 +166,7 @@ bool hypervisor::install_ept_hook(const void* destination, const void* source, c
|
||||
vmx::ept_translation_hint* translation_hint)
|
||||
{
|
||||
volatile long failures = 0;
|
||||
thread::dispatch_on_all_cores([&]()
|
||||
thread::dispatch_on_all_cores([&]
|
||||
{
|
||||
if (!this->try_install_ept_hook_on_core(destination, source, length, translation_hint))
|
||||
{
|
||||
@ -176,7 +179,7 @@ bool hypervisor::install_ept_hook(const void* destination, const void* source, c
|
||||
|
||||
void hypervisor::disable_all_ept_hooks() const
|
||||
{
|
||||
thread::dispatch_on_all_cores([&]()
|
||||
thread::dispatch_on_all_cores([&]
|
||||
{
|
||||
auto* vm_state = this->get_current_vm_state();
|
||||
if (!vm_state)
|
||||
@ -203,7 +206,7 @@ void hypervisor::enable()
|
||||
const auto cr3 = __readcr3();
|
||||
|
||||
volatile long failures = 0;
|
||||
thread::dispatch_on_all_cores([&]()
|
||||
thread::dispatch_on_all_cores([&]
|
||||
{
|
||||
if (!this->try_enable_core(cr3))
|
||||
{
|
||||
@ -332,7 +335,8 @@ vmx::gdt_entry convert_gdt_entry(const uint64_t gdt_base, const uint16_t selecto
|
||||
return result;
|
||||
}
|
||||
|
||||
const auto* gdt_entry = reinterpret_cast<segment_descriptor_64*>(gdt_base + static_cast<uint64_t>(selector.index) * 8);
|
||||
const auto* gdt_entry = reinterpret_cast<segment_descriptor_64*>(gdt_base + static_cast<uint64_t>(selector.index) *
|
||||
8);
|
||||
|
||||
result.selector = selector;
|
||||
result.limit = __segmentlimit(selector.flags);
|
||||
@ -377,16 +381,13 @@ void vmx_handle_invd()
|
||||
__wbinvd();
|
||||
}
|
||||
|
||||
#define DPL_USER 3
|
||||
#define DPL_SYSTEM 0
|
||||
|
||||
void vmx_handle_cpuid(vmx::guest_context& guest_context)
|
||||
{
|
||||
INT32 cpu_info[4];
|
||||
|
||||
if ((guest_context.vp_regs->Rax == 0x41414141) &&
|
||||
(guest_context.vp_regs->Rcx == 0x42424242) &&
|
||||
((read_vmx(VMCS_GUEST_CS_SELECTOR) & SEGMENT_ACCESS_RIGHTS_DESCRIPTOR_PRIVILEGE_LEVEL_MASK) == DPL_SYSTEM))
|
||||
if (guest_context.vp_regs->Rax == 0x41414141 &&
|
||||
guest_context.vp_regs->Rcx == 0x42424242 &&
|
||||
(read_vmx(VMCS_GUEST_CS_SELECTOR) & SEGMENT_ACCESS_RIGHTS_DESCRIPTOR_PRIVILEGE_LEVEL_MASK) == DPL_SYSTEM)
|
||||
{
|
||||
guest_context.exit_vm = true;
|
||||
return;
|
||||
|
@ -1,12 +0,0 @@
|
||||
set(DRIVER_FILE "$<TARGET_FILE:driver>")
|
||||
|
||||
file (GENERATE
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>/driver_file.h"
|
||||
CONTENT "#define DRIVER_FILE \"${DRIVER_FILE}\"\n"
|
||||
)
|
||||
|
||||
add_library(driver_file INTERFACE)
|
||||
|
||||
target_include_directories(driver_file INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>)
|
||||
|
||||
add_dependencies(driver_file driver)
|
Loading…
x
Reference in New Issue
Block a user