C# Class Binarysharp.MemoryManagement.Memory.MemoryCore

Static core class providing tools for memory editing.
Show file Open project: ZenLulz/MemorySharp Class Usage Examples

Public Methods

Method Description
Allocate ( SafeMemoryHandle processHandle, int size, MemoryProtectionFlags protectionFlags = MemoryProtectionFlags.ExecuteReadWrite, MemoryAllocationFlags allocationFlags = MemoryAllocationFlags.Commit ) : IntPtr

Reserves a region of memory within the virtual address space of a specified process.

ChangeProtection ( SafeMemoryHandle processHandle, IntPtr address, int size, MemoryProtectionFlags protection ) : MemoryProtectionFlags

Changes the protection on a region of committed pages in the virtual address space of a specified process.

CloseHandle ( IntPtr handle ) : void

Closes an open object handle.

Free ( SafeMemoryHandle processHandle, IntPtr address ) : void

Releases a region of memory within the virtual address space of a specified process.

NtQueryInformationProcess ( SafeMemoryHandle processHandle ) : ProcessBasicInformation

etrieves information about the specified process.

OpenProcess ( ProcessAccessFlags accessFlags, int processId ) : SafeMemoryHandle

Opens an existing local process object.

Query ( SafeMemoryHandle processHandle, IntPtr addressFrom, IntPtr addressTo ) : IEnumerable

Retrieves information about a range of pages within the virtual address space of a specified process.

Query ( SafeMemoryHandle processHandle, IntPtr baseAddress ) : MemoryBasicInformation

Retrieves information about a range of pages within the virtual address space of a specified process.

ReadBytes ( SafeMemoryHandle processHandle, IntPtr address, int size ) : byte[]

Reads an array of bytes in the memory form the target process.

WriteBytes ( SafeMemoryHandle processHandle, IntPtr address, byte byteArray ) : int

Writes data to an area of memory in a specified process.

Method Details

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

ChangeProtection() public static method

Changes the protection on a region of committed pages in the virtual address space of a specified process.
public static ChangeProtection ( SafeMemoryHandle processHandle, IntPtr address, int size, MemoryProtectionFlags protection ) : MemoryProtectionFlags
processHandle Binarysharp.MemoryManagement.Native.SafeMemoryHandle A handle to the process whose memory protection is to be changed.
address System.IntPtr A pointer to the base address of the region of pages whose access protection attributes are to be changed.
size int The size of the region whose access protection attributes are changed, in bytes.
protection MemoryProtectionFlags The memory protection option.
return MemoryProtectionFlags

CloseHandle() public static method

Closes an open object handle.
public static CloseHandle ( IntPtr handle ) : void
handle System.IntPtr A valid handle to an open object.
return void

Free() public static method

Releases a region of memory within the virtual address space of a specified process.
public static Free ( SafeMemoryHandle processHandle, IntPtr address ) : void
processHandle Binarysharp.MemoryManagement.Native.SafeMemoryHandle A handle to a process.
address System.IntPtr A pointer to the starting address of the region of memory to be freed.
return void

NtQueryInformationProcess() public static method

etrieves information about the specified process.
public static NtQueryInformationProcess ( SafeMemoryHandle processHandle ) : ProcessBasicInformation
processHandle Binarysharp.MemoryManagement.Native.SafeMemoryHandle A handle to the process to query.
return Binarysharp.MemoryManagement.Native.ProcessBasicInformation

OpenProcess() public static method

Opens an existing local process object.
public static OpenProcess ( ProcessAccessFlags accessFlags, int processId ) : SafeMemoryHandle
accessFlags ProcessAccessFlags The access level to the process object.
processId int The identifier of the local process to be opened.
return Binarysharp.MemoryManagement.Native.SafeMemoryHandle

Query() public static method

Retrieves information about a range of pages within the virtual address space of a specified process.
public static Query ( SafeMemoryHandle processHandle, IntPtr addressFrom, IntPtr addressTo ) : IEnumerable
processHandle Binarysharp.MemoryManagement.Native.SafeMemoryHandle A handle to the process whose memory information is queried.
addressFrom System.IntPtr A pointer to the starting address of the region of pages to be queried.
addressTo System.IntPtr A pointer to the ending address of the region of pages to be queried.
return IEnumerable

Query() public static method

Retrieves information about a range of pages within the virtual address space of a specified process.
public static Query ( SafeMemoryHandle processHandle, IntPtr baseAddress ) : MemoryBasicInformation
processHandle Binarysharp.MemoryManagement.Native.SafeMemoryHandle A handle to the process whose memory information is queried.
baseAddress System.IntPtr A pointer to the base address of the region of pages to be queried.
return Binarysharp.MemoryManagement.Native.MemoryBasicInformation

ReadBytes() public static method

Reads an array of bytes in the memory form the target process.
public static ReadBytes ( SafeMemoryHandle processHandle, IntPtr address, int size ) : byte[]
processHandle Binarysharp.MemoryManagement.Native.SafeMemoryHandle A handle to the process with memory that is being read.
address System.IntPtr A pointer to the base address in the specified process from which to read.
size int The number of bytes to be read from the specified process.
return byte[]

WriteBytes() public static method

Writes data to an area of memory in a specified process.
public static WriteBytes ( SafeMemoryHandle processHandle, IntPtr address, byte byteArray ) : int
processHandle Binarysharp.MemoryManagement.Native.SafeMemoryHandle A handle to the process memory to be modified.
address System.IntPtr A pointer to the base address in the specified process to which data is written.
byteArray byte A buffer that contains data to be written in the address space of the specified process.
return int