Hello people,
 I am trying to write a library, which shall be loaded via LD_PRELOAD and
replace several original libc functions. (for example, I want to have my
fopen function, which would make some additional checks/logs).

Now the problem is how would I call the original routine within my
library?
 the only thing I have figured out, is something like:


static void initialise(void)
{
        void *lib;

        if (orig_fopen)
                return;

        lib = dlopen("libc.so.6", RTLD_NOW);
        orig_fopen = dlsym(lib, "fopen");
}


FILE *fopen(... ..)
{
        initialise();

        fprintf(stderr, "fopen() called\n");

        return (*orig_fopen)(t);
}

but maybe there's an easier way?


--
[EMAIL PROTECTED]           http://www.kalug.lug.net

Reply via email to