Class representing an allocated memory in a remote process.
Inheritance: RemoteRegion, IDisposableState
Exemple #1
0
 /// <summary>
 /// Allocates a region of memory within the virtual address space of the remote process.
 /// </summary>
 /// <param name="size">The size of the memory to allocate.</param>
 /// <param name="protection">The protection of the memory to allocate.</param>
 /// <param name="mustBeDisposed">The allocated memory will be released when the finalizer collects the object.</param>
 /// <returns>A new instance of the <see cref="RemoteAllocation"/> class.</returns>
 public RemoteAllocation Allocate(int size, MemoryProtectionFlags protection = MemoryProtectionFlags.ExecuteReadWrite, bool mustBeDisposed = true)
 {
     // Allocate a memory space
     var memory = new RemoteAllocation(MemorySharp, size, protection, mustBeDisposed);
     // Add the memory in the list
     InternalRemoteAllocations.Add(memory);
     return memory;
 }
Exemple #2
0
 /// <summary>
 /// Deallocates a region of memory previously allocated within the virtual address space of the remote process.
 /// </summary>
 /// <param name="allocation">The allocated memory to release.</param>
 public void Deallocate(RemoteAllocation allocation)
 {
     // Dispose the element
     if(!allocation.IsDisposed)
         allocation.Dispose();
     // Remove the element from the allocated memory list
     if (InternalRemoteAllocations.Contains(allocation))
         InternalRemoteAllocations.Remove(allocation);
 }
 /// <summary>
 ///     Allocates a region of memory within the virtual address space of the remote process.
 /// </summary>
 /// <param name="size">The size of the memory to allocate.</param>
 /// <param name="protection">The protection of the memory to allocate.</param>
 /// <param name="mustBeDisposed">The allocated memory will be released when the finalizer collects the object.</param>
 /// <returns>A new instance of the <see cref="RemoteAllocation" /> class.</returns>
 public RemoteAllocation Allocate(int size, MemoryProtectionFlags protection = MemoryProtectionFlags.ExecuteReadWrite, bool mustBeDisposed = true)
 {
     // Allocate a memory space
     var memory = new RemoteAllocation(MemorySharp, size, protection, mustBeDisposed);
     // Add the memory in the list
     InternalRemoteAllocations.Add(memory);
     return memory;
 }
 /// <summary>
 ///     Deallocates a region of memory previously allocated within the virtual address space of the remote process.
 /// </summary>
 /// <param name="allocation">The allocated memory to release.</param>
 public void Deallocate(RemoteAllocation allocation)
 {
     // Dispose the element
     if (!allocation.IsDisposed)
     {
         allocation.Dispose();
     }
     // Remove the element from the allocated memory list
     if (InternalRemoteAllocations.Contains(allocation))
     {
         InternalRemoteAllocations.Remove(allocation);
     }
 }