Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save therathatter/ef33e05b534489e1939042854e134f87 to your computer and use it in GitHub Desktop.
Save therathatter/ef33e05b534489e1939042854e134f87 to your computer and use it in GitHub Desktop.
g++ suspend.cpp -fPIC -m32 -shared -dl -o suspend.so
#include <stdio.h>
#include <dlfcn.h>
#define VISIBLE __attribute__((visibility("default")))
using void_fn = void(*)(void);
using main_fn = int(*)(int, char**, char**);
extern "C" VISIBLE int __libc_start_main(main_fn main, int argc, char** argv, main_fn init, void_fn fini, void_fn rtld_fini, void* stack_end) {
static auto o_libc_start_main = reinterpret_cast<decltype(&__libc_start_main)>(dlsym(RTLD_NEXT, "__libc_start_main"));
printf("Press ENTER to start the program.\n");
getchar();
return o_libc_start_main(main, argc, argv, init, fini, rtld_fini, stack_end);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment