From dbec823be6118d18d3aa9f561395626537b114d9 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 28 May 2022 02:05:54 +0200 Subject: [PATCH] FileSystem improvements * Added vftable interface for 'IFileSystem::RemoveSearchPath'. * Added hook for 'CBaseFileSystem::AddSearchPath'. * Added hook for 'CBaseFileSystem::RemoveSearchPath'. * Added method in KeyValues for loading a KV file and parsing it via the game exe (loads from cache, vpk and disk). * Added method in KeyValues to parse GameInfo.txt when the engine loads this. --- r5dev/filesystem/basefilesystem.cpp | 46 ++++++++++++++++----- r5dev/filesystem/basefilesystem.h | 26 +++++++++--- r5dev/filesystem/filesystem.cpp | 13 ++++++ r5dev/filesystem/filesystem.h | 4 ++ r5dev/gameui/IBrowser.cpp | 2 +- r5dev/vpc/keyvalues.cpp | 63 +++++++++++++++++++++++++---- r5dev/vpc/keyvalues.h | 26 ++++++++---- r5dev/vstdlib/keyvaluessystem.cpp | 2 +- r5dev/vstdlib/keyvaluessystem.h | 1 + 9 files changed, 151 insertions(+), 32 deletions(-) diff --git a/r5dev/filesystem/basefilesystem.cpp b/r5dev/filesystem/basefilesystem.cpp index 01ce0217..dd3063c1 100644 --- a/r5dev/filesystem/basefilesystem.cpp +++ b/r5dev/filesystem/basefilesystem.cpp @@ -34,6 +34,16 @@ FileHandle_t CBaseFileSystem::Open(const char* pFileName, const char* pOptions, return CallVFunc(index, this, pFileName, pOptions, pPathID, unknown); } +//--------------------------------------------------------------------------------- +// Purpose: close file by handle +// Input : file - +//--------------------------------------------------------------------------------- +void CBaseFileSystem::Close(FileHandle_t file) +{ + int index = 3; + CallVFunc(index, this, file); +} + //--------------------------------------------------------------------------------- // Purpose: checks if file exists in all searchpaths and pak files // Input : *pFileName - @@ -46,15 +56,6 @@ bool CBaseFileSystem::FileExists(const char* pFileName, const char* pPathID) return CallVFunc(index, this, pFileName, pPathID); } -//--------------------------------------------------------------------------------- -// Purpose: close file by handle -// Input : file - -//--------------------------------------------------------------------------------- -void CBaseFileSystem::Close(FileHandle_t file) -{ - int index = 3; - CallVFunc(index, this, file); -} //--------------------------------------------------------------------------------- // Purpose: prints the output of the filesystem based on the warning level // Input : *this - @@ -154,11 +155,36 @@ bool CBaseFileSystem::ReadFromCache(CBaseFileSystem* pFileSystem, char* pszFileP return CBaseFileSystem_LoadFromCache(pFileSystem, pszFilePath, pResults); } +//----------------------------------------------------------------------------- +// Purpose: create the search path. +// Input : *pPath - +// *pPathID - +// addType - +//----------------------------------------------------------------------------- +void CBaseFileSystem::AddSearchPath(CBaseFileSystem* pFileSystem, const char* pPath, const char* pPathID, SearchPathAdd_t addType) +{ + CBaseFileSystem_AddSearchPath(pFileSystem, pPath, pPathID, addType); +} + +//----------------------------------------------------------------------------- +// Purpose: remove the search path. +// Input : *pPath - +// *pPathID - +// addType - +// Output : true on success, false otherwise. +//----------------------------------------------------------------------------- +bool CBaseFileSystem::RemoveSearchPath(CBaseFileSystem* pFileSystem, const char* pPath, const char* pPathID) +{ + return CBaseFileSystem_RemoveSearchPath(pFileSystem, pPath, pPathID); +} + void CBaseFileSystem_Attach() { DetourAttach((LPVOID*)&CBaseFileSystem_Warning, &CBaseFileSystem::Warning); DetourAttach((LPVOID*)&CBaseFileSystem_LoadFromVPK, &CBaseFileSystem::ReadFromVPK); DetourAttach((LPVOID*)&CBaseFileSystem_LoadFromCache, &CBaseFileSystem::ReadFromCache); + DetourAttach((LPVOID*)&CBaseFileSystem_AddSearchPath, &CBaseFileSystem::AddSearchPath); + DetourAttach((LPVOID*)&CBaseFileSystem_RemoveSearchPath, &CBaseFileSystem::RemoveSearchPath); } void CBaseFileSystem_Detach() @@ -166,5 +192,7 @@ void CBaseFileSystem_Detach() DetourDetach((LPVOID*)&CBaseFileSystem_Warning, &CBaseFileSystem::Warning); DetourDetach((LPVOID*)&CBaseFileSystem_LoadFromVPK, &CBaseFileSystem::ReadFromVPK); DetourDetach((LPVOID*)&CBaseFileSystem_LoadFromCache, &CBaseFileSystem::ReadFromCache); + DetourDetach((LPVOID*)&CBaseFileSystem_AddSearchPath, &CBaseFileSystem::AddSearchPath); + DetourDetach((LPVOID*)&CBaseFileSystem_RemoveSearchPath, &CBaseFileSystem::RemoveSearchPath); } CBaseFileSystem* g_pFileSystem = nullptr; \ No newline at end of file diff --git a/r5dev/filesystem/basefilesystem.h b/r5dev/filesystem/basefilesystem.h index e3b43448..0cec726b 100644 --- a/r5dev/filesystem/basefilesystem.h +++ b/r5dev/filesystem/basefilesystem.h @@ -11,6 +11,8 @@ public: static void Warning(CBaseFileSystem* pFileSystem, FileWarningLevel_t level, const char* fmt, ...); static FileHandle_t ReadFromVPK(CBaseFileSystem* pVpk, std::int64_t* pResults, char* pszFilePath); static bool ReadFromCache(CBaseFileSystem* pFileSystem, char* pszFilePath, void* pResults); + static void AddSearchPath(CBaseFileSystem* pFileSystem, const char* pPath, const char* pPathID, SearchPathAdd_t addType); + static bool RemoveSearchPath(CBaseFileSystem* pFileSystem, const char* pPath, const char* pPathID); }; /* ==== CBASEFILESYSTEM ================================================================================================================================================= */ @@ -23,6 +25,12 @@ inline auto CBaseFileSystem_LoadFromVPK = p_CBaseFileSystem_LoadFromVPK.RCast(); +inline CMemory p_CBaseFileSystem_AddSearchPath; +inline auto CBaseFileSystem_AddSearchPath = p_CBaseFileSystem_AddSearchPath.RCast(); + +inline CMemory p_CBaseFileSystem_RemoveSearchPath; +inline auto CBaseFileSystem_RemoveSearchPath = p_CBaseFileSystem_RemoveSearchPath.RCast(); + extern CBaseFileSystem* g_pFileSystem; /////////////////////////////////////////////////////////////////////////////// @@ -37,18 +45,24 @@ class VBaseFileSystem : public IDetour spdlog::debug("| FUN: CBaseFileSystem::Warning : {:#18x} |\n", p_CBaseFileSystem_Warning.GetPtr()); spdlog::debug("| FUN: CBaseFileSystem::LoadFromVPK : {:#18x} |\n", p_CBaseFileSystem_LoadFromVPK.GetPtr()); spdlog::debug("| FUN: CBaseFileSystem::LoadFromCache : {:#18x} |\n", p_CBaseFileSystem_LoadFromCache.GetPtr()); + spdlog::debug("| FUN: CBaseFileSystem::AddSearchPath : {:#18x} |\n", p_CBaseFileSystem_AddSearchPath.GetPtr()); + spdlog::debug("| FUN: CBaseFileSystem::RemoveSearchPath : {:#18x} |\n", p_CBaseFileSystem_RemoveSearchPath.GetPtr()); spdlog::debug("| VAR: g_pFileSystem : {:#18x} |\n", reinterpret_cast(g_pFileSystem)); spdlog::debug("+----------------------------------------------------------------+\n"); } virtual void GetFun(void) const { - p_CBaseFileSystem_Warning = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x4C\x89\x4C\x24\x20\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48"), "xxxxxx??????????x"); - p_CBaseFileSystem_LoadFromVPK = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x49\x8B\xC0\x4C\x8D\x8C\x24\x00\x00\x00\x00"), "xxxx?xxxx????xxxxxxx????"); - p_CBaseFileSystem_LoadFromCache = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x81\xEC\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x49\x8B\xD8"), "xxxxx????xx?????xxx"); + p_CBaseFileSystem_Warning = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x4C\x89\x4C\x24\x20\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48"), "xxxxxx??????????x"); + p_CBaseFileSystem_LoadFromVPK = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x49\x8B\xC0\x4C\x8D\x8C\x24\x00\x00\x00\x00"), "xxxx?xxxx????xxxxxxx????"); + p_CBaseFileSystem_LoadFromCache = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x81\xEC\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x49\x8B\xD8"), "xxxxx????xx?????xxx"); + p_CBaseFileSystem_AddSearchPath = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x44\x89\x4C\x24\x00\x48\x89\x4C\x24\x00\x55\x57"), "xxxx?xxxx?xx"); + p_CBaseFileSystem_RemoveSearchPath = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x55\x56\x57\x41\x54\x41\x56\x41\x57\x48\x81\xEC\x00\x00\x00\x00\xC6\x44\x24\x00\x00"), "xxxxxxxxxxxxxx????xxx??"); - CBaseFileSystem_Warning = p_CBaseFileSystem_Warning.RCast(); /*4C 89 4C 24 20 C3 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 48*/ - CBaseFileSystem_LoadFromVPK = p_CBaseFileSystem_LoadFromVPK.RCast(); /*48 89 5C 24 ?? 57 48 81 EC ?? ?? ?? ?? 49 8B C0 4C 8D 8C 24 ?? ?? ?? ??*/ - CBaseFileSystem_LoadFromCache = p_CBaseFileSystem_LoadFromCache.RCast(); /*40 53 48 81 EC ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 49 8B D8*/ + CBaseFileSystem_Warning = p_CBaseFileSystem_Warning.RCast(); /*4C 89 4C 24 20 C3 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 48*/ + CBaseFileSystem_LoadFromVPK = p_CBaseFileSystem_LoadFromVPK.RCast(); /*48 89 5C 24 ?? 57 48 81 EC ?? ?? ?? ?? 49 8B C0 4C 8D 8C 24 ?? ?? ?? ??*/ + CBaseFileSystem_LoadFromCache = p_CBaseFileSystem_LoadFromCache.RCast(); /*40 53 48 81 EC ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 49 8B D8*/ + CBaseFileSystem_AddSearchPath = p_CBaseFileSystem_AddSearchPath.RCast(); /*44 89 4C 24 ?? 48 89 4C 24 ?? 55 57*/ + CBaseFileSystem_RemoveSearchPath = p_CBaseFileSystem_RemoveSearchPath.RCast(); /*40 53 55 56 57 41 54 41 56 41 57 48 81 EC ?? ?? ?? ?? C6 44 24 ?? ??*/ } virtual void GetVar(void) const { diff --git a/r5dev/filesystem/filesystem.cpp b/r5dev/filesystem/filesystem.cpp index 32f68e16..1aa6c7d5 100644 --- a/r5dev/filesystem/filesystem.cpp +++ b/r5dev/filesystem/filesystem.cpp @@ -14,6 +14,19 @@ void IFileSystem::AddSearchPath(const char* pPath, const char* pPathID, SearchPa CallVFunc(index, this, pPath, pPathID, addType); } +//----------------------------------------------------------------------------- +// Purpose: removes the search path. +// Input : *pPath - +// *pPathID - +// addType - +// Output : true on success, false otherwise. +//----------------------------------------------------------------------------- +bool IFileSystem::RemoveSearchPath(const char* pPath, const char* pPathID) +{ + static int index = 13; + CallVFunc(index, this, pPath, pPathID); +} + //----------------------------------------------------------------------------- // Purpose: read file from cache. // Input : *pPath - diff --git a/r5dev/filesystem/filesystem.h b/r5dev/filesystem/filesystem.h index 9fbde28b..4a22f5b4 100644 --- a/r5dev/filesystem/filesystem.h +++ b/r5dev/filesystem/filesystem.h @@ -2,6 +2,9 @@ #define FILESYSTEM_H #include "vpklib/packedstore.h" +#define GAMEINFOPATH_TOKEN "|gameinfo_path|" +#define BASESOURCEPATHS_TOKEN "|all_source_engine_paths|" + typedef void* FileHandle_t; enum class SearchPathAdd_t : int @@ -27,6 +30,7 @@ class IFileSystem { public: void AddSearchPath(const char* pPath, const char* pathID, SearchPathAdd_t addType); + bool RemoveSearchPath(const char* pPath, const char* pPathID); bool ReadFromCache(const char* pPath, void* pResult); VPKData_t* MountVPK(const char* vpkPath); }; diff --git a/r5dev/gameui/IBrowser.cpp b/r5dev/gameui/IBrowser.cpp index 436c8cae..cf919162 100644 --- a/r5dev/gameui/IBrowser.cpp +++ b/r5dev/gameui/IBrowser.cpp @@ -539,7 +539,7 @@ void CBrowser::HostServerSection(void) if (ImGui::Button("Reload Playlist", ImVec2(ImGui::GetWindowSize().x, 32))) { _DownloadPlaylists_f(); - KeyValues::InitPlaylist(); // Re-Init playlist. + KeyValues::InitPlaylists(); // Re-Init playlist. } } #endif // !CLIENT_DLL diff --git a/r5dev/vpc/keyvalues.cpp b/r5dev/vpc/keyvalues.cpp index 5e61a823..b49edfbe 100644 --- a/r5dev/vpc/keyvalues.cpp +++ b/r5dev/vpc/keyvalues.cpp @@ -16,7 +16,7 @@ //----------------------------------------------------------------------------- void KeyValues::Init(void) { - std::thread t1(KeyValues::InitPlaylist); // Start thread to grab playlists. + std::thread t1(KeyValues::InitPlaylists); // Start thread to grab playlists. t1.detach(); // Detach thread from current one. } @@ -107,19 +107,20 @@ void KeyValues::SetFloat(const char* pKeyName, float flValue) //----------------------------------------------------------------------------- // Purpose: Initializes the playlist //----------------------------------------------------------------------------- -void KeyValues::InitPlaylist(void) +void KeyValues::InitPlaylists(void) { while (true) { if (*g_pPlaylistKeyValues) { - KeyValues* playlists = (*g_pPlaylistKeyValues)->FindKey("Playlists", false); - if (playlists) + KeyValues* pPlaylists = (*g_pPlaylistKeyValues)->FindKey("Playlists", false); + if (pPlaylists) { g_vAllPlaylists.clear(); - for (KeyValues* dat = playlists->m_pSub; dat != nullptr; dat = dat->m_pPeer) // Parse through all sub keys. + for (KeyValues* dat = pPlaylists->m_pSub; dat != nullptr; dat = dat->m_pPeer) // Parse through all sub keys. { - g_vAllPlaylists.push_back(dat->GetName()); // Get all playlist names. + printf("%s\n", dat->GetName()); + g_vAllPlaylists.push_back(dat->GetName()); // Get all playlists. } break; // Break if playlist got filled. @@ -130,6 +131,34 @@ void KeyValues::InitPlaylist(void) } } +//----------------------------------------------------------------------------- +// Purpose: Initializes the filesystem paths +//----------------------------------------------------------------------------- +void KeyValues::InitFileSystem(void) +{ + KeyValues* pMainFile = KeyValues::ReadKeyValuesFile(g_pFileSystem_Stdio, "GameInfo.txt"); + if (pMainFile) + { + KeyValues* pFileSystemInfo = pMainFile->FindKey("FileSystem", false); + if (pFileSystemInfo) + { + KeyValues* pSearchPaths = pFileSystemInfo->FindKey("SearchPaths", false); + if (pSearchPaths) + { + g_vAllSearchPaths.clear(); + for (KeyValues* dat = pSearchPaths->m_pSub; dat != nullptr; dat = dat->m_pPeer) // Parse through all sub keys. + { + string svValue = dat->m_sValue; + StringReplace(svValue, GAMEINFOPATH_TOKEN, ""); + StringReplace(svValue, BASESOURCEPATHS_TOKEN, ""); + + g_vAllSearchPaths.push_back(svValue); // Get all SearchPaths + } + } + } + } +} + //----------------------------------------------------------------------------- // Purpose: loads the playlist // Input : *szPlaylist - @@ -163,17 +192,37 @@ bool KeyValues::LoadPlaylist(const char* szPlaylist) return KeyValues_LoadPlaylist(szPlaylist); // Parse playlist. } +//----------------------------------------------------------------------------- +// Purpose: reads a keyvalues file +// Input : *pFileSystem - +// * pFileName - +// Output : pointer to KeyValues object +//----------------------------------------------------------------------------- +KeyValues* KeyValues::ReadKeyValuesFile(CFileSystem_Stdio* pFileSystem, const char* pFileName) +{ + static bool bInit{}; + if (!bInit) + { + bInit = true; + KeyValues::InitFileSystem(); + } + return KeyValues_ReadKeyValuesFile(pFileSystem, pFileName); +} + /////////////////////////////////////////////////////////////////////////////// void CKeyValueSystem_Attach() { DetourAttach((LPVOID*)&KeyValues_LoadPlaylist, &KeyValues::LoadPlaylist); + DetourAttach((LPVOID*)&KeyValues_ReadKeyValuesFile, &KeyValues::ReadKeyValuesFile); } void CKeyValueSystem_Detach() { DetourDetach((LPVOID*)&KeyValues_LoadPlaylist, &KeyValues::LoadPlaylist); + DetourDetach((LPVOID*)&KeyValues_ReadKeyValuesFile, &KeyValues::ReadKeyValuesFile); } /////////////////////////////////////////////////////////////////////////////// inline KeyValues** g_pPlaylistKeyValues = nullptr; // Get the KeyValue for the playlist file. -vector g_vAllPlaylists = { "<>" }; \ No newline at end of file +vector g_vAllPlaylists = { "<>" }; +vector g_vAllSearchPaths = { "\\" }; \ No newline at end of file diff --git a/r5dev/vpc/keyvalues.h b/r5dev/vpc/keyvalues.h index 6ebdccd5..757da62d 100644 --- a/r5dev/vpc/keyvalues.h +++ b/r5dev/vpc/keyvalues.h @@ -1,7 +1,9 @@ #pragma once +#include "filesystem/filesystem.h" #define MAKE_3_BYTES_FROM_1_AND_2( x1, x2 ) (( (( uint16_t )x2) << 8 ) | (uint8_t)(x1)) extern vector g_vAllPlaylists; +extern vector g_vAllSearchPaths; //--------------------------------------------------------------------------------- // Purpose: Forward declarations @@ -15,11 +17,14 @@ inline auto KeyValues_Init = p_KeyValues_Init.RCast(); +inline CMemory p_KeyValues_LoadPlaylist; +inline auto KeyValues_LoadPlaylist = p_KeyValues_LoadPlaylist.RCast(); + inline CMemory p_KeyValues_GetCurrentPlaylist; inline auto KeyValues_GetCurrentPlaylist = p_KeyValues_GetCurrentPlaylist.RCast(); -inline CMemory p_KeyValues_LoadPlaylist; -inline auto KeyValues_LoadPlaylist = p_KeyValues_LoadPlaylist.RCast(); +inline CMemory p_KeyValues_ReadKeyValuesFile; +inline auto KeyValues_ReadKeyValuesFile = p_KeyValues_ReadKeyValuesFile.RCast(); enum KeyValuesTypes { @@ -47,8 +52,10 @@ public: void SetInt(const char* pKeyName, int iValue); void SetFloat(const char* keyName, float flValue); - static void InitPlaylist(void); + static void InitPlaylists(void); + static void InitFileSystem(void); static bool LoadPlaylist(const char* szPlaylist); + static KeyValues* ReadKeyValuesFile(CFileSystem_Stdio* pFileSystem, const char* pFileName); public: uint32_t m_iKeyName : 24; // 0x0000 @@ -86,6 +93,7 @@ class VKeyValues : public IDetour spdlog::debug("| FUN: KeyValues::FindKey : {:#18x} |\n", p_KeyValues_FindKey.GetPtr()); spdlog::debug("| FUN: KeyValues::LoadPlaylist : {:#18x} |\n", p_KeyValues_LoadPlaylist.GetPtr()); spdlog::debug("| FUN: KeyValues::GetCurrentPlaylist : {:#18x} |\n", p_KeyValues_GetCurrentPlaylist.GetPtr()); + spdlog::debug("| FUN: KeyValues::ReadKeyValuesFile : {:#18x} |\n", p_KeyValues_ReadKeyValuesFile.GetPtr()); spdlog::debug("| VAR: g_pPlaylistKeyValues : {:#18x} |\n", reinterpret_cast(g_pPlaylistKeyValues)); spdlog::debug("+----------------------------------------------------------------+\n"); } @@ -95,18 +103,20 @@ class VKeyValues : public IDetour p_KeyValues_Init = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x48\x8B\xD9\xC7\x44\x24\x30\xFF\xFF\xFF"), "xxxxxxxxxxxxxxxx"); p_KeyValues_FindKey = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x10\x48\x89\x6C\x24\x18\x48\x89\x74\x24\x20\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\x20\x01\x00\x00\x45"), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); p_KeyValues_GetCurrentPlaylist = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\x0D\x00\x00\x00\x00\x48\x85\xC9\x75\x08\x48\x8D\x05\x00\x00\x00\x00"), "xxx????xxxxxxxx????"); + p_KeyValues_ReadKeyValuesFile = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x55\x56\x57\x41\x54\x41\x57\x48\x8D\x6C\x24\x00"), "xxxx?xxxxxxxxxxx?"); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) p_KeyValues_Init = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\x48\x8B\x05\x00\x00\x00\x01\x48\x8B\xD9\x4C\x8B\xC2"), "xxxxxxxxx???xxxxxxx"); p_KeyValues_FindKey = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x40\x56\x57\x41\x57\x48\x81\xEC\x00\x00\x00\x00\x45"), "xxxxxxxx????x"); p_KeyValues_GetCurrentPlaylist = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\x05\x00\x00\x00\x00\x48\x85\xC0\x75\x08\x48\x8D\x05\x00\x00\x00\x00\xC3\x0F\xB7\x50\x2A"), "xxx????xxxxxxxx????xxxxx"); + p_KeyValues_ReadKeyValuesFile = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x55\x53\x57\x41\x54\x48\x8D\x68\xA1"), "xxxxxxxxxxxx"); #endif p_KeyValues_LoadPlaylist = g_mGameDll.FindPatternSIMD(reinterpret_cast("\xE8\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x74\x0C"), "x????xx?????xx").FollowNearCallSelf().GetPtr(); - KeyValues_Init = p_KeyValues_Init.RCast(); /*40 53 48 83 EC 20 48 8B 05 ?? ?? ?? 01 48 8B D9 4C 8B C2*/ - KeyValues_FindKey = p_KeyValues_FindKey.RCast(); /*40 56 57 41 57 48 81 EC 30 01 00 00 45 0F B6 F8*/ - KeyValues_LoadPlaylist = p_KeyValues_LoadPlaylist.RCast(); /*E8 ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 74 0C*/ - KeyValues_GetCurrentPlaylist = p_KeyValues_GetCurrentPlaylist.RCast(); /*48 8B 05 ?? ?? ?? ?? 48 85 C0 75 08 48 8D 05 ?? ?? ?? ?? C3 0F B7 50 2A*/ - + KeyValues_Init = p_KeyValues_Init.RCast(); /*40 53 48 83 EC 20 48 8B 05 ?? ?? ?? 01 48 8B D9 4C 8B C2*/ + KeyValues_FindKey = p_KeyValues_FindKey.RCast(); /*40 56 57 41 57 48 81 EC 30 01 00 00 45 0F B6 F8*/ + KeyValues_LoadPlaylist = p_KeyValues_LoadPlaylist.RCast(); /*E8 ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 74 0C*/ + KeyValues_GetCurrentPlaylist = p_KeyValues_GetCurrentPlaylist.RCast(); /*48 8B 05 ?? ?? ?? ?? 48 85 C0 75 08 48 8D 05 ?? ?? ?? ?? C3 0F B7 50 2A*/ + KeyValues_ReadKeyValuesFile = p_KeyValues_ReadKeyValuesFile.RCast(); /*48 8B C4 55 53 57 41 54 48 8D 68 A1*/ } virtual void GetVar(void) const { diff --git a/r5dev/vstdlib/keyvaluessystem.cpp b/r5dev/vstdlib/keyvaluessystem.cpp index 45009bb1..12f13615 100644 --- a/r5dev/vstdlib/keyvaluessystem.cpp +++ b/r5dev/vstdlib/keyvaluessystem.cpp @@ -128,7 +128,7 @@ bool CKeyValuesSystem::GetKeyValuesExpressionSymbol(const char* szName) // Input : *hCaseInsensitiveSymbol - // *szName - // bCreate - -// Output : handle to KeyValue symbol on success, -1 on failure +// Output : handle to KeyValue symbol on success, INVALID_KEY_SYMBOL on failure //----------------------------------------------------------------------------- HKeySymbol CKeyValuesSystem::GetSymbolForStringCaseSensitive(HKeySymbol& hCaseInsensitiveSymbol, const char* szName, bool bCreate) { diff --git a/r5dev/vstdlib/keyvaluessystem.h b/r5dev/vstdlib/keyvaluessystem.h index a28e8643..cb38a74f 100644 --- a/r5dev/vstdlib/keyvaluessystem.h +++ b/r5dev/vstdlib/keyvaluessystem.h @@ -1,6 +1,7 @@ #pragma once typedef int HKeySymbol; +#define INVALID_KEY_SYMBOL (-1) class CKeyValuesSystem // VTABLE @ 0x1413AA1E8 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM {