The online racing simulator
DirectX Graphics Injection
(15 posts, started )
DirectX Graphics Injection
This is most likely well over my head, but nonetheless I'd like to know more about how to go about drawing a DX window of my own into LFS without using a proxy DLL if possible (I'm hoping to interface it with OutGauge). Anyone have any linkies to examples, source code or just general literature on the subject that could be emplyed in LFS? I ask direct relation to LFS because reading about proxy DLLs, injections and hooks and whatnots makes me very confuzzled when it comes to how I should interface pre-DX9 tech, and stuff.

Very much appreciated
You need Kegetysis.
(taken three times a day before eating)
#4 - Stuff
I dunno much about overlaying an image onto DX, but why not use a proxy dll? Its the way Kegetys did it I think, its the way Racer_S2 did it and the only way I have found to do it, through mikoweb.eu, a good project that also uses the proxy method..

Its a very good idea and would love to know how to use it too..
About why I'd prefer not to use a proxy DLL: Word of warning first, my reasoning is based on what I quickly went thru on the net so I could be wrong just as well.

A proxy DLL is essentially used to replace or hijack d3d9.dll. This could be done in 2 ways: put the custom dll in the prog's root dir, or replace the file in the system dir.

I'd rather not replace original files because LFS is not the only DX game I play. The latter is a good choice, provided the game looks in the root folder to begin with, it can be made not to. Also, I can see a fair argument as to why a game could consider it an illegal 'hack' to not use the original files only.

Online, it could easily be used to one's advantage (wallhacks, anyone?). Therefore, the least intrusive way that I saw was to inject without a proxy dll. The only problem with that, from what I understood, is that the game has to use the DX9 api, and since LFS doesn't this option would be a no-go.

But, if the proxy dll is the way to go, I saw some actual examples with .net that may prove to be useful.

Nice site, Stuff. Ty
I doubt that Lfs is D3D9, as far as I know it is D3D8, so you would have to put a wrapper d3d8.dll into the LfS directory. Of course this would work in case of Lfs without any problem, other developers already did with success.

If you follow the link from Stuff then you will also find a proxy.dll so that you do not need to write your own wrapper dll, but just load the proxy dll, that will connect to the wrapper dll (look for GPP). There is an API, where you can call functions inside the proxy dll.

Nevertheless I see some issues with this solution:

Reliability: if every developer is writing his own wrapper dll and going to put it into the Lfs folder then they will overwrite the wrapper dlls of other addons (keep in mind, that every wrapper dll has to use the filename d3d8.dll)

Stability: the wrapper dll is running in the process of Lfs. So if there is a bug in the wrapper dll, then it would have impact on Lfs too.

It is of course an interesting possibility for addon developers. And for my LfS TV director tool I would need to add some output too (later), but atm I am still not sure about the way to go. If there is no other simple possibilty (maybe Scawen would implement an API), then I would need to use this solution too.
This is the prob with a proxy. How about this

Quote from http://www.codeguru.com/cpp/g-m/directx/directx8/comments.php/c11453/?thread=9505 :If you force process X to load "yourhookdll.dll", look up the import table in memory, and overwrite the desired function pointers it will achieve the same results without requiring you to tamper with the system .dll in any way. It's generally a good idea to save the old function ptrs so you can return the the import table back to its previous state if you unload "yourhookdll.dll" at some point before the application terminates.

Any developer could add whatever DLLs they need without overwritignn anything. From what I gathered this works with DX8.

There's something on this here: http://www.codeproject.com/useritems/Hooking_DirectX_COM.asp, where the hook is to DINPUT8.DLL instead of d3d8.dll. I don't understand anything about COM apps so I don't know if any of this applies, but if it does maybe it's possible to hook to LFS without proxying.
Quote from NotAnIllusion :This is the prob with a proxy. ....

Why? What problem?
All you need to to is to download the appropriate GPP version from http://www.mikoweb.eu/index.php?node=28, there is a wrapper dll called d3d8.dll and a proxy dll called gpcomms.dll included. Put the d3d8.dll into the Lfs folder. Then in your application load gpcomms.dll, it is a simple Win32 dll. Load it as you would load any other dll. Inside this dll there is a function like OutputText(x,y,text) or PrintImage(x,y,filename.bmp). All your application needs to do is to call these functions and gpcomms.dll will do the job for you.

Instead of this you want to force lfs to load your own dll. You write that you don't understand anything about COM and you are confused about dll injection and hooks and ....

hmmmm .... Sorry .....
Quote from Soeren Scharf :
It is of course an interesting possibility for addon developers. And for my LfS TV director tool I would need to add some output too (later), but atm I am still not sure about the way to go. If there is no other simple possibilty (maybe Scawen would implement an API), then I would need to use this solution too.

:woohoo:
We need a meta mod style interface.
what you want is called DETOURS... its a source code provided by microsoft that shows how to reroute api calls to your own code. of couse you will need another application active during runtime to detect and inject your dll into the game.


you could do this without detours but you would need to find the exact address of the d3d pointers


here is the source for dll injector and a test dll etc.. its for d3d9 but should be easy to convert to d3d8

http://dl.tocaedit.com/Detours-dx.rar

if you want to know more about detours just google it
I have a question to someone who had some experience with proxy dlls. Is it possible not only add some geometry data to the scene (like Ghost mod) but also use additional pixel or vertex shaders? I mean rendering the screen into texture and make some shader calculation on it (the same way "heat haze" effects are made).

Thanks
Quote from himself :I have a question to someone who had some experience with proxy dlls. Is it possible not only add some geometry data to the scene (like Ghost mod) but also use additional pixel or vertex shaders? I mean rendering the screen into texture and make some shader calculation on it (the same way "heat haze" effects are made).

Thanks

you mean like the Motion blur test from kegety?
http://www.kegetys.net/lfs/
Something like that but this motion blur effect is not made using pixel shaders.
Quote from Racer_S2 :what you want is called DETOURS...
...
...
(skipped)

hello Racer_S2,

in your addon tool Drift Gauge and G-Meter v1.4 you are using the proxy-dll approach instead of using DETOURS. May I ask, why you did choose in this way?

Secondly, what about the performance? I have played a little with the dll from mikoweb and noticed, that LFS is doing between 2000 up to 10000 function calls into the interface every frame. Curiously I did not noticed any frame drop. How much time we are loosing by every function call into the interface (due to the fact, that now every call has to go through our proxy dll).

I am very interested in your answers.

regards
Sören

Edit: Big thx for making the source code of your addon tool public, hopefully it will help me in getting started with DirectX.

DirectX Graphics Injection
(15 posts, started )
FGED GREDG RDFGDR GSFDG