forked from YimMenu/YimMenuV2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
112 lines (89 loc) · 3.1 KB
/
main.cpp
File metadata and controls
112 lines (89 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "common.hpp"
#include "core/backend/ScriptMgr.hpp"
#include "core/backend/FiberPool.hpp"
#include "core/commands/Commands.hpp"
#include "core/commands/HotkeySystem.hpp"
#include "core/settings/Settings.hpp"
#include "core/filemgr/FileMgr.hpp"
#include "core/frontend/Notifications.hpp"
#include "core/hooking/Hooking.hpp"
#include "core/hooking/CallHook.hpp"
#include "core/memory/ModuleMgr.hpp"
#include "core/renderer/Renderer.hpp"
#include "game/backend/AnticheatBypass.hpp"
#include "game/backend/Players.hpp"
#include "game/backend/SavedLocations.hpp"
#include "game/backend/SavedPlayers.hpp"
#include "game/backend/Self.hpp"
#include "game/backend/NativeHooks.hpp"
#include "game/backend/Tunables.hpp"
#include "game/backend/ScriptPointers.hpp"
#include "game/frontend/GUI.hpp"
#include "game/pointers/Pointers.hpp"
#include "game/features/recovery/GiveVehicleReward.hpp"
namespace YimMenu
{
DWORD Main(void*)
{
const auto documents = std::filesystem::path(std::getenv("appdata")) / "YimMenuV2";
FileMgr::Init(documents);
LogHelper::Init("YimMenuV2", FileMgr::GetProjectFile("./cout.log"));
g_HotkeySystem.RegisterCommands();
SavedLocations::FetchSavedLocations();
Settings::Initialize(FileMgr::GetProjectFile("./settings.json"));
if (!ModuleMgr.LoadModules())
goto EARLY_UNLOAD;
if (!Pointers.Init())
goto EARLY_UNLOAD;
if (!Renderer::Init())
goto EARLY_UNLOAD;
Players::Init();
Hooking::Init();
ScriptMgr::Init();
LOG(INFO) << "ScriptMgr initialized";
ScriptPointers::Init();
GUI::Init();
ScriptMgr::AddScript(std::make_unique<Script>(&NativeHooks::RunScript)); // runs once
ScriptMgr::AddScript(std::make_unique<Script>(&Tunables::RunScript)); // runs once
ScriptMgr::AddScript(std::make_unique<Script>(&AnticheatBypass::RunScript));
ScriptMgr::AddScript(std::make_unique<Script>(&Self::RunScript));
ScriptMgr::AddScript(std::make_unique<Script>(&GUI::RunScript));
FiberPool::Init(16);
ScriptMgr::AddScript(std::make_unique<Script>(&HotkeySystem::RunScript));
ScriptMgr::AddScript(std::make_unique<Script>(&Commands::RunScript));
ScriptMgr::AddScript(std::make_unique<Script>(&GiveVehicleReward::RunScript));
ScriptMgr::AddScript(std::make_unique<Script>(&SavedPlayers::RunScript));
if (!Pointers.LateInit())
LOG(WARNING) << "Socialclub patterns failed to load";
Notifications::Show("YimMenuV2", "Loaded succesfully", NotificationType::Success);
while (g_Running)
{
Settings::Tick();
std::this_thread::yield();
}
LOG(INFO) << "Unloading";
NativeHooks::Destroy();
FiberPool::Destroy();
ScriptMgr::Destroy();
Hooking::Destroy();
CallSiteHook::Destroy();
EARLY_UNLOAD:
g_Running = false;
Renderer::Destroy();
LogHelper::Destroy();
CloseHandle(g_MainThread);
FreeLibraryAndExitThread(g_DllInstance, EXIT_SUCCESS);
return EXIT_SUCCESS;
}
}
BOOL WINAPI DllMain(HINSTANCE dllInstance, DWORD reason, void*)
{
using namespace YimMenu;
DisableThreadLibraryCalls(dllInstance);
if (reason == DLL_PROCESS_ATTACH)
{
g_DllInstance = dllInstance;
g_MainThread = CreateThread(nullptr, 0, Main, nullptr, 0, &g_MainThreadId);
}
return true;
}