简体   繁体   English

如何从delphi XE2中的绝对地址读取数据

[英]How to read data from absolute address in delphi XE2

Let's say that I want to read from absolute address gs:$30 in 64bit mode, so the asm code looks something like: 假设我想从64位模式的绝对地址gs:$30读取,所以asm代码看起来像:

asm
  mov   rax, gs:[$30]
end;

...and compiler translate this code to... ...和编译器将此代码翻译为......

  65 48 8B 05 30 00 00 00       mov rax,gs:[rel $00000030]

But I don't want to use relative address (rip + $30) . 但我不想使用相对地址(rip + $30) I want the compiler to use absolute address and compile in this way: 我希望编译器使用绝对地址并以这种方式编译:

  65 48 8B 04 25 30 00 00 00    mov rax,gs:[+$0030]

(It is the same, if I use gs: prefix or not!) (它是相同的,如果我使用gs:前缀或不!)

How do I do this? 我该怎么做呢?

EDIT: 编辑:

I know for work-around. 我知道解决方法。 I ask if exist any comand to tell compiler to address location as absolute instead relative. 我问是否存在任何命令告诉编译器将位置称为绝对而非相对。

EDIT 编辑

So far so good... :) 到现在为止还挺好... :)

drhirsch helped me to find the command, and now the compiler translates: drhirsch帮我找到了命令,现在编译器翻译:

mov   rax, gs:[abs qword ptr $30]
or
mov   rax, gs:[abs $30]

to this: 对此:

6548A13000000000000000 mov rax,[qword $0000000000000030]

Which is almost ok :) Because I want short 32bit opcode (look upper opcodes) instlonger long 64bit opcode. 这几乎是好的:)因为我想要短的32位操作码(看上面的操作码)更长的64位操作码。

Is there any way to tell compiler to use short 32 bit address opcode instead long? 有没有办法告诉编译器使用短32位地址操作码而不是长?

You need to use the movabs instruction. 您需要使用movabs指令。

movabs  rax, gs:[$30]

Edit: rip relative addressing is the default mode, on some assemblers you may be able to force 32 bit absolute addressing with 编辑:rip相对寻址是默认模式,在某些汇编器上,您可以强制使用32位绝对寻址

mov rax, gs:[dword $30]  #nasm, tasm
mov rax, gs:[abs $30]    #yasm

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

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