Function alloc_dual_mapping

Source
pub fn alloc_dual_mapping(
    size: usize,
    memory_flags: MemoryFlags,
) -> Result<DualMapping, Error>
Expand description

Allocates virtual memory and creates two views of it where the first view has no write access. This is an addition to the API that should be used in cases in which the operating system either enforces W^X security policy or the application wants to use this policy by default to improve security and prevent an accidental (or purposed) self-modifying code.

The memory returned in the dm are two independent mappings of the same shared memory region. You must use release_dual_mapping to release it when it’s no longer needed. Never use release to release the memory returned by alloc_dual_mapping() as that would fail on Windows.

Both pointers in dm would be set to null if the function fails.