Repository navigation
Expand file tree
/
Copy pathIMemory.cs
More file actions
93 lines (83 loc) · 3.99 KB
/
Copy pathIMemory.cs
File metadata and controls
93 lines (83 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using System.Text;
namespace ProcessNET.Memory
{
public interface IMemory
{
bool Is32Bit { get; }
/// <summary>
/// Writes a set of bytes to memory.
/// </summary>
/// <param name="intPtr">The address where the bytes start in memory.</param>
/// <param name="length">The slength of the byte chunk to read from the memory address.</param>
/// <returns>
/// The byte array section read from memory.
/// </returns>
byte[] Read(IntPtr intPtr, int length);
/// <summary>
/// Writes a set of bytes to memory.
/// </summary>
/// <param name="intPtr">The address where the bytes start in memory.</param>
/// <param name="buffer">The buffer to read data onto, it's size determines the count of bytes to read.</param>
void Read(IntPtr intPtr, byte[] buffer);
/// <summary>
/// Reads a string with a specified encoding from memory.
/// </summary>
/// <param name="intPtr">The address where the string is read.</param>
/// <param name="encoding">The encoding used.</param>
/// <param name="maxLength">
/// The number of maximum bytes to read. The string is automatically cropped at this end ('\0'
/// char).
/// </param>
/// <returns>The string.</returns>
string ReadString(IntPtr intPtr, Encoding encoding, int maxLength = 512);
/// <summary>
/// Reads the value of a specified type from memory.
/// </summary>
/// <typeparam name="T">The type of the value.</typeparam>
/// <param name="intPtr">The address where the value is read.</param>
/// <returns>A value.</returns>
T Read<T>(IntPtr intPtr);
/// <summary>
/// Reads an array of a specified type from memory.
/// </summary>
/// <typeparam name="T">The type of the values.</typeparam>
/// <param name="intPtr">The address where the values is read.</param>
/// <param name="length">The number of cells in the array.</param>
/// <returns>An array.</returns>
T[] Read<T>(IntPtr intPtr, int length);
/// <summary>
/// Write an array of bytes in the remote process.
/// </summary>
/// <param name="intPtr">The address where the array is written.</param>
/// <param name="bytesToWrite">The array of bytes to write.</param>
int Write(IntPtr intPtr, byte[] bytesToWrite);
/// <summary>
/// Writes a string with a specified encoding to memory.
/// </summary>
/// <param name="intPtr">The address where the string is written.</param>
/// <param name="stringToWrite">The text to write.</param>
/// <param name="encoding">The encoding used.</param>
void WriteString(IntPtr intPtr, string stringToWrite, Encoding encoding);
/// <summary>
/// Writes an array of a specified type to memory,
/// </summary>
/// <typeparam name="T">The type of the values.</typeparam>
/// <param name="intPtr">The address where the values is written.</param>
/// <param name="values">The array to write.</param>
void Write<T>(IntPtr intPtr, T[] values);
/// <summary>
/// Writes the values of a specified type to memory.
/// </summary>
/// <typeparam name="T">The type of the value.</typeparam>
/// <param name="intPtr">The address where the value is written.</param>
/// <param name="value">The value to write.</param>
void Write<T>(IntPtr intPtr, T value);
/// <summary>
/// Reads the Runtime Type Information (RTTI) at certain address.
/// </summary>
/// <param name="address">Address to read the type from.</param>
/// <returns>Runtime Type Information of the object at the passed address or null if it's not an object.</returns>
string ReadRemoteRuntimeTypeInformation(IntPtr address);
}
}