超急问题~ 帮忙翻译一小段C代码,请将代码翻译为delphi的~ 谢谢 ( 积分: 200 )

  • 主题发起人 主题发起人 micronet
  • 开始时间 开始时间
M

micronet

Unregistered / Unconfirmed
GUEST, unregistred user!
请各位大哥帮我把以下的代码翻译为delphi版的!
//--------------------------------------------------------
unsigned char *tbl64k = 0x054E50E8;//64k字节的代码转换表
unsigned char *tbl32b = 0x0070B887;//32字节的中间计算表

unsigned char *pData = (unsigned char *)recvPack.data;
unsigned selSeg;

for(int i=0; i<recvPack.dataLen-3; i++)
{
selSeg = (tbl32b[i%32]^(recvPack.packNo &amp; 0x0ff))<<8;
for(int j=0; j<0x100; j++)
if (tbl64k[selSeg + j] == pData) break;
pData = j;
}
 
请各位大哥帮我把以下的代码翻译为delphi版的!
//--------------------------------------------------------
unsigned char *tbl64k = 0x054E50E8;//64k字节的代码转换表
unsigned char *tbl32b = 0x0070B887;//32字节的中间计算表

unsigned char *pData = (unsigned char *)recvPack.data;
unsigned selSeg;

for(int i=0; i<recvPack.dataLen-3; i++)
{
selSeg = (tbl32b[i%32]^(recvPack.packNo &amp; 0x0ff))<<8;
for(int j=0; j<0x100; j++)
if (tbl64k[selSeg + j] == pData) break;
pData = j;
}
 
procedure TForm1.Button1Click(Sender: TObject);
type
TrecvPack = record
data:PChar;
dataLen: Integer;
packNo:Integer;
end;
var
tbl64k, tbl32b: PChar;
pData: PChar;
selSeg: byte;
I,J : Integer;
recvPack : TrecvPack;
begin
Integer(tbl64k) := $054E50E8;//64k字节的代码转换表
Integer(tbl32b) := $0070B887;//32字节的中间计算表

pData := PChar(recvPack.data);

for i:=0 to recvPack.dataLen-3 do begin
selSeg := ((Integer(tbl32b[i div 32]) or (recvPack.packNo and $0ff)) shl 8);
for j:=0 to $100 do begin
if (tbl64k[selSeg + j] = pData) then break;
pData := Char(j);
end;
end;
这种问题,lichengbin和zjan521最拿手了

参考http://www.delphibbs.com/delphibbs/dispq.asp?lid=3188479

可能需要GetMem一下
 
procedure TForm2.Button1Click(Sender: TObject);
type
TBYTEARR = Array[0..0] of BYTE;
LPBYTE = ^TBYTEARR;
TRecvPack = packed record
packNo : Integer;
dataLen : Integer;
data : LPBYTE;
end;
var
recvPack: TRecvPack;

tbl64k : LPBYTE;
tbl32b : LPBYTE;
pData : LPBYTE;
selSeg : DWORD;

i,j : Integer;
begin
tbl64k := LPBYTE($054E50E8);
tbl32b := LPBYTE($0070B887);

pData := recvPack.data;
for i:=0 to recvPack.dataLen-3 -1 do
begin
selSeg := (tbl32b[i mod 32] xor (recvPack.packNo and $FF)) shl 8;
for j:=0 to $100 -1 do
if(tbl64k[selSeg+j] = pData) then
break;
pData := j;
end;
end;
 
请问解出来后,怎么用?我要解密封包。。。 但不会用!
 
怎么用,呵呵.根据文档自己写了拉!
 
请问解出来后,怎么用?我要解密封包。。。 但不会用!

楼主,是不是问得有点没头没脑,应该有资料吧,根据资料自己来吧
 
后退
顶部