diff --git a/framework/dllmain.cpp b/framework/dllmain.cpp index f0d0979..00032fb 100644 --- a/framework/dllmain.cpp +++ b/framework/dllmain.cpp @@ -15,6 +15,7 @@ BOOL APIENTRY DllMain( HMODULE hModule, switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: + myhModule = hModule; init_il2cpp(); CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) Run, NULL, 0, NULL); break; diff --git a/framework/helpers.cpp b/framework/helpers.cpp index 2aeaed2..a4eaebf 100644 --- a/framework/helpers.cpp +++ b/framework/helpers.cpp @@ -36,6 +36,11 @@ void il2cppi_new_console() { freopen_s((FILE**) stdout, "CONOUT$", "w", stdout); } +void il2cpp_close_console() { + fclose((FILE *)stdout); + FreeConsole(); +} + #if _MSC_VER >= 1920 // Helper function to convert Il2CppString to std::string std::string il2cppi_to_string(Il2CppString* str) { diff --git a/framework/helpers.h b/framework/helpers.h index c640757..4517439 100644 --- a/framework/helpers.h +++ b/framework/helpers.h @@ -18,6 +18,8 @@ void il2cppi_log_write(std::string text); // Helper function to open a new console window and redirect stdout there void il2cppi_new_console(); +void il2cpp_close_console(); + #if _MSC_VER >= 1920 // Helper function to convert Il2CppString to std::string std::string il2cppi_to_string(Il2CppString* str); diff --git a/user/main.cpp b/user/main.cpp index 7b97d75..ae9e187 100644 --- a/user/main.cpp +++ b/user/main.cpp @@ -18,6 +18,13 @@ // Set the name of your log file here extern const LPCWSTR LOG_FILE = L"DevourClient.txt"; +HMODULE myhModule = NULL; +DWORD __stdcall EjectThread(LPVOID lpParameter) { + Sleep(100); + il2cpp_close_console(); + FreeLibraryAndExitThread(myhModule, 0); //Freeing the module, that's why we needed the myhModule variable +} + // Custom injected code entry point void Run() { @@ -38,6 +45,9 @@ void Run() } + if (GetAsyncKeyState(VK_END) & 0x8000) + break; std::this_thread::sleep_for(std::chrono::milliseconds(50)); } + CreateThread(0, 0, EjectThread, 0, 0, 0); } \ No newline at end of file diff --git a/user/main.h b/user/main.h index a1cbaa9..1b24a75 100644 --- a/user/main.h +++ b/user/main.h @@ -3,5 +3,7 @@ #pragma once +extern HMODULE myhModule; + // Custom injected code entry point void Run(); \ No newline at end of file