mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
fetch ui sqvm and register ui script functions (#61)
* create ui vm hook and fetching ui vm global ptr * an actually functional hook for registering ui funcs
This commit is contained in:
parent
421d5e3c73
commit
47dc117cff
@ -13,6 +13,7 @@
|
||||
#include "squirrel/sqvm.h"
|
||||
#include "vgui/CEngineVGui.h"
|
||||
#include "gameui/IConsole.h"
|
||||
#include "serverbrowser/serverbrowser.h"
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: prints the output of each VM to the console
|
||||
@ -284,6 +285,17 @@ void RegisterServerScriptFunctions(void* sqvm)
|
||||
HSQVM_RegisterFunction(sqvm, "ServerNativeTest", "native server function", "void", "", &HSQVM_NativeTest);
|
||||
}
|
||||
|
||||
ADDRESS UIVM = (void*)p_SQVM_CreateUIVM.FollowNearCall().FindPatternSelf("48 8B 1D", ADDRESS::Direction::DOWN, 50).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr();
|
||||
|
||||
void HSQVM_RegisterOriginFuncs(void* sqvm)
|
||||
{
|
||||
if (sqvm == *UIVM.RCast<void**>())
|
||||
RegisterUIScriptFunctions(sqvm);
|
||||
else
|
||||
RegisterClientScriptFunctions(sqvm);
|
||||
return SQVM_RegisterOriginFuncs(sqvm);
|
||||
}
|
||||
|
||||
void SQVM_Attach()
|
||||
{
|
||||
DetourAttach((LPVOID*)&SQVM_PrintFunc, &HSQVM_PrintFunc);
|
||||
@ -291,6 +303,7 @@ void SQVM_Attach()
|
||||
DetourAttach((LPVOID*)&SQVM_WarningCmd, &HSQVM_WarningCmd);
|
||||
DetourAttach((LPVOID*)&SQVM_LoadRson, &HSQVM_LoadRson);
|
||||
DetourAttach((LPVOID*)&SQVM_LoadScript, &HSQVM_LoadScript);
|
||||
DetourAttach((LPVOID*)&SQVM_RegisterOriginFuncs, &HSQVM_RegisterOriginFuncs);
|
||||
}
|
||||
|
||||
void SQVM_Detach()
|
||||
@ -300,6 +313,7 @@ void SQVM_Detach()
|
||||
DetourDetach((LPVOID*)&SQVM_WarningCmd, &HSQVM_WarningCmd);
|
||||
DetourDetach((LPVOID*)&SQVM_LoadRson, &HSQVM_LoadRson);
|
||||
DetourDetach((LPVOID*)&SQVM_LoadScript, &HSQVM_LoadScript);
|
||||
DetourDetach((LPVOID*)&SQVM_RegisterOriginFuncs, &HSQVM_RegisterOriginFuncs);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -50,6 +50,17 @@ namespace
|
||||
|
||||
ADDRESS p_SQVM_RegisterFunc = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x83\xEC\x38\x45\x0F\xB6\xC8", "xxxxxxxx"); /*48 83 EC 38 45 0F B6 C8*/
|
||||
void* (*SQVM_RegisterFunc)(void* sqvm, SQFuncRegistration* sqFunc, int a1) = (void* (*)(void*, SQFuncRegistration*, int))p_SQVM_RegisterFunc.GetPtr();
|
||||
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
ADDRESS p_SQVM_CreateUIVM = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\xE8\x00\x00\x00\x00\x84\xC0\x74\x18\xE8\x00\x00\x00\x00", "x????xxxxx????")
|
||||
bool (*SQVM_CreateUIVM)() = (bool(*)())p_SQVM_CreateUIVM.FollowNearCall().GetPtr();
|
||||
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
|
||||
ADDRESS p_SQVM_CreateUIVM = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\xE8\x00\x00\x00\x00\x84\xC0\x74\xE0\x44\x38\x25\x00\x00\x00\x00", "x????xxxxxxx????");
|
||||
bool (*SQVM_CreateUIVM)() = (bool(*)())p_SQVM_CreateUIVM.FollowNearCall().GetPtr();
|
||||
#endif
|
||||
|
||||
ADDRESS p_SQVM_RegisterOriginFuncs = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\xE8\x00\x00\x00\x00\x48\x8B\x0D\x00\x00\x00\x00\x48\x8D\x15\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x48\x8B\x05\x00\x00\x00\x00\xC7\x05\x00\x00\x00\x00\x00\x00\x00\x00", "x????xxx????xxx????x????xxx????xx????????");
|
||||
void (*SQVM_RegisterOriginFuncs)(void* sqvm) = (void(*)(void*))p_SQVM_RegisterOriginFuncs.FollowNearCall().GetPtr();
|
||||
}
|
||||
|
||||
void* HSQVM_PrintFunc(void* sqvm, char* fmt, ...);
|
||||
@ -59,6 +70,7 @@ bool HSQVM_LoadScript(void* sqvm, const char* szScriptPath, const char* szScript
|
||||
void HSQVM_RegisterFunction(void* sqvm, const char* szName, const char* szHelpString, const char* szRetValType, const char* szArgTypes, void* pFunction);
|
||||
int HSQVM_NativeTest(void* sqvm);
|
||||
|
||||
void HSQVM_RegisterOriginFuncs(void* sqvm);
|
||||
|
||||
void SQVM_Attach();
|
||||
void SQVM_Detach();
|
||||
|
Loading…
x
Reference in New Issue
Block a user