kk2k
asked on
How to Hook Winsock Api ,
Situation:
Need to intercept the Connect APIs on Windows NT and replace it with my own function, being called
from a DLL, and then have my program call the "old" API function to complete the process.
Connect -> 192.1.1.254
replace to
if (Connect == '192.1.1.254')
{
Connect == ' 192.1.1.10'
}
Good luck! Let me know if you have any questions. I would like VC++6.0 source code... Thanks!
Need to intercept the Connect APIs on Windows NT and replace it with my own function, being called
from a DLL, and then have my program call the "old" API function to complete the process.
Connect -> 192.1.1.254
replace to
if (Connect == '192.1.1.254')
{
Connect == ' 192.1.1.10'
}
Good luck! Let me know if you have any questions. I would like VC++6.0 source code... Thanks!
Do you need this system wide or only for a specific process? Do you need to do this programatically or would perhaps installing a proxy (or something like that) solve the problem, too?
ASKER
Just only for a specific process.
Then you might want to look at my package "madCodeHookLib" (free for non-commercial purpose). With this package you can inject a self-written dll into the specific process. Then in the dll you can hook the connect APIs, again using my package.
Here is the online documentation. It is for the Delphi version of my package, but a C++ package is also available.
http://help.madshi.net/Data/madCodeHook.htm
Here is a demo, which shows all the basic framework you need:
http://help.madshi.net/Data/HookingNotepad.htm
Regards, Madshi.
Here is the online documentation. It is for the Delphi version of my package, but a C++ package is also available.
http://help.madshi.net/Data/madCodeHook.htm
Here is a demo, which shows all the basic framework you need:
http://help.madshi.net/Data/HookingNotepad.htm
Regards, Madshi.
ASKER
Hi,Madshi
Can you use your package write some functions for me
Connect -> 192.1.1.254
replace to
if (Connect == '192.1.1.254')
{
Connect == ' 192.1.1.10'
}
VC code ~~ thanks~
Can you use your package write some functions for me
Connect -> 192.1.1.254
replace to
if (Connect == '192.1.1.254')
{
Connect == ' 192.1.1.10'
}
VC code ~~ thanks~
ASKER
Hi,Madshi
Can you use your package write some functions for me
Connect -> 192.1.1.254
replace to
if (Connect == '192.1.1.254')
{
Connect == ' 192.1.1.10'
}
VC code ~~ thanks~
Can you use your package write some functions for me
Connect -> 192.1.1.254
replace to
if (Connect == '192.1.1.254')
{
Connect == ' 192.1.1.10'
}
VC code ~~ thanks~
I'm sorry. First of all I'm a Delphi programmer. Second, I've not the time to do all the work for you... :-/ There are also C++ demos in the demo folder. If you dig a bit, you'll be able to do it yourself, I think...
Here's another great source of information:
http://www.codeguru.com/system/apihook.html
Not only is the article itself excellent, but an example application is supplied and there are references to just about every item written on this topic.
http://www.codeguru.com/system/apihook.html
Not only is the article itself excellent, but an example application is supplied and there are references to just about every item written on this topic.
ASKER
I want some demo c++ code for my example
It really would help if you would READ THE COMMENTS offered here to help you:
Here's another great source of information:
http://www.codeguru.com/system/apihook.html
Not only is the article itself excellent, but AN EXAMPLE APPLICATION IS SUPPLIED and there are references
to just about every item written on this topic.
Here's another great source of information:
http://www.codeguru.com/system/apihook.html
Not only is the article itself excellent, but AN EXAMPLE APPLICATION IS SUPPLIED and there are references
to just about every item written on this topic.
The article & source code mentioned by jhance is really a good one. However, I don't like the API hooking method used there, namely Import Table Patching. It's really not the best method. Well, but it's good enough in a lot of situations, so you will have to try out, whether you catch all needed API calls with this method or not.
The nicest thing about the article is the collection of references. All the different techniques have their own advantages and disadvantatges.
Let me just add a comment to one part of that article:
>> Injecting DLL by using CreateRemoteThread() API function. Well, this is my favorite one. Unfortunately it is supported only by NT and Windows 2K operating systems.
Win9x does have a CreateRemoteThread like function, it's just not exported from kernel32. My package is able to access this internal function... :-)
>> Injecting DLL by using CreateRemoteThread() API function. Well, this is my favorite one. Unfortunately it is supported only by NT and Windows 2K operating systems.
Win9x does have a CreateRemoteThread like function, it's just not exported from kernel32. My package is able to access this internal function... :-)
ASKER
OK, but not have source file for my Question .
To: jhance
you havn't Detail for my Question.
To: Madshi
i am VC programmer. i don't Use Delphi . but you madCodeHookLib is good tool .
can you get me some source for vc ?
i will accept comment as answer in tomorrow.
To: jhance
you havn't Detail for my Question.
To: Madshi
i am VC programmer. i don't Use Delphi . but you madCodeHookLib is good tool .
can you get me some source for vc ?
i will accept comment as answer in tomorrow.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What messages are avaliabled on the Socket APIs ?