【发布时间】:2012-12-30 04:08:07
【问题描述】:
int a, hex = 0x573285;
int * pA; // Pointer?
*pa = &a; // &a = the hexadecimal-memory location and *pa is now going to point to that place.
所以我想:
假设可以这样写:
(*hex) = 5; or whatever the hexadecimal number is
改变内存的值?
如果我有一个程序(我不知道),它会显示我的游戏使用的所有内存位置。 如果我更改了程序中的值然后回到我的游戏或其他任何情况下,它也会在那里更改吗? (如果游戏正在运行)。
是(*this) the same as (this*)?
编辑: 这行得通
int a = 5, b=0x28ff1c;
int* c = &a;
cout << *(c);
但不是:
int a = 5;
int * b=0x28ff1c;
int * c = &a;
cout << *(b);
也不:
int a = 5, b=0x28ff1c;
int * c = &a;
cout << *(b);
你明白我在做什么吗?
【问题讨论】:
-
*this取消引用this。this*后面需要一些东西才能调用operator*,但它本身并不完整。 -
幸运的是,现代操作系统阻止您读取/写入您不拥有的内存......
-
@K-ballo,直到你打电话给
WriteProcessMemory(在 Windows 中);) -
@MaggiQall 恐怕这个问题没有多大意义。
hex是一个int,所以没有*hex这样的东西。 C++ 教科书见stackoverflow.com/questions/388242/…。 -
当然,除非这不是在具有内存保护的 32/64 位现代架构上。我记得,任天堂允许从内存位置读取和写入(使用整数2指针转换)。