什么是相对跳跃?

EPr*_*und 2 delphi assembly page-jump

为什么它用于挂钩和重定向功能?

像这样:

procedure RedirectProcedure(OldAddress, NewAddress: Pointer);
var
  NewCode: TInstruction;
begin
  NewCode.Opcode := $E9; //relative jump
  NewCode.Offset := NativeInt(NewAddress)-NativeInt(OldAddress)-SizeOf(NewCode);
  PatchCode(OldAddress, NewCode, SizeOf(NewCode));
end;
Run Code Online (Sandbox Code Playgroud)

顺便说一句,$ E9常数意味着什么?

Dav*_*nan 8

跳转指令将指令指针移动到新位置.它是机器语言相当于goto.绝对跳转将指令指针移动到绝对地址.相对跳转跳转到相对于当前指令指针指定的地址.

$ E9操作码是一个32位偏移的相对跳转.请注意,对于具有不同大小偏移的跳转,存在不同的跳转操作码.

地址相对于跳转指令的结束,因此是SizeOf(NewCode)调整.

这段代码对我来说确实很熟悉.我想我写了!