diff --git a/core/logic/smn_gameconfigs.cpp b/core/logic/smn_gameconfigs.cpp index 933c5e2e..eaff876a 100644 --- a/core/logic/smn_gameconfigs.cpp +++ b/core/logic/smn_gameconfigs.cpp @@ -162,6 +162,38 @@ static cell_t smn_GameConfGetAddress(IPluginContext *pCtx, const cell_t *params) #endif } +static cell_t smn_GameConfGetMemSig(IPluginContext *pCtx, const cell_t *params) +{ + Handle_t hndl = static_cast(params[1]); + HandleError herr; + HandleSecurity sec; + IGameConfig *gc; + + sec.pOwner = NULL; + sec.pIdentity = g_pCoreIdent; + + if ((herr=handlesys->ReadHandle(hndl, g_GameConfigsType, &sec, (void **)&gc)) + != HandleError_None) + { + return pCtx->ThrowNativeError("Invalid game config handle %x (error %d)", hndl, herr); + } + + char *key; + void *val; + pCtx->LocalToString(params[2], &key); + + if (!gc->GetMemSig(key, &val)) + { + return 0; + } + +#ifdef PLATFORM_X86 + return (cell_t)val; +#else + return pseudoAddr.ToPseudoAddress(val); +#endif +} + static GameConfigsNatives s_GameConfigsNatives; REGISTER_NATIVES(gameconfignatives) @@ -176,5 +208,6 @@ REGISTER_NATIVES(gameconfignatives) {"GameData.GetOffset", smn_GameConfGetOffset}, {"GameData.GetKeyValue", smn_GameConfGetKeyValue}, {"GameData.GetAddress", smn_GameConfGetAddress}, + {"GameData.GetMemSig", smn_GameConfGetMemSig}, {NULL, NULL} }; diff --git a/plugins/include/sourcemod.inc b/plugins/include/sourcemod.inc index 3d261768..d1fcd2a9 100644 --- a/plugins/include/sourcemod.inc +++ b/plugins/include/sourcemod.inc @@ -113,6 +113,12 @@ methodmap GameData < Handle // @param name Name of the property to find. // @return An address calculated on success, or 0 on failure. public native Address GetAddress(const char[] name); + + // Returns a function address calculated from a signature. + // + // @param name Name of the property to find. + // @return An address calculated on success, or 0 on failure. + public native Address GetMemSig(const char[] name); }; /**