I need some tip to undrestand what is the best way to execute external code from DLL or command line.

I like to add the force feedback support to different games that not support it.

I can write a DLL or a commnad line exe that execute the FFB. The problem is how I call these function from the game.

For the moment I have disassebled one game with IDA and found the point to put the call.

I don't have any experience in assembly. So I'am not sure if I'am in the right way.

There are some tool like: wininject so I was think to use it to add the dll dependency to my exe game.

After I need to do the call of my function inside the DLL in assembly (ex. exectute_ffb(par1) ), but I don't known the code to do the call.

Here the screenshot about the call.

enter image description here

enter image description here

int __cdecl sub_43AC70(char *a1, int a2)
  call my_function(a1) from mylibrary.dll

  int i; // [esp+0h] [ebp-4h]

  for ( i = sub_43BC50(); i; i = *(_DWORD *)i )
    if ( *(_DWORD *)(i + 88) == a2 && (!a1 || !stricmp((const char *)(i + 4), a1)) )
      return i;
  return 0;

Can you help me please ?

  • Not sure if I understand you correctly, you want to make game call your function from your dll? – morsisko Jul 10 '20 at 17:06
  • yes I confirm, in short I like that a game call my function inside a external dll or if it is too difficoult, I like that a game call an external command line exe with parameters. – user3449922 Jul 10 '20 at 17:30

It is indeed possible, and not that hard to do - providing the game doesn't have any anti-cheat nor integrity checks.

The thing you are looking for is called function hooking. If you don't want to mess with assembly there are few good libs that can do the most important and tedious part of work for you.

Take a look into examples, for example that one in PolyHook`s repository. Here they hook (intercept) printf function, but there is no problem to intercept game function at 43AC70 to call your function from mylibrary.dll.

If you want to write your own detour you can take a look at my other reply on that site: here

  • Hi morsisko, your example with PolyHook, is very interesting, there is a video tutorial that do this ? if is possible, I like to create the dll in C# or if is not possible, create a "generic" DLL in c++ that call my dll in C#. – user3449922 Jul 11 '20 at 18:09
  • I think you will find a lot of tutorials, just search with the phrase "function hooking". I think it will be better to inject native .dll into native code, and then eventually call your C# dll – morsisko Jul 11 '20 at 19:00
  • thank you ! last question: I suppose before do a function hooking, I need to inject the DLL. Do you confirm ? if yes what is the best tool in this case ? – user3449922 Jul 12 '20 at 7:33
  • DLL injection would be the easiest I think. You may write your own injector (that's fairy easy), or use some existing one as Cheat Engine, or even better make proxy dll which will inject your payload on game start. – morsisko Jul 12 '20 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.