logic: Add ability to skip mprotect with StoreToAddress (#1523)
* Implement StoreToAddress param to optionally set memory page permissions * Update comment
This commit is contained in:
parent
823b55c22a
commit
387b85406e
@ -747,18 +747,34 @@ static cell_t StoreToAddress(IPluginContext *pContext, const cell_t *params)
|
|||||||
|
|
||||||
NumberType size = static_cast<NumberType>(params[3]);
|
NumberType size = static_cast<NumberType>(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)
|
switch(size)
|
||||||
{
|
{
|
||||||
case NumberType_Int8:
|
case NumberType_Int8:
|
||||||
|
if (updateMemAccess)
|
||||||
|
{
|
||||||
SourceHook::SetMemAccess(addr, sizeof(uint8_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC);
|
SourceHook::SetMemAccess(addr, sizeof(uint8_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC);
|
||||||
|
}
|
||||||
*reinterpret_cast<uint8_t*>(addr) = data;
|
*reinterpret_cast<uint8_t*>(addr) = data;
|
||||||
break;
|
break;
|
||||||
case NumberType_Int16:
|
case NumberType_Int16:
|
||||||
|
if (updateMemAccess)
|
||||||
|
{
|
||||||
SourceHook::SetMemAccess(addr, sizeof(uint16_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC);
|
SourceHook::SetMemAccess(addr, sizeof(uint16_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC);
|
||||||
|
}
|
||||||
*reinterpret_cast<uint16_t*>(addr) = data;
|
*reinterpret_cast<uint16_t*>(addr) = data;
|
||||||
break;
|
break;
|
||||||
case NumberType_Int32:
|
case NumberType_Int32:
|
||||||
|
if (updateMemAccess)
|
||||||
|
{
|
||||||
SourceHook::SetMemAccess(addr, sizeof(uint32_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC);
|
SourceHook::SetMemAccess(addr, sizeof(uint32_t), SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC);
|
||||||
|
}
|
||||||
*reinterpret_cast<uint32_t*>(addr) = data;
|
*reinterpret_cast<uint32_t*>(addr) = data;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -702,9 +702,11 @@ native any LoadFromAddress(Address addr, NumberType size);
|
|||||||
* @param data Value to store at the address.
|
* @param data Value to store at the address.
|
||||||
* @param size How many bytes should be written.
|
* @param size How many bytes should be written.
|
||||||
* If storing a floating-point value, use NumberType_Int32.
|
* 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.
|
* @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 {
|
methodmap FrameIterator < Handle {
|
||||||
// Creates a stack frame iterator to build your own stack traces.
|
// Creates a stack frame iterator to build your own stack traces.
|
||||||
|
Loading…
Reference in New Issue
Block a user