Hooks do not work?

niXman i.nixman@autistici.org
Sat Oct 26 09:22:00 GMT 2013


Hi,

I try to create the hooks for open()/fopen().

hook code:
#include <stdio.h>

int open(const char *fname, int mode, ...) {
	printf("fname=%s\n", fname);
}

FILE* fopen(const char *fname, const char *mode) {
	printf("fname=%s\n", fname);
}


test code:
#include <stdio.h>

int main() {
	FILE *file = fopen("main.c", "rb");
	if ( file ) fclose(file);
}


compiled as:
gcc hook.c -shared -oopenhook.dll
gcc main.c -omain

run as:
LD_PRELOAD=/home/niXman/openhook.dll ./main

But a can't see the output.
What I am doing wrongly?

Thanks!

-- 
Regards, niXman
___________________________________________________
Dual-target(32 & 64-bit) MinGW-W64 compilers for 32 and 64-bit Windows:
http://sourceforge.net/projects/mingw-w64/
___________________________________________________
Another online IDE: http://liveworkspace.org/

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list