将数字添加到指针值
Adding number to pointer value
我正在尝试使用以下表达式将数字添加到指针值:
&AddressHelper::getInstance().GetBaseAddress() + 0x39EA0;
&AddressHelper::getInstance().GetBaseAddress()
的值总是 0x00007ff851cd3c68 {140700810412032}
我不应该得到 0x00007ff851cd3c68 + 0x39EA0 = 7FF81350DB08
作为结果吗?
当我得到:0x00007ff851ea3168
或有时 0x00007ff852933168
或其他一些数字时。
我是不是取错了指针值?
使用指针算法,类型被考虑在内,
因此:
int buffer[42];
char* start_c = reinterpret_cast<char*>(buffer);
int *start_i = buffer;
我们有
start_i + 1 == &buffer[1]
reinterpret_cast<char*>(start_i + 1) == start_c + sizeof(int)
.
- 和(当
sizeof(int) != 1
)reinterpret_cast<char*>(start_i + 1) != start_c + 1
你的情况:
0x00007ff851ea3168 - 0x00007ff851cd3c68) / 0x39EA0 = 0x08
和sizeof(DWORD) == 8
.
我正在尝试使用以下表达式将数字添加到指针值:
&AddressHelper::getInstance().GetBaseAddress() + 0x39EA0;
&AddressHelper::getInstance().GetBaseAddress()
的值总是 0x00007ff851cd3c68 {140700810412032}
我不应该得到 0x00007ff851cd3c68 + 0x39EA0 = 7FF81350DB08
作为结果吗?
当我得到:0x00007ff851ea3168
或有时 0x00007ff852933168
或其他一些数字时。
我是不是取错了指针值?
使用指针算法,类型被考虑在内,
因此:
int buffer[42];
char* start_c = reinterpret_cast<char*>(buffer);
int *start_i = buffer;
我们有
start_i + 1 == &buffer[1]
reinterpret_cast<char*>(start_i + 1) == start_c + sizeof(int)
.- 和(当
sizeof(int) != 1
)reinterpret_cast<char*>(start_i + 1) != start_c + 1
你的情况:
0x00007ff851ea3168 - 0x00007ff851cd3c68) / 0x39EA0 = 0x08
和sizeof(DWORD) == 8
.