Skip to content

Instantly share code, notes, and snippets.

@attilaolah
Created July 18, 2013 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save attilaolah/6025843 to your computer and use it in GitHub Desktop.
Save attilaolah/6025843 to your computer and use it in GitHub Desktop.
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");
close(fp);
// Call the original function but return a different value:
long (*orig)(void) = dlsym(RTLD_NEXT, "PP_Initialize");
orig();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment