【发布时间】:2016-07-14 10:12:23
【问题描述】:
我正在尝试将 DDetours lib 移植到 Delphi 5/7。不会编译的行有这种模式:
procedure Decode_J(PInst: PInstruction; Size: Byte);
var
Value: Int64;
VA: PByte;
begin
...
VA := PInst^.VirtualAddr + (PInst^.NextInst - PInst^.Addr) // <- compiler error
编译器错误:
[Error] InstDecode.pas(882): 运算符不适用于此操作数 输入
PInst^.VirtualAddr, PInst^.NextInst, PInst^.Addr 都被声明为PByte (PByte = ^Byte)
我能做些什么来解决这个问题?
编辑:
PInstruction 定义为:
TInstruction = record
Archi: Byte; { CPUX32 or CPUX64 ! }
AddrMode: Byte; { Address Mode }
Addr: PByte;
VirtualAddr: PByte;
NextInst: PByte; { Pointer to the Next Instruction }
OpCode: Byte; { OpCode Value }
OpType: Byte;
OpKind: Byte;
OpTable: Byte; { tbOneByte,tbTwoByte,... }
OperandFlags: Byte;
Prefixes: Word; { Sets of Prf_xxx }
ModRm: TModRM;
Sib: TSib;
Disp: TDisplacement;
Imm: TImmediat; { Primary Immediat }
ImmEx: TImmediat; { Secondary Immediat if used ! }
Branch: TBranch; { JMP & CALL }
SegReg: Byte; { Segment Register }
Rex: TRex;
Vex: TVex;
LID: TInternalData; { Internal Data }
Errors: Byte;
InstSize: Byte;
Options: Byte;
UserTag: UInt64;
end;
PInstruction = ^TInstruction;
【问题讨论】: