Skip to content

Instantly share code, notes, and snippets.

@Ravenstine
Created September 10, 2016 01:31
Show Gist options
  • Save Ravenstine/74c92bc3b6d119e548cfabab30cf7c01 to your computer and use it in GitHub Desktop.
Save Ravenstine/74c92bc3b6d119e548cfabab30cf7c01 to your computer and use it in GitHub Desktop.
Override Shared Library Function Calls
override.so:override.c
gcc -shared -fPIC $^ -o $@
test:
LD_PRELOAD=$(PWD)/override.so glxgears
clean:
rm $(PWD)/override.so
// This will take OpenGL calls to draw a 3D vertex
// and print the X coordinate.
//
// Run `make` and `make test` to see it happen.
#include <stdio.h>
void glVertex3f(float x, float y, float z){
printf("%.6f", x);
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment