我正在尝试将Magenta数据包捕获单元编译为64位 .
https://www.magsys.co.uk/delphi/magmonsock.asp
当我编译时,我得到了可怕的左侧无法分配到以下代码行
LongWord(bp) := LongWord(bp) + BPF_WORDALIGN(caplen + hdrlen);
这是因为 LongWord
强制转换是64位不同的字节长度吗?任何人都可以帮助正确修复该行,以便在32位和64位版本中快速编译? bp
被声明为指针 . caplen
和 hdrlen
被声明为整数 .
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;