Msg : Prev 3 / 222 Next -2 +4
1999-09-13 10:20:50

To  :

Subj:

Re: LD_PRELOAD - anonymous


> This is a bit cleaner. It also contains correct initialisation. 
> You can load it with LD_PRELOAD. If you want to use original 
> function 'signal', you must use oldsignal(). Coded by Lubos Janica. 

I believe that this is the correct way to interpose on library 
functions. It's also as `portable' as these things get. 

[email protected] ~ ? cat foo.c 
#include <dlfcn.h> 
#include <stdio.h> 

#include <sys/types.h> 
#include <sys/socket.h> 

int 
connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) 
{ 
int (*real_connect)(int, const struct sockaddr *, socklen_t) = 
dlsym(RTLD_NEXT, "connect"); 

printf("woop!\n"); 
return (*real_connect)(sockfd, addr, addrlen); 
} 
[email protected] ~ ? gcc -shared -o foo.so foo.c -ldl 
[email protected] ~ ? setenv LD_PRELOAD `pwd`/foo.so 
[email protected] ~ ? telnet localhost 11111 
Trying 127.0.0.1... 
woop! 
telnet: Unable to connect to remote host: Connection refused 

VX Heavens - collection of viruses,sources and articles.
Длинный список? Alt + Home - в начало, Alt + End - в конец
Пользовательского поиска