I have a dll file that I inject into a game, is it possible using curl Inside dll?
The second How protect dll,
As we know, there are many programs to inject a dll file into any process .
How do I make this dll can only be injected by my exe .
1) yes, you can invoke anything in your dll.
2) you can't, directly. You can add some protection, like a secret handshake between your program and the dll that if is not done, the dll functions exit/terminate/crash/something using shared memory or something like that. There are probably tools to do that, or you can make a stab at it yourself. This is the kind of thing you need to either buy a high quality one or accept that your home rolled solution is likely going to be cracked by anyone who has both your program and the dll in hand, and the motivation to do so. Its challenging to do this in a way that is hard to break. Its like those little locks you put on luggage or a locker: it keeps honest people out.
DLL code can use GetModuleFileName() with hModule set to NULL to get the full path of the EXE file that has loaded the DLL. If the EXE file is not the "expected" one (e.g. by checking the "file name" part of the path), the DLL may cause the process to terminate/crash.
Once you have the full path of the EXE file, it is also possible to use GetFileVersionInfo() to get more information about the EXE file, provided that the EXE file has a proper VERSIONINFO resource. Then "FileDescription", "ProductName" or "InternalName" can be checked. If those properties do not have the "expected" value (or if they are absent), the DLL could cause the process to terminate/crash. https://docs.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource#examples
Obviously, none of this is a 100% "secure" protection and it could easily be worked around by someone who knows what they're doing...
________
One way to "crash" the running process, out of indefinitely many:
Edit: I was focused on the protect the DLL portion, and skipped over the DLL injection bit, so obviously my suggestion here doesn't apply:
[What about sandboxing the whole program using Docker or RLBox?
Sure a bad dll could crash your program or do whatever with your game, so they are still given a lot of power in that sense; but they can't leave the box. They only have access to the things that you give them.]