Skip to content

Instantly share code, notes, and snippets.

@therathatter
therathatter / Suspend Linux program at start with LD_PRELOAD
Created May 31, 2024 23:51
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"));
@therathatter
therathatter / fps-limit.c
Created June 18, 2022 06:03
Pump It Up 60 FPS locker
#include <dlfcn.h>
#include <GL/glx.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <unistd.h>
#include <sched.h>