In
LM_ProtMemory and LM_ProtMemoryEx, the oldprot_out parameter contains the old protection of the first page of the whole region, which is enough for most cases. You should pick the old protections yourself with LM_FindSegments or LM_FindSegmentsEx in case of a multi-segment memory protection.LM_ProtMemory
Sets memory protection flags for a specified memory address range.The memory address to be protected.
The size of memory to be protected. If the size is 0, the function will default to using the system’s page size for the operation.
The new protection flags that will be applied to the memory region. It is a bit mask of
LM_PROT_X (execute), LM_PROT_R (read), LM_PROT_W (write). See Memory Protection for more details.A pointer to a variable that will store the old protection flags of the memory segment before they are updated with the new protection settings. Can be
NULL if you don’t need the old protection.LM_TRUE if the memory protection operation was successful, or LM_FALSE if it failed.
Example
LM_ProtMemoryEx
Modifies memory protection flags for a specified address range in a given process.A pointer to the process that the memory flags will be modified from.
The memory address to be protected.
The size of memory to be protected. If the size is 0, the function will default to using the system’s page size for the operation.
The new protection flags that will be applied to the memory region. It is a bit mask of
LM_PROT_X (execute), LM_PROT_R (read), LM_PROT_W (write). See Memory Protection for more details.A pointer to a variable that will store the old protection flags of the memory segment before they are updated. Can be
NULL if you don’t need the old protection.LM_TRUE if the memory protection operation was successful, or LM_FALSE if it failed.
Example
Memory Protection Flags
The following protection flags can be combined using bitwise OR:| Flag | Description |
|---|---|
LM_PROT_NONE | No access |
LM_PROT_X | Execute permission |
LM_PROT_R | Read permission |
LM_PROT_W | Write permission |
LM_PROT_XR | Execute + Read |
LM_PROT_XW | Execute + Write |
LM_PROT_RW | Read + Write |
LM_PROT_XRW | Execute + Read + Write |