From 21fb501b27c1e594605d9da7792c93830aaf0ad1 Mon Sep 17 00:00:00 2001 From: Yimura Date: Mon, 21 Feb 2022 18:23:05 +0100 Subject: [PATCH] feat(Main): Initialize file_manager and logger --- BigBaseV2/src/main.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/BigBaseV2/src/main.cpp b/BigBaseV2/src/main.cpp index 4cd896d9..d70c87e9 100644 --- a/BigBaseV2/src/main.cpp +++ b/BigBaseV2/src/main.cpp @@ -28,10 +28,17 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID) while (!FindWindow(L"grcWindow", L"Grand Theft Auto V")) std::this_thread::sleep_for(1s); - auto logger_instance = std::make_unique(); + std::filesystem::path base_dir = std::getenv("appdata"); + base_dir /= "BigBaseV2"; + auto file_manager_instance = std::make_unique(base_dir); + + auto logger_instance = std::make_unique( + "YimMenu", + file_manager_instance->get_project_file("./cout.log") + ); try { - LOG(RAW_GREEN_TO_CONSOLE) << "Yim's Menu Initializing"; + LOG(INFO) << "Yim's Menu Initializing"; auto pointers_instance = std::make_unique(); LOG(INFO) << "Pointers initialized."; @@ -67,15 +74,11 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID) LOG(INFO) << "Hooking enabled."; while (g_running) - { std::this_thread::sleep_for(500ms); - } g_hooking->disable(); LOG(INFO) << "Hooking disabled."; - std::this_thread::sleep_for(1000ms); - native_hooks_instance.reset(); LOG(INFO) << "Dynamic native hooker uninitialized."; @@ -83,14 +86,18 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID) LOG(INFO) << "Scripts unregistered."; vehicle_service_instance.reset(); + LOG(INFO) << "Vehicle Service reset."; mobile_service_instance.reset(); + LOG(INFO) << "Mobile Service reset."; player_service_instance.reset(); + LOG(INFO) << "Player Service reset."; globals_service_instace.reset(); + LOG(INFO) << "Globals Service reset."; LOG(INFO) << "Services uninitialized."; // Make sure that all threads created don't have any blocking loops // otherwise make sure that they have stopped executing - g_thread_pool->destroy(); + thread_pool_instance->destroy(); LOG(INFO) << "Destroyed thread pool."; thread_pool_instance.reset(); @@ -111,12 +118,16 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID) catch (std::exception const &ex) { LOG(WARNING) << ex.what(); - MessageBoxA(nullptr, ex.what(), nullptr, MB_OK | MB_ICONEXCLAMATION); } LOG(INFO) << "Farewell!"; + logger_instance->destroy(); logger_instance.reset(); + file_manager_instance.reset(); + + std::this_thread::sleep_for(10s); + CloseHandle(g_main_thread); FreeLibraryAndExitThread(g_hmodule, 0); }, nullptr, 0, &g_main_thread_id);