[英]ReadProcessMemory faster
I'm making an application that will simulate an action using mouse/keyboard (macro) deppending on the value of a variable. 我正在制作一个应用程序,该应用程序将使用依赖于变量值的鼠标/键盘(宏)来模拟动作。
Here I have de scanning code that I made: 在这里,我已删除了我编写的代码:
void ReadMemory(int value){
DWORD primeiroAddress = 0x000000;
DWORD finalAddress = 0xFFFFFF;
DWORD address=0;
std::ostringstream ss;
int i=0;
TListItem *ListIt;
int valor;
HANDLE phandle = OpenProcess(PROCESS_VM_READ,0,TargetPID);
if(!phandle){
ShowMessage("Não encoutrou o processo");
}else{
for(address=primeiroAddress;address<=finalAddress;address+=sizeof(valor)){
ReadProcessMemory(phandle,(void*)address,&valor,sizeof(valor),0);
if(valor==value){
i++;
ss << std::hex << address;
Form1->Label5->Caption=i;
ListIt = Form1->ListView1->Items->Add();
ListIt->Caption = AnsiString(ss.str().c_str()).UpperCase();
ListIt->SubItems->Add(IntToStr(valor));
ss.str(std::string());
}
}
}
}
I was wondering what I could make to make the scanning faster 我想知道如何使扫描速度更快
You're reading one int
at a time. 您一次读取一个int
。 Instead call ReadProcessMemory
once, reading the 16MB in one swoop, then scan the memory in your own process. 而是一次调用ReadProcessMemory
一次读取16MB,然后在自己的进程中扫描内存。 It'll be a lot faster. 会快很多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.