mirror of
https://github.com/YimMenu/YimMenuV2.git
synced 2026-10-10 11:53:14 +08:00
fix: work with SHV scripts
This commit is contained in:
@@ -15,7 +15,7 @@ namespace YimMenu
|
|||||||
unsigned long temp;
|
unsigned long temp;
|
||||||
VirtualProtect(m_Address, m_Size, PAGE_EXECUTE_READWRITE, &old_protect);
|
VirtualProtect(m_Address, m_Size, PAGE_EXECUTE_READWRITE, &old_protect);
|
||||||
memcpy(m_Address, m_Value.get(), m_Size);
|
memcpy(m_Address, m_Value.get(), m_Size);
|
||||||
VirtualProtect(m_Address, m_Size, old_protect, &temp);
|
VirtualProtect(m_Address, m_Size, old_protect, &temp);
|
||||||
m_Applied = true;
|
m_Applied = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace YimMenu
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < 176; i++)
|
for (int i = 0; i < 176; i++)
|
||||||
{
|
{
|
||||||
if (Pointers.ScriptPrograms[i] != nullptr)
|
if (Pointers.ScriptPrograms[i] != nullptr && Pointers.ScriptPrograms[i]->m_CodeSize && Pointers.ScriptPrograms[i]->m_CodeBlocks)
|
||||||
RegisterProgram(Pointers.ScriptPrograms[i]);
|
RegisterProgram(Pointers.ScriptPrograms[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ namespace YimMenu
|
|||||||
// find existing programs to register
|
// find existing programs to register
|
||||||
for (int i = 0; i < 176; i++)
|
for (int i = 0; i < 176; i++)
|
||||||
{
|
{
|
||||||
if (Pointers.ScriptPrograms[i] && Pointers.ScriptPrograms[i]->m_NameHash == script)
|
if (Pointers.ScriptPrograms[i] && Pointers.ScriptPrograms[i]->m_NameHash == script && Pointers.ScriptPrograms[i]->m_CodeSize && Pointers.ScriptPrograms[i]->m_CodeBlocks)
|
||||||
RegisterProgram(Pointers.ScriptPrograms[i]);
|
RegisterProgram(Pointers.ScriptPrograms[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
#include "game/backend/ScriptPatches.hpp"
|
#include "game/backend/ScriptPatches.hpp"
|
||||||
#include "game/hooks/Hooks.hpp"
|
#include "game/hooks/Hooks.hpp"
|
||||||
|
|
||||||
|
#include "types/script/scrProgram.hpp"
|
||||||
|
|
||||||
namespace YimMenu::Hooks
|
namespace YimMenu::Hooks
|
||||||
{
|
{
|
||||||
void Script::InitNativeTables(rage::scrProgram* program)
|
void Script::InitNativeTables(rage::scrProgram* program)
|
||||||
@@ -10,8 +12,16 @@ namespace YimMenu::Hooks
|
|||||||
BaseHook::Get<Script::InitNativeTables, DetourHook<decltype(&Script::InitNativeTables)>>()->Original()(program);
|
BaseHook::Get<Script::InitNativeTables, DetourHook<decltype(&Script::InitNativeTables)>>()->Original()(program);
|
||||||
if (g_Running)
|
if (g_Running)
|
||||||
{
|
{
|
||||||
NativeHooks::RegisterProgram(program);
|
if (program->m_CodeBlocks && program->m_CodeSize)
|
||||||
ScriptPatches::RegisterProgram(program);
|
{
|
||||||
|
NativeHooks::RegisterProgram(program);
|
||||||
|
ScriptPatches::RegisterProgram(program);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// printing name causes crash
|
||||||
|
// LOGF(VERBOSE, "InitNativeTables: skipping SHV script {}", program->m_Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user