This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Hooks do not work?



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]