Table of Contents

Class MemoryProtection

Namespace
SharpPluginLoader.Core.Memory
Assembly
SharpPluginLoader.Core.dll

Temporarily changes the protection of a given region of memory.

public class MemoryProtection : IDisposable
Inheritance
MemoryProtection
Implements
Inherited Members

Examples

using (var prot = MemoryProtection(0x141234567, 0x100))
{
    // Make changes to the memory
}

Remarks

This class should always be used in a using context. You should only ever have ONE of these active per memory region at a time!

Constructors

MemoryProtection(nint, int, MEM_PROTECTION)

public MemoryProtection(nint address, int size, Kernel32.MEM_PROTECTION protection = MEM_PROTECTION.PAGE_EXECUTE_READWRITE)

Parameters

address nint

The start address of the memory region to adjust

size int

The size of the memory region to adjust

protection Kernel32.MEM_PROTECTION

The protection value to change it to.

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

~MemoryProtection()

protected ~MemoryProtection()