Using MadCodeHook in an Layered Service Provider solution?

c++ / delphi package - dll injection and api hooking
Post Reply
MaestroNaj
Posts: 4
Joined: Tue Dec 22, 2009 8:51 pm

Using MadCodeHook in an Layered Service Provider solution?

Post by MaestroNaj »

Greetings,
Has anyone used MadCodeHook to create an LSP transport service? In the context of parental control LSP seems a natural fit.
Do you think MadCodeHook is the way to go to achieve this? If not, how have you used MadCodeHook to hook into Winsock2?

Your feedback is greatly appreciated.
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

I've no idea. Maybe someone else can help out here?
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

A forum search found this:

viewtopic.php?t=4049&highlight=lsp
MaestroNaj
Posts: 4
Joined: Tue Dec 22, 2009 8:51 pm

LSP versus Hook: Pros and cons thus far

Post by MaestroNaj »

Based a preliminary study it would seem that hooking and LSPs are attempting to accomplish the same goal: inject a process in an existing flow to monitor, modify or block the outcome. The (current) pros and cons are as follows: please feel free to add to this initial list. Also, the list is presented in the (it's late and I've got other things to attend to order and no priority should be ascribed to the ordering.

1. Reusability: hook wins hands down since LSPs are (as far as I can tell) specific to winsock 2. I do not know if they are being used elsewhere.

2. Scalability: jury is still out. It would seem that since LSP is inherent to Winsock2 the Microsoft engineers would have structured it to handle the appropriate load although it is unsettling that no such details are given in the SDK docs. If you plan to hook within the context of a client than I'd wager that scalability is not important. If you plan to hook a server with thousands of connections / second, this may become important.

3. Legitimacy: LSP wins hands down. It is the Microsoft approved way to hook into Winsock. Hooking has a tarnished reputation since it has been used by (begin rant) pre-Cro-Magnon individuals who have tightly coupled their self-worth and finger muscles to a haggard collection of indisposed bits(end rant)

4. Shield Strength by "shield strength" I mean the ability of a piece of software to resist being summarily dislodged by a haggard collection of indisposed bits (see previous rants) or by a well-meaning but ignorant virus removal program. My current view is that it is a wash since both hooks and LSPs can be targeted by the same variety of software and Microsoft does not seem to offer a protection for installed LSPs. I do not know if virus removal programs ignore LSPs altogether or not.

5. Ease of Programming If you are a Delphi coder, hooking with MadCodeHook wins hands-down. If you are a C++ coder and do not fully understand how LSPs function hooking wins hands-down. If you are a c++/c coder who is proficient in Winsock then you might consider LSPs but I would like someone who is far more knowledgeable in this area to comment on this one.

6. Performance: TBD.

To be continued...
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Check out dcsoft's comment in the thread I linked to. You'll find some answers there. E.g. there's an answer to "I do not know if virus removal programs ignore LSPs altogether or not".
jonny_valentine
Posts: 109
Joined: Thu Dec 30, 2004 9:59 pm
Location: UK

Post by jonny_valentine »

DCsoft may be able to help better here, however in my opinion, Hooking with MCH is a lot easier than LSP... MCH is designed for this kind of thing, plus like David says, LSP can easily mess up and cause problems with your PC... MCH can also, but just play around with User processes only and restart PC if something goes wrong :)

Be careful not to return bigger packet back to browser than it expects without first increasing the memory first or you will crash the browser.
Post Reply