Introduction
I am currently using a class to read bytes in memory (via pointers). The code that I still work fine, I really do not want to change the way the class is installed, if possible (because it works), but hopefully some minor changes can be made to the class and my code to make it highly efficient.
What I am achieving at the moment:
Start with the address of the pointer in memory, read the byte at this address, add data to the array, add 1 to the source address so that we can now read the next address (for example, the source address is 24004, after saving the byte, increment 1 and the next address to read become 24005).
Reads a byte to the following address (24005), adds it to the same array, adds 1 to this address (next to reading it becomes 24006).
And so on for a fixed number of iterations (approximately 10,000).
Problem:
Making 10,000 readprocessmemory calls one by one causes a system delay of 20 seconds while she goes about her business.
I hope you can achieve:
Readprocessmemory , 10 000 , ( 10 000 ), , , ( {0} (1) (2).. .. {0}, , 10 000 ( )) , , . , 5 : {12345} {1} {2} {3} {4} {5}. , 1 2 3 4 5 1 200 40 43 20.
, , ( , , ):
:
private void label1_Click(object sender, EventArgs e)
{
int[] valuesSeperated[200];
List<byte> PreArray = new List<byte>();
Process[] test = Process.GetProcessesByName("MyProcess");
int baseAddress = test[0].MainModule.BaseAddress.ToInt32();
byte ReadX = MyClass.ReadPointerByte("MyProcess", BaseAddress, new int[] { 0xc, 0x0, 0x2 });
PreArray.Add(ReadX);
byte[] PreArrayToInt = PreArray.ToArray();
int[] MYConvertedBytes = PreArray ToInt.Select(x => (int)x).ToArray();
foreach (int i in MYConvertedBytes)
{
valuesSeperated
}
}
:
[DllImport("kernel32", EntryPoint = "ReadProcessMemory")]
private static extern byte ReadProcessMemoryByte(int Handle, int Address, ref byte Value, int Size, ref int BytesRead);
public static byte ReadPointerByte(string EXENAME, int Pointer, int[] Offset)
{
byte Value = 0;
checked
{
try
{
Process[] Proc = Process.GetProcessesByName(EXENAME);
if (Proc.Length != 0)
{
int Bytes = 0;
int Handle = OpenProcess(PROCESS_ALL_ACCESS, 0, Proc[0].Id);
if (Handle != 0)
{
foreach (int i in Offset)
{
ReadProcessMemoryInteger((int)Handle, Pointer, ref Pointer, 4, ref Bytes);
Pointer += i;
}
ReadProcessMemoryByte((int)Handle, Pointer, ref Value, 2, ref Bytes);
CloseHandle(Handle);
}
}
}
catch
{ }
}
return Value;
}