The library is developed by Vlad Kirichok, Ivan Kovalyonok, Artem Smirnov as their group project at Faculty of Computer Science of Higher School of Economics. The supervisor is Andrei Tatarnikov.
The library patches executable file to inject code that will be executed before the main function.
For example, consider the "Hello World" program below.
It defines the func
function and has its call inserted in the main
function.
The injection library provides an API to construct functions like func
and to inject them in the specified executable.
#include <stdio.h>
/**
* Type for a pointer to a functon that prints messages.
*/
typedef int (* fptr_t)(const char *);
/**
* Example of an injected function:
* prints the specified message woth the specified function
* the specified number of times.
*
* @param print the print function
* @param message the messge to be printed
* @param count the count of times to print the message
*/
void func(const fptr_t print, const char* message, const int count) {
for (int i = 0; i < count; ++i) {
print(message);
}
}
/**
* Example: entry point of a program to be patched.
*
* @return exit code
*/
int main() {
func(puts, "Injected message!", 3);
puts("Hello, World!");
return 0;
}