mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Adapt majority of SQVM to SQ types
This commit is contained in:
parent
42ef6ef228
commit
66146f6590
@ -8,6 +8,7 @@
|
||||
#include "squirrel/sqapi.h"
|
||||
#include "squirrel/sqtype.h"
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
SQChar* sq_getstring(HSQUIRRELVM v, SQInteger i)
|
||||
{
|
||||
std::uintptr_t thisptr = reinterpret_cast<std::uintptr_t>(v);
|
||||
@ -15,6 +16,7 @@ SQChar* sq_getstring(HSQUIRRELVM v, SQInteger i)
|
||||
return *(char**)(*(std::int64_t*)(thisptr + 0x58) + 0x10 * i + 0x8) + 0x40;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
SQInteger sq_getinteger(HSQUIRRELVM v, SQInteger i)
|
||||
{
|
||||
std::uintptr_t thisptr = reinterpret_cast<std::uintptr_t>(v);
|
||||
@ -22,61 +24,73 @@ SQInteger sq_getinteger(HSQUIRRELVM v, SQInteger i)
|
||||
return *(SQInteger*)(*(std::int64_t*)(thisptr + 0x58) + 0x10 * i + 0x8);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
SQRESULT sq_pushroottable(HSQUIRRELVM v)
|
||||
{
|
||||
return v_sq_pushroottable(v);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
void sq_pushbool(HSQUIRRELVM v, SQBool b)
|
||||
{
|
||||
v_sq_pushbool(v, b);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
void sq_pushstring(HSQUIRRELVM v, const SQChar* s, SQInteger len)
|
||||
{
|
||||
v_sq_pushstring(v, s, len);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
void sq_pushinteger(HSQUIRRELVM v, SQInteger val)
|
||||
{
|
||||
v_sq_pushinteger(v, val);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
void sq_pushconstant(HSQUIRRELVM v, const SQChar* name, SQInteger val)
|
||||
{
|
||||
v_sq_pushconstant(v, name, val);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
void sq_newarray(HSQUIRRELVM v, SQInteger size)
|
||||
{
|
||||
v_sq_newarray(v, size);
|
||||
}
|
||||
|
||||
void sq_arrayappend(HSQUIRRELVM v, SQInteger idx)
|
||||
{
|
||||
v_sq_arrayappend(v, idx);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
void sq_newtable(HSQUIRRELVM v)
|
||||
{
|
||||
v_sq_newtable(v);
|
||||
}
|
||||
|
||||
void sq_newslot(HSQUIRRELVM v, SQInteger idx)
|
||||
//---------------------------------------------------------------------------------
|
||||
SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx)
|
||||
{
|
||||
v_sq_newslot(v, idx);
|
||||
return v_sq_newslot(v, idx);
|
||||
}
|
||||
|
||||
void sq_pushstructure(HSQUIRRELVM v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2)
|
||||
//---------------------------------------------------------------------------------
|
||||
SQRESULT sq_arrayappend(HSQUIRRELVM v, SQInteger idx)
|
||||
{
|
||||
v_sq_pushstructure(v, name, member, codeclass1, codeclass2);
|
||||
return v_sq_arrayappend(v, idx);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
SQRESULT sq_pushstructure(HSQUIRRELVM v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2)
|
||||
{
|
||||
return v_sq_pushstructure(v, name, member, codeclass1, codeclass2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
SQRESULT sq_compilebuffer(HSQUIRRELVM v, SQBufState* bufferState, const SQChar* buffer, SQInteger level)
|
||||
{
|
||||
return v_sq_compilebuffer(v, bufferState, buffer, level);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
SQRESULT sq_call(HSQUIRRELVM v, SQInteger params, SQBool retval, SQBool raiseerror)
|
||||
{
|
||||
return v_sq_call(v, params, retval, raiseerror);
|
||||
@ -90,9 +104,9 @@ void SQAPI_Attach()
|
||||
DetourAttach((LPVOID*)&v_sq_pushinteger, &sq_pushinteger);
|
||||
DetourAttach((LPVOID*)&v_sq_pushconstant, &sq_pushconstant);
|
||||
DetourAttach((LPVOID*)&v_sq_newarray, &sq_newarray);
|
||||
DetourAttach((LPVOID*)&v_sq_arrayappend, &sq_arrayappend);
|
||||
DetourAttach((LPVOID*)&v_sq_newtable, &sq_newtable);
|
||||
DetourAttach((LPVOID*)&v_sq_newslot, &sq_newslot);
|
||||
DetourAttach((LPVOID*)&v_sq_arrayappend, &sq_arrayappend);
|
||||
DetourAttach((LPVOID*)&v_sq_pushstructure, &sq_pushstructure);
|
||||
DetourAttach((LPVOID*)&v_sq_compilebuffer, &sq_compilebuffer);
|
||||
DetourAttach((LPVOID*)&v_sq_call, &sq_call);
|
||||
@ -106,9 +120,9 @@ void SQAPI_Detach()
|
||||
DetourDetach((LPVOID*)&v_sq_pushinteger, &sq_pushinteger);
|
||||
DetourDetach((LPVOID*)&v_sq_pushconstant, &sq_pushconstant);
|
||||
DetourDetach((LPVOID*)&v_sq_newarray, &sq_newarray);
|
||||
DetourDetach((LPVOID*)&v_sq_arrayappend, &sq_arrayappend);
|
||||
DetourDetach((LPVOID*)&v_sq_newtable, &sq_newtable);
|
||||
DetourDetach((LPVOID*)&v_sq_newslot, &sq_newslot);
|
||||
DetourDetach((LPVOID*)&v_sq_arrayappend, &sq_arrayappend);
|
||||
DetourDetach((LPVOID*)&v_sq_pushstructure, &sq_pushstructure);
|
||||
DetourDetach((LPVOID*)&v_sq_compilebuffer, &sq_compilebuffer);
|
||||
DetourDetach((LPVOID*)&v_sq_call, &sq_call);
|
||||
|
@ -11,7 +11,7 @@ namespace
|
||||
void (*v_sq_pushbool)(HSQUIRRELVM v, SQBool b) = (void (*)(HSQUIRRELVM, SQBool))p_sq_pushbool.GetPtr(); /*48 83 EC 38 33 C0 48 C7 44 24 20 08 00 00 01 48*/
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2)
|
||||
ADDRESS p_sq_pushstring = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x56\x48\x83\xEC\x30\x48\x8B\xF1\x48\x85\xD2\x0F\x84\x8C\x00", "xxxxxxxxxxxxxxxx");
|
||||
void (*v_sq_pushstring)(HSQUIRRELVM v, const SQChar* string, int len) = (void (*)(HSQUIRRELVM, const SQChar*, int))p_sq_pushstring.GetPtr(); /*40 56 48 83 EC 30 48 8B F1 48 85 D2 0F 84 8C 00*/
|
||||
void (*v_sq_pushstring)(HSQUIRRELVM v, const SQChar* string, SQInteger len) = (void (*)(HSQUIRRELVM, const SQChar*, SQInteger))p_sq_pushstring.GetPtr(); /*40 56 48 83 EC 30 48 8B F1 48 85 D2 0F 84 8C 00*/
|
||||
#elif defined (GAMEDLL_S3)
|
||||
ADDRESS p_sq_pushstring = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x56\x48\x83\xEC\x30\x48\x8B\xF1\x48\x85\xD2\x0F\x84\x8F\x00", "xxxxxxxxxxxxxxxx");
|
||||
void (*v_sq_pushstring)(HSQUIRRELVM v, const SQChar* string, SQInteger len) = (void (*)(HSQUIRRELVM, const SQChar*, SQInteger))p_sq_pushstring.GetPtr(); /*40 56 48 83 EC 30 48 8B F1 48 85 D2 0F 84 8F 00*/
|
||||
@ -25,20 +25,20 @@ namespace
|
||||
ADDRESS p_sq_newarray = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x08\x57\x48\x83\xEC\x30\x48\x8B\xD9\x48\xC7\x44\x24\x20\x40", "xxxxxxxxxxxxxxxxxxx");
|
||||
void (*v_sq_newarray)(HSQUIRRELVM v, SQInteger size) = (void (*)(HSQUIRRELVM, SQInteger))p_sq_newarray.GetPtr(); /*48 89 5C 24 08 57 48 83 EC 30 48 8B D9 48 C7 44 24 20 40*/
|
||||
|
||||
ADDRESS p_sq_arrayappend = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x48\x83\xEC\x20\x8B\x41\x00\x48\x8B\xD9\x2B\x41\x00\x83\xF8\x02\x7D", "xxxxxxxx?xxxxx?xxxx");
|
||||
void (*v_sq_arrayappend)(HSQUIRRELVM v, SQInteger idx) = (void (*)(HSQUIRRELVM, SQInteger))p_sq_arrayappend.GetPtr(); /*40 53 48 83 EC 20 8B 41 ?? 48 8B D9 2B 41 ?? 83 F8 02 7D*/
|
||||
|
||||
ADDRESS p_sq_newtable = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x08\x57\x48\x83\xEC\x30\x48\x8B\xD9\x48\xC7\x44\x24\x20\x20", "xxxxxxxxxxxxxxxxxxx");
|
||||
void (*v_sq_newtable)(HSQUIRRELVM v) = (void (*)(HSQUIRRELVM))p_sq_newtable.GetPtr(); /*48 89 5C 24 08 57 48 83 EC 30 48 8B D9 48 C7 44 24 20 20*/
|
||||
|
||||
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 (*v_sq_newslot)(HSQUIRRELVM v, SQInteger idx) = (void (*)(HSQUIRRELVM, SQInteger))p_sq_newslot.GetPtr(); /*40 53 48 83 EC 20 8B 41 ?? 48 8B D9 2B 41 ?? 83 F8 02 7D*/
|
||||
SQRESULT(*v_sq_newslot)(HSQUIRRELVM v, SQInteger idx) = (SQRESULT(*)(HSQUIRRELVM, SQInteger))p_sq_newslot.GetPtr(); /*40 53 48 83 EC 20 8B 41 ?? 48 8B D9 2B 41 ?? 83 F8 02 7D*/
|
||||
|
||||
ADDRESS p_sq_arrayappend = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x48\x83\xEC\x20\x8B\x41\x00\x48\x8B\xD9\x2B\x41\x00\x83\xF8\x02\x7D", "xxxxxxxx?xxxxx?xxxx");
|
||||
SQRESULT(*v_sq_arrayappend)(HSQUIRRELVM v, SQInteger idx) = (SQRESULT(*)(HSQUIRRELVM, SQInteger))p_sq_arrayappend.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 (*v_sq_pushstructure)(HSQUIRRELVM v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2) = (void (*)(HSQUIRRELVM, const SQChar*, const SQChar*, const SQChar*, const SQChar*))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*/
|
||||
SQRESULT(*v_sq_pushstructure)(HSQUIRRELVM v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2) = (SQRESULT(*)(HSQUIRRELVM, const SQChar*, const SQChar*, const SQChar*, const SQChar*))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 (*v_sq_pushstructure)(HSQUIRRELVM v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2) = (void (*)(HSQUIRRELVM, const SQChar*, const SQChar*, const SQChar*, const SQChar*))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*/
|
||||
SQRESULT (*v_sq_pushstructure)(HSQUIRRELVM v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2) = (SQRESULT(*)(HSQUIRRELVM, const SQChar*, const SQChar*, const SQChar*, const SQChar*))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
|
||||
ADDRESS p_sq_compilebuffer = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x41\x56\x41\x57\x48\x83\xEC\x50\x41\x8B\xE9\x49\x8B\xF8", "xxxx?xxxx?xxxx?xxxxxxxxxxxxxxx");
|
||||
SQRESULT (*v_sq_compilebuffer)(HSQUIRRELVM v, SQBufState* bufferState, const SQChar* buffer, SQInteger level) = (SQRESULT (*)(HSQUIRRELVM, SQBufState*, const SQChar*, SQInteger))p_sq_compilebuffer.GetPtr(); /*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 41 56 41 57 48 83 EC 50 41 8B E9 49 8B F8*/
|
||||
@ -57,10 +57,10 @@ void sq_pushstring(HSQUIRRELVM v, const SQChar* string, SQInteger len);
|
||||
void sq_pushinteger(HSQUIRRELVM v, SQInteger val);
|
||||
void sq_pushconstant(HSQUIRRELVM v, const SQChar* name, SQInteger val);
|
||||
void sq_newarray(HSQUIRRELVM v, SQInteger size);
|
||||
void sq_arrayappend(HSQUIRRELVM v, SQInteger idx);
|
||||
void sq_newtable(HSQUIRRELVM v);
|
||||
void sq_newslot(HSQUIRRELVM v, SQInteger idx);
|
||||
void sq_pushstructure(HSQUIRRELVM v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2);
|
||||
SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx);
|
||||
SQRESULT sq_arrayappend(HSQUIRRELVM v, SQInteger idx);
|
||||
SQRESULT sq_pushstructure(HSQUIRRELVM v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2);
|
||||
SQRESULT sq_compilebuffer(HSQUIRRELVM v, SQBufState* bufferState, const SQChar* buffer, SQInteger context);
|
||||
SQRESULT sq_call(HSQUIRRELVM v, SQInteger params, SQBool retval, SQBool raiseerror);
|
||||
|
||||
|
@ -72,14 +72,16 @@ enum class SQCONTEXT : int
|
||||
{
|
||||
SERVER = 0,
|
||||
CLIENT,
|
||||
UI
|
||||
UI,
|
||||
NONE
|
||||
};
|
||||
|
||||
const static std::string SQVM_TYPE_T[3] =
|
||||
const static std::string SQVM_TYPE_T[4] =
|
||||
{
|
||||
"SERVER",
|
||||
"CLIENT",
|
||||
"UI",
|
||||
"NONE"
|
||||
};
|
||||
|
||||
const static std::string SQVM_LOG_T[4] =
|
||||
|
@ -25,33 +25,33 @@
|
||||
// *fmt -
|
||||
// ... -
|
||||
//---------------------------------------------------------------------------------
|
||||
void* HSQVM_PrintFunc(void* sqvm, char* fmt, ...)
|
||||
SQRESULT HSQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
||||
{
|
||||
static int vmIdx{};
|
||||
static SQCONTEXT context{};
|
||||
// We use the sqvm pointer as index for SDK usage as the function prototype has to match assembly.
|
||||
switch (reinterpret_cast<int>(sqvm))
|
||||
switch (static_cast<SQCONTEXT>(reinterpret_cast<int>(v)))
|
||||
{
|
||||
case 0:
|
||||
vmIdx = 0;
|
||||
case SQCONTEXT::SERVER:
|
||||
context = SQCONTEXT::SERVER;
|
||||
break;
|
||||
case 1:
|
||||
vmIdx = 1;
|
||||
case SQCONTEXT::CLIENT:
|
||||
context = SQCONTEXT::CLIENT;
|
||||
break;
|
||||
case 2:
|
||||
vmIdx = 2;
|
||||
case SQCONTEXT::UI:
|
||||
context = SQCONTEXT::UI;
|
||||
break;
|
||||
case 3:
|
||||
vmIdx = 3;
|
||||
case SQCONTEXT::NONE:
|
||||
context = SQCONTEXT::NONE;
|
||||
break;
|
||||
default:
|
||||
#ifdef GAMEDLL_S3
|
||||
vmIdx = *reinterpret_cast<int*>(reinterpret_cast<std::uintptr_t>(sqvm) + 0x18);
|
||||
context = *reinterpret_cast<SQCONTEXT*>(reinterpret_cast<std::uintptr_t>(v) + 0x18);
|
||||
#else // TODO [ AMOS ]: nothing equal to 'rdx + 18h' exist in the vm structs for anything below S3.
|
||||
vmIdx = 3;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
static char buf[1024] = {};
|
||||
static SQChar buf[1024] = {};
|
||||
static std::regex rxAnsiExp("\\\033\\[.*?m");
|
||||
|
||||
static std::shared_ptr<spdlog::logger> iconsole = spdlog::get("game_console");
|
||||
@ -68,7 +68,7 @@ void* HSQVM_PrintFunc(void* sqvm, char* fmt, ...)
|
||||
va_end(args);
|
||||
}/////////////////////////////
|
||||
|
||||
std::string vmStr = SQVM_LOG_T[vmIdx].c_str();
|
||||
std::string vmStr = SQVM_LOG_T[static_cast<SQInteger>(context)].c_str();
|
||||
vmStr.append(buf);
|
||||
|
||||
if (sq_showvmoutput->GetInt() > 0)
|
||||
@ -86,7 +86,7 @@ void* HSQVM_PrintFunc(void* sqvm, char* fmt, ...)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string vmStrAnsi = SQVM_ANSI_LOG_T[vmIdx].c_str();
|
||||
std::string vmStrAnsi = SQVM_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str();
|
||||
vmStrAnsi.append(buf);
|
||||
wconsole->debug(vmStrAnsi);
|
||||
#ifdef DEDICATED
|
||||
@ -103,14 +103,14 @@ void* HSQVM_PrintFunc(void* sqvm, char* fmt, ...)
|
||||
std::string s = g_spd_sys_w_oss.str();
|
||||
|
||||
g_pIConsole->m_ivConLog.push_back(Strdup(s.c_str()));
|
||||
g_pLogSystem.AddLog(static_cast<LogType_t>(vmIdx), s);
|
||||
g_pLogSystem.AddLog(static_cast<LogType_t>(context), s);
|
||||
|
||||
g_spd_sys_w_oss.str("");
|
||||
g_spd_sys_w_oss.clear();
|
||||
}
|
||||
#endif // !DEDICATED
|
||||
}
|
||||
return NULL;
|
||||
return SQ_OK;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
@ -121,27 +121,27 @@ void* HSQVM_PrintFunc(void* sqvm, char* fmt, ...)
|
||||
// *nStringSize -
|
||||
// **ppString -
|
||||
//---------------------------------------------------------------------------------
|
||||
void* HSQVM_WarningFunc(void* sqvm, int a2, int a3, int* nStringSize, void** ppString)
|
||||
SQRESULT HSQVM_WarningFunc(HSQUIRRELVM v, SQInteger a2, SQInteger a3, SQInteger* nStringSize, SQChar** ppString)
|
||||
{
|
||||
static void* retaddr = reinterpret_cast<void*>(p_SQVM_WarningCmd.Offset(0x10).FindPatternSelf("85 ?? ?? 99", ADDRESS::Direction::DOWN).GetPtr());
|
||||
void* result = SQVM_WarningFunc(sqvm, a2, a3, nStringSize, ppString);
|
||||
SQRESULT result = SQVM_WarningFunc(v, a2, a3, nStringSize, ppString);
|
||||
|
||||
if (retaddr != _ReturnAddress()) // Check if its SQVM_Warning calling.
|
||||
{
|
||||
return result; // If not return.
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef GAMEDLL_S3
|
||||
int vmIdx = *(int*)((std::uintptr_t)sqvm + 0x18);
|
||||
SQCONTEXT context = *reinterpret_cast<SQCONTEXT*>(reinterpret_cast<std::uintptr_t>(v) + 0x18);
|
||||
#else // TODO [ AMOS ]: nothing equal to 'rdx + 18h' exist in the vm structs for anything below S3.
|
||||
int vmIdx = 3;
|
||||
SQCONTEXT context = SQCONTEXT::NONE;
|
||||
#endif
|
||||
|
||||
static std::shared_ptr<spdlog::logger> iconsole = spdlog::get("game_console");
|
||||
static std::shared_ptr<spdlog::logger> wconsole = spdlog::get("win_console");
|
||||
static std::shared_ptr<spdlog::logger> sqlogger = spdlog::get("sqvm_warn_logger");
|
||||
|
||||
std::string vmStr = SQVM_WARNING_LOG_T[vmIdx].c_str();
|
||||
std::string vmStr = SQVM_WARNING_LOG_T[static_cast<int>(context)].c_str();
|
||||
std::string svConstructor((char*)*ppString, *nStringSize); // Get string from memory via std::string constructor.
|
||||
vmStr.append(svConstructor);
|
||||
|
||||
@ -160,7 +160,7 @@ void* HSQVM_WarningFunc(void* sqvm, int a2, int a3, int* nStringSize, void** ppS
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string vmStrAnsi = SQVM_WARNING_ANSI_LOG_T[vmIdx].c_str();
|
||||
std::string vmStrAnsi = SQVM_WARNING_ANSI_LOG_T[static_cast<int>(context)].c_str();
|
||||
vmStrAnsi.append(svConstructor);
|
||||
wconsole->debug(vmStrAnsi);
|
||||
#ifdef DEDICATED
|
||||
@ -195,29 +195,29 @@ void* HSQVM_WarningFunc(void* sqvm, int a2, int a3, int* nStringSize, void** ppS
|
||||
// nLine -
|
||||
// nColumn -
|
||||
//---------------------------------------------------------------------------------
|
||||
void HSQVM_ErrorFunc(void* sqvm, const char* pszError, const char* pszFile, unsigned int nLine, int nColumn)
|
||||
void HSQVM_CompileError(HSQUIRRELVM v, const SQChar* pszError, const SQChar* pszFile, SQUnsignedInteger nLine, SQInteger nColumn)
|
||||
{
|
||||
static int vmIdx{};
|
||||
static SQCONTEXT context{};
|
||||
static char szContextBuf[256]{};
|
||||
|
||||
#ifdef GAMEDLL_S3
|
||||
vmIdx = *reinterpret_cast<int*>(reinterpret_cast<std::uintptr_t>(sqvm) + 0x18);
|
||||
context = *reinterpret_cast<SQCONTEXT*>(reinterpret_cast<std::uintptr_t>(v) + 0x18);
|
||||
#else // TODO [ AMOS ]: nothing equal to 'rdx + 18h' exist in the vm structs for anything below S3.
|
||||
vmIdx = 3;
|
||||
#endif
|
||||
|
||||
SQVM_GetErrorLine(pszFile, nLine, szContextBuf, sizeof(szContextBuf));
|
||||
|
||||
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);
|
||||
Error(static_cast<eDLL_T>(context), "%s SCRIPT COMPILE ERROR: %s\n", SQVM_TYPE_T[static_cast<int>(context)].c_str(), pszError);
|
||||
Error(static_cast<eDLL_T>(context), " -> %s\n\n", szContextBuf);
|
||||
Error(static_cast<eDLL_T>(context), "%s line [%d] column [%d]\n", pszFile, nLine, nColumn);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: prints the global include file the compiler loads for loading scripts
|
||||
// Input : *szRsonName -
|
||||
//---------------------------------------------------------------------------------
|
||||
void* HSQVM_LoadRson(const char* szRsonName)
|
||||
SQInteger HSQVM_LoadRson(const SQChar* szRsonName)
|
||||
{
|
||||
if (sq_showrsonloading->GetBool())
|
||||
{
|
||||
@ -237,7 +237,7 @@ void* HSQVM_LoadRson(const char* szRsonName)
|
||||
// *szScriptPath -
|
||||
// nFlag -
|
||||
//---------------------------------------------------------------------------------
|
||||
bool HSQVM_LoadScript(void* sqvm, const char* szScriptPath, const char* szScriptName, int nFlag)
|
||||
SQBool HSQVM_LoadScript(HSQUIRRELVM v, const SQChar* szScriptPath, const SQChar* szScriptName, SQInteger nFlag)
|
||||
{
|
||||
if (sq_showscriptloading->GetBool())
|
||||
{
|
||||
@ -245,7 +245,7 @@ bool HSQVM_LoadScript(void* sqvm, const char* szScriptPath, const char* szScript
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
return SQVM_LoadScript(sqvm, szScriptPath, szScriptName, nFlag);
|
||||
return SQVM_LoadScript(v, szScriptPath, szScriptName, nFlag);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
@ -257,7 +257,7 @@ bool HSQVM_LoadScript(void* sqvm, const char* szScriptPath, const char* szScript
|
||||
// *szArgTypes -
|
||||
// *pFunction -
|
||||
//---------------------------------------------------------------------------------
|
||||
void HSQVM_RegisterFunction(void* sqvm, const char* szName, const char* szHelpString, const char* szRetValType, const char* szArgTypes, void* pFunction)
|
||||
SQRESULT HSQVM_RegisterFunction(HSQUIRRELVM v, const SQChar* szName, const SQChar* szHelpString, const SQChar* szRetValType, const SQChar* szArgTypes, void* pFunction)
|
||||
{
|
||||
SQFuncRegistration* sqFunc = new SQFuncRegistration();
|
||||
|
||||
@ -268,17 +268,17 @@ void HSQVM_RegisterFunction(void* sqvm, const char* szName, const char* szHelpSt
|
||||
sqFunc->m_szArgTypes = szArgTypes;
|
||||
sqFunc->m_pFunction = pFunction;
|
||||
|
||||
SQVM_RegisterFunc(sqvm, sqFunc, 1);
|
||||
return SQVM_RegisterFunc(v, sqFunc, 1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: registers script functions in SERVER context
|
||||
// Input : *sqvm -
|
||||
//---------------------------------------------------------------------------------
|
||||
void SQVM_RegisterServerScriptFunctions(void* sqvm)
|
||||
void SQVM_RegisterServerScriptFunctions(HSQUIRRELVM v)
|
||||
{
|
||||
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);
|
||||
HSQVM_RegisterFunction(v, "SDKNativeTest", "Native SERVER test function", "void", "", &VSquirrel::SHARED::SDKNativeTest);
|
||||
HSQVM_RegisterFunction(v, "GetSDKVersion", "Gets the SDK version as a string", "string", "", &VSquirrel::SHARED::GetSDKVersion);
|
||||
}
|
||||
|
||||
#ifndef DEDICATED
|
||||
@ -286,38 +286,38 @@ void SQVM_RegisterServerScriptFunctions(void* sqvm)
|
||||
// Purpose: registers script functions in CLIENT context
|
||||
// Input : *sqvm -
|
||||
//---------------------------------------------------------------------------------
|
||||
void SQVM_RegisterClientScriptFunctions(void* sqvm)
|
||||
void SQVM_RegisterClientScriptFunctions(HSQUIRRELVM v)
|
||||
{
|
||||
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);
|
||||
HSQVM_RegisterFunction(v, "SDKNativeTest", "Native CLIENT test function", "void", "", &VSquirrel::SHARED::SDKNativeTest);
|
||||
HSQVM_RegisterFunction(v, "GetSDKVersion", "Gets the SDK version as a string", "string", "", &VSquirrel::SHARED::GetSDKVersion);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: registers script functions in UI context
|
||||
// Input : *sqvm -
|
||||
//---------------------------------------------------------------------------------
|
||||
void SQVM_RegisterUIScriptFunctions(void* sqvm)
|
||||
void SQVM_RegisterUIScriptFunctions(HSQUIRRELVM v)
|
||||
{
|
||||
HSQVM_RegisterFunction(sqvm, "SDKNativeTest", "Native UI test function", "void", "", &VSquirrel::SHARED::SDKNativeTest);
|
||||
HSQVM_RegisterFunction(v, "SDKNativeTest", "Native UI test function", "void", "", &VSquirrel::SHARED::SDKNativeTest);
|
||||
|
||||
// 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);
|
||||
HSQVM_RegisterFunction(v, "GetServerName", "Gets the name of the server at the specified index of the server list", "string", "int", &VSquirrel::UI::GetServerName);
|
||||
HSQVM_RegisterFunction(v, "GetServerPlaylist", "Gets the playlist of the server at the specified index of the server list", "string", "int", &VSquirrel::UI::GetServerPlaylist);
|
||||
HSQVM_RegisterFunction(v, "GetServerMap", "Gets the map of the server at the specified index of the server list", "string", "int", &VSquirrel::UI::GetServerMap);
|
||||
HSQVM_RegisterFunction(v, "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::SHARED::GetSDKVersion);
|
||||
HSQVM_RegisterFunction(sqvm, "GetPromoData", "Gets promo data for specified slot type", "string", "int", &VSquirrel::UI::GetPromoData);
|
||||
HSQVM_RegisterFunction(v, "GetSDKVersion", "Gets the SDK version as a string", "string", "", &VSquirrel::SHARED::GetSDKVersion);
|
||||
HSQVM_RegisterFunction(v, "GetPromoData", "Gets promo data for specified slot type", "string", "int", &VSquirrel::UI::GetPromoData);
|
||||
|
||||
// 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);
|
||||
HSQVM_RegisterFunction(sqvm, "GetPrivateServerMessage", "Gets private server join status message", "string", "string", &VSquirrel::UI::GetPrivateServerMessage);
|
||||
HSQVM_RegisterFunction(sqvm, "ConnectToIPFromMenu", "Joins server by ip and encryption key", "void", "string,string", &VSquirrel::UI::ConnectToIPFromMenu);
|
||||
HSQVM_RegisterFunction(v, "CreateServer", "Start server with the specified settings", "void", "string,string,string,int", &VSquirrel::UI::CreateServerFromMenu);
|
||||
HSQVM_RegisterFunction(v, "SetEncKeyAndConnect", "Set the encryption key to that of the specified server and connects to it", "void", "int", &VSquirrel::UI::SetEncKeyAndConnect);
|
||||
HSQVM_RegisterFunction(v, "JoinPrivateServerFromMenu", "Joins private server by token", "void", "string", &VSquirrel::UI::JoinPrivateServerFromMenu);
|
||||
HSQVM_RegisterFunction(v, "GetPrivateServerMessage", "Gets private server join status message", "string", "string", &VSquirrel::UI::GetPrivateServerMessage);
|
||||
HSQVM_RegisterFunction(v, "ConnectToIPFromMenu", "Joins server by ip and encryption key", "void", "string,string", &VSquirrel::UI::ConnectToIPFromMenu);
|
||||
|
||||
HSQVM_RegisterFunction(sqvm, "GetAvailableMaps", "Gets an array of all the available maps that can be used to host a server", "array<string>", "", &VSquirrel::UI::GetAvailableMaps);
|
||||
HSQVM_RegisterFunction(v, "GetAvailableMaps", "Gets an array of all the available maps that can be used to host a server", "array<string>", "", &VSquirrel::UI::GetAvailableMaps);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
@ -325,13 +325,13 @@ void SQVM_RegisterUIScriptFunctions(void* sqvm)
|
||||
// Input : *sqvm -
|
||||
// context - (1 = CLIENT 2 = UI)
|
||||
//---------------------------------------------------------------------------------
|
||||
int HSQVM_InitializeCLGlobalScriptStructs(void* sqvm/**(+8)*/, SQCONTEXT context)
|
||||
SQInteger HSQVM_InitializeCLGlobalScriptStructs(SQVM* sqvm, SQCONTEXT context)
|
||||
{
|
||||
int results = SQVM_InitializeCLGlobalScriptStructs(sqvm/**(+8)*/, context);
|
||||
int results = SQVM_InitializeCLGlobalScriptStructs(sqvm, context);
|
||||
if (context == SQCONTEXT::CLIENT)
|
||||
SQVM_RegisterClientScriptFunctions(g_pClientVM.GetValue<void*>());
|
||||
SQVM_RegisterClientScriptFunctions(g_pClientVM.GetValue<HSQUIRRELVM>());
|
||||
if (context == SQCONTEXT::UI)
|
||||
SQVM_RegisterUIScriptFunctions(g_pUIVM.GetValue<void*>());
|
||||
SQVM_RegisterUIScriptFunctions(g_pUIVM.GetValue<HSQUIRRELVM>());
|
||||
return results;
|
||||
}
|
||||
#endif // !DEDICATED
|
||||
@ -341,21 +341,21 @@ int HSQVM_InitializeCLGlobalScriptStructs(void* sqvm/**(+8)*/, SQCONTEXT context
|
||||
// Purpose: Initialize all SERVER global structs and register SDK (SERVER) script functions
|
||||
// Input : *sqvm -
|
||||
//---------------------------------------------------------------------------------
|
||||
void HSQVM_InitializeSVGlobalScriptStructs(void* sqvm/**(+8)*/)
|
||||
void HSQVM_InitializeSVGlobalScriptStructs(SQVM* sqvm)
|
||||
{
|
||||
SQVM_InitializeSVGlobalScriptStructs(sqvm/**(+8)*/);
|
||||
SQVM_RegisterServerScriptFunctions(g_pServerVM.GetValue<void*>());
|
||||
SQVM_InitializeSVGlobalScriptStructs(sqvm);
|
||||
SQVM_RegisterServerScriptFunctions(g_pServerVM.GetValue<HSQUIRRELVM>());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: Creates the SERVER Squirrel VM
|
||||
// Output : True on success, false on failure
|
||||
//---------------------------------------------------------------------------------
|
||||
bool HSQVM_CreateServerVM()
|
||||
SQBool HSQVM_CreateServerVM()
|
||||
{
|
||||
bool results = SQVM_CreateServerVM();
|
||||
if (results)
|
||||
DevMsg(eDLL_T::SERVER, "Created SERVER VM: '%p'\n", g_pServerVM.GetValue<void*>());
|
||||
DevMsg(eDLL_T::SERVER, "Created SERVER VM: '%p'\n", g_pServerVM.GetValue<HSQUIRRELVM>());
|
||||
else
|
||||
Error(eDLL_T::SERVER, "Failed to create SERVER VM\n");
|
||||
return results;
|
||||
@ -368,11 +368,11 @@ bool HSQVM_CreateServerVM()
|
||||
// Input : *chlclient -
|
||||
// Output : True on success, false on failure
|
||||
//---------------------------------------------------------------------------------
|
||||
bool HSQVM_CreateClientVM(void* chlclient)
|
||||
SQBool HSQVM_CreateClientVM(void* chlclient)
|
||||
{
|
||||
bool results = SQVM_CreateClientVM(chlclient);
|
||||
if (results)
|
||||
DevMsg(eDLL_T::CLIENT, "Created CLIENT VM: '%p'\n", g_pClientVM.GetValue<void*>());
|
||||
DevMsg(eDLL_T::CLIENT, "Created CLIENT VM: '%p'\n", g_pClientVM.GetValue<HSQUIRRELVM>());
|
||||
else
|
||||
Error(eDLL_T::CLIENT, "Failed to create CLIENT VM\n");
|
||||
return results;
|
||||
@ -382,11 +382,11 @@ bool HSQVM_CreateClientVM(void* chlclient)
|
||||
// Purpose: Creates the UI Squirrel VM
|
||||
// Output : True on success, false on failure
|
||||
//---------------------------------------------------------------------------------
|
||||
bool HSQVM_CreateUIVM()
|
||||
SQBool HSQVM_CreateUIVM()
|
||||
{
|
||||
bool results = SQVM_CreateUIVM();
|
||||
if (results)
|
||||
DevMsg(eDLL_T::UI, "Created UI VM: '%p'\n", g_pUIVM.GetValue<void*>());
|
||||
DevMsg(eDLL_T::UI, "Created UI VM: '%p'\n", g_pUIVM.GetValue<HSQUIRRELVM>());
|
||||
else
|
||||
Error(eDLL_T::UI, "Failed to create UI VM\n");
|
||||
return results;
|
||||
@ -424,10 +424,12 @@ HSQUIRRELVM SQVM_GetVM(SQCONTEXT context)
|
||||
{
|
||||
case SQCONTEXT::SERVER:
|
||||
return g_pServerVM.GetValue<HSQUIRRELVM>();
|
||||
#ifndef DEDICATED
|
||||
case SQCONTEXT::CLIENT:
|
||||
return g_pClientVM.GetValue<HSQUIRRELVM>();
|
||||
case SQCONTEXT::UI:
|
||||
return g_pUIVM.GetValue<HSQUIRRELVM>();
|
||||
#endif // !DEDICATED
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
@ -469,7 +471,7 @@ void SQVM_Attach()
|
||||
{
|
||||
DetourAttach((LPVOID*)&SQVM_PrintFunc, &HSQVM_PrintFunc);
|
||||
DetourAttach((LPVOID*)&SQVM_WarningFunc, &HSQVM_WarningFunc);
|
||||
DetourAttach((LPVOID*)&SQVM_ErrorFunc, &HSQVM_ErrorFunc);
|
||||
DetourAttach((LPVOID*)&SQVM_CompileError, &HSQVM_CompileError);
|
||||
DetourAttach((LPVOID*)&SQVM_LoadRson, &HSQVM_LoadRson);
|
||||
DetourAttach((LPVOID*)&SQVM_LoadScript, &HSQVM_LoadScript);
|
||||
#ifndef DEDICATED
|
||||
@ -489,7 +491,7 @@ void SQVM_Detach()
|
||||
{
|
||||
DetourDetach((LPVOID*)&SQVM_PrintFunc, &HSQVM_PrintFunc);
|
||||
DetourDetach((LPVOID*)&SQVM_WarningFunc, &HSQVM_WarningFunc);
|
||||
DetourDetach((LPVOID*)&SQVM_ErrorFunc, &HSQVM_ErrorFunc);
|
||||
DetourDetach((LPVOID*)&SQVM_CompileError, &HSQVM_CompileError);
|
||||
DetourDetach((LPVOID*)&SQVM_LoadRson, &HSQVM_LoadRson);
|
||||
DetourDetach((LPVOID*)&SQVM_LoadScript, &HSQVM_LoadScript);
|
||||
#ifndef DEDICATED
|
||||
|
@ -5,63 +5,60 @@ namespace
|
||||
{
|
||||
/* ==== SQUIRREL ======================================================================================================================================================== */
|
||||
ADDRESS p_SQVM_PrintFunc = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x8B\xC4\x48\x89\x50\x10\x4C\x89\x40\x18\x4C\x89\x48\x20\x53\x56\x57\x48\x81\xEC\x30\x08\x00\x00\x48\x8B\xDA\x48\x8D\x70\x18\x48\x8B\xF9\xE8\x00\x00\x00\xFF\x48\x89\x74\x24\x28\x48\x8D\x54\x24\x30\x33", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx???xxxxxxxxxxxx");
|
||||
void* SQVM_PrintFunc = (void*)p_SQVM_PrintFunc.GetPtr(); /*48 8B C4 48 89 50 10 4C 89 40 18 4C 89 48 20 53 56 57 48 81 EC 30 08 00 00 48 8B DA 48 8D 70 18 48 8B F9 E8 ?? ?? ?? FF 48 89 74 24 28 48 8D 54 24 30 33*/
|
||||
SQRESULT (*SQVM_PrintFunc)(HSQUIRRELVM v, SQChar* fmt, ...) = (SQRESULT (*)(HSQUIRRELVM, SQChar*, ...))p_SQVM_PrintFunc.GetPtr(); /*48 8B C4 48 89 50 10 4C 89 40 18 4C 89 48 20 53 56 57 48 81 EC 30 08 00 00 48 8B DA 48 8D 70 18 48 8B F9 E8 ?? ?? ?? FF 48 89 74 24 28 48 8D 54 24 30 33*/
|
||||
|
||||
ADDRESS p_SQVM_WarningFunc = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x4C\x89\x4C\x24\x20\x44\x89\x44\x24\x18\x89\x54\x24\x10\x53\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x83\xEC\x00\x48\x8B", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx?xx");
|
||||
void* (*SQVM_WarningFunc)(void* sqvm, int a2, int a3, int* nStringSize, void** ppString) = (void* (*)(void*, int, int, int*, void**))p_SQVM_WarningFunc.GetPtr(); /*4C 89 4C 24 20 44 89 44 24 18 89 54 24 10 53 55 56 57 41 54 41 55 41 56 41 57 48 83 EC ?? 48 8B*/
|
||||
|
||||
ADDRESS p_SQVM_ErrorFunc = 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_ErrorFunc)(void* sqvm, const char* pszError, const char* pszFile, unsigned int nLine, int nColumn) = (void* (*)(void*, const char*, const char*, unsigned int, int))p_SQVM_ErrorFunc.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*/
|
||||
SQRESULT (*SQVM_WarningFunc)(HSQUIRRELVM v, SQInteger a2, SQInteger a3, SQInteger* nStringSize, SQChar** ppString) = (SQRESULT (*)(HSQUIRRELVM, SQInteger, SQInteger, SQInteger*, SQChar**))p_SQVM_WarningFunc.GetPtr(); /*4C 89 4C 24 20 44 89 44 24 18 89 54 24 10 53 55 56 57 41 54 41 55 41 56 41 57 48 83 EC ?? 48 8B*/
|
||||
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
ADDRESS p_SQVM_GetErrorLine = 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\x8D\xAC\x24\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x83\x65\x90\xFC", "xxxx?xxxx?xxxx?xxxxxxxxxxxxx????xxx????xxxx");
|
||||
void* (*SQVM_GetErrorLine)(const char* pszFile, int nLine, char* pszContextBuf, int nBufLen) = (void* (*)(const char*, int, char*, int))p_SQVM_GetErrorLine.GetPtr(); /*48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 55 41 54 41 55 41 56 41 57 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 83 65 90 FC*/
|
||||
size_t (*SQVM_GetErrorLine)(const SQChar* pszFile, SQInteger nLine, SQChar* pszContextBuf, SQInteger nBufLen) = (size_t (*)(const SQChar*, SQInteger, SQChar*, SQInteger))p_SQVM_GetErrorLine.GetPtr(); /*48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 55 41 54 41 55 41 56 41 57 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 83 65 90 FC*/
|
||||
|
||||
ADDRESS p_SQVM_LoadScript = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x10\x48\x89\x74\x24\x18\x48\x89\x7C\x24\x20\x48\x89\x4C\x24\x08\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
|
||||
bool (*SQVM_LoadScript)(void* sqvm, const char* szScriptPath, const char* szScriptName, int nFlag) = (bool (*)(void*, const char*, const char*, int))p_SQVM_LoadScript.GetPtr(); /*48 89 5C 24 10 48 89 74 24 18 48 89 7C 24 20 48 89 4C 24 08 55 41 54 41 55 41 56 41 57 48 8D 6C*/
|
||||
SQBool (*SQVM_LoadScript)(HSQUIRRELVM v, const SQChar* szScriptPath, const SQChar* szScriptName, SQInteger nFlag) = (SQBool (*)(HSQUIRRELVM, const SQChar*, const SQChar*, SQInteger))p_SQVM_LoadScript.GetPtr(); /*48 89 5C 24 10 48 89 74 24 18 48 89 7C 24 20 48 89 4C 24 08 55 41 54 41 55 41 56 41 57 48 8D 6C*/
|
||||
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
|
||||
ADDRESS p_SQVM_GetErrorLine = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x8B\xC4\x55\x56\x48\x8D\xA8\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x83\x65\x90\xFC", "xxxxxxxx????xxx????xxxx");
|
||||
void* (*SQVM_GetErrorLine)(const char* pszFile, int nLine, char* pszContextBuf, int nBufLen) = (void* (*)(const char*, int, char*, int))p_SQVM_GetErrorLine.GetPtr(); /*48 8B C4 55 56 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 83 65 90 FC*/
|
||||
size_t (*SQVM_GetErrorLine)(const SQChar* pszFile, SQInteger nLine, SQChar* pszContextBuf, SQInteger nBufLen) = (size_t (*)(const SQChar*, SQInteger, SQChar*, SQInteger))p_SQVM_GetErrorLine.GetPtr(); /*48 8B C4 55 56 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 83 65 90 FC*/
|
||||
|
||||
ADDRESS p_SQVM_LoadScript = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x8B\xC4\x48\x89\x48\x08\x55\x41\x56\x48\x8D\x68", "xxxxxxxxxxxxx"); /*48 8B C4 48 89 48 08 55 41 56 48 8D 68*/
|
||||
bool (*SQVM_LoadScript)(void* sqvm, const char* szScriptPath, const char* szScriptName, int nFlag) = (bool (*)(void*, const char*, const char*, int))p_SQVM_LoadScript.GetPtr();
|
||||
SQBool (*SQVM_LoadScript)(HSQUIRRELVM v, const SQChar* szScriptPath, const SQChar* szScriptName, SQInteger nFlag) = (SQBool (*)(HSQUIRRELVM, const SQChar*, const SQChar*, SQInteger))p_SQVM_LoadScript.GetPtr();
|
||||
#endif
|
||||
ADDRESS p_SQVM_LoadRson = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x4C\x8B\xDC\x49\x89\x5B\x08\x57\x48\x81\xEC\xA0\x00\x00\x00\x33", "xxxxxxxxxxxxxxxx");
|
||||
void* (*SQVM_LoadRson)(const char* szRsonName) = (void* (*)(const char*))p_SQVM_LoadRson.GetPtr(); /*4C 8B DC 49 89 5B 08 57 48 81 EC A0 00 00 00 33*/
|
||||
SQInteger (*SQVM_LoadRson)(const SQChar* szRsonName) = (SQInteger (*)(const SQChar*))p_SQVM_LoadRson.GetPtr(); /*4C 8B DC 49 89 5B 08 57 48 81 EC A0 00 00 00 33*/
|
||||
|
||||
ADDRESS p_SQVM_WarningCmd = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x48\x83\xEC\x30\x33\xDB\x48\x8D\x44\x24\x00\x4C\x8D\x4C\x24\x00", "xxxxxxxxxxxx?xxxx?");
|
||||
void* (*SQVM_WarningCmd)(int a1, int a2) = (void* (*)(int, int))p_SQVM_WarningCmd.GetPtr(); /*40 53 48 83 EC 30 33 DB 48 8D 44 24 ?? 4C 8D 4C 24 ??*/
|
||||
SQRESULT (*SQVM_WarningCmd)(HSQUIRRELVM v, SQInteger a2) = (SQRESULT (*)(HSQUIRRELVM, SQInteger))p_SQVM_WarningCmd.GetPtr(); /*40 53 48 83 EC 30 33 DB 48 8D 44 24 ?? 4C 8D 4C 24 ??*/
|
||||
|
||||
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();
|
||||
SQRESULT (*SQVM_RegisterFunc)(HSQUIRRELVM v, SQFuncRegistration* sqFunc, SQInteger a1) = (SQRESULT (*)(HSQUIRRELVM, SQFuncRegistration*, SQInteger))p_SQVM_RegisterFunc.GetPtr();
|
||||
|
||||
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*/
|
||||
void (*SQVM_CompileError)(HSQUIRRELVM v, const SQChar* pszError, const SQChar* pszFile, SQUnsignedInteger nLine, SQInteger nColumn) = (void (*)(HSQUIRRELVM, const SQChar*, const SQChar*, SQUnsignedInteger, SQInteger))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*/
|
||||
#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*/
|
||||
void (*SQVM_InitializeSVGlobalScriptStructs)(SQVM* vtable) = (void (*)(SQVM*))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 ? ? ? ?*/
|
||||
SQRESULT (*SQVM_InitializeCLGlobalScriptStructs)(SQVM* vtable, SQCONTEXT context) = (SQRESULT (*)(SQVM*, 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 ? ? ? ?*/
|
||||
SQBool (*SQVM_CreateServerVM)() = (SQBool(*)())p_SQVM_CreateServerVM.GetPtr(); /*40 53 48 83 EC 50 48 8D 0D ? ? ? ?*/
|
||||
#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 ? ? ? ?*/
|
||||
SQBool(*SQVM_CreateServerVM)() = (SQBool(*)())p_SQVM_CreateServerVM.GetPtr(); /*40 53 56 48 83 EC 48 48 8D 0D ? ? ? ?*/
|
||||
#endif
|
||||
#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*/
|
||||
SQBool(*SQVM_CreateClientVM)(void* chlclient) = (SQBool(*)(void*))p_SQVM_CreateClientVM.GetPtr(); /*48 83 EC 58 48 83 3D ? ? ? ? ? 74 05*/
|
||||
#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 ? ? ? ? ?*/
|
||||
SQBool(*SQVM_CreateClientVM)(void* chlclient) = (SQBool(*)(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 ? ? ? ? ?*/
|
||||
SQBool(*SQVM_CreateUIVM)() = (SQBool(*)())p_SQVM_CreateUIVM.GetPtr(); /*40 53 48 83 EC 20 48 8B 1D ? ? ? ? C6 05 ? ? ? ? ?*/
|
||||
#endif // !DEDICATED
|
||||
|
||||
#if !defined (CLIENT_DLL)
|
||||
@ -73,10 +70,25 @@ namespace
|
||||
#endif // !DEDICATED
|
||||
}
|
||||
|
||||
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);
|
||||
SQRESULT HSQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...);
|
||||
SQRESULT HSQVM_WarningFunc(HSQUIRRELVM v, SQInteger a2, SQInteger a3, SQInteger* nStringSize, SQChar** ppString);
|
||||
void HSQVM_CompileError(HSQUIRRELVM v, const SQChar* pszError, const SQChar* pszFile, SQUnsignedInteger nLine, SQInteger nColumn);
|
||||
|
||||
SQInteger HSQVM_LoadRson(const SQChar* szRsonName);
|
||||
SQBool HSQVM_LoadScript(HSQUIRRELVM v, const SQChar* szScriptPath, const SQChar* szScriptName, SQInteger nFlag);
|
||||
|
||||
SQRESULT HSQVM_RegisterFunction(HSQUIRRELVM v, const SQChar* szName, const SQChar* szHelpString, const SQChar* szRetValType, const SQChar* szArgTypes, void* pFunction);
|
||||
void SQVM_RegisterServerScriptFunctions(HSQUIRRELVM v);
|
||||
void SQVM_RegisterClientScriptFunctions(HSQUIRRELVM v);
|
||||
void SQVM_RegisterUIScriptFunctions(HSQUIRRELVM v);
|
||||
|
||||
SQInteger HSQVM_InitializeCLGlobalScriptStructs(SQVM* sqvm, SQCONTEXT context);
|
||||
void HSQVM_InitializeSVGlobalScriptStructs(SQVM* sqvm);
|
||||
|
||||
SQBool HSQVM_CreateServerVM();
|
||||
SQBool HSQVM_CreateClientVM(void* chlclient);
|
||||
SQBool HSQVM_CreateUIVM();
|
||||
|
||||
const SQChar* SQVM_GetContextName(SQCONTEXT context);
|
||||
HSQUIRRELVM SQVM_GetVM(SQCONTEXT context);
|
||||
void SQVM_Execute(const SQChar* code, SQCONTEXT context);
|
||||
@ -91,7 +103,6 @@ class HSQVM : public IDetour
|
||||
{
|
||||
std::cout << "| FUN: SQVM_PrintFunc : 0x" << std::hex << std::uppercase << p_SQVM_PrintFunc.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: SQVM_WarningFunc : 0x" << std::hex << std::uppercase << p_SQVM_WarningFunc.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: SQVM_ErrorFunc : 0x" << std::hex << std::uppercase << p_SQVM_ErrorFunc.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: SQVM_GetErrorLine : 0x" << std::hex << std::uppercase << p_SQVM_GetErrorLine.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: SQVM_LoadScript : 0x" << std::hex << std::uppercase << p_SQVM_LoadScript.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
std::cout << "| FUN: SQVM_LoadRson : 0x" << std::hex << std::uppercase << p_SQVM_LoadRson.GetPtr() << std::setw(npad) << " |" << std::endl;
|
||||
|
@ -957,7 +957,7 @@ void _CMaterial_GetMaterialAtCrossHair_f_ComplectionFunc(const CCommand& args)
|
||||
}
|
||||
else
|
||||
{
|
||||
DevMsg(eDLL_T::MS, "No Material found >:(");
|
||||
DevMsg(eDLL_T::MS, "No Material found >:(\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user