DirectX and automatic dll loading

Discussion about everything. New games, 3d math, development tips...
Post Reply
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

DirectX and automatic dll loading

Post by roxaz »

Does directix application scan its directory for any dx dlls and load them? Im trying to make a game modification and one developer gave me a tip how can i load dll without adding new import to application. Just want to make sure because developer who told me this dropped just few phrases and nothing specific
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Every operating system uses a predefined search mechanism to locate shared libraries. The rules that are used by windows for locating dll files are well documented.

Making a modification to a game in this way will be difficult at best. You might want to consider want to using something like the detours library so that you can get your replacement function arbitrary code and then invoke the original code so that everything functions as it should.

Travis
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Detours is a better way to go (with hindsight ;) )but if for some reason you want to go down the DLL replacement route, then you could use this code to create a shim DLL.

If you're replacing a DX dll then you'll have to create and wrap real DX interfaces internally as well as simply cloning the functions. See dsound.cpp in this app for an example of that.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

well if i wanted to make a simple dll hook then i just would attach it to executable with cff explorer. the problem is i am looking for a way that was used in that plugin i mentioned. you know, just drop it into folder and run. i know method of clone dll. if i was lucky i would be able to find dll with few imported functions. otherwise i will kill myself while clong a dll. and yes, such way of making plugin is not easy indeed, but its not so hard if man knows what he does. anyway there are no other options to do that :) i dunno about detours library much but i prefer my own methods. its easy as hell, just write jump to your own code and jump back in the end of execution of your code ;)

P.S. i forgot to tell that source code of the game i want to make plugin for is not available, thats why i must do it in so low level ;)
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

roxaz wrote:the problem is i am looking for a way that was used in that plugin i mentioned.
What "plugin"? It's a bit rich to complain about someone else "[dropping] just few phrases and nothing specific" when you're being pretty free and easy with your own terminology.

roxaz wrote:otherwise i will kill myself while clong a dll.
What's wrong with the code that I posted? That creates source for a shim DLL that you can "just drop [...] into folder and run". Cloning a DLL is easy, it's modifying it that takes work, but it'll be the same work however you hook or intercept the DLL call.

If that doesn't do what you want, can you be a bit more specific about your requirements please.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

i told in the first post. i would like to know if directx scans directory for directx-related dlls and load them
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

After reading the link that Vitek provided, what part of the DLL search order is giving you problems?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply