Created
October 11, 2017 20:10
-
-
Save 3v1n0/d37ffad515109d66caade15c7c7549fc to your computer and use it in GitHub Desktop.
GObject LD_PRELOAD override
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
gcc -shared -fPIC -o liboverride.so gobject-override.c -ldl $(pkg-config --cflags --libs glib-2.0 gtk+-3.0) | |
LD_PRELOAD=./liboverride.so any-binary! | |
*/ | |
#define _GNU_SOURCE 1 | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <dlfcn.h> | |
#include <gtk/gtk.h> | |
void g_object_unref(gpointer object) | |
{ | |
void (*orig_unref)(gpointer) = dlsym(RTLD_NEXT, "g_object_unref"); | |
if (GTK_IS_WIDGET (object)) | |
printf("Calling Unref on %p, ref_count %d\n",object,G_OBJECT(object)->ref_count); | |
orig_unref(object); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment