#pragma once #include // Get library name and base address that contains the function uintptr_t get_function_lib(uintptr_t addr, char *lib); // Get library base address with name uintptr_t get_remote_lib(int pid, const char *lib); // Write bytes to the remote process at addr bool _remote_write(int pid, uintptr_t addr, const void *buf, size_t len); #define remote_write(...) _remote_write(pid, __VA_ARGS__) // Read bytes from the remote process at addr bool _remote_read(int pid, uintptr_t addr, void *buf, size_t len); #define remote_read(...) _remote_read(pid, __VA_ARGS__) // Call a remote function // Arguments are expected to be only integer-like or pointer types // as other more complex C ABIs are not implemented. uintptr_t remote_call_vararg(int pid, uintptr_t addr, int nargs, ...); // C++ wrapper for auto argument counting and casting function pointers template static uintptr_t _remote_call(int pid, FuncPtr sym, Args && ...args) { auto addr = reinterpret_cast(sym); return remote_call_vararg(pid, addr, sizeof...(args), std::forward(args)...); } #define remote_call(...) _remote_call(pid, __VA_ARGS__)