1
0
mirror of https://github.com/momo5502/hypervisor.git synced 2025-07-03 09:41:56 +00:00

Support multiple instances

This commit is contained in:
Maurice Heumann
2022-12-28 08:38:51 +01:00
parent 4cde82aae1
commit a3f67b20b8
3 changed files with 43 additions and 10 deletions

View File

@ -44,28 +44,48 @@ driver_device& get_driver_device()
static driver hypervisor{};
static driver_device device{};
if (device)
{
return device;
}
try
{
device = create_driver_device();
}
catch (...)
if (!hypervisor)
{
hypervisor = create_driver();
}
if (!device)
{
device = create_driver_device();
}
return device;
}
extern "C" __declspec(dllexport)
int hyperhook_initialize()
{
try
{
const auto& device = get_driver_device();
if (device)
{
return 1;
}
}
catch (const std::exception& e)
{
printf("%s\n", e.what());
}
return 0;
}
extern "C" __declspec(dllexport)
int hyperhook_write(const unsigned int process_id, const unsigned long long address, const void* data,
const unsigned long long size)
{
if (hyperhook_initialize() == 0)
{
return 0;
}
try
{
const auto& device = get_driver_device();