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:
@ -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();
|
||||
|
Reference in New Issue
Block a user