Create include file

This commit is contained in:
Maurice Heumann 2022-12-28 09:19:39 +01:00
parent 8b4c277f11
commit 083e67e1d7
11 changed files with 74 additions and 76 deletions

18
src/include/hyperhook.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef EXTERN_C
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else
#define EXTERN_C
#endif
#endif
#ifndef DLL_IMPORT
#define DLL_IMPORT __declspec(dllimport)
#endif
EXTERN_C DLL_IMPORT
int hyperhook_initialize();
EXTERN_C DLL_IMPORT
int hyperhook_write(unsigned int process_id, unsigned long long address, const void* data,
unsigned long long size);

View File

@ -15,6 +15,10 @@ target_link_libraries(library PRIVATE
driver_file
)
target_include_directories(library PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../include
)
set_source_files_properties(resource.rc PROPERTIES LANGUAGE RC)
target_sources(library PRIVATE
resource.rc

View File

@ -1,20 +1,21 @@
#include "std_include.hpp"
#include <iostream>
#include <conio.h>
#include <set>
#include "driver.hpp"
#include "driver_device.hpp"
#include <driver_file.h>
#include <irp_data.hpp>
#include "resource.hpp"
#include "utils/io.hpp"
void patch_data(const driver_device& driver_device, const uint32_t pid, const uint64_t address, const uint8_t* buffer,
const size_t length)
#define DLL_IMPORT __declspec(dllexport)
#include <hyperhook.h>
namespace
{
void patch_data(const driver_device& driver_device, const uint32_t pid, const uint64_t address,
const uint8_t* buffer,
const size_t length)
{
hook_request hook_request{};
hook_request.process_id = pid;
hook_request.target_address = reinterpret_cast<void*>(address);
@ -27,20 +28,20 @@ void patch_data(const driver_device& driver_device, const uint32_t pid, const ui
reinterpret_cast<uint8_t*>(&hook_request) + sizeof(hook_request));
(void)driver_device.send(HOOK_DRV_IOCTL, input);
}
}
driver_device create_driver_device()
{
driver_device create_driver_device()
{
return driver_device{R"(\\.\HyperHook)"};
}
}
driver create_driver()
{
driver create_driver()
{
return driver{std::filesystem::absolute(DRIVER_NAME), "HyperHook"};
}
}
driver_device& get_driver_device()
{
driver_device& get_driver_device()
{
static driver hypervisor{};
static driver_device device{};
@ -55,9 +56,9 @@ driver_device& get_driver_device()
}
return device;
}
}
extern "C" __declspec(dllexport)
int hyperhook_initialize()
{
try
@ -76,8 +77,6 @@ int hyperhook_initialize()
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)
{

View File

@ -1 +0,0 @@
#pragma once

View File

@ -8,7 +8,6 @@
// Generated from the TEXTINCLUDE 2 resource.
//
#include "windows.h"
#include "resource.hpp"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

View File

@ -5,10 +5,13 @@
#include <mutex>
#include <filesystem>
#include <functional>
#include <iostream>
#include <set>
#include <Windows.h>
#include <Shlwapi.h>
#include <ShlObj.h>
#include <Psapi.h>
#include <conio.h>
#pragma comment(lib, "Shlwapi.lib")

View File

@ -6,10 +6,6 @@ add_executable(runner #WIN32
${runner_headers}
)
target_precompile_headers(runner PRIVATE
std_include.hpp
)
set_property(TARGET runner APPEND_STRING PROPERTY LINK_FLAGS " /MANIFESTUAC:\"level='requireAdministrator'\"")
target_link_libraries(runner PRIVATE

View File

@ -1,17 +1,13 @@
#include "std_include.hpp"
#include <iostream>
#include <vector>
#include <conio.h>
#include <set>
#include <optional>
#include <stdexcept>
#include "resource.hpp"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
extern "C" __declspec(dllimport)
int hyperhook_initialize();
#include <hyperhook.h>
extern "C" __declspec(dllimport)
int hyperhook_write(unsigned int process_id, unsigned long long address, const void* data,
unsigned long long size);
bool patch_data(const uint32_t process_id, const uint64_t address, const void* buffer,
const size_t length)

View File

@ -1 +0,0 @@
#pragma once

View File

@ -8,7 +8,6 @@
// Generated from the TEXTINCLUDE 2 resource.
//
#include "windows.h"
#include "resource.hpp"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

View File

@ -1,14 +0,0 @@
#pragma once
#include <string>
#include <vector>
#include <mutex>
#include <filesystem>
#include <functional>
#include <Windows.h>
#include <Shlwapi.h>
#include <ShlObj.h>
#include <Psapi.h>
#pragma comment(lib, "Shlwapi.lib")