Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/core/backend/ScriptMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ namespace YimMenu
void ScriptMgr::DestroyImpl()
{
std::lock_guard lock(m_Mutex);

std::this_thread::sleep_for(100ms);

m_Scripts.clear();
}

Expand Down
5 changes: 4 additions & 1 deletion src/core/hooking/DetourHook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ namespace YimMenu
template<typename T>
inline DetourHook<T>::~DetourHook()
{
DisableNow();
if (m_OriginalFunc)
{
MH_RemoveHook(m_TargetFunc);
}
}

template<typename T>
Expand Down
2 changes: 1 addition & 1 deletion src/core/hooking/Hooking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace YimMenu
{
BaseHook::DisableAll();
m_MinHook.ApplyQueued();

for (auto it : BaseHook::Hooks())
{
delete it;
Expand Down
8 changes: 7 additions & 1 deletion src/game/backend/AnticheatBypass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ using FnBattlEyeBypass = bool (*)();

namespace YimMenu
{
static bool HooksInitialized = false;

static bool CheckForFSL()
{
int num_versions = 0;
Expand Down Expand Up @@ -50,7 +52,11 @@ namespace YimMenu

void AnticheatBypass::RunScriptImpl()
{
NativeHooks::AddHook("shop_controller"_J, NativeIndex::NET_GAMESERVER_BEGIN_SERVICE, &TransactionHook);
if (!HooksInitialized)
{
NativeHooks::AddHook("shop_controller"_J, NativeIndex::NET_GAMESERVER_BEGIN_SERVICE, &TransactionHook);
HooksInitialized = true;
}

m_IsFSLLoaded = CheckForFSL();
m_BattlEyeRunning = (NETWORK::_NETWORK_GET_GAME_RESTART_REASON() == 0 && GetModuleHandleA("BEClient_x64.dll")) && !m_IsFSLLoaded;
Expand Down
5 changes: 5 additions & 0 deletions src/game/backend/NativeHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ namespace YimMenu
void NativeHooks::DestroyImpl()
{
for (auto& [_, program] : m_RegisteredPrograms)
{
program->Cleanup();
}
m_RegisteredPrograms.clear();

m_RegisteredHooks.clear();
}
}
19 changes: 19 additions & 0 deletions src/game/features/settings/UnloadMenu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "core/commands/Command.hpp"
#include "game/backend/Self.hpp"
#include "core/commands/Commands.hpp"

namespace YimMenu::Features
{
class UnloadMenu : public Command
{
using Command::Command;

virtual void OnCall() override
{
Commands::Shutdown();
g_Running = false;
}
};

static UnloadMenu _UnloadMenu{"unloadmenu", "Unload", "Unload YimMenuV2."};
}
3 changes: 2 additions & 1 deletion src/game/frontend/submenus/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace YimMenu::Submenus
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();

// this assumes we can't add new commands in runtime, but a lot of other subsystems assume that too
static std::map<std::string, CommandLink*> sortedCommands;
static bool commandsSorted = []() {
Expand Down Expand Up @@ -101,6 +101,7 @@ namespace YimMenu::Submenus

chat->AddItem(std::make_shared<BoolCommandItem>("clearchat"_J));

gui->AddItem(std::make_shared<CommandItem>("unloadmenu"_J));
game->AddItem(playerEsp);
game->AddItem(pedEsp);
game->AddItem(objectEsp);
Expand Down
7 changes: 6 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,19 @@ namespace YimMenu
}

LOG(INFO) << "Unloading";

ScriptMgr::Destroy();

NativeHooks::Destroy();

FiberPool::Destroy();
ScriptMgr::Destroy();

Hooking::Destroy();
CallSiteHook::Destroy();

EARLY_UNLOAD:
g_Running = false;

Renderer::Destroy();
LogHelper::Destroy();

Expand Down