Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
LD_PRELOAD example for the closed-source fglrx driver.
#define _GNU_SOURCE 1
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <dlfcn.h>
long PP_Initialize(void) {
fp = fopen("/dev/stderr", "a");
fprintf(fp, "DEBUG: entering PP_Initialize.\n");
// Call the original function but return a different value:
long (*orig)(void) = dlsym(RTLD_NEXT, "PP_Initialize");
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment