Windows x64 的近绝对调用 (0xFF 0x15) 寻址

Near absolute call (0xFF 0x15) addressing for windows x64

本文关键字:0xFF 0x15 寻址 调用 x64 Windows      更新时间:2023-10-16

我发现与 Linux 相关的主题x86_64绝对寻址: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 个命令(营销或任何愚蠢的原因)中,该模式下(尚)没有绝对调用。上述组合(必要时用其他临时寄存器替换它)可让您获得所需的内容。预测器应至少通过其在内存中的位置来识别此类调用,而不会受到惩罚(调用命令本身)。我没有测试第一个呼叫惩罚,但它应该与间接地址的呼叫相同或更低(正确对齐)。