[C++] Direct3D hooking sample

Started by
31 comments, last by undead 12 years, 7 months ago
Hi there, thank you for this resource it should prove extremely useful however I have two questions if some one could please answer: (I am a beginner)

> Firstly when I download the sample files and run launcher.exe it says “usage: launcher filename” could some one just briefly interpret this describing how this application is used exactly. For example I have a game installed in my C:\ named abc.exe what is the command I would enter for the launcher to work and hook?

> Secondly can this method be used to interact with game textures for example changing them or recognising coordinates or does it simply draw directly above the game with no means of interaction?


Thank you.
Advertisement
Quote:Original post by cykino
> Firstly when I download the sample files and run launcher.exe it says “usage: launcher filename” could some one just briefly interpret this describing how this application is used exactly. For example I have a game installed in my C:\ named abc.exe what is the command I would enter for the launcher to work and hook?

launcher abc.exe

Quote:> Secondly can this method be used to interact with game textures for example changing them or recognising coordinates or does it simply draw directly above the game with no means of interaction?

You can do anything. I only demonstrated modifying the behavior of Present to draw a colored quad.

Very cool man. Anyone know of a link that shows how do to these things in OpenGL as well?
Ive tried to test this and I cannot seem to get it to work. I have no problems with the compilation. But when I launch Egyptian_Addiction.exe and then run Launcher.exe "Egyptian_Addiction.exe" nothing happens. Am I doing something in the wrong order?

EDIT: I read the OP just a little bit more and saw what I needed to do. It is working now.

Thanks,
Soul

[Edited by - DaSoul on January 21, 2006 11:34:37 AM]
The sample file is gone, NeXe is destroyed?! Doh!
Quote:Original post by Pipo DeClown
The sample file is gone, NeXe is destroyed?! Doh!
The staff are aware of this and it should be sorted out fairly soon I hope. NeXe (or the other hosted sites) are not gone forever [smile]

Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Is there a way to just hook the specific function EndScene() in the vtable instead of creating a wrapper class?

ie, couldn't you do something like:

__stdcall HRESULT MyEndScene(void * this) {      IDirect3DDevice9 * device = (IDirect3DDevice9 *)this;      // do some rendering calls      return device->EndScene();}


It just seems like creating a whole class for one little function is a lot of extra code.
Quote:Original post by ApolloEx
Is there a way to just hook the specific function EndScene() in the vtable instead of creating a wrapper class?

ie, couldn't you do something like:

__stdcall HRESULT MyEndScene(void * this) {      IDirect3DDevice9 * device = (IDirect3DDevice9 *)this;      // do some rendering calls      return device->EndScene();}


It just seems like creating a whole class for one little function is a lot of extra code.


Assuming you inserted a pointer to that function into the vtable, that would result in infinite recursion. Think about what device->EndScene(); is doing.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

Quote:Original post by Washu
Quote:Original post by ApolloEx
Is there a way to just hook the specific function EndScene() in the vtable instead of creating a wrapper class?

ie, couldn't you do something like:

__stdcall HRESULT MyEndScene(void * this) {      IDirect3DDevice9 * device = (IDirect3DDevice9 *)this;      // do some rendering calls      return device->EndScene();}


It just seems like creating a whole class for one little function is a lot of extra code.


Assuming you inserted a pointer to that function into the vtable, that would result in infinite recursion. Think about what device->EndScene(); is doing.


Whoops. Should have called a function pointer to the old address.
Assuming you know the layout of the vtable though (which you do since it's based on COM) then yes, you could change the implementation such that you didn't need to implement that interface. On the other hand, typically if you are going to hijack one function, you'll probably need to hijack others.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

This topic is closed to new replies.

Advertisement