#include #include #include #include #include #include #include HMODULE this_module; size_t unload_ctr = 0; void unload_ctr_inc() { unload_ctr++; } void unload_ctr_dec() { unload_ctr--; if (unload_ctr == 0) { void *pFreeLibrary = GetProcAddress(GetModuleHandleA("kernel32.dll"), "FreeLibrary"); CreateThread(NULL, 0, pFreeLibrary, this_module, 0, NULL); } } BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) { // Only listen to attach if (reason != DLL_PROCESS_ATTACH) { return TRUE; } this_module = instance; // Dynamically link functions from ntdll ntdll_link(); // Detect which game the user is trying to run struct game_data game; game_detect(&game); // Create fake ACE driver files ace_fake_driver_files(); // Load both ACE modules HMODULE baseModule = ace_load_base_module(game.name); ace_load_driver_module(); // ...magic tp6_setup_patcher(&game, baseModule); // Load the UnityPlayer module and invoke the callback HMODULE unityModule = LoadLibraryA("UnityPlayer.dll"); INVOKE_CALLBACK(game.unityplayer_callback, unityModule); return TRUE; }