1
0
mirror of https://github.com/momo5502/hypervisor.git synced 2025-07-03 17:51:52 +00:00

Support global constructors/destructors

This commit is contained in:
Maurice Heumann
2022-12-25 18:00:21 +01:00
parent 6f7f0f74c4
commit 06db3371ad
4 changed files with 138 additions and 1 deletions

View File

@ -24,7 +24,6 @@ public:
~global_driver()
{
debug_log("Unloading driver\n");
this->hypervisor_.disable_all_ept_hooks();
}
global_driver(global_driver&&) noexcept = delete;
@ -70,7 +69,10 @@ _Function_class_(DRIVER_UNLOAD) void unload(const PDRIVER_OBJECT driver_object)
{
global_driver_instance->pre_destroy(driver_object);
delete global_driver_instance;
global_driver_instance = nullptr;
}
globals::run_destructors();
}
catch (std::exception& e)
{
@ -87,6 +89,7 @@ extern "C" NTSTATUS DriverEntry(const PDRIVER_OBJECT driver_object, PUNICODE_STR
try
{
driver_object->DriverUnload = unload;
globals::run_constructors();
global_driver_instance = new global_driver(driver_object);
}
catch (std::exception& e)