library-interposition

memory-mapped files in C

Hi, I was playing around with memory-mapped files in C and was wondering if there is a way to replace the FILE * from fopen with a memory mapped file transparently. Example: FILE * fp = g_fopen(...); //Program does things to this fp. fclose(); But instead, is it possible to have FILE *fp = my_fopen(...) Where my own function would...

Problem replacing Linux system calls using LD_PRELOAD

I am trying to write a program that allows a binary to be run, substituting a certain file when requested with another. It is a library with simple replacements for the system call functions, that is used with LD_PRELOAD. The problem is that it catches opens for reading (the substitute file is read instead), but writes always go back to ...

Interposing library: XOpenDisplay

Hello, I am working on a project where I need to change the behaviour of the XOpenDisplay function defined in X11/Xlib.h. I have found an example, which should do exactly what I am looking for, but when I compile it, I get the following error messages: XOpenDisplay_interpose.c:14: Error: conflicting types for »XOpenDisplay« /usr...

LD_PRELOAD for C++ class methods

I need to interpose on a method call in a C++ program (the class resides in a separate shared library). I thought I could use LD_PRELOAD, but i am not sure how this would work (i only found examples of C functions): is there a way to setup interposition for a single method without copying over any code from the interposed class implement...

Find out if a received pointer is a string, ushort or array.

Hello :) I am interposing the memcpy() function in C because the target application uses it to concatenate strings and I want to find out which strings are being created. The code is: void * my_memcpy ( void * destination, const void * source, size_t num ) { void *ret = memcpy(destination, source, num); // printf ("[MEMCPY] = %...