Rosalink usage
Here's a c++ file that you can compile as a shared object and
inject into the test program to force it to execute the
HookFunction function whenever the programs function at the
provided address is called
Just make sure to replace the hookTarget offset with the target
function ones and that it has the same parameters
Windows and cross compiling version example coming soon...
#include <stdio.h>
#include <unistd.h>
#include <fstream>
#include <iostream>
#include <string>
#include <thread>
#include "rosalink.h"
void HookFunction() {
printf("Hello from the hook :)\n");
}
static void Attach() {
// Get the base address of the executible we're injecting into
std::ifstream file("/proc/self/maps");
std::string line;
std::getline(file, line);
auto pos = line.find("-");
auto truncated = line.substr(0, pos);
auto base = std::stoul(truncated, nullptr, 16);
// set the hook target to the address
void* hookTarget = base + 0x1189;
// Initalize and install our hook
printf("RosaLink - Installing hook\n");
LinkHook testFunctionHook(hookTarget, (void*)HookFunction);
}
int __attribute__((constructor)) Entry() {
std::thread mainThread(Attach);
mainThread.detach();
return 0;
}