dllmain.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "api/directx/D3D11Hook.hpp"
  2. #include "il2cpp/il2cpp-init.hpp"
  3. #include "api/lua/luahook.hpp"
  4. #include "includes.h"
  5. #include "utils/discordrpc/Discord.h"
  6. #include "utils/ProtectionBypass.h"
  7. #include "functions/Settings/Settings.h"
  8. Discord* g_Discord;
  9. DWORD WINAPI MainThread(LPVOID lpReserved) {
  10. AllocConsole();
  11. freopen("CONIN$", "r", stdin);
  12. freopen("CONOUT$", "w", stdout);
  13. freopen("CONOUT$", "w", stderr);
  14. LOG_INFO("Starting...");
  15. while (!FindWindowA("UnityWndClass", nullptr))
  16. Sleep(3000);
  17. LOG_INFO("Initializing IL2CPP...");
  18. init_il2cpp();
  19. Sleep(5000);
  20. LOG_INFO("Initialized IL2CPP");
  21. ProtectionBypass::Init();
  22. auto& settings = cheat::Settings::getInstance();
  23. int initDelay = settings.f_InitDelay.getValue();
  24. if (settings.f_ShowRpc.getValue()) {
  25. g_Discord->Initialize();
  26. g_Discord->Update();
  27. LOG_INFO("Showing RPC...");
  28. }
  29. LOG_INFO("Waiting %i seconds before starting DirectX...", initDelay / 1000);
  30. Sleep(initDelay);
  31. LOG_INFO("Waited, assuming that your game already opened. Opening menu...");
  32. __try {
  33. GetPresent();
  34. DetourDirectXPresent();
  35. } __except (EXCEPTION_EXECUTE_HANDLER) {
  36. LOG_ERROR("Unhandled exception in opening menu.");
  37. }
  38. return 0;
  39. }
  40. BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
  41. if (fdwReason == DLL_PROCESS_ATTACH) {
  42. CloseHandle(CreateThread(NULL, 0, &initLua, NULL, NULL, NULL));
  43. CreateThread(NULL, 0, &MainThread, NULL, NULL, NULL);
  44. }
  45. return TRUE;
  46. }