I'm currently trying to modify an old strategy game so that it's online functionality (based on GameSpy) is fully functional again. Therefore i wrote a small DLL that redirects the gamespy DNS queries to servers that the community maintains. I already confirmed that the DLL does what i want using the Xenos Injector and Wireshark. (Source can be found here: https://github.com/DarkAtra/bfme2-patcher/tree/fb7c6b66b505a853e72ad0d9122b74da3b0de681/game-patcher)
The next step for me was to add injection functionalities to my game launcher so that me and my friends wouldn't have to inject the dll manually every time we wanted to play. The game launcher is a fairly old project of mine and was written entirely in Kotlin. I opted to using JNA so that i would have access to OpenProcess, VirtualAllocEx and all the other function that i needed.
So far, i've manged to allocate memory in the game process, write the DLL path to the allocated memory and create a remote thread which should in theory load the dll using LoadLibrary. However, the DLL is not loaded and the thread just dies instantly. (Source can be found here: https://github.com/DarkAtra/bfme2-patcher/blob/fb7c6b66b505a853e72ad0d9122b74da3b0de681/updater/src/main/kotlin/de/darkatra/bfme2/util/InjectionUtils.kt)
What would be the best way to debug this?