Giter VIP home page Giter VIP logo

Comments (6)

Netdex avatar Netdex commented on August 16, 2024

Definitely, as long as the game uses DirectX 9.0. th_d3d9_hook, which is the sub-component of twinject that handles DirectX hooking, should work in theory with any DirectX 9 game. It can hook the entry point regardless of whether the DirectX is loaded statically (link-time) or dynamically (LoadLibrary).
th_d3d9_hook hooks BeginScene, EndScene, and CreateDevice, so custom code can be run in each of these methods while exposing the underlying IDirect3D9Device.

If the game does not use DirectX 9.0, then adaptations must be made to the wrapper methods (such as Direct3DCreate9) to the appropriate methods in the other version.

Also note that the code containing th_d3d9_hook must be injected into the target game.

from twinject.

callTx avatar callTx commented on August 16, 2024

Good. As I was looking at twinject 1.2.86 release version and testing with Touhou 10, I could see it works perfectly. I've done a good job man.

So I'd like to integrate a simpler twinject version to my project, so that:

  • Neither all that initial UI windows overlaying the game will be needed nor all that render targets
  • The my own 'bot' will need to start feeding fake input when the game start playing.

from twinject.

Netdex avatar Netdex commented on August 16, 2024

Thanks, I'm glad it worked the way it's supposed to (I've never tested twinject on another system).

If you need to fake input too, that is a separate component (th_di8_hook). It only supports DirectInput8, supporting any other versions of DirectInput would require similar changes as I mentioned above with other versions of DirectX. If the game uses the Windows Event Loop to handle input, you can probably adapt the Windows Event Hook code used for the IMGUI integration.

If you want to integrate twinject functionality into your project there are a few major components you will need to consider:

Injection

This is the job done by the injector portion using Microsoft Detours to create the game process and inject the hook DLL, this code should be easy to abstract for your case since it is very generic.

Hooking

You also need to initialize the hooks so that the code trampolines are created and the detours are set, this should be done in the injected DLL right after injection (DllMain).

Frame processing

The code that the hook calls is in this file, and can be modified (you said you didn't need the IMGUI functionality or rendering, which is in d3d9EndHook). you will probably need to modify this code to suit your needs.

The input hooking is very generic, and probably doesn't need to be modified, you can check the method names should be fairly self explanatory.

You should be able to figure out how most of the components work by inspecting how they are used for Touhou games.

from twinject.

callTx avatar callTx commented on August 16, 2024

Such a great information!

Really thanks.

from twinject.

callTx avatar callTx commented on August 16, 2024

from twinject.

Netdex avatar Netdex commented on August 16, 2024

Sorry for the late reply (I didn't see the issue because it was closed).

I am netdex#9804 on Discord, and you can contact me there for support (I should respond more quickly there than emails).

Anyone else who sees this ticket can also contact me via Discord.

from twinject.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.