diff --git a/core/logic/smn_core.cpp b/core/logic/smn_core.cpp index b7512752..adf0a0fb 100644 --- a/core/logic/smn_core.cpp +++ b/core/logic/smn_core.cpp @@ -747,18 +747,34 @@ static cell_t StoreToAddress(IPluginContext *pContext, const cell_t *params) NumberType size = static_cast(params[3]); + // new parameter added after SM 1.10; defaults to true for backwards compatibility + bool updateMemAccess = true; + if (params[0] >= 4) + { + updateMemAccess = params[4]; + } + switch(size) { case NumberType_Int8: - SourceHook::SetMemAccess(addr, sizeof(uint8_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC); + if (updateMemAccess) + { + SourceHook::SetMemAccess(addr, sizeof(uint8_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC); + } *reinterpret_cast(addr) = data; break; case NumberType_Int16: - SourceHook::SetMemAccess(addr, sizeof(uint16_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC); + if (updateMemAccess) + { + SourceHook::SetMemAccess(addr, sizeof(uint16_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC); + } *reinterpret_cast(addr) = data; break; case NumberType_Int32: - SourceHook::SetMemAccess(addr, sizeof(uint32_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC); + if (updateMemAccess) + { + SourceHook::SetMemAccess(addr, sizeof(uint32_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC); + } *reinterpret_cast(addr) = data; break; default: diff --git a/plugins/include/sourcemod.inc b/plugins/include/sourcemod.inc index 8b219200..71262d7d 100644 --- a/plugins/include/sourcemod.inc +++ b/plugins/include/sourcemod.inc @@ -698,13 +698,15 @@ native any LoadFromAddress(Address addr, NumberType size); /** * Store up to 4 bytes to a memory address. * - * @param addr Address to a memory location. - * @param data Value to store at the address. - * @param size How many bytes should be written. - * If storing a floating-point value, use NumberType_Int32. - * @error Address is null or pointing to reserved memory. + * @param addr Address to a memory location. + * @param data Value to store at the address. + * @param size How many bytes should be written. + * If storing a floating-point value, use NumberType_Int32. + * @param updateMemAccess If true, SourceMod will set read / write / exec permissions + * on the memory page being written to. + * @error Address is null or pointing to reserved memory. */ -native void StoreToAddress(Address addr, any data, NumberType size); +native void StoreToAddress(Address addr, any data, NumberType size, bool updateMemAccess = true); methodmap FrameIterator < Handle { // Creates a stack frame iterator to build your own stack traces.