mirror of
https://github.com/momo5502/hypervisor.git
synced 2025-04-19 05:32:55 +00:00
Fix formatting
This commit is contained in:
parent
90e2c262ad
commit
965dd3a5bc
10
.editorconfig
Normal file
10
.editorconfig
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[*.{cpp,hpp}]
|
||||||
|
end_of_line = crlf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
charset = utf-8
|
||||||
|
brace_style = next_line
|
||||||
|
namespace_indentation = all
|
||||||
|
cpp_indent_namespace_contents = true
|
@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "std_include.hpp"
|
#include "std_include.hpp"
|
||||||
|
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
void _sldt(uint16_t* ldtr);
|
void _sldt(uint16_t* ldtr);
|
||||||
void _ltr(uint16_t tr);
|
void _ltr(uint16_t tr);
|
||||||
void _str(uint16_t* tr);
|
void _str(uint16_t* tr);
|
||||||
@ -15,5 +15,4 @@ void __invept(size_t type, invept_descriptor* descriptor);
|
|||||||
[[ noreturn ]] void vm_launch();
|
[[ noreturn ]] void vm_launch();
|
||||||
[[ noreturn ]] void vm_exit();
|
[[ noreturn ]] void vm_exit();
|
||||||
[[ noreturn ]] void restore_context(CONTEXT* context);
|
[[ noreturn ]] void restore_context(CONTEXT* context);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,8 @@ namespace vmx
|
|||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
void install_hook(const void* destination, const void* source, size_t length, ept_translation_hint* translation_hint = nullptr);
|
void install_hook(const void* destination, const void* source, size_t length,
|
||||||
|
ept_translation_hint* translation_hint = nullptr);
|
||||||
void disable_all_hooks() const;
|
void disable_all_hooks() const;
|
||||||
|
|
||||||
void handle_violation(guest_context& guest_context) const;
|
void handle_violation(guest_context& guest_context) const;
|
||||||
@ -95,6 +96,7 @@ namespace vmx
|
|||||||
|
|
||||||
void split_large_page(uint64_t physical_address);
|
void split_large_page(uint64_t physical_address);
|
||||||
|
|
||||||
void install_page_hook(void* destination, const void* source, size_t length, ept_translation_hint* translation_hint = nullptr);
|
void install_page_hook(void* destination, const void* source, size_t length,
|
||||||
|
ept_translation_hint* translation_hint = nullptr);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,6 @@ void enter_root_mode_on_cpu(vmx::state& vm_state)
|
|||||||
|
|
||||||
if (__vmx_vmclear(&launch_context->vmcs_physical_address))
|
if (__vmx_vmclear(&launch_context->vmcs_physical_address))
|
||||||
{
|
{
|
||||||
|
|
||||||
throw std::runtime_error("Failed to clear vmcs");
|
throw std::runtime_error("Failed to clear vmcs");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@ public:
|
|||||||
|
|
||||||
bool is_enabled() const;
|
bool is_enabled() const;
|
||||||
|
|
||||||
bool install_ept_hook(const void* destination, const void* source, size_t length, vmx::ept_translation_hint* translation_hint = nullptr);
|
bool install_ept_hook(const void* destination, const void* source, size_t length,
|
||||||
|
vmx::ept_translation_hint* translation_hint = nullptr);
|
||||||
void disable_all_ept_hooks() const;
|
void disable_all_ept_hooks() const;
|
||||||
|
|
||||||
static hypervisor* get_instance();
|
static hypervisor* get_instance();
|
||||||
@ -35,8 +36,10 @@ private:
|
|||||||
void allocate_vm_states();
|
void allocate_vm_states();
|
||||||
void free_vm_states();
|
void free_vm_states();
|
||||||
|
|
||||||
bool try_install_ept_hook_on_core(const void* destination, const void* source, size_t length, vmx::ept_translation_hint* translation_hint = nullptr);
|
bool try_install_ept_hook_on_core(const void* destination, const void* source, size_t length,
|
||||||
void install_ept_hook_on_core(const void* destination, const void* source, size_t length, vmx::ept_translation_hint* translation_hint = nullptr);
|
vmx::ept_translation_hint* translation_hint = nullptr);
|
||||||
|
void install_ept_hook_on_core(const void* destination, const void* source, size_t length,
|
||||||
|
vmx::ept_translation_hint* translation_hint = nullptr);
|
||||||
|
|
||||||
vmx::state* get_current_vm_state() const;
|
vmx::state* get_current_vm_state() const;
|
||||||
};
|
};
|
||||||
|
@ -120,7 +120,8 @@ namespace memory
|
|||||||
|
|
||||||
void assert_readability(const void* address, const size_t length, const uint64_t alignment)
|
void assert_readability(const void* address, const size_t length, const uint64_t alignment)
|
||||||
{
|
{
|
||||||
if(!prope_for_read(address, length, alignment)) {
|
if (!prope_for_read(address, length, alignment))
|
||||||
|
{
|
||||||
throw std::runtime_error("Access violation");
|
throw std::runtime_error("Access violation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +141,8 @@ namespace memory
|
|||||||
|
|
||||||
void assert_writability(const void* address, const size_t length, const uint64_t alignment)
|
void assert_writability(const void* address, const size_t length, const uint64_t alignment)
|
||||||
{
|
{
|
||||||
if (!prope_for_write(address, length, alignment)) {
|
if (!prope_for_write(address, length, alignment))
|
||||||
|
{
|
||||||
throw std::runtime_error("Access violation");
|
throw std::runtime_error("Access violation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
@ -52,6 +52,7 @@ void sleep_callback::dispatcher(const type type) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
_Function_class_(CALLBACK_FUNCTION)
|
_Function_class_(CALLBACK_FUNCTION)
|
||||||
|
|
||||||
void sleep_callback::static_callback(void* context, void* argument1, void* argument2)
|
void sleep_callback::static_callback(void* context, void* argument1, void* argument2)
|
||||||
{
|
{
|
||||||
if (!context || argument1 != reinterpret_cast<PVOID>(PO_CB_SYSTEM_STATE_LOCK))
|
if (!context || argument1 != reinterpret_cast<PVOID>(PO_CB_SYSTEM_STATE_LOCK))
|
||||||
|
@ -37,7 +37,6 @@ namespace std
|
|||||||
|
|
||||||
// TEMPLATE FUNCTION forward
|
// TEMPLATE FUNCTION forward
|
||||||
template <class _Ty>
|
template <class _Ty>
|
||||||
inline
|
|
||||||
constexpr _Ty&& forward(
|
constexpr _Ty&& forward(
|
||||||
typename remove_reference<_Ty>::type& _Arg)
|
typename remove_reference<_Ty>::type& _Arg)
|
||||||
{
|
{
|
||||||
@ -46,7 +45,6 @@ namespace std
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class _Ty>
|
template <class _Ty>
|
||||||
inline
|
|
||||||
constexpr _Ty&& forward(
|
constexpr _Ty&& forward(
|
||||||
typename remove_reference<_Ty>::type&& _Arg)
|
typename remove_reference<_Ty>::type&& _Arg)
|
||||||
{
|
{
|
||||||
|
@ -73,7 +73,7 @@ namespace std
|
|||||||
static constexpr auto is_array_type = is_array<T>::value;
|
static constexpr auto is_array_type = is_array<T>::value;
|
||||||
T* pointer_{nullptr};
|
T* pointer_{nullptr};
|
||||||
|
|
||||||
void delete_pointer()
|
void delete_pointer() const
|
||||||
{
|
{
|
||||||
if (is_array_type)
|
if (is_array_type)
|
||||||
{
|
{
|
||||||
|
@ -9,8 +9,7 @@ driver_device::driver_device(const std::string& driver_device)
|
|||||||
nullptr,
|
nullptr,
|
||||||
OPEN_EXISTING,
|
OPEN_EXISTING,
|
||||||
NULL,
|
NULL,
|
||||||
nullptr
|
nullptr);
|
||||||
);
|
|
||||||
|
|
||||||
if (!this->device_)
|
if (!this->device_)
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
|
|
||||||
#include "std_include.hpp"
|
#include "std_include.hpp"
|
||||||
#include "finally.hpp"
|
|
||||||
#include "driver.hpp"
|
#include "driver.hpp"
|
||||||
#include "driver_device.hpp"
|
#include "driver_device.hpp"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user