-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There is not enough guide for using the library without using third-party tools #26
Comments
I wasn't feeling well late yesterday, so sorry for the delay. Anyway, yeah, you pretty much got the jist of what it takes to load .NET Code in a native process from scratch. Simplifying this process is one of the reasons Reloaded-II exists, even though it has far outgrown its original purpose. Some notes below.
You might find it easier to just deploy a portable version of Reloaded-II. Here's the source code and files for a self-contained installer that deploys Reloaded-II in a portable fashion to FlatOut2. Over there, I faked a bit of the process, as I actually included repacked game files for better load times. Anyway, you should be able to get this adjusted for your game with the following steps
User would just run Reloaded stuff in a subfolder, a User can open Mod Manager from the Edge Cases
|
Ah, I forgot. |
Brilliant! Thank you very much for the detailed explanation! |
No worries :p |
This is how we solved this problem for FF9: |
Looks like you're stubbing a binary. |
Hi! This is both a request to improve the documentation and an attempt to verify that my understanding of the process.
Please correct me if I'm wrong. To hook a native call in a C++ game, I need:
Launcher: Write a C# application that will launch the game process in the Suspended state and inject a C++ DLL into it, wait for initialization to complete and resume the process.
1.1. To start a process in the Suspended state, use WinAPI CreateProcess with the appropriate flag.
1.2. To load the library, use WinAPI CreateThread(loadLibraryWPtr, pathPtr)
1.3. To allocate memory in a remote process and pass the path to the loaded library, use Kernel32.VirtualAllocEx
1.4. Reloaded.Injector is not suitable for this task, since it cannot inject itself into processes in the Suspended State.
1.5. To bypass the restrictions of Steam, which may refuse to enable the overlay if the original launcher has been replaced, register the custom launcher registration as Debugger in the Windows registry for the original
.exe
.Bootstrap: Write a native C++ DLL that will be injected by the launcher to the game process and then rise the .NET Runtime.
2.1 x86 for x86 games, x64 for x64 games
2.2. This is a simple example: Reloaded.Core.Bootstrap
2.3. This is a advanced example of DllMain which raises .NET Runtime in a separate thread, thereby avoiding deadlock: Reloaded.Mod.Loader.Bootstrapper
.NET Mod: Write a managed .NET8+ DLL that will be loaded from async thread in DllMain and will use Reloaded.Hooks
3.1 Good example of how to call it from DllMain: Reloaded.Mod.Loader.Bootstrapper
3.2 RTFM: GettingStarted
Am I understanding everything correctly?
Or are there already easier ways to do this?
P.S. Just in case, I’ll explain why, with lack of knowledge about the wonderful world of C++, I write a launcher myself, rather than using Reloaded-II:
It's all about delivering the mod to the end player:
I would like to have one
.exe
file or.zip
archive that needs to be launched/unpacked into the game, after which launching the game on Steam will launch a modified version of the game without performing any additional actions.At the same time, I want to remain compatible with the latest version of all libraries (which makes it seem like a bad idea to ship Reloaded with the mod in the same archive).
At the same time, I want not to break compatibility with other mods that the player already has installed.
As far as I know, you are currently developing Reloaded-3. Perhaps these comments will give you some ideas.
In my ideal world, Reloaded could package itself and selected mods into a self-contained .exe file, which when run, would check for Reloaded in the game folder. If it exists, the mod will add it to it. If it is not there, it will unpack it from the archive or offer to download a newer version if there is a network. Then it will launch the game. And each subsequent launch through this
.exe
file will launch the game with the mod forcibly enabled (and the rest that are included in Reloaded, if any) without displaying the Reloaded window.The text was updated successfully, but these errors were encountered: