mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Improve SQVM function registration and add SERVER and CLIENT logic
SERVER and CLIENT functions can now be registered as well. For checking whether to register for CLIENT or UI, we now check its context instead of comparing pointers. For server, a dedicated function was build.
This commit is contained in:
parent
56a71aba56
commit
446f13680f
@ -291,7 +291,7 @@ FORCEINLINE void CHostState::UnloadPakFile(void)
|
||||
RPakLoadedInfo_t pakInfo = g_pRTech->GetPakLoadedInfo(it);
|
||||
if (pakInfo.m_pszFileName)
|
||||
{
|
||||
DevMsg(eDLL_T::RTECH, "Unloading PakFile '%s' now.", pakInfo.m_pszFileName);
|
||||
DevMsg(eDLL_T::RTECH, "%s - Unloading PakFile '%s'\n", "CHostState::UnloadPakFile", pakInfo.m_pszFileName);
|
||||
}
|
||||
#endif // GAMEDLL_S3
|
||||
RTech_UnloadPak(it);
|
||||
|
@ -14,7 +14,7 @@ History:
|
||||
- 10:09:2021 | 18:22 : Implement 'StringToGuid' method
|
||||
- 12:11:2021 | 14:41 : Add decompression method to ConCommand callback
|
||||
- 25:12:2021 | 23:20 : Made everything more readable thanks to bezdna5-rs
|
||||
- 28:03:2021 | 18:00 : Added getting pak info by PakID.
|
||||
- 28:03:2022 | 18:00 : Added getting pak info by PakID.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
@ -510,7 +510,7 @@ RPakLoadedInfo_t RTech::GetPakLoadedInfo(int nPakId)
|
||||
return info;
|
||||
}
|
||||
|
||||
Warning(eDLL_T::RTECH, "Failed getting RPakLoadInfo_t for PakId '%d'", nPakId);
|
||||
Warning(eDLL_T::RTECH, "%s - Failed getting RPakLoadInfo_t for PakId '%d'\n", __FUNCTION__, nPakId);
|
||||
#endif // GAMEDLL_S3
|
||||
|
||||
return RPakLoadedInfo_t();
|
||||
|
@ -61,6 +61,11 @@ void hsq_newslot(void* sqvm, int idx)
|
||||
sq_newslot(sqvm, idx);
|
||||
}
|
||||
|
||||
void hsq_pushstructure(void* sqvm, const char* name, const char* member, const char* codeclass1, const char* codeclass2)
|
||||
{
|
||||
sq_pushstructure(sqvm, name, member, codeclass1, codeclass2);
|
||||
}
|
||||
|
||||
void SQAPI_Attach()
|
||||
{
|
||||
DetourAttach((LPVOID*)&sq_pushbool, &hsq_pushbool);
|
||||
@ -71,6 +76,7 @@ void SQAPI_Attach()
|
||||
DetourAttach((LPVOID*)&sq_arrayappend, &hsq_arrayappend);
|
||||
DetourAttach((LPVOID*)&sq_newtable, &hsq_newtable);
|
||||
DetourAttach((LPVOID*)&sq_newslot, &hsq_newslot);
|
||||
DetourAttach((LPVOID*)&sq_pushstructure, &hsq_pushstructure);
|
||||
}
|
||||
|
||||
void SQAPI_Detach()
|
||||
@ -83,4 +89,5 @@ void SQAPI_Detach()
|
||||
DetourDetach((LPVOID*)&sq_arrayappend, &hsq_arrayappend);
|
||||
DetourDetach((LPVOID*)&sq_newtable, &hsq_newtable);
|
||||
DetourDetach((LPVOID*)&sq_newslot, &hsq_newslot);
|
||||
DetourDetach((LPVOID*)&sq_pushstructure, &hsq_pushstructure);
|
||||
}
|
@ -29,6 +29,13 @@ namespace
|
||||
|
||||
ADDRESS p_sq_newslot = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x48\x83\xEC\x30\x44\x8B\x49\x00\x48\x8B\xD9\x41\x8B\xC1", "xxxxxxxxx?xxxxxx");
|
||||
void (*sq_newslot)(void* sqvm, int idx) = (void (*)(void*, int))p_sq_newslot.GetPtr(); /*40 53 48 83 EC 20 8B 41 ?? 48 8B D9 2B 41 ?? 83 F8 02 7D*/
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2)
|
||||
ADDRESS p_sq_pushstructure = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x4C\x89\x4C\x24\x00\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8B\xEC", "xxxx?xxxx?xxxx?xxxx?xxxxxxxxxxxx");
|
||||
void (*sq_pushstructure)(void* sqvm, const char* name, const char* member, const char* codeclass1, const char* codeclass2) = (void (*)(void*, const char*, const char*, const char*, const char*))p_sq_pushstructure.GetPtr(); /*48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 4C 89 4C 24 ? 55 41 54 41 55 41 56 41 57 48 8B EC*/
|
||||
#elif defined (GAMEDLL_S3)
|
||||
ADDRESS p_sq_pushstructure = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8B\xEC\x48\x83\xEC\x60\x48\x8B\x59\x60", "xxxx?xxxx?xxxx?xxxxxxxxxxxxxxxxxxxx");
|
||||
void (*sq_pushstructure)(void* sqvm, const char* name, const char* member, const char* codeclass1, const char* codeclass2) = (void (*)(void*, const char*, const char*, const char*, const char*))p_sq_pushstructure.GetPtr(); /*48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 55 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 60 48 8B 59 60*/
|
||||
#endif
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -42,6 +49,7 @@ void hsq_newarray(void* sqvm, int size);
|
||||
void hsq_arrayappend(void* sqvm, int idx);
|
||||
void hsq_newtable(void* sqvm);
|
||||
void hsq_newslot(void* sqvm, int idx);
|
||||
void hsq_pushstructure(void* sqvm, const char* name, const char* member, const char* codeclass1, const char* codeclass2);
|
||||
|
||||
void SQAPI_Attach();
|
||||
void SQAPI_Detach();
|
||||
@ -57,14 +65,15 @@ class HSqapi : public IDetour
|
||||
{
|
||||
virtual void debugp()
|
||||
{
|
||||
std::cout << "| FUN: sq_pushbool : 0x" << std::hex << std::uppercase << p_sq_pushbool.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_pushstring : 0x" << std::hex << std::uppercase << p_sq_pushstring.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_pushinteger : 0x" << std::hex << std::uppercase << p_sq_pushinteger.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_pushconstant : 0x" << std::hex << std::uppercase << p_sq_pushconstant.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_newarray : 0x" << std::hex << std::uppercase << p_sq_newarray.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_arrayappend : 0x" << std::hex << std::uppercase << p_sq_arrayappend.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_newtable : 0x" << std::hex << std::uppercase << p_sq_newtable.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_newslot : 0x" << std::hex << std::uppercase << p_sq_newslot.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_pushbool : 0x" << std::hex << std::uppercase << p_sq_pushbool.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_pushstring : 0x" << std::hex << std::uppercase << p_sq_pushstring.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_pushinteger : 0x" << std::hex << std::uppercase << p_sq_pushinteger.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_pushconstant : 0x" << std::hex << std::uppercase << p_sq_pushconstant.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_newarray : 0x" << std::hex << std::uppercase << p_sq_newarray.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_arrayappend : 0x" << std::hex << std::uppercase << p_sq_arrayappend.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_newtable : 0x" << std::hex << std::uppercase << p_sq_newtable.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_newslot : 0x" << std::hex << std::uppercase << p_sq_newslot.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: sq_pushstructure : 0x" << std::hex << std::uppercase << p_sq_pushstructure.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "+----------------------------------------------------------------+" << std::endl;
|
||||
}
|
||||
};
|
||||
|
@ -24,11 +24,23 @@ namespace VSquirrel
|
||||
{
|
||||
namespace SHARED
|
||||
{
|
||||
SQRESULT Script_NativeTest(void* sqvm)
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: SDK test and example body
|
||||
//-----------------------------------------------------------------------------
|
||||
SQRESULT SDKNativeTest(void* sqvm)
|
||||
{
|
||||
// Function code goes here.
|
||||
return SQ_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: expose SDK version to the VScript API
|
||||
//-----------------------------------------------------------------------------
|
||||
SQRESULT GetSDKVersion(void* sqvm)
|
||||
{
|
||||
hsq_pushstring(sqvm, g_pR5net->GetSDKVersion().c_str(), -1);
|
||||
return SQ_OK;
|
||||
}
|
||||
}
|
||||
#ifndef CLIENT_DLL
|
||||
namespace SERVER
|
||||
@ -92,16 +104,6 @@ namespace VSquirrel
|
||||
return SQ_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: expose SDK version to the UI VM
|
||||
//-----------------------------------------------------------------------------
|
||||
SQRESULT GetSDKVersion(void* sqvm)
|
||||
{
|
||||
hsq_pushstring(sqvm, g_pR5net->GetSDKVersion().c_str(), -1);
|
||||
|
||||
return SQ_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: get promo data for serverbrowser panels
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -18,7 +18,8 @@ namespace VSquirrel
|
||||
{
|
||||
namespace SHARED
|
||||
{
|
||||
SQRESULT Script_NativeTest(void* sqvm);
|
||||
SQRESULT SDKNativeTest(void* sqvm);
|
||||
SQRESULT GetSDKVersion(void* sqvm);
|
||||
}
|
||||
namespace SERVER
|
||||
{
|
||||
@ -33,7 +34,6 @@ namespace VSquirrel
|
||||
SQRESULT GetServerPlaylist(void* sqvm);
|
||||
SQRESULT GetServerMap(void* sqvm);
|
||||
SQRESULT GetServerCount(void* sqvm);
|
||||
SQRESULT GetSDKVersion(void* sqvm);
|
||||
SQRESULT GetPromoData(void* sqvm);
|
||||
SQRESULT SetEncKeyAndConnect(void* sqvm);
|
||||
SQRESULT CreateServerFromMenu(void* sqvm);
|
||||
|
@ -207,9 +207,9 @@ void HSQVM_ErrorFunc(void* sqvm, const char* pszError, const char* pszFile, unsi
|
||||
|
||||
SQVM_GetErrorLine(pszFile, nLine, szContextBuf, sizeof(szContextBuf));
|
||||
|
||||
Error(eDLL_T::SERVER, "%s SCRIPT COMPILE ERROR: %s\n", SQVM_TYPE_T[vmIdx].c_str(), pszError);
|
||||
Error(eDLL_T::SERVER, " -> %s\n\n", szContextBuf);
|
||||
Error(eDLL_T::SERVER, "%s line [%d] column [%d]\n", pszFile, nLine, nColumn);
|
||||
Error(static_cast<eDLL_T>(vmIdx), "%s SCRIPT COMPILE ERROR: %s\n", SQVM_TYPE_T[vmIdx].c_str(), pszError);
|
||||
Error(static_cast<eDLL_T>(vmIdx), " -> %s\n\n", szContextBuf);
|
||||
Error(static_cast<eDLL_T>(vmIdx), "%s line [%d] column [%d]\n", pszFile, nLine, nColumn);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
@ -274,9 +274,10 @@ void HSQVM_RegisterFunction(void* sqvm, const char* szName, const char* szHelpSt
|
||||
// Purpose: registers script functions in SERVER context
|
||||
// Input : *sqvm -
|
||||
//---------------------------------------------------------------------------------
|
||||
void RegisterServerScriptFunctions(void* sqvm)
|
||||
void SQVM_RegisterServerScriptFunctions(void* sqvm)
|
||||
{
|
||||
HSQVM_RegisterFunction(sqvm, "SDKNativeTest", "Native SERVER test function", "void", "", &VSquirrel::SHARED::Script_NativeTest);
|
||||
HSQVM_RegisterFunction(sqvm, "SDKNativeTest", "Native SERVER test function", "void", "", &VSquirrel::SHARED::SDKNativeTest);
|
||||
HSQVM_RegisterFunction(sqvm, "GetSDKVersion", "Gets the SDK version as a string", "string", "", &VSquirrel::SHARED::GetSDKVersion);
|
||||
}
|
||||
|
||||
#ifndef DEDICATED
|
||||
@ -284,30 +285,31 @@ void RegisterServerScriptFunctions(void* sqvm)
|
||||
// Purpose: registers script functions in CLIENT context
|
||||
// Input : *sqvm -
|
||||
//---------------------------------------------------------------------------------
|
||||
void RegisterClientScriptFunctions(void* sqvm)
|
||||
void SQVM_RegisterClientScriptFunctions(void* sqvm)
|
||||
{
|
||||
HSQVM_RegisterFunction(sqvm, "SDKNativeTest", "Native CLIENT test function", "void", "", &VSquirrel::SHARED::Script_NativeTest);
|
||||
HSQVM_RegisterFunction(sqvm, "SDKNativeTest", "Native CLIENT test function", "void", "", &VSquirrel::SHARED::SDKNativeTest);
|
||||
HSQVM_RegisterFunction(sqvm, "GetSDKVersion", "Gets the SDK version as a string", "string", "", &VSquirrel::SHARED::GetSDKVersion);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: registers script functions in UI context
|
||||
// Input : *sqvm -
|
||||
//---------------------------------------------------------------------------------
|
||||
void RegisterUIScriptFunctions(void* sqvm)
|
||||
void SQVM_RegisterUIScriptFunctions(void* sqvm)
|
||||
{
|
||||
HSQVM_RegisterFunction(sqvm, "SDKNativeTest", "Native UI test function", "void", "", &VSquirrel::SHARED::Script_NativeTest);
|
||||
HSQVM_RegisterFunction(sqvm, "SDKNativeTest", "Native UI test function", "void", "", &VSquirrel::SHARED::SDKNativeTest);
|
||||
|
||||
// functions for retrieving server browser data
|
||||
// Functions for retrieving server browser data
|
||||
HSQVM_RegisterFunction(sqvm, "GetServerName", "Gets the name of the server at the specified index of the server list", "string", "int", &VSquirrel::UI::GetServerName);
|
||||
HSQVM_RegisterFunction(sqvm, "GetServerPlaylist", "Gets the playlist of the server at the specified index of the server list", "string", "int", &VSquirrel::UI::GetServerPlaylist);
|
||||
HSQVM_RegisterFunction(sqvm, "GetServerMap", "Gets the map of the server at the specified index of the server list", "string", "int", &VSquirrel::UI::GetServerMap);
|
||||
HSQVM_RegisterFunction(sqvm, "GetServerCount", "Gets the number of public servers", "int", "", &VSquirrel::UI::GetServerCount);
|
||||
|
||||
// misc main menu functions
|
||||
HSQVM_RegisterFunction(sqvm, "GetSDKVersion", "Gets the SDK version as a string", "string", "", &VSquirrel::UI::GetSDKVersion);
|
||||
// Misc main menu functions
|
||||
HSQVM_RegisterFunction(sqvm, "GetSDKVersion", "Gets the SDK version as a string", "string", "", &VSquirrel::SHARED::GetSDKVersion);
|
||||
HSQVM_RegisterFunction(sqvm, "GetPromoData", "Gets promo data for specified slot type", "string", "int", &VSquirrel::UI::GetPromoData);
|
||||
|
||||
// functions for connecting to servers
|
||||
// Functions for connecting to servers
|
||||
HSQVM_RegisterFunction(sqvm, "CreateServer", "Start server with the specified settings", "void", "string,string,string,int", &VSquirrel::UI::CreateServerFromMenu);
|
||||
HSQVM_RegisterFunction(sqvm, "SetEncKeyAndConnect", "Set the encryption key to that of the specified server and connects to it", "void", "int", &VSquirrel::UI::SetEncKeyAndConnect);
|
||||
HSQVM_RegisterFunction(sqvm, "JoinPrivateServerFromMenu", "Joins private server by token", "void", "string", &VSquirrel::UI::JoinPrivateServerFromMenu);
|
||||
@ -318,18 +320,75 @@ void RegisterUIScriptFunctions(void* sqvm)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: Origin functions are the last to be registered in UI context, we register anything ours below
|
||||
// Purpose: Initialize all CLIENT/UI global structs and register SDK (CLIENT/UI) script functions
|
||||
// Input : *sqvm -
|
||||
// TODO : Hook 'CreateVM' instead
|
||||
// context - (1 = CLIENT 2 = UI)
|
||||
//---------------------------------------------------------------------------------
|
||||
void HSQVM_RegisterOriginFuncs(void* sqvm)
|
||||
int HSQVM_InitializeCLGlobalScriptStructs(void* sqvm/**(+8)*/, SQCONTEXT context)
|
||||
{
|
||||
if (sqvm == *g_pUIVM.RCast<void**>())
|
||||
RegisterUIScriptFunctions(sqvm);
|
||||
else
|
||||
RegisterClientScriptFunctions(sqvm);
|
||||
int results = SQVM_InitializeCLGlobalScriptStructs(sqvm/**(+8)*/, context);
|
||||
if (context == SQCONTEXT::CLIENT)
|
||||
SQVM_RegisterClientScriptFunctions(g_pClientVM.GetValue<void*>());
|
||||
if (context == SQCONTEXT::UI)
|
||||
SQVM_RegisterUIScriptFunctions(g_pUIVM.GetValue<void*>());
|
||||
return results;
|
||||
}
|
||||
#endif // !DEDICATED
|
||||
|
||||
return SQVM_RegisterOriginFuncs(sqvm);
|
||||
#ifndef CLIENT_DLL
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: Initialize all SERVER global structs and register SDK (SERVER) script functions
|
||||
// Input : *sqvm -
|
||||
//---------------------------------------------------------------------------------
|
||||
void HSQVM_InitializeSVGlobalScriptStructs(void* sqvm/**(+8)*/)
|
||||
{
|
||||
SQVM_InitializeSVGlobalScriptStructs(sqvm/**(+8)*/);
|
||||
SQVM_RegisterServerScriptFunctions(g_pServerVM.GetValue<void*>());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: Creates the SERVER Squirrel VM
|
||||
// Output : True on success, false on failure
|
||||
//---------------------------------------------------------------------------------
|
||||
bool HSQVM_CreateServerVM()
|
||||
{
|
||||
bool results = SQVM_CreateServerVM();
|
||||
if (results)
|
||||
DevMsg(eDLL_T::SERVER, "Created SERVER VM: '%p'\n", g_pServerVM.GetValue<void*>());
|
||||
else
|
||||
Error(eDLL_T::SERVER, "Failed to create SERVER VM\n");
|
||||
return results;
|
||||
}
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
#ifndef DEDICATED
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: Creates the CLIENT Squirrel VM
|
||||
// Input : *chlclient -
|
||||
// Output : True on success, false on failure
|
||||
//---------------------------------------------------------------------------------
|
||||
bool HSQVM_CreateClientVM(void* chlclient)
|
||||
{
|
||||
bool results = SQVM_CreateClientVM(chlclient);
|
||||
if (results)
|
||||
DevMsg(eDLL_T::CLIENT, "Created CLIENT VM: '%p'\n", g_pClientVM.GetValue<void*>());
|
||||
else
|
||||
Error(eDLL_T::CLIENT, "Failed to create CLIENT VM\n");
|
||||
return results;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: Creates the UI Squirrel VM
|
||||
// Output : True on success, false on failure
|
||||
//---------------------------------------------------------------------------------
|
||||
bool HSQVM_CreateUIVM()
|
||||
{
|
||||
bool results = SQVM_CreateUIVM();
|
||||
if (results)
|
||||
DevMsg(eDLL_T::UI, "Created UI VM: '%p'\n", g_pUIVM.GetValue<void*>());
|
||||
else
|
||||
Error(eDLL_T::UI, "Failed to create UI VM\n");
|
||||
return results;
|
||||
}
|
||||
#endif // !DEDICATED
|
||||
|
||||
@ -341,7 +400,15 @@ void SQVM_Attach()
|
||||
DetourAttach((LPVOID*)&SQVM_LoadRson, &HSQVM_LoadRson);
|
||||
DetourAttach((LPVOID*)&SQVM_LoadScript, &HSQVM_LoadScript);
|
||||
#ifndef DEDICATED
|
||||
DetourAttach((LPVOID*)&SQVM_RegisterOriginFuncs, &HSQVM_RegisterOriginFuncs);
|
||||
DetourAttach((LPVOID*)&SQVM_InitializeCLGlobalScriptStructs, &HSQVM_InitializeCLGlobalScriptStructs);
|
||||
#endif // !DEDICATED
|
||||
#ifndef CLIENT_DLL
|
||||
DetourAttach((LPVOID*)&SQVM_InitializeSVGlobalScriptStructs, &HSQVM_InitializeSVGlobalScriptStructs);
|
||||
DetourAttach((LPVOID*)&SQVM_CreateServerVM, &HSQVM_CreateServerVM);
|
||||
#endif // !CLIENT_DLL
|
||||
#ifndef DEDICATED
|
||||
DetourAttach((LPVOID*)&SQVM_CreateClientVM, &HSQVM_CreateClientVM);
|
||||
DetourAttach((LPVOID*)&SQVM_CreateUIVM, &HSQVM_CreateUIVM);
|
||||
#endif // !DEDICATED
|
||||
}
|
||||
|
||||
@ -353,7 +420,15 @@ void SQVM_Detach()
|
||||
DetourDetach((LPVOID*)&SQVM_LoadRson, &HSQVM_LoadRson);
|
||||
DetourDetach((LPVOID*)&SQVM_LoadScript, &HSQVM_LoadScript);
|
||||
#ifndef DEDICATED
|
||||
DetourDetach((LPVOID*)&SQVM_RegisterOriginFuncs, &HSQVM_RegisterOriginFuncs);
|
||||
DetourDetach((LPVOID*)&SQVM_InitializeCLGlobalScriptStructs, &HSQVM_InitializeCLGlobalScriptStructs);
|
||||
#endif // !DEDICATED
|
||||
#ifndef CLIENT_DLL
|
||||
DetourDetach((LPVOID*)&SQVM_InitializeSVGlobalScriptStructs, &HSQVM_InitializeSVGlobalScriptStructs);
|
||||
DetourDetach((LPVOID*)&SQVM_CreateServerVM, &HSQVM_CreateServerVM);
|
||||
#endif // !CLIENT_DLL
|
||||
#ifndef DEDICATED
|
||||
DetourDetach((LPVOID*)&SQVM_CreateClientVM, &HSQVM_CreateClientVM);
|
||||
DetourDetach((LPVOID*)&SQVM_CreateUIVM, &HSQVM_CreateUIVM);
|
||||
#endif // !DEDICATED
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,13 @@ typedef int SQRESULT;
|
||||
#define SQ_FAILED(res) (res<0)
|
||||
#define SQ_SUCCEEDED(res) (res>=0)
|
||||
|
||||
enum class SQCONTEXT : int
|
||||
{
|
||||
SERVER = 0,
|
||||
CLIENT,
|
||||
UI
|
||||
};
|
||||
|
||||
const static std::string SQVM_TYPE_T[3] =
|
||||
{
|
||||
"SERVER",
|
||||
@ -108,34 +115,38 @@ namespace
|
||||
|
||||
ADDRESS p_SQVM_CompileError = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xD9\x4C\x8B\xF2", "xxxx?xxxx?xxxx?xxxx?xxxxx????xxxxxx");
|
||||
void (*SQVM_CompileError)(void* sqvm, std::int64_t a2, std::int64_t a3, std::uint32_t a4, int a5) = (void(*)(void*, std::int64_t, std::int64_t, std::uint32_t, int))p_SQVM_CompileError.GetPtr();/*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 41 56 48 81 EC ? ? ? ? 48 8B D9 4C 8B F2*/
|
||||
#ifndef DEDICATED
|
||||
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(); /*E8 ? ? ? ? 48 8B 0D ? ? ? ? 48 8D 15 ? ? ? ? E8 ? ? ? ? 48 8B 05 ? ? ? ? C7 05 ? ? ? ? ? ? ? ?*/
|
||||
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
#if !defined (CLIENT_DLL)
|
||||
ADDRESS p_SQVM_InitializeSVGlobalScriptStructs = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x30\x48\x8B\x3D\x00\x00\x00\x00\x48\x8B\xF1", "xxxx?xxxxxxxx????xxx");
|
||||
void* (*SQVM_InitializeSVGlobalScriptStructs)(void* sqvm/**(+8)*/) = (void* (*)(void*))p_SQVM_InitializeSVGlobalScriptStructs.GetPtr(); /*48 89 74 24 ? 57 48 83 EC 30 48 8B 3D ? ? ? ? 48 8B F1*/
|
||||
#endif // !CLIENT_DLL
|
||||
#if !defined (DEDICATED)
|
||||
ADDRESS p_SQVM_InitializeCLGlobalScriptStructs = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x83\xEC\x30\x48\x63\xC2\x48\x8D\x3D\x00\x00\x00\x00", "xxxx?xxxx?xxxxxxxxxxxx????");
|
||||
int (*SQVM_InitializeCLGlobalScriptStructs)(void* sqvm/**(+8)*/, SQCONTEXT context) = (int (*)(void*, SQCONTEXT))p_SQVM_InitializeCLGlobalScriptStructs.GetPtr(); /*48 89 74 24 ? 48 89 7C 24 ? 41 56 48 83 EC 30 48 63 C2 48 8D 3D ? ? ? ?*/
|
||||
#endif // !DEDICATED
|
||||
|
||||
#if !defined (CLIENT_DLL) && defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
ADDRESS p_SQVM_CreateServerVM = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x48\x83\xEC\x50\x48\x8D\x0D\x00\x00\x00\x00", "xxxxxxxxx????");
|
||||
bool (*SQVM_CreateServerVM)() = (bool(*)())p_SQVM_CreateServerVM.GetPtr(); /*40 53 48 83 EC 50 48 8D 0D ? ? ? ?*/
|
||||
#endif // !CLIENT_DLL
|
||||
#elif defined (GAMEDLL_S3) || defined (GAMEDLL_S2)
|
||||
#if !defined (CLIENT_DLL)
|
||||
#elif !defined (CLIENT_DLL) && defined (GAMEDLL_S3) || defined (GAMEDLL_S2)
|
||||
ADDRESS p_SQVM_CreateServerVM = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x56\x48\x83\xEC\x48\x48\x8D\x0D\x00\x00\x00\x00", "xxxxxxxxxx????");
|
||||
bool (*SQVM_CreateServerVM)() = (bool(*)())p_SQVM_CreateServerVM.GetPtr(); /*40 53 56 48 83 EC 48 48 8D 0D ? ? ? ?*/
|
||||
#endif // !CLIENT_DLL
|
||||
#endif
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2)
|
||||
#if !defined (DEDICATED) && defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2)
|
||||
ADDRESS p_SQVM_CreateClientVM = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x83\xEC\x58\x48\x83\x3D\x00\x00\x00\x00\x00\x74\x05", "xxxxxxx?????xx");
|
||||
bool (*SQVM_CreateClientVM)(void* chlclient) = (bool(*)(void*))p_SQVM_CreateClientVM.GetPtr(); /*48 83 EC 58 48 83 3D ? ? ? ? ? 74 05*/
|
||||
#elif defined (GAMEDLL_S3)
|
||||
#elif !defined (DEDICATED) && defined (GAMEDLL_S3)
|
||||
ADDRESS p_SQVM_CreateClientVM = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x41\x57\x48\x83\xEC\x68\x48\x83\x3D\x00\x00\x00\x00\x00", "xxxxxxxxxxx?????");
|
||||
bool (*SQVM_CreateClientVM)(void* chlclient) = (bool(*)(void*))p_SQVM_CreateClientVM.GetPtr(); /*40 53 41 57 48 83 EC 68 48 83 3D ? ? ? ? ?*/
|
||||
#endif
|
||||
#if !defined (DEDICATED)
|
||||
ADDRESS p_SQVM_CreateUIVM = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x48\x83\xEC\x20\x48\x8B\x1D\x00\x00\x00\x00\xC6\x05\x00\x00\x00\x00\x00", "xxxxxxxxx????xx?????");
|
||||
bool (*SQVM_CreateUIVM)() = (bool(*)())p_SQVM_CreateUIVM.GetPtr(); /*40 53 48 83 EC 20 48 8B 1D ? ? ? ? C6 05 ? ? ? ? ?*/
|
||||
#endif // !DEDICATED
|
||||
|
||||
#if !defined (CLIENT_DLL)
|
||||
ADDRESS g_pServerVM = p_SQVM_CreateServerVM.FindPatternSelf("48 89 1D", ADDRESS::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x8);
|
||||
ADDRESS g_pServerVM = p_SQVM_CreateServerVM.FindPatternSelf("48 89 1D", ADDRESS::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x7);
|
||||
#endif // !CLIENT_DLL
|
||||
#if !defined (DEDICATED)
|
||||
ADDRESS g_pClientVM = p_SQVM_CreateClientVM.FindPatternSelf("48 83 3D", ADDRESS::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x8);
|
||||
ADDRESS g_pUIVM = p_SQVM_CreateUIVM.FindPatternSelf("48 8B 1D", ADDRESS::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x7);
|
||||
#endif // !DEDICATED
|
||||
@ -144,9 +155,7 @@ namespace
|
||||
void* HSQVM_PrintFunc(void* sqvm, char* fmt, ...);
|
||||
void* HSQVM_LoadRson(const char* szRsonName);
|
||||
bool HSQVM_LoadScript(void* sqvm, const char* szScriptPath, const char* szScriptName, int nFlags);
|
||||
|
||||
void HSQVM_RegisterFunction(void* sqvm, const char* szName, const char* szHelpString, const char* szRetValType, const char* szArgTypes, void* pFunction);
|
||||
void HSQVM_RegisterOriginFuncs(void* sqvm);
|
||||
|
||||
void SQVM_Attach();
|
||||
void SQVM_Detach();
|
||||
@ -165,16 +174,23 @@ class HSQVM : public IDetour
|
||||
std::cout << "| FUN: SQVM_WarningCmd : 0x" << std::hex << std::uppercase << p_SQVM_WarningCmd.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: SQVM_RegisterFunc : 0x" << std::hex << std::uppercase << p_SQVM_RegisterFunc.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: SQVM_CompileError : 0x" << std::hex << std::uppercase << p_SQVM_CompileError.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
#ifndef CLIENT_DLL
|
||||
std::cout << "| FUN: SQVM_InitializeSVGlobalScriptStructs : 0x" << std::hex << std::uppercase << p_SQVM_InitializeSVGlobalScriptStructs.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
#endif // !CLIENT_DLL
|
||||
#ifndef DEDICATED
|
||||
std::cout << "| FUN: SQVM_RegisterOriginFuncs : 0x" << std::hex << std::uppercase << p_SQVM_RegisterOriginFuncs.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: SQVM_InitializeCLGlobalScriptStructs : 0x" << std::hex << std::uppercase << p_SQVM_InitializeCLGlobalScriptStructs.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
#endif // !DEDICATED
|
||||
#ifndef CLIENT_DLL
|
||||
std::cout << "| FUN: SQVM_CreateServerVM : 0x" << std::hex << std::uppercase << p_SQVM_CreateServerVM.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
#endif // !CLIENT_DLL
|
||||
#ifndef DEDICATED
|
||||
std::cout << "| FUN: SQVM_CreateClientVM : 0x" << std::hex << std::uppercase << p_SQVM_CreateClientVM.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: SQVM_CreateUIVM : 0x" << std::hex << std::uppercase << p_SQVM_CreateUIVM.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
#endif // !DEDICATED
|
||||
#ifndef CLIENT_DLL
|
||||
std::cout << "| VAR: g_pServerVM : 0x" << std::hex << std::uppercase << g_pServerVM.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
#endif // !CLIENT_DLL
|
||||
#ifndef DEDICATED
|
||||
std::cout << "| VAR: g_pClientVM : 0x" << std::hex << std::uppercase << g_pClientVM.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| VAR: g_pUIVM : 0x" << std::hex << std::uppercase << g_pUIVM.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
#endif // !DEDICATED
|
||||
|
@ -140,8 +140,8 @@ void ConCommand::Init(void)
|
||||
//-------------------------------------------------------------------------
|
||||
// RTECH API |
|
||||
ConCommand* rtech_strtoguid = new ConCommand("rtech_strtoguid", "Calculates the GUID from input data.", FCVAR_DEVELOPMENTONLY, _RTech_StringToGUID_f_CompletionFunc, nullptr);
|
||||
ConCommand* pak_requestload = new ConCommand("pak_requestload", "Requests asynchronous load for specified RPAK FILE.", FCVAR_DEVELOPMENTONLY, _Pak_RequestLoad_f_CompletionFunc, nullptr);
|
||||
ConCommand* pak_requestunload = new ConCommand("pak_requestunload", "Requests unload for specified RPAK ID.", FCVAR_DEVELOPMENTONLY, _Pak_RequestUnload_f_CompletionFunc, nullptr);
|
||||
ConCommand* pak_requestload = new ConCommand("pak_requestload", "Requests asynchronous load for specified RPAK file.", FCVAR_DEVELOPMENTONLY, _Pak_RequestLoad_f_CompletionFunc, nullptr);
|
||||
ConCommand* pak_requestunload = new ConCommand("pak_requestunload", "Requests unload for specified RPAK by ID.", FCVAR_DEVELOPMENTONLY, _Pak_RequestUnload_f_CompletionFunc, nullptr);
|
||||
ConCommand* pak_decompress = new ConCommand("pak_decompress", "Decompresses the specified RPAK file.", FCVAR_DEVELOPMENTONLY, _RTech_Decompress_f_CompletionFunc, nullptr);
|
||||
ConCommand* pak_listpaks = new ConCommand("pak_listpaks", "Display a list of the loaded Pak files.", FCVAR_DEVELOPMENTONLY, _Pak_ListPaks_f_CompletionFunc, nullptr);
|
||||
//-------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user