Class representing an allocated memory in a remote process.
Inheritance: RemoteRegion, IDisposableState
Beispiel #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;
 }
Beispiel #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);
 }
Beispiel #3
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;
 }
Beispiel #4
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);
     }
 }