I am currently trying to read from a memory address, then open its contents in a web browser (its contents is always a url.) I am currently attempting to do it like this:
public static void Main(string[] args)
{
Process[] pname = Process.GetProcessesByName("t6mp");
if (pname.Length == 0)
{
Console.WriteLine("Game not found. Please run your game then restart this program.");
Console.ReadLine();
}
else
{
void ReadProcessMemory(object t6mp, int v1, byte[] url, int v2, ref int read)
{
}
Console.WriteLine("Game found. Please go to the page where you can start a demo, then press enter to continue.");
Console.ReadLine();
Console.WriteLine("Please press enter to export");
Console.ReadLine();
var buffer = new byte[1];
var sb = new StringBuilder();
var handle = Process.GetProcessesByName("t6mp")[0];
int _bytesused = 200;
for (var i = 0; i < _bytesused; i++)
{
ReadProcessMemory(handle, 0x2BDA932 + i, buffer, buffer.Length, ref _bytesused);
if (buffer[0] != 0)
{
sb.Append(Encoding.ASCII.GetString(buffer));
Process.Start(sb.ToString());
}
else
{
Console.WriteLine("Error has occured, please try again. Press enter to close program");
Console.ReadLine();
break;
}
}
}
}
It is correctly recognizing when the process is open, and I am sure that the address exists (I have tried both 0x2BDA932 and 0x02BDA932) However, It always displays the error message, for some reason if (buffer[0] != 0)
is always false. When I remove the if / else and just have it go straight to sb.Append(Encoding.ASCII.GetString(buffer));
Process.Start(sb.ToString());
It just crashes. Ideally, it would open the contents of the address in my browser, as it is a url. Any ideas?