How to map machine instctions in memory and execute them? (Aka, how to create a loader)

Adam D Ruppe destructionator at gmail.com
Mon Jun 6 16:08:28 UTC 2022


On Monday, 6 June 2022 at 15:13:45 UTC, rempas wrote:
>   void* code = mmap(null, cast(ulong)500, PROT_READ | 
> PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0);

On a lot of systems, it can't be executable and writable at the 
same time, it is a security measure.

see https://en.wikipedia.org/wiki/W%5EX


so you might have to mprotect it to remove the write permission 
before trying to execute it.

idk though


More information about the Digitalmars-d-learn mailing list