fix: work with SHV scripts

This commit is contained in:
maybegreat48
2025-04-30 18:49:02 -04:00
parent ff4164ed26
commit abe569176f
4 changed files with 15 additions and 5 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ namespace YimMenu
unsigned long temp;
VirtualProtect(m_Address, m_Size, PAGE_EXECUTE_READWRITE, &old_protect);
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;
}
+1 -1
View File
@@ -52,7 +52,7 @@ namespace YimMenu
{
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]);
}
}
+1 -1
View File
@@ -116,7 +116,7 @@ namespace YimMenu
// find existing programs to register
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]);
}
+12 -2
View File
@@ -3,6 +3,8 @@
#include "game/backend/ScriptPatches.hpp"
#include "game/hooks/Hooks.hpp"
#include "types/script/scrProgram.hpp"
namespace YimMenu::Hooks
{
void Script::InitNativeTables(rage::scrProgram* program)
@@ -10,8 +12,16 @@ namespace YimMenu::Hooks
BaseHook::Get<Script::InitNativeTables, DetourHook<decltype(&Script::InitNativeTables)>>()->Original()(program);
if (g_Running)
{
NativeHooks::RegisterProgram(program);
ScriptPatches::RegisterProgram(program);
if (program->m_CodeBlocks && program->m_CodeSize)
{
NativeHooks::RegisterProgram(program);
ScriptPatches::RegisterProgram(program);
}
else
{
// printing name causes crash
// LOGF(VERBOSE, "InitNativeTables: skipping SHV script {}", program->m_Name);
}
}
}
}