Page 1 of 1

C++ winsock hooking

Posted: Tue May 18, 2004 9:44 am
by behelit
could you use madcodehook to hook/inject another process and use that processes winsock send method/s

Posted: Wed May 19, 2004 9:55 am
by madshi
That is possible, but it sounds "bad" to me. Please use madCodeHook only for legal projects! :-x

Posted: Wed May 19, 2004 3:47 pm
by nildo
madshi wrote:That is possible, but it sounds "bad" to me. Please use madCodeHook only for legal projects! :-x
Not at all the time.
If you have a socket openned in another process, and if you want to send a Buffer by this Openned Socket, you can not do in our own process, we need to inject a DLL and send messages to the DLL recognize this.

If it is what you want, so you dont need to inject a DLL. Just use the API DuplicateHandle and passing the SocketID as the source parameter, then you could call SEND or RECV (whatever) in your own process.

Posted: Sun May 23, 2004 1:55 am
by behelit
its not "bad" if its a process you made

that api is perfect thx for the help
but how would you get the socket descriptor

Posted: Sun May 23, 2004 6:58 am
by madshi
If the other process is your own, then I take that "bad" word back... :D

Okay, could you tell us a bit more about why one of your processes wants to use the socket functions of another of your processes? Why can't you implement the socket functions in both processes?

Anyway, there are several possibilities:

(1) Either the non-socket process can ask the socket process to send data for it. You can use SendMessage to send the request or madCodeHook's SendIpcMessage.

(2) Or the non-socket process can copy the socket's process socket (that's nildo's suggestion). Not sure how/whether this works, since I'm not socket expert at all!

(3) Or the non-socket process could execute a function in the context of the socket process (e.g. by using madRemote's RemoteExecute).

(4) Or the non-socket process could inject a dll into the socket process which could then do the sending.

Posted: Mon May 24, 2004 12:10 pm
by behelit
it was something my brother made
ive wanted to learn hooks for awhile so this was a good chance to start
would madshi or someone be able to write a small tutorial on how to use madcodehook even if it has nothing to do with socks

Posted: Mon May 24, 2004 12:14 pm
by nildo
Look at HELP and DEMOS.
They will help a lot.

Posted: Mon May 24, 2004 12:21 pm
by madshi
Yep, nildo is right. Some of the demos are pretty easy to understand and I did my best to document them well. Together with the documentation it should hopefully get you going.

Posted: Thu May 27, 2004 9:40 am
by behelit
hmm the help page is all in delphi code

Posted: Thu May 27, 2004 11:38 am
by nildo
Delphi to C++ and C++ to Delphi is easy to translate... The HELP shows the teory and How to use. See the Demos for examples of use