简体   繁体   English

C++ 内存地址和偏移写入/读取

[英]C++ memory address and offset writing / read

Hello sorry for my bad English.你好抱歉我的英语不好。 I want to calculate an address with offset.我想用偏移量计算地址。

The example I have got a base address: 0x00D2038 with offset 0x1c我有一个基地址的例子:0x00D2038,偏移量为0x1c

I have tried this.我试过这个。

DWORD address = 0x004D2038;
DWORD offset = 0x1c;

DWORD base = (DWORD)(address + offset);
int old_value = 0;
int value = 3000;

//Obtain new address form the address whit offset.
DWORD addr2 =  ReadProcessMemory(phandle,(void*)base,&old_value,sizeof(old_value),0);

//Write Memory
WriteProcessMemory(phandle,(void*)addr2,&value,(DWORD)sizeof(value),NULL);

But it does not work.但它不起作用。 Memory is not changed.内存没有改变。 what is my error?我的错误是什么?

According to msdn, ReadProcessMemory returns a BOOL and you use that as addr2 to WriteProcessMemory.根据 msdn,ReadProcessMemory 返回一个 BOOL,您将其用作 WriteProcessMemory 的 addr2。 How can the memory be changed?怎么改内存?

Suggest search from msdn on ReadProcessMemory and WriteProcessMemory and their example and learn how to use these 2 functions.建议从 msdn 搜索 ReadProcessMemory 和 WriteProcessMemory 及其示例,并了解如何使用这两个函数。

Think you have a simple typo -- Try;认为你有一个简单的错字——试试;

//Write Memory
WriteProcessMemory(phandle,(void*)base,&value,(DWORD)sizeof(value),NULL);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM