diff --git a/src/impl/dispatcher.cpp b/src/impl/dispatcher.cpp new file mode 100644 index 0000000..b12e09b --- /dev/null +++ b/src/impl/dispatcher.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include + +#include +#include + +namespace fxn +{ + void NativeDispatcher(fxn::NativeContext* context, std::uint64_t nativeHash) + { + + } + + void* CreateNativeDispatcher(std::uint64_t nativeHash) + { + constexpr auto STUB_SIZE = 22; + constexpr auto STUB_BYTES = std::array + { + 0x48, 0xB8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // mov rax, + 0x48, 0xBA, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // mov rdx, + 0xFF, 0xE0 // jmp rax + }; + + auto stub = VirtualAllocEx(GetCurrentProcess(), nullptr, STUB_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); + if (!stub) + { + return nullptr; + } + + auto stubBytes = STUB_BYTES; + auto dispatcherAddress = reinterpret_cast(&NativeDispatcher); + std::memcpy(&stubBytes[2], &dispatcherAddress, sizeof(std::uintptr_t)); + std::memcpy(&stubBytes[12], &nativeHash, sizeof(std::uintptr_t)); + + std::memcpy(stub, stubBytes.data(), STUB_SIZE); + return stub; + } +} \ No newline at end of file