[UnityDoorstop](https://github.com/NeighTools/UnityDoorstop) is a tool to execute managed code (.NET DLLs) before Unity does, useful for modding frameworks such as BepInEx.
This PR integrates parts of its code into segatools, so loading BepInEx is as simple as adding 2 lines to `segatools.ini`:
```ini
[unity]
targetAssembly=BepInEx\core\BepInEx.Preloader.dll
```
This PR also factors out the Unity path redirection hooks to its own module.
Reviewed-on: #11
Co-authored-by: beerpsi <beerpsi@duck.com>
Co-committed-by: beerpsi <beerpsi@duck.com>
IDZ only supports D3D11 and Ongeki/Unity uses D3D11 by default.
This also includes a window hook and fullscreen fix for problematic
games (I am looking at you IDZ).
This change deletes the GetProcAddress hook and exports symbols
corresponding to the hooked functions from each hook DLL instead;
we stop at redirecting LoadLibrary/GetModuleHandle calls to the
hook DLL. This simplified approach has less hidden magic going on
behind the scenes and is more readily composable (i.e. a hook DLL
can export redirect symbols for more than one dynamically-loaded
DLL).
Returning from the EXE PE entry point merely terminates the main
thread and leaves the process hanging. We need to explicitly exit
from the process since the NTDLL RTL Start code won't do it for us.
- If the Unity `LoadLibraryW` hook is done too early, then it somehow
interferes with the other DLL and hook table IAT hooks. Workaround
this by moving the Unity `LoadLibraryW` hook initialization after all
other hooks are done.
- Also, correct the platform ID to the ALLS HX
- Unity loads plugin DLLs and Mono dynamically.
- Ongeki uses Criware for videos so hook the Criware plugin DLL so the
path hooks load the videos from the hooked paths.