使用WinXP SP3。 Visual Studio 2005。
尝试读取另一个进程的内存。
std::cout<<"Reading Process Memory\n";
const DWORD pid = 3476;
HANDLE handle = OpenProcess(PROCESS_VM_READ,FALSE,pid);
if(handle == NULL) {std::cout<<"Failed to open process\n";return 0;}
char* buffer1 = new char[256];
char* buffer2 = new char[256];
memset(buffer1,0,256*sizeof(char));
memset(buffer2,0,256*sizeof(char));
DWORD nbr = 0;
int address = 0x400000;
BOOL result = ReadProcessMemory(handle,&address,buffer1,32,&nbr);
if(result!=1) std::cout<<"Failed to read memory\n";
address = 0x400000+0x1000;
result = ReadProcessMemory(handle,&address,buffer2,32,&nbr);
if(result!=1) std::cout<<"Failed to read memory\n";
int i = 0;
while(i++<10)
{
if(buffer1[i]!=buffer2[i]) {std::cout<<"Buffers are different\n";break;}
}
delete[] buffer1;
delete[] buffer2;
CloseHandle(handle);
std::cin>>i;
return 0;
问题是两个缓冲区都获得了相同的值。 ReadProcMemory返回1,读取的字节数与请求的相同。
答案 0 :(得分:4)
您对ReadProcessMemory的调用不正确。您应该直接使用address
,而不是&address
。您可能需要将其投射到const void *
。
result = ReadProcessMemory(handle, reinterpret_cast<const void *>(address), buffer, 32, &nbr);
您可能应该将address
声明为足以处理指针的类型,例如std::ssize_t
或INT_PTR
。
INT_PTR address = 0x400000;
答案 1 :(得分:0)
缓冲区不能成为char,它必须是int,这是一个有效的例子
Dim message As New Chat.ChatMessage
message.Recipients.Add("07867660552")
message.Body = "This is a text message from an riaz!"
Await Chat.ChatMessageManager.ShowComposeSmsMessageAsync(message)