我当前正在尝试从内存地址中读取内容,然后在Web浏览器中打开其内容(其内容始终是url。) 我目前正在尝试这样做:
timestamp
它可以正确识别何时打开了该进程,并且我确定该地址存在(我已经尝试了0x2BDA932和0x02BDA932)。但是,由于某种原因,它始终显示错误消息,define('DEFAULT_TIMEZONE','UTC');//set this in your global config.php file
$date = new DateTime('2000-01-01', new DateTimeZone(DEFAULT_TIMEZONE));
始终为假。当我删除if / else并直接进入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;
}
}
}
}
它只是崩溃了。理想情况下,它将在我的浏览器中打开地址的内容,因为它是一个URL。有什么想法吗?
答案 0 :(得分:0)
var buffer = new byte[1];
您的缓冲区只有1个字节的长度,您的while循环会使您的缓冲区溢出,从而可能导致不确定的行为。
buffer.Length
在对ReadProcessMemory的调用中
长度为1,您只读取1个字节,这就是为什么它永远不会为0的原因。
您应该使用固定大小(例如2000)定义数组长度,该大小应涵盖所有可能的URL情况。
这是我读取空终止字符串的功能:
public static string ReadNullTerminatedString(IntPtr handle, IntPtr addr, int maxlength)
{
var bytearray = new byte[maxlength];
IntPtr bytesread = IntPtr.Zero;
ReadProcessMemory(handle, addr, bytearray, maxlength, out bytesread);
int nullterm = 0;
while (nullterm < bytesread.ToInt64() && bytearray[nullterm] != 0)
{
nullterm++;
}
string s = Encoding.ASCII.GetString(bytearray, 0, nullterm);
return s;
}