nosoop / SMExt-SourceScramble

A SourceMod extension for dealing with memory-related operations.
https://forums.alliedmods.net/showthread.php?p=2657347
GNU General Public License v3.0
83 stars 12 forks source link

Ability to allocate executable region of memory #7

Closed dragokas closed 3 years ago

dragokas commented 3 years ago

Hi, Can I ask you please to add a native for allocating memory with an executable flag?

I'd like to solve some crash by inserting

if (x != NULL)

in arbitrary place inside the function, so using your extension, I could do a manual detour by jumping to a new executable memory, do a required check, and jump back.

Thanks in advance. Nice job on this very useful extension!

nosoop commented 3 years ago

Provided you're using StoreToAddress or MemoryBlock.StoreToOffset (which just wraps around the former) to write to the MemoryBlock, it should already be marking the region as executable.

One of my private projects has no problems running executable code in MemoryBlock-allocated space, so I'm not sure that a new native is necessary for this. But if it is, I have no issue with adding it (probably as a permissions property).

I'll leave this issue open for now; please try the extension then report back.

dragokas commented 3 years ago

Ahh, I'm sorry, I couldn't imagine that StoreToAddress() already cover that. I just studying stuff so far, and didn't try to exec anything yet. If you said, you already did it before, that's great and no additional natives required. Thanks for clarifying.