From dd456dcb1908baae4f401136e2a3867f38b39da9 Mon Sep 17 00:00:00 2001 From: Michael Flaherty Date: Sat, 11 Aug 2018 05:37:05 -0700 Subject: [PATCH 1/6] Individualize NameHashSet Hashing & Revisit #709 (#740) (1.9-dev) (#866) This is a clone of #740, but without the amtl ke::AString lowercase which was implemented in a new version of amtl that 1.9-dev isn't pinned to. Updating this pin and moving fixes is beyond what should go in 1.9, and this fixes a annoying and user-impactful bug with reload/unloading plugins on windows. Currently in 1.9, once a plugin is loaded into the pluginsys, they must be used with lowercase characters *only*, since pr #709 ignorantly modified their names. ``` // test.smx exists in /plugins/ sm plugins load TEST.smx // successful sm plugins unload TEST.smx // TEST.smx not found, it's actually test.smx ``` This pr fixes that error by converting *all* lookups, not just loads. --- core/ConVarManager.h | 5 +++ core/EventManager.h | 4 +++ core/HalfLife2.h | 14 ++++++++- core/logic/AdminCache.h | 4 +++ core/logic/GameConfigs.h | 4 +++ core/logic/HandleSys.h | 4 +++ core/logic/Native.h | 5 +++ core/logic/PluginSys.cpp | 31 ++----------------- core/logic/PluginSys.h | 54 +++++++++++++++++++++++++++++---- core/logic/RootConsoleMenu.h | 4 +++ core/logic/smn_maplists.cpp | 4 +++ core/smn_console.cpp | 4 +++ extensions/clientprefs/cookie.h | 4 +++ extensions/topmenus/TopMenu.h | 4 +++ public/sm_namehashset.h | 12 +++++--- 15 files changed, 117 insertions(+), 40 deletions(-) diff --git a/core/ConVarManager.h b/core/ConVarManager.h index 07dfdd35..f39cd295 100644 --- a/core/ConVarManager.h +++ b/core/ConVarManager.h @@ -43,6 +43,7 @@ #include #include "concmd_cleaner.h" #include "PlayerManager.h" +#include using namespace SourceHook; @@ -67,6 +68,10 @@ struct ConVarInfo { return strcmp(name, info->pVar->GetName()) == 0; } + static inline uint32_t hash(const detail::CharsAndLength &key) + { + return key.hash(); + } }; /** diff --git a/core/EventManager.h b/core/EventManager.h index bf7bd37b..1c8a1da5 100644 --- a/core/EventManager.h +++ b/core/EventManager.h @@ -77,6 +77,10 @@ struct EventHook { return strcmp(name, hook->name.chars()) == 0; } + static inline uint32_t hash(const detail::CharsAndLength &key) + { + return key.hash(); + } }; enum EventHookMode diff --git a/core/HalfLife2.h b/core/HalfLife2.h index 9156069c..f7c077d4 100644 --- a/core/HalfLife2.h +++ b/core/HalfLife2.h @@ -92,13 +92,21 @@ struct DataTableInfo { return strcmp(name, info.prop->GetName()) == 0; } + static inline uint32_t hash(const detail::CharsAndLength &key) + { + return key.hash(); + } }; static inline bool matches(const char *name, const DataTableInfo *info) { return strcmp(name, info->sc->GetName()) == 0; } - + static inline uint32_t hash(const detail::CharsAndLength &key) + { + return key.hash(); + } + DataTableInfo(ServerClass *sc) : sc(sc) { @@ -114,6 +122,10 @@ struct DataMapCachePolicy { return strcmp(name, info.prop->fieldName) == 0; } + static inline uint32_t hash(const detail::CharsAndLength &key) + { + return key.hash(); + } }; typedef NameHashSet DataMapCache; diff --git a/core/logic/AdminCache.h b/core/logic/AdminCache.h index 0cdd5859..18aa2361 100644 --- a/core/logic/AdminCache.h +++ b/core/logic/AdminCache.h @@ -82,6 +82,10 @@ struct AuthMethod { return strcmp(name, method->name.c_str()) == 0; } + static inline uint32_t hash(const detail::CharsAndLength &key) + { + return key.hash(); + } }; struct UserAuth diff --git a/core/logic/GameConfigs.h b/core/logic/GameConfigs.h index 802b9ebb..44a40110 100644 --- a/core/logic/GameConfigs.h +++ b/core/logic/GameConfigs.h @@ -72,6 +72,10 @@ public: //NameHashSet { return strcmp(key, value->m_File) == 0; } + static inline uint32_t hash(const detail::CharsAndLength &key) + { + return key.hash(); + } private: char m_File[PLATFORM_MAX_PATH]; char m_CurFile[PLATFORM_MAX_PATH]; diff --git a/core/logic/HandleSys.h b/core/logic/HandleSys.h index a549c251..bb4e5ea9 100644 --- a/core/logic/HandleSys.h +++ b/core/logic/HandleSys.h @@ -110,6 +110,10 @@ struct QHandleType { return type->name && type->name->compare(key) == 0; } + static inline uint32_t hash(const detail::CharsAndLength &key) + { + return key.hash(); + } }; typedef ke::Lambda HandleReporter; diff --git a/core/logic/Native.h b/core/logic/Native.h index 3ac2aa9a..438d5d36 100644 --- a/core/logic/Native.h +++ b/core/logic/Native.h @@ -36,6 +36,7 @@ #include #include #include +#include #include "common_logic.h" class CNativeOwner; @@ -93,6 +94,10 @@ struct Native : public ke::Refcounted { return strcmp(name, entry->name()) == 0; } + static inline uint32_t hash(const detail::CharsAndLength &key) + { + return key.hash(); + } }; diff --git a/core/logic/PluginSys.cpp b/core/logic/PluginSys.cpp index e98f4a58..8ee33abd 100644 --- a/core/logic/PluginSys.cpp +++ b/core/logic/PluginSys.cpp @@ -31,7 +31,6 @@ #include #include -#include #include "PluginSys.h" #include "ShareSys.h" #include @@ -47,7 +46,6 @@ #include "frame_tasks.h" #include #include -#include #include #include @@ -934,38 +932,16 @@ void CPluginManager::LoadPluginsFromDir(const char *basedir, const char *localpa libsys->CloseDirectory(dir); } -#if defined PLATFORM_WINDOWS || defined PLATFORM_APPLE -char *strdup_tolower(const char *input) -{ - char *str = strdup(input); - - for (char *c = str; *c; c++) - { - *c = tolower((unsigned char)*c); - } - - return str; -} -#endif - LoadRes CPluginManager::LoadPlugin(CPlugin **aResult, const char *path, bool debug, PluginType type) { if (m_LoadingLocked) return LoadRes_NeverLoad; -/* For windows & mac, we convert the path to lower-case in order to avoid duplicate plugin loading */ -#if defined PLATFORM_WINDOWS || defined PLATFORM_APPLE - ke::UniquePtr finalPath = ke::UniquePtr(strdup_tolower(path)); -#else - ke::UniquePtr finalPath = ke::UniquePtr(strdup(path)); -#endif - - /** * Does this plugin already exist? */ CPlugin *pPlugin; - if (m_LoadLookup.retrieve(finalPath.get(), &pPlugin)) + if (m_LoadLookup.retrieve(path, &pPlugin)) { /* Check to see if we should try reloading it */ if (pPlugin->GetStatus() == Plugin_BadLoad @@ -978,12 +954,11 @@ LoadRes CPluginManager::LoadPlugin(CPlugin **aResult, const char *path, bool deb { if (aResult) *aResult = pPlugin; - return LoadRes_AlreadyLoaded; } } - CPlugin *plugin = CompileAndPrep(finalPath.get()); + CPlugin *plugin = CompileAndPrep(path); // Assign our outparam so we can return early. It must be set. *aResult = plugin; @@ -2416,4 +2391,4 @@ static OldPluginAPI sOldPluginAPI; IPluginManager *CPluginManager::GetOldAPI() { return &sOldPluginAPI; -} +} \ No newline at end of file diff --git a/core/logic/PluginSys.h b/core/logic/PluginSys.h index 43f04c7b..c5b05a98 100644 --- a/core/logic/PluginSys.h +++ b/core/logic/PluginSys.h @@ -143,11 +143,6 @@ public: */ static CPlugin *Create(const char *file); - static inline bool matches(const char *file, const CPlugin *plugin) - { - return strcmp(plugin->m_filename, file) == 0; - } - public: // Evicts the plugin from memory and sets an error state. void EvictWithError(PluginStatus status, const char *error_fmt, ...); @@ -483,7 +478,54 @@ private: typedef decltype(m_listeners)::iterator ListenerIter; typedef decltype(m_plugins)::iterator PluginIter; - NameHashSet m_LoadLookup; + struct CPluginPolicy + { + static inline uint32_t hash(const detail::CharsAndLength &key) + { +/* For windows & mac, we convert the path to lower-case in order to avoid duplicate plugin loading */ +#if defined PLATFORM_WINDOWS || defined PLATFORM_APPLE + const char *original = key.chars(); + char *copy = strdup(original); + + for (size_t i = 0; copy[i]; ++i) + { + copy[i] = tolower(copy[i]); + } + + uint32_t hash = detail::CharsAndLength(copy).hash(); + free(copy); + return hash; +#else + return key.hash(); +#endif + } + + static inline bool matches(const char *file, const CPlugin *plugin) + { + const char *pluginFile = const_cast(plugin)->GetFilename(); +#if defined PLATFORM_WINDOWS || defined PLATFORM_APPLE + size_t fileLen = strlen(file); + if (fileLen != strlen(pluginFile)) + { + return false; + } + + for (size_t i = 0; i < fileLen; ++i) + { + if (tolower(file[i]) != tolower(pluginFile[i])) + { + return false; + } + } + + return true; +#else + return strcmp(pluginFile, file) == 0; +#endif + } + }; + NameHashSet m_LoadLookup; + bool m_AllPluginsLoaded; IdentityToken_t *m_MyIdent; diff --git a/core/logic/RootConsoleMenu.h b/core/logic/RootConsoleMenu.h index 4b687bec..c240a488 100644 --- a/core/logic/RootConsoleMenu.h +++ b/core/logic/RootConsoleMenu.h @@ -46,6 +46,10 @@ struct ConsoleEntry { return strcmp(name, entry->command.c_str()) == 0; } + static inline uint32_t hash(const detail::CharsAndLength &key) + { + return key.hash(); + } }; class RootConsoleMenu : diff --git a/core/logic/smn_maplists.cpp b/core/logic/smn_maplists.cpp index 093aaa15..2393a141 100644 --- a/core/logic/smn_maplists.cpp +++ b/core/logic/smn_maplists.cpp @@ -58,6 +58,10 @@ struct maplist_info_t { return strcmp(value->name, key) == 0; } + static inline uint32_t hash(const detail::CharsAndLength &key) + { + return key.hash(); + } }; #define MAPLIST_FLAG_MAPSFOLDER (1<<0) /**< On failure, use all maps in the maps folder. */ diff --git a/core/smn_console.cpp b/core/smn_console.cpp index 43f8ccc6..799e1359 100644 --- a/core/smn_console.cpp +++ b/core/smn_console.cpp @@ -184,6 +184,10 @@ private: { return strcmp(name, base->GetName()) == 0; } + static inline uint32_t hash(const detail::CharsAndLength &key) + { + return key.hash(); + } }; NameHashSet m_CmdFlags; } s_CommandFlagsHelper; diff --git a/extensions/clientprefs/cookie.h b/extensions/clientprefs/cookie.h index 9684b264..31b59f35 100644 --- a/extensions/clientprefs/cookie.h +++ b/extensions/clientprefs/cookie.h @@ -96,6 +96,10 @@ struct Cookie { return strcmp(name, cookie->name) == 0; } + static inline uint32_t hash(const detail::CharsAndLength &key) + { + return key.hash(); + } }; class CookieManager : public IClientListener, public IPluginsListener diff --git a/extensions/topmenus/TopMenu.h b/extensions/topmenus/TopMenu.h index a22a1ba0..298c7f58 100644 --- a/extensions/topmenus/TopMenu.h +++ b/extensions/topmenus/TopMenu.h @@ -77,6 +77,10 @@ struct topmenu_object_t { return strcmp(name, topmenu->name) == 0; } + static inline uint32_t hash(const detail::CharsAndLength &key) + { + return key.hash(); + } }; struct topmenu_category_t diff --git a/public/sm_namehashset.h b/public/sm_namehashset.h index 5e6fbe95..26507353 100644 --- a/public/sm_namehashset.h +++ b/public/sm_namehashset.h @@ -48,10 +48,12 @@ namespace SourceMod { -// The HashPolicy type must have this method: +// The HashPolicy type must have these methods: // static bool matches(const char *key, const T &value); +// static uint32_t hash(const CharsAndLength &key); // -// Depending on what lookup types are used. +// Depending on what lookup types are used, and how hashing should be done. +// Most of the time, key hashing will just call the key's hash() method. // // If these members are available on T, then the HashPolicy type can be left // default. It is okay to use |T *|, the functions will still be looked up @@ -69,7 +71,7 @@ class NameHashSet : public ke::SystemAllocatorPolicy static uint32_t hash(const CharsAndLength &key) { - return key.hash(); + return KeyPolicyType::hash(key); } static bool matches(const CharsAndLength &key, const KeyType &value) @@ -85,9 +87,9 @@ class NameHashSet : public ke::SystemAllocatorPolicy { typedef KeyType *Payload; - static uint32_t hash(const detail::CharsAndLength &key) + static uint32_t hash(const CharsAndLength &key) { - return key.hash(); + return KeyType::hash(key); } static bool matches(const CharsAndLength &key, const KeyType *value) From 3a6144662653b8a28fe9d1e38b855452b85e5aaa Mon Sep 17 00:00:00 2001 From: Asher Baker Date: Sun, 12 Aug 2018 22:33:19 +0100 Subject: [PATCH 2/6] Update blacklist.plugins.txt --- gamedata/core.games/blacklist.plugins.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gamedata/core.games/blacklist.plugins.txt b/gamedata/core.games/blacklist.plugins.txt index d2fdbd8d..176b2dfe 100644 --- a/gamedata/core.games/blacklist.plugins.txt +++ b/gamedata/core.games/blacklist.plugins.txt @@ -102,6 +102,10 @@ "plugin_33a4351dd2b9350d6f2b21dab68f7d9e" "" /* [CS:GO] Komutcu Daire System (Sourceless distro) - Version 1.0 */ "plugin_0f9828ea5fe6900981137f3c6fb9d70b" "" /* token changer (Adi) - Version 1.1.2 */ "plugin_267929e572d647c43e54ab7aa921174d" "" /* Playwire MOTD (Playwire Media) - Version 1.1.0 */ + "plugin_f9874d362c5c8142037045a0a2c6249c" "" /* [AnoX]A-Nox Core (A-Nox dev.) - Version 3.1a */ + "plugin_eae8ed2c593591814f9e6bfa73000d85" "" /* Unknown VIP plugin with fake myinfo */ + "plugin_da0e76b67029c12eb5c1995df4fa4f89" "" /* token changer (Adi) - Version 1.3.9 */ + "plugin_514efe1f39061e7365a31fc21d452a79" "" /* Token Auto Updater (Phoenix) - Version 1.4 */ } } } From 98be188cbeb556e73b2c92885c7b22a6ba1000c2 Mon Sep 17 00:00:00 2001 From: Michael Flaherty Date: Wed, 15 Aug 2018 17:56:04 -0700 Subject: [PATCH 3/6] Fix SetClanTag CS:GO Windows Signature (#868) --- gamedata/sm-cstrike.games/game.csgo.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamedata/sm-cstrike.games/game.csgo.txt b/gamedata/sm-cstrike.games/game.csgo.txt index d96029d8..0660bf0e 100644 --- a/gamedata/sm-cstrike.games/game.csgo.txt +++ b/gamedata/sm-cstrike.games/game.csgo.txt @@ -145,7 +145,7 @@ "SetClanTag" { "library" "server" - "windows" "\x55\x8B\xEC\x8B\x55\x08\x85\xD2\x74\x2A\x8D\x81\x44\x25\x00\x00" + "windows" "\x55\x8B\xEC\x8B\x55\x08\x85\xD2\x74\x2A\x8D\x81\x48\x25\x00\x00" "linux" "\x55\x89\xE5\x83\xEC\x18\x8B\x45\x0C\x85\xC0\x74\x2A\x89\x44\x24\x04\x8B\x45\x08\xC7\x44\x24\x08\x10\x00\x00\x00" } "SetModelFromClass" From 14eaa097cb68fb2313036842e1949d58ab534dc8 Mon Sep 17 00:00:00 2001 From: Ruben Gonzalez Date: Wed, 12 Sep 2018 10:13:39 -0400 Subject: [PATCH 4/6] Add new weapons to CSWeaponID enum. (#869) --- extensions/cstrike/util_cstrike.cpp | 2 +- plugins/include/cstrike.inc | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/extensions/cstrike/util_cstrike.cpp b/extensions/cstrike/util_cstrike.cpp index 99e6f5fe..02bdd6de 100644 --- a/extensions/cstrike/util_cstrike.cpp +++ b/extensions/cstrike/util_cstrike.cpp @@ -336,7 +336,7 @@ SMCSWeapon GetWeaponIdFromDefIdx(uint16_t iDefIdx) SMCSWeapon_AUG, SMCSWeapon_AWP, SMCSWeapon_FAMAS, SMCSWeapon_G3SG1, SMCSWeapon_NONE, SMCSWeapon_GALILAR, SMCSWeapon_M249, SMCSWeapon_NONE, SMCSWeapon_M4A1, SMCSWeapon_MAC10, SMCSWeapon_NONE, SMCSWeapon_P90, - SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_NONE, + SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_NONE, SMCSWeapon_MP5NAVY, SMCSWeapon_UMP45, SMCSWeapon_XM1014, SMCSWeapon_BIZON, SMCSWeapon_MAG7, SMCSWeapon_NEGEV, SMCSWeapon_SAWEDOFF, SMCSWeapon_TEC9, SMCSWeapon_TASER, SMCSWeapon_HKP2000, SMCSWeapon_MP7, SMCSWeapon_MP9, SMCSWeapon_NOVA, diff --git a/plugins/include/cstrike.inc b/plugins/include/cstrike.inc index 49e0aec0..940f6b7f 100644 --- a/plugins/include/cstrike.inc +++ b/plugins/include/cstrike.inc @@ -152,6 +152,10 @@ enum CSWeaponID CSWeapon_KNIFE_SURVIVAL_BOWIE = 514, CSWeapon_KNIFE_BUTTERFLY = 515, CSWeapon_KNIFE_PUSH = 516, + CSWeapon_KNIFE_URSUS = 519, + CSWeapon_KNIFE_GYPSY_JACKKNIFE = 520, + CSWeapon_KNIFE_STILETTO = 522, + CSWeapon_KNIFE_WIDOWMAKER = 523, CSWeapon_MAX_WEAPONS //THIS MUST BE LAST, EASY WAY TO CREATE LOOPS. When looping, do CS_IsValidWeaponID(i), to check. }; From ada56b06bb7dae76205e11a2332e3eda9caca4ac Mon Sep 17 00:00:00 2001 From: Michael Flaherty Date: Wed, 3 Oct 2018 19:50:31 -0700 Subject: [PATCH 5/6] Fix CS_TerminateRound calls & detour (#893) --- extensions/cstrike/forwards.cpp | 28 +++++++++++++++----- extensions/cstrike/natives.cpp | 47 ++++++++++++++++++++++++++++++--- 2 files changed, 66 insertions(+), 9 deletions(-) diff --git a/extensions/cstrike/forwards.cpp b/extensions/cstrike/forwards.cpp index 261807a2..8f1b1db8 100644 --- a/extensions/cstrike/forwards.cpp +++ b/extensions/cstrike/forwards.cpp @@ -126,7 +126,7 @@ DETOUR_DECL_MEMBER0(DetourWeaponPrice, int) } #endif -#if SOURCE_ENGINE != SE_CSGO || !defined(WIN32) +#if SOURCE_ENGINE != SE_CSGO DETOUR_DECL_MEMBER2(DetourTerminateRound, void, float, delay, int, reason) { if (g_pIgnoreTerminateDetour) @@ -135,20 +135,31 @@ DETOUR_DECL_MEMBER2(DetourTerminateRound, void, float, delay, int, reason) DETOUR_MEMBER_CALL(DetourTerminateRound)(delay, reason); return; } +#elif !defined(WIN32) +DETOUR_DECL_MEMBER4(DetourTerminateRound, void, float, delay, int, reason, int, unknown, int, unknown2) +{ + if (g_pIgnoreTerminateDetour) + { + g_pIgnoreTerminateDetour = false; + DETOUR_MEMBER_CALL(DetourTerminateRound)(delay, reason, unknown, unknown2); + return; + } #else //Windows CSGO //char __userpurge TerminateRound(int a1@, float a2@, int *a3) // a1 - this // a2 - delay // a3 - reason -DETOUR_DECL_MEMBER1(DetourTerminateRound, void, int, reason) +// a4 - unknown +// a5 - unknown +DETOUR_DECL_MEMBER3(DetourTerminateRound, void, int, reason, int, unknown, int, unknown2) { float delay; if (g_pIgnoreTerminateDetour) { g_pIgnoreTerminateDetour = false; - return DETOUR_MEMBER_CALL(DetourTerminateRound)(reason); + return DETOUR_MEMBER_CALL(DetourTerminateRound)(reason, unknown, unknown2); } //Save the delay @@ -178,11 +189,16 @@ DETOUR_DECL_MEMBER1(DetourTerminateRound, void, int, reason) reason++; #endif -#if SOURCE_ENGINE != SE_CSGO || !defined(WIN32) +#if SOURCE_ENGINE != SE_CSGO if (result == Pl_Changed) return DETOUR_MEMBER_CALL(DetourTerminateRound)(delay, reason); return DETOUR_MEMBER_CALL(DetourTerminateRound)(orgdelay, orgreason); +#elif !defined(WIN32) + if (result == Pl_Changed) + return DETOUR_MEMBER_CALL(DetourTerminateRound)(delay, reason, unknown, unknown2); + + return DETOUR_MEMBER_CALL(DetourTerminateRound)(orgdelay, orgreason, unknown, unknown2); #else if (result == Pl_Changed) { @@ -190,13 +206,13 @@ DETOUR_DECL_MEMBER1(DetourTerminateRound, void, int, reason) { movss xmm1, delay } - return DETOUR_MEMBER_CALL(DetourTerminateRound)(reason); + return DETOUR_MEMBER_CALL(DetourTerminateRound)(reason, unknown, unknown2); } __asm { movss xmm1, orgdelay } - return DETOUR_MEMBER_CALL(DetourTerminateRound)(orgreason); + return DETOUR_MEMBER_CALL(DetourTerminateRound)(orgreason, unknown, unknown2); #endif } diff --git a/extensions/cstrike/natives.cpp b/extensions/cstrike/natives.cpp index 626347cb..7c961852 100644 --- a/extensions/cstrike/natives.cpp +++ b/extensions/cstrike/natives.cpp @@ -314,17 +314,17 @@ static cell_t CS_TerminateRound(IPluginContext *pContext, const cell_t *params) reason++; #endif -#if SOURCE_ENGINE != SE_CSGO || !defined(WIN32) +#if SOURCE_ENGINE != SE_CSGO static ICallWrapper *pWrapper = NULL; if (!pWrapper) { REGISTER_NATIVE_ADDR("TerminateRound", PassInfo pass[2]; \ - pass[0].flags = PASSFLAG_BYVAL; \ + pass[0].flags = PASSFLAG_BYVAL; \ // delay pass[0].type = PassType_Basic; \ pass[0].size = sizeof(float); \ - pass[1].flags = PASSFLAG_BYVAL; \ + pass[1].flags = PASSFLAG_BYVAL; \ // reason pass[1].type = PassType_Basic; \ pass[1].size = sizeof(int); \ pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 2)) @@ -342,6 +342,45 @@ static cell_t CS_TerminateRound(IPluginContext *pContext, const cell_t *params) vptr += sizeof(float); *(int*)vptr = reason; + pWrapper->Execute(vstk, NULL); +#elif !defined(WIN32) + static ICallWrapper *pWrapper = NULL; + + if (!pWrapper) + { + REGISTER_NATIVE_ADDR("TerminateRound", + PassInfo pass[4]; \ + pass[0].flags = PASSFLAG_BYVAL; \ // delay + pass[0].type = PassType_Basic; \ + pass[0].size = sizeof(float); \ + pass[1].flags = PASSFLAG_BYVAL; \ // reason + pass[1].type = PassType_Basic; \ + pass[1].size = sizeof(int); \ + pass[2].flags = PASSFLAG_BYVAL; \ // unknown + pass[2].type = PassType_Basic; \ + pass[2].size = sizeof(int); \ + pass[3].flags = PASSFLAG_BYVAL; \ // unknown2 + pass[3].type = PassType_Basic; \ + pass[3].size = sizeof(int); \ + pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 4)) + } + + if (params[3] == 1 && g_pTerminateRoundDetoured) + g_pIgnoreTerminateDetour = true; + + unsigned char vstk[sizeof(void *) + sizeof(float)+ sizeof(int)]; + unsigned char *vptr = vstk; + + *(void **)vptr = gamerules; + vptr += sizeof(void *); + *(float *)vptr = sp_ctof(params[1]); + vptr += sizeof(float); + *(int*)vptr = reason; + vptr += sizeof(int); + *(int*)vptr = 0; + vptr += sizeof(int); + *(int*)vptr = 0; + pWrapper->Execute(vstk, NULL); #else static void *addr = NULL; @@ -358,6 +397,8 @@ static cell_t CS_TerminateRound(IPluginContext *pContext, const cell_t *params) __asm { + push 0 + push 0 push reason movss xmm1, delay mov ecx, gamerules From 8803219dd5ea034e99b1bb96919c80056cd6f324 Mon Sep 17 00:00:00 2001 From: Michael Flaherty Date: Thu, 4 Oct 2018 05:08:29 -0700 Subject: [PATCH 6/6] Fix regression in vstk size (#894) * Fix regression in vstk size * Fix macro comment mistake * More macro comment removals --- extensions/cstrike/natives.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/extensions/cstrike/natives.cpp b/extensions/cstrike/natives.cpp index 7c961852..0b4b87bf 100644 --- a/extensions/cstrike/natives.cpp +++ b/extensions/cstrike/natives.cpp @@ -321,10 +321,10 @@ static cell_t CS_TerminateRound(IPluginContext *pContext, const cell_t *params) { REGISTER_NATIVE_ADDR("TerminateRound", PassInfo pass[2]; \ - pass[0].flags = PASSFLAG_BYVAL; \ // delay + pass[0].flags = PASSFLAG_BYVAL; \ pass[0].type = PassType_Basic; \ pass[0].size = sizeof(float); \ - pass[1].flags = PASSFLAG_BYVAL; \ // reason + pass[1].flags = PASSFLAG_BYVAL; \ pass[1].type = PassType_Basic; \ pass[1].size = sizeof(int); \ pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 2)) @@ -350,16 +350,16 @@ static cell_t CS_TerminateRound(IPluginContext *pContext, const cell_t *params) { REGISTER_NATIVE_ADDR("TerminateRound", PassInfo pass[4]; \ - pass[0].flags = PASSFLAG_BYVAL; \ // delay + pass[0].flags = PASSFLAG_BYVAL; \ pass[0].type = PassType_Basic; \ pass[0].size = sizeof(float); \ - pass[1].flags = PASSFLAG_BYVAL; \ // reason + pass[1].flags = PASSFLAG_BYVAL; \ pass[1].type = PassType_Basic; \ pass[1].size = sizeof(int); \ - pass[2].flags = PASSFLAG_BYVAL; \ // unknown + pass[2].flags = PASSFLAG_BYVAL; \ pass[2].type = PassType_Basic; \ pass[2].size = sizeof(int); \ - pass[3].flags = PASSFLAG_BYVAL; \ // unknown2 + pass[3].flags = PASSFLAG_BYVAL; \ pass[3].type = PassType_Basic; \ pass[3].size = sizeof(int); \ pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 4)) @@ -368,7 +368,7 @@ static cell_t CS_TerminateRound(IPluginContext *pContext, const cell_t *params) if (params[3] == 1 && g_pTerminateRoundDetoured) g_pIgnoreTerminateDetour = true; - unsigned char vstk[sizeof(void *) + sizeof(float)+ sizeof(int)]; + unsigned char vstk[sizeof(void *) + sizeof(float) + (sizeof(int)*3)]; unsigned char *vptr = vstk; *(void **)vptr = gamerules;