mirror of
https://github.com/momo5502/hypervisor.git
synced 2025-06-02 09:27:43 +00:00
More cleanup
This commit is contained in:
parent
4cbbaed72f
commit
f8f636a829
@ -7,8 +7,8 @@
|
|||||||
#include "globals.hpp"
|
#include "globals.hpp"
|
||||||
#include "process_callback.hpp"
|
#include "process_callback.hpp"
|
||||||
|
|
||||||
#define DOS_DEV_NAME L"\\DosDevices\\HelloDev"
|
#define DOS_DEV_NAME L"\\DosDevices\\HyperHook"
|
||||||
#define DEV_NAME L"\\Device\\HelloDev"
|
#define DEV_NAME L"\\Device\\HyperHook"
|
||||||
|
|
||||||
class global_driver
|
class global_driver
|
||||||
{
|
{
|
||||||
|
@ -123,7 +123,7 @@ namespace
|
|||||||
|
|
||||||
void watch_regions(const watch_request& watch_request)
|
void watch_regions(const watch_request& watch_request)
|
||||||
{
|
{
|
||||||
auto* hypervisor = hypervisor::get_instance();
|
const auto* hypervisor = hypervisor::get_instance();
|
||||||
if (!hypervisor)
|
if (!hypervisor)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Hypervisor not installed");
|
throw std::runtime_error("Hypervisor not installed");
|
||||||
|
@ -213,86 +213,21 @@ void report_records(const std::atomic_bool& flag, const driver_device& driver_de
|
|||||||
|
|
||||||
void unsafe_main(const int /*argc*/, char* /*argv*/[])
|
void unsafe_main(const int /*argc*/, char* /*argv*/[])
|
||||||
{
|
{
|
||||||
//{
|
const auto driver_file = extract_driver();
|
||||||
const auto driver_file = extract_driver();
|
|
||||||
|
|
||||||
driver driver{driver_file, "MomoLul"};
|
driver driver{driver_file, "HyperHook"};
|
||||||
const driver_device driver_device{R"(\\.\HelloDev)"};
|
const driver_device driver_device{R"(\\.\HyperHook)"};
|
||||||
|
|
||||||
const auto pid = get_process_id();
|
const auto pid = get_process_id();
|
||||||
|
|
||||||
printf("Opening process...\n");
|
printf("Opening process...\n");
|
||||||
auto proc = process::open(pid, PROCESS_QUERY_INFORMATION | PROCESS_VM_READ);
|
auto proc = process::open(pid, PROCESS_QUERY_INFORMATION | PROCESS_VM_READ);
|
||||||
if (!proc)
|
if (!proc)
|
||||||
{
|
{
|
||||||
printf("Failed to open process...\n");
|
printf("Failed to open process...\n");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/*printf("Reading modules...\n");
|
|
||||||
const auto modules = process::get_modules(proc);
|
|
||||||
printf("Found %zu modules:\n", modules.size());
|
|
||||||
|
|
||||||
std::vector<std::string> module_files{};
|
|
||||||
module_files.reserve(modules.size());
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
for (const auto& module : modules)
|
|
||||||
{
|
|
||||||
auto name = process::get_module_filename(proc, module);
|
|
||||||
printf("(%i)\t%p: %s\n", i++, static_cast<void*>(module), name.data());
|
|
||||||
module_files.emplace_back(std::move(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't need this anymore
|
|
||||||
proc = {};
|
|
||||||
|
|
||||||
std::string module_str{};
|
|
||||||
printf("\nPlease enter the module number: ");
|
|
||||||
std::getline(std::cin, module_str);
|
|
||||||
|
|
||||||
const auto module_num = atoi(module_str.data());
|
|
||||||
|
|
||||||
if (module_num < 0 || static_cast<size_t>(module_num) >= modules.size())
|
|
||||||
{
|
|
||||||
printf("Invalid module num\n");
|
|
||||||
_getch();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto target_module = modules[module_num];
|
|
||||||
const auto module_base = reinterpret_cast<uint8_t*>(target_module);
|
|
||||||
const auto& file = module_files[module_num];
|
|
||||||
printf("Analyzing %s...\n", file.data());
|
|
||||||
const auto regions = find_executable_regions(file);
|
|
||||||
|
|
||||||
printf("Executable regions:\n");
|
|
||||||
for (const auto& region : regions)
|
|
||||||
{
|
|
||||||
printf("%p - %zu\n", module_base + region.first, region.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
watch_regions(driver_device, pid, target_module, regions);
|
|
||||||
|
|
||||||
std::atomic_bool terminate{false};
|
|
||||||
std::thread t([&]()
|
|
||||||
{
|
|
||||||
printf("\nWatching access:\n");
|
|
||||||
report_records(terminate, driver_device, pid, target_module, regions);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
_getch();
|
|
||||||
|
|
||||||
terminate = true;
|
|
||||||
t.join();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\nWatching stopped.\n");
|
|
||||||
_getch();
|
|
||||||
|
|
||||||
return;*/
|
|
||||||
|
|
||||||
|
|
||||||
// IW5
|
// IW5
|
||||||
insert_nop(driver_device, pid, 0x4488A8, 2); // Force calling CG_DrawFriendOrFoeTargetBoxes
|
insert_nop(driver_device, pid, 0x4488A8, 2); // Force calling CG_DrawFriendOrFoeTargetBoxes
|
||||||
@ -312,18 +247,6 @@ void unsafe_main(const int /*argc*/, char* /*argv*/[])
|
|||||||
patch_data(driver_device, pid, 0x443A2A, data3, sizeof(data3));
|
patch_data(driver_device, pid, 0x443A2A, data3, sizeof(data3));
|
||||||
patch_data(driver_device, pid, 0x443978, data3, sizeof(data3));
|
patch_data(driver_device, pid, 0x443978, data3, sizeof(data3));
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
insert_nop(driver_device, pid, 0x441D5A, 6);
|
|
||||||
insert_nop(driver_device, pid, 0x525104, 2);
|
|
||||||
insert_nop(driver_device, pid, 0x525121, 2);
|
|
||||||
|
|
||||||
constexpr uint8_t data3[] = {0xEB};
|
|
||||||
patch_data(driver_device, pid, 0x525087, data3, sizeof(data3));
|
|
||||||
patch_data(driver_device, pid, 0x524E7F, data3, sizeof(data3));
|
|
||||||
patch_data(driver_device, pid, 0x52512C, data3, sizeof(data3));
|
|
||||||
*/
|
|
||||||
|
|
||||||
printf("Press any key to disable all hooks!\n");
|
printf("Press any key to disable all hooks!\n");
|
||||||
(void)_getch();
|
(void)_getch();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user