简体   繁体   中英

C++ - DLL injection and call function

Long time i'm trying to find a answer for my question.

I have a game DLL and a program.

I the DLL I have a function that changes something in the game. (if the DLL is injected into the game). The program is my injector.

My question is, after injection, how is it possible to manually call a function in the DLL?

Now this function is called when is attached to the game, but how to call this function from the injector?

是的,您可以在正在运行的进程上创建远程线程,然后在该线程上使用您提到的功能。

In order to call the function, you need code that executes in the target process. That's the game, but you want to invoke the function from your injector, a different process. You already have code in the target process, the DLL that you injected. So, get the injected DLL to call the function. Some ways to achieve that:

  1. Create another remote thread in the target process that calls a function defined in the DLL. That can then do whatever it likes, in the context of the target process.
  2. Use some IPC mechanism (eg named pipes, sockets, etc.) to ask the injected DLL to carry out the action.

You have to load the symbol (function) from the dll into your program.

That symbol would be a function pointer that you can call. There are significant differences between operating systems so I would search for "call function from dll" to get an example for your OS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM