Delphi错误“ E2064左侧无法分配给” 64位

时间:2018-07-06 07:17:42

标签: delphi

我正在尝试将洋红色数据包捕获单元编译为64位。

https://www.magsys.co.uk/delphi/magmonsock.asp

编译时,我无法在下面的代码行中分配可怕的左侧

LongWord(bp) := LongWord(bp) + BPF_WORDALIGN(caplen + hdrlen);

这是因为LongWord强制转换在64位中是不同的字节长吗?任何人都可以帮助正确修复该行,以便在32位和64位版本中愉快地进行编译吗? bp被声明为指针。 caplenhdrlen被声明为整数。

BPF_WORDALIGN函数是

function BPF_WORDALIGN(X:LongWord) : LongWord;
begin
     result := (((X)+(BPF_ALIGNMENT-1))and not(BPF_ALIGNMENT-1));
end;

感谢您提供帮助以使其正常工作。

如果有帮助的话,这里是带有错误线路的完整过程;

function pcap_read( p:PPcap;cnt:integer;CallBack:Tpcap_handler;User:pointer)
     : integer;
var cc   : Longword;//Counter ?
n    : integer;
bp,ep: pointer; //Begin and End Point ?
//bhp  : Pbpf_hdr;//pointer to BPF header struct - removed by Lars Peter
hdrlen,         //Length of Header
caplen: integer;//Length of captured
begin
  if NOT LoadPacketDll then
  begin
     p.errbuf := 'Cannot load packet.dll';
     result:=-1;
     exit;
  end;
  cc := p.cc;
  n  := 0;

  if p.cc = 0 then
    begin

   // *Capture the Packets*
     if PacketReceivePacket(p.adapter,p.packet,TRUE)=false then
     begin
       // ERROR!
       p.errbuf :='Read Error: PacketRecievePacket failed';
       result:=-1;
       exit;
     end;
     cc := p.packet.ulBytesReceived;

     bp := p.buffer;

    end else bp := p.bp;


// Loop through each packet.

ep := ptr(longword(bp)+cc); //move end pointer
while (longword(bp) < longword(ep) ) do
  begin
    caplen := Pbpf_hdr(bp).bh_caplen;
    hdrlen := Pbpf_hdr(bp).bh_hdrlen;

    // XXX A bpf_hdr matches apcap_pkthdr.

    callback(user,
    Ppcap_pkthdr(bp),
    ptr(longword(bp)+longword(HdrLen)));

    LongWord(bp) := LongWord(bp) + BPF_WORDALIGN(caplen + hdrlen);

    inc(n);
    if (n >= cnt)and(cnt>0) then
      begin
        p.bp := bp;
        p.cc := longword(ep)-longword(bp);
        result := n;
        exit;
      end;
      end;

   p.cc := 0;
   result:=n;
end;

0 个答案:

没有答案