mirror of
https://github.com/momo5502/hypervisor.git
synced 2025-04-19 21:52:55 +00:00
Library support
This commit is contained in:
parent
ab6e9808b5
commit
6730723d36
@ -86,6 +86,7 @@ extern "C" NTSTATUS DriverEntry(const PDRIVER_OBJECT driver_object, PUNICODE_STR
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
debug_log("Starting driver...");
|
||||||
driver_object->DriverUnload = unload;
|
driver_object->DriverUnload = unload;
|
||||||
global_driver_instance = new global_driver(driver_object);
|
global_driver_instance = new global_driver(driver_object);
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
file(GLOB_RECURSE runner_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
file(GLOB_RECURSE runner_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||||
file(GLOB_RECURSE runner_headers ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
|
file(GLOB_RECURSE runner_headers ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
|
||||||
|
|
||||||
add_executable(runner #WIN32
|
add_library(hyperhook SHARED #WIN32
|
||||||
${runner_sources}
|
${runner_sources}
|
||||||
${runner_headers}
|
${runner_headers}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_precompile_headers(runner
|
target_precompile_headers(hyperhook
|
||||||
PRIVATE std_include.hpp
|
PRIVATE std_include.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set_property(TARGET runner APPEND_STRING PROPERTY LINK_FLAGS " /MANIFESTUAC:\"level='requireAdministrator'\"")
|
set_property(TARGET hyperhook APPEND_STRING PROPERTY LINK_FLAGS " /MANIFESTUAC:\"level='requireAdministrator'\"")
|
||||||
|
|
||||||
target_link_libraries(runner
|
target_link_libraries(hyperhook
|
||||||
shared
|
shared
|
||||||
driver_file
|
driver_file
|
||||||
)
|
)
|
||||||
|
|
||||||
set_source_files_properties(resource.rc PROPERTIES LANGUAGE RC)
|
set_source_files_properties(resource.rc PROPERTIES LANGUAGE RC)
|
||||||
target_sources(runner PRIVATE
|
target_sources(hyperhook PRIVATE
|
||||||
resource.rc
|
resource.rc
|
||||||
)
|
)
|
||||||
|
@ -333,7 +333,7 @@ void unsafe_main(const int /*argc*/, char* /*argv*/[])
|
|||||||
(void)_getch();*/
|
(void)_getch();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(const int argc, char* argv[])
|
int _main(const int argc, char* argv[])
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -354,7 +354,7 @@ int main(const int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int __stdcall WinMain(HINSTANCE, HINSTANCE, char*, int)
|
int __stdcall _WinMain(HINSTANCE, HINSTANCE, char*, int)
|
||||||
{
|
{
|
||||||
AllocConsole();
|
AllocConsole();
|
||||||
AttachConsole(GetCurrentProcessId());
|
AttachConsole(GetCurrentProcessId());
|
||||||
@ -364,5 +364,19 @@ int __stdcall WinMain(HINSTANCE, HINSTANCE, char*, int)
|
|||||||
freopen_s(&fp, "conout$", "w", stdout);
|
freopen_s(&fp, "conout$", "w", stdout);
|
||||||
freopen_s(&fp, "conout$", "w", stderr);
|
freopen_s(&fp, "conout$", "w", stderr);
|
||||||
|
|
||||||
return main(__argc, __argv);
|
return _main(__argc, __argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
const driver_device& get_driver_device()
|
||||||
|
{
|
||||||
|
static const auto driver_file = extract_driver();
|
||||||
|
|
||||||
|
static driver driver{driver_file, "MomoLul"};
|
||||||
|
static const driver_device driver_device{R"(\\.\HelloDev)"};
|
||||||
|
return driver_device;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" __declspec(dllexport) void hyperhook_patch_data(const uint32_t pid, const uint64_t address, const void* data, const size_t length)
|
||||||
|
{
|
||||||
|
patch_data(get_driver_device(), pid, address, static_cast<const uint8_t*>(data), length);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user