我找到了与 linux x86_64 绝对寻址相关的主题: Absolute addressing for runtime code replacement in x86_64 .被告知 linux 不支持绝对寻址。
windows x64 是否支持近绝对调用?
对于 windows x86,可以通过这种方式从近绝对调用 (0xFF 0x15) 中获取函数的地址:
unsigned char call_nearAbsolute[2] = {0xFF, 0x15};
if(memcmp(bytes, call_nearAbsolute, sizeof(call_nearAbsolute)) == 0) {
{
unsigned char offset[] = {
*(bytes + 0x5),
*(bytes + 0x4),
*(bytes + 0x3),
*(bytes + 0x2)
};
PDWORD_PTR absolute_addr =
(PDWORD_PTR)(((offset[0] & 0xFF) << 24) |
((offset[1] & 0xFF) << 16) |
((offset[2] & 0xFF) << 8) |
offset[3] & 0xFF);
}
如果支持x64,如何正确获取程序地址?
最佳答案
使用
MOV rax, address(your routine)'
CALL rax
在 1 个命令(营销或任何愚蠢的原因)中(还)没有绝对调用该模式。提到的组合(必要时用其他临时寄存器替换它)可以让你得到你想要的。预测器应该至少通过它在内存中的位置来识别这种调用而不会受到惩罚(调用命令本身)。虽然我没有测试第一个调用惩罚,但它应该与使用间接地址的调用相同或更低(当正确对齐时)。
关于c++ - Windows x64 的近绝对调用 (0xFF 0x15) 寻址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10480709/