C++将ProcessMemory读取到字节数组中
我正在尝试使用 ReadProcessMemory 将动态数量的字节读取到数组中,然后返回它。我根本无法让它正常工作。我当前的代码是...
byte *Application::readMemory(DWORD address, int length) {
byte *buffer = new byte[length];
SIZE_T bytesRead;
ReadProcessMemory(piProcessInfo.hProcess, (void *)address, &buffer, length, &bytesRead);
return buffer;
}
任何帮助将不胜感激。
I'm attempting to use ReadProcessMemory to read a dynamic amount of bytes into an array and then return it. I simply can't get it to work properly. My current code is...
byte *Application::readMemory(DWORD address, int length) {
byte *buffer = new byte[length];
SIZE_T bytesRead;
ReadProcessMemory(piProcessInfo.hProcess, (void *)address, &buffer, length, &bytesRead);
return buffer;
}
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
难道不应该吗
?如果您将缓冲区指针地址作为输入参数,则 ReadProcessMemory 会将其复制到缓冲区指针所在的位置(不是复制到缓冲区,而是复制到 vatiable 及其他缓冲区指针中) - 并且由于它位于堆栈上,因此堆栈会损坏。
Shouldn't it be
? If you give buffer-pointer address as input parameter, then ReadProcessMemory copies it where buffer pointer lies (not to the buffer but into buffer pointer vatiable and beyond) - and sice it is on the stack, stack gets corrupted.