2019-03-21 20:18:31 +01:00
|
|
|
|
#include "common.hpp"
|
2022-02-22 01:18:49 +01:00
|
|
|
|
#include "core/globals.hpp"
|
2019-03-21 20:18:31 +01:00
|
|
|
|
#include "features.hpp"
|
|
|
|
|
#include "fiber_pool.hpp"
|
|
|
|
|
#include "gui.hpp"
|
|
|
|
|
#include "logger.hpp"
|
|
|
|
|
#include "hooking.hpp"
|
|
|
|
|
#include "pointers.hpp"
|
|
|
|
|
#include "renderer.hpp"
|
|
|
|
|
#include "script_mgr.hpp"
|
2021-09-18 22:09:07 +02:00
|
|
|
|
#include "thread_pool.hpp"
|
2019-03-21 20:18:31 +01:00
|
|
|
|
|
2022-01-21 23:13:43 +01:00
|
|
|
|
#include "native_hooks/native_hooks.hpp"
|
2022-01-08 05:31:24 +01:00
|
|
|
|
#include "services/globals_service.hpp"
|
2022-01-31 18:27:35 +01:00
|
|
|
|
#include "services/player_service.hpp"
|
2022-01-08 05:31:24 +01:00
|
|
|
|
#include "services/mobile_service.hpp"
|
2022-03-02 00:21:29 +01:00
|
|
|
|
#include "services/notification_service.hpp"
|
2022-01-08 05:31:24 +01:00
|
|
|
|
#include "services/vehicle_service.hpp"
|
|
|
|
|
|
2019-03-21 20:18:31 +01:00
|
|
|
|
BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
|
|
|
|
|
{
|
|
|
|
|
using namespace big;
|
|
|
|
|
if (reason == DLL_PROCESS_ATTACH)
|
|
|
|
|
{
|
|
|
|
|
DisableThreadLibraryCalls(hmod);
|
|
|
|
|
|
|
|
|
|
g_hmodule = hmod;
|
|
|
|
|
g_main_thread = CreateThread(nullptr, 0, [](PVOID) -> DWORD
|
|
|
|
|
{
|
2020-03-28 02:00:19 -04:00
|
|
|
|
while (!FindWindow(L"grcWindow", L"Grand Theft Auto V"))
|
|
|
|
|
std::this_thread::sleep_for(1s);
|
|
|
|
|
|
2022-02-21 18:23:05 +01:00
|
|
|
|
std::filesystem::path base_dir = std::getenv("appdata");
|
|
|
|
|
base_dir /= "BigBaseV2";
|
|
|
|
|
auto file_manager_instance = std::make_unique<file_manager>(base_dir);
|
|
|
|
|
|
2022-02-22 01:18:49 +01:00
|
|
|
|
auto globals_instance = std::make_unique<menu_settings>(
|
|
|
|
|
file_manager_instance->get_project_file("./settings.json")
|
|
|
|
|
);
|
|
|
|
|
|
2022-02-21 18:23:05 +01:00
|
|
|
|
auto logger_instance = std::make_unique<logger>(
|
|
|
|
|
"YimMenu",
|
|
|
|
|
file_manager_instance->get_project_file("./cout.log")
|
|
|
|
|
);
|
2019-03-21 20:18:31 +01:00
|
|
|
|
try
|
|
|
|
|
{
|
2022-02-21 18:23:05 +01:00
|
|
|
|
LOG(INFO) << "Yim's Menu Initializing";
|
2019-03-21 20:18:31 +01:00
|
|
|
|
auto pointers_instance = std::make_unique<pointers>();
|
2020-02-22 18:37:42 -05:00
|
|
|
|
LOG(INFO) << "Pointers initialized.";
|
|
|
|
|
|
2019-03-21 20:18:31 +01:00
|
|
|
|
auto renderer_instance = std::make_unique<renderer>();
|
2020-02-22 18:37:42 -05:00
|
|
|
|
LOG(INFO) << "Renderer initialized.";
|
2019-03-21 20:18:31 +01:00
|
|
|
|
|
|
|
|
|
auto fiber_pool_instance = std::make_unique<fiber_pool>(10);
|
2020-02-22 18:37:42 -05:00
|
|
|
|
LOG(INFO) << "Fiber pool initialized.";
|
2019-03-21 20:18:31 +01:00
|
|
|
|
|
|
|
|
|
auto hooking_instance = std::make_unique<hooking>();
|
2020-02-22 18:37:42 -05:00
|
|
|
|
LOG(INFO) << "Hooking initialized.";
|
|
|
|
|
|
2022-02-22 01:18:49 +01:00
|
|
|
|
g->load();
|
2020-02-22 18:37:42 -05:00
|
|
|
|
LOG(INFO) << "Settings Loaded.";
|
2019-03-21 20:18:31 +01:00
|
|
|
|
|
2021-09-18 22:09:07 +02:00
|
|
|
|
auto thread_pool_instance = std::make_unique<thread_pool>();
|
|
|
|
|
LOG(INFO) << "Thread pool initialized.";
|
|
|
|
|
|
2021-12-24 01:53:50 +01:00
|
|
|
|
auto globals_service_instace = std::make_unique<globals_service>();
|
2022-01-08 05:42:36 +01:00
|
|
|
|
auto mobile_service_instance = std::make_unique<mobile_service>();
|
2022-03-02 00:21:29 +01:00
|
|
|
|
auto notification_service_instance = std::make_unique<notification_service>();
|
2022-01-31 18:27:35 +01:00
|
|
|
|
auto player_service_instance = std::make_unique<player_service>();
|
2021-08-08 15:10:08 +02:00
|
|
|
|
auto vehicle_service_instance = std::make_unique<vehicle_service>();
|
2022-01-21 23:13:43 +01:00
|
|
|
|
LOG(INFO) << "Registered service instances...";
|
|
|
|
|
|
2022-01-31 18:27:35 +01:00
|
|
|
|
g_script_mgr.add_script(std::make_unique<script>(&features::script_func));
|
|
|
|
|
g_script_mgr.add_script(std::make_unique<script>(&gui::script_func));
|
|
|
|
|
LOG(INFO) << "Scripts registered.";
|
|
|
|
|
|
2022-01-21 23:13:43 +01:00
|
|
|
|
auto native_hooks_instance = std::make_unique<native_hooks>();
|
|
|
|
|
LOG(INFO) << "Dynamic native hooker initialized.";
|
2021-08-08 15:10:08 +02:00
|
|
|
|
|
2022-01-31 18:27:35 +01:00
|
|
|
|
g_hooking->enable();
|
|
|
|
|
LOG(INFO) << "Hooking enabled.";
|
|
|
|
|
|
2019-03-21 20:18:31 +01:00
|
|
|
|
while (g_running)
|
2020-02-22 18:37:42 -05:00
|
|
|
|
std::this_thread::sleep_for(500ms);
|
2019-03-21 20:18:31 +01:00
|
|
|
|
|
2022-01-31 18:27:35 +01:00
|
|
|
|
g_hooking->disable();
|
|
|
|
|
LOG(INFO) << "Hooking disabled.";
|
|
|
|
|
|
2022-01-21 23:13:43 +01:00
|
|
|
|
native_hooks_instance.reset();
|
|
|
|
|
LOG(INFO) << "Dynamic native hooker uninitialized.";
|
|
|
|
|
|
2022-01-31 18:27:35 +01:00
|
|
|
|
g_script_mgr.remove_all_scripts();
|
|
|
|
|
LOG(INFO) << "Scripts unregistered.";
|
|
|
|
|
|
2021-12-24 01:53:50 +01:00
|
|
|
|
vehicle_service_instance.reset();
|
2022-02-21 18:23:05 +01:00
|
|
|
|
LOG(INFO) << "Vehicle Service reset.";
|
2022-01-08 05:42:36 +01:00
|
|
|
|
mobile_service_instance.reset();
|
2022-02-21 18:23:05 +01:00
|
|
|
|
LOG(INFO) << "Mobile Service reset.";
|
2022-01-31 18:27:35 +01:00
|
|
|
|
player_service_instance.reset();
|
2022-02-21 18:23:05 +01:00
|
|
|
|
LOG(INFO) << "Player Service reset.";
|
2021-12-24 01:53:50 +01:00
|
|
|
|
globals_service_instace.reset();
|
2022-02-21 18:23:05 +01:00
|
|
|
|
LOG(INFO) << "Globals Service reset.";
|
2022-01-31 18:27:35 +01:00
|
|
|
|
LOG(INFO) << "Services uninitialized.";
|
2021-12-24 01:53:50 +01:00
|
|
|
|
|
|
|
|
|
// Make sure that all threads created don't have any blocking loops
|
|
|
|
|
// otherwise make sure that they have stopped executing
|
2022-02-21 18:23:05 +01:00
|
|
|
|
thread_pool_instance->destroy();
|
2021-09-18 22:09:07 +02:00
|
|
|
|
LOG(INFO) << "Destroyed thread pool.";
|
|
|
|
|
|
|
|
|
|
thread_pool_instance.reset();
|
|
|
|
|
LOG(INFO) << "Thread pool uninitialized.";
|
|
|
|
|
|
2019-03-21 20:18:31 +01:00
|
|
|
|
hooking_instance.reset();
|
2020-02-22 18:37:42 -05:00
|
|
|
|
LOG(INFO) << "Hooking uninitialized.";
|
2019-03-21 20:18:31 +01:00
|
|
|
|
|
|
|
|
|
fiber_pool_instance.reset();
|
2020-02-22 18:37:42 -05:00
|
|
|
|
LOG(INFO) << "Fiber pool uninitialized.";
|
2019-03-21 20:18:31 +01:00
|
|
|
|
|
|
|
|
|
renderer_instance.reset();
|
2020-02-22 18:37:42 -05:00
|
|
|
|
LOG(INFO) << "Renderer uninitialized.";
|
2019-03-21 20:18:31 +01:00
|
|
|
|
|
|
|
|
|
pointers_instance.reset();
|
2020-02-22 18:37:42 -05:00
|
|
|
|
LOG(INFO) << "Pointers uninitialized.";
|
2019-03-21 20:18:31 +01:00
|
|
|
|
}
|
|
|
|
|
catch (std::exception const &ex)
|
|
|
|
|
{
|
2020-02-22 18:37:42 -05:00
|
|
|
|
LOG(WARNING) << ex.what();
|
2019-03-21 20:18:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 18:37:42 -05:00
|
|
|
|
LOG(INFO) << "Farewell!";
|
2022-02-21 18:23:05 +01:00
|
|
|
|
logger_instance->destroy();
|
2019-03-21 20:18:31 +01:00
|
|
|
|
logger_instance.reset();
|
|
|
|
|
|
2022-02-22 01:18:49 +01:00
|
|
|
|
globals_instance.reset();
|
2022-02-21 18:23:05 +01:00
|
|
|
|
|
2022-02-22 01:18:49 +01:00
|
|
|
|
file_manager_instance.reset();
|
2022-02-21 18:23:05 +01:00
|
|
|
|
|
2019-03-21 20:18:31 +01:00
|
|
|
|
CloseHandle(g_main_thread);
|
|
|
|
|
FreeLibraryAndExitThread(g_hmodule, 0);
|
|
|
|
|
}, nullptr, 0, &g_main_thread_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|