Quote:
Originally Posted by
chercheur857
i'd like to use for example a library linked to my program , if there is a send or a receive it will redirect it and attach the couple
I've already explained in detail why that's a bad idea -- please read it.
1) If you did this with a proxy, you could just recv() as much as you wanted and send() as much as you want, but when intercepting system calls, there's no guarantee you get what you actually want. Just because you're reading data in x-size chunks doesn't mean it's being written in x-size chunks. Your fake send() call may need to be extremely complex.
2) Just because send() is called doesn't mean it's a send() call you actually wanted to intercept.
3) It's plagued with security problems.
4) It's far harder than it looks, to the point that it's turned out to be
literally impossible for most other folks I've tried to help with it. "overloading gettimeofday()", for instance, turned out to mean "overloading gettimeofday(), 9 other time-related functions, select(), half of lpthread, and recompiling". Altering the way a program works without recompiling it can cause it work strangely -- or, more to the point --
not work. Writing 17 bytes when it actually asked to write 12 can have more side-effects than you would have suspected.
Quote:
I want to do like that (i found it in a research)
Yes, you've made it clear. It's just
not a good idea.
If you're hellbent on doing so, check out the source code to
libkeepalive. It'll show you how to build a library you can LD_PRELOAD.