Allocate() public static method

Reserves a region of memory within the virtual address space of a specified process.
public static Allocate ( SafeMemoryHandle processHandle, int size, MemoryProtectionFlags protectionFlags = MemoryProtectionFlags.ExecuteReadWrite, MemoryAllocationFlags allocationFlags = MemoryAllocationFlags.Commit ) : IntPtr
processHandle Binarysharp.MemoryManagement.Native.SafeMemoryHandle The handle to a process.
size int The size of the region of memory to allocate, in bytes.
protectionFlags MemoryProtectionFlags The memory protection for the region of pages to be allocated.
allocationFlags MemoryAllocationFlags The type of memory allocation.
return System.IntPtr
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteAllocation"/> class.
 /// </summary>
 /// <param name="memorySharp">The reference of the <see cref="MemorySharp"/> object.</param>
 /// <param name="size">The size of the allocated memory.</param>
 /// <param name="protection">The protection of the allocated memory.</param>
 /// <param name="mustBeDisposed">The allocated memory will be released when the finalizer collects the object.</param>
 internal RemoteAllocation(MemorySharp memorySharp, int size, MemoryProtectionFlags protection = MemoryProtectionFlags.ExecuteReadWrite,
                           bool mustBeDisposed = true)
     : base(memorySharp, MemoryCore.Allocate(memorySharp.Handle, size, protection))
 {
     // Set local vars
     MustBeDisposed = mustBeDisposed;
     IsDisposed     = false;
 }