Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wrapping system calls. LD_PRELOAD replacement in windows

Status
Not open for further replies.

theodorg

Programmer
Sep 10, 2002
3
IS

I have an interesting task to perform in Windows and I haven't got a clue how to do it. I have done a similar task in Linux and it worked well. I am writing a http tunnel program that can create any bi-directional tcp connection through any type of proxy server, through CONNECT and/or regular HTTP requests.

The programs involved are and agent(daemon) that is multithreaded, written in C and runs on a linux box and the second program is a shared library(dll) that wraps a certain system call, connect() and does a few things like change the sockaddr_in structure and port information and other specific stuff. Basically what the library and the agent do is to create a way to make the user be able to connect to anywhere he wants via TCP transperantly.

Obviously the uses of this program can be quite nice, especially for people that have no internet access at work and want full TCP access. All of this works great on Linux and I use the library simply by placing it in a system wide LD_PRELOAD. LD_PRELOAD is an environment variable that every application save suid applications looks at and loads before it loads any other shared library(dll).


My dilemma started when I was porting the library to the Windows platform, I know how to load a library, LoadLibrary() and I know how to get at the functions within that library but I have absolutly no clue how to do anything like LD_PRELOAD in unix. How do I make each and every application in windows look at my library before it does any other, specifically wsock32.dll?

I currently have just ported the library as a C++ application written in Microsoft Visual C++ 6.0 but it needs to take parameters about creating connections and so forth which is totally unacceptable in my case. And to sum up what I need is a way to do something similar to LD_PRELOAD on unix system wide in Windows.

I would greatly appreciate any help with this and I apologize for my English,

Thanks a lot!

Theodor Gislason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top