Traduction ???

greg38bj Messages postés 83 Date d'inscription jeudi 11 mars 2004 Statut Membre Dernière intervention 17 novembre 2008 - 2 mars 2008 à 09:00
greg38bj Messages postés 83 Date d'inscription jeudi 11 mars 2004 Statut Membre Dernière intervention 17 novembre 2008 - 3 mars 2008 à 21:26
bonjour à tous
Je galère sur la traduction d'un code que l'on m'a dit être en delphi
lorsque j'essaye, j'obtiens des erreurs un peu partout
je develloppe en vb2005.
est ce qu'une personne calée en delphi et en vb pourrait m'aider à traduire ce code s'il vous plait ? :

var Buffer : array[0..2097151] of byte; // Max size of a flash

function Get4Bytes(adr:longword):longword;
begin
  Result:=Buffer[adr] shl 24 + Buffer[adr+1] shl 16 + Buffer[adr+2] shl 8 + Buffer[adr+3];
end;

function BufferGetString(adr:longword):string;
var i:integer;
begin
   i:=0;
   Result:='';
   while (i<16) and (buffer[adr+i]<>0) do
    begin
     Result:=Result+chr(buffer[adr+i]);
     inc(i);
    end;
end;

function TFormMain.CalculateCRC(Start,Stop:longword):longword;
var CRC : longword;
    i:integer;
begin
   i:=Start;
   CRC := $FFFFFFFF;
   while (i <= Stop) do
      begin
       CRC := (CRC shl 8) xor (CRC_table[buffer[i] xor (CRC shr 24)]);
       inc(i);
      end;
   Result := CRC;
end;

procedure TFormMain.FixCRC;
var BlockID,offset,len,crc,newCRC:longword;
    ptr:longword;
    s:string;
begin
  Generate_CRC_Table(FidMergerSeed);
  Memo.Lines.Add('CRC Table Calculated!');
  ptr:=0;
  BlockID:=Get4Bytes(ptr);
  Memo.Lines.Add('BlockID = '+inttohex(BlockID,8));
  if BlockID = $E3000010 then
    begin
      Memo.Lines.Add('Boot loader -> NO CRC');
      Buffer[12]:=ord('N');
      Buffer[13]:=ord('C');
      Buffer[14]:=ord('R');
      Buffer[15]:=ord('C');
    end;
  offset:=Get4Bytes(ptr+8);
  ptr:=offset;
  // check for rest
  while (PTR+16 < BinSize) do
    begin
      BlockID:=Get4Bytes(ptr);
      len:=Get4Bytes(ptr+4);
      offset:=Get4Bytes(ptr+8);
      CRC:=Get4Bytes(ptr+12);
      s:='BlockID = '+inttohex(BlockID,8);
      s:=s+' SIZE = '+inttohex(len,8);
      s:=s+' OFFSET = '+inttohex(offset,8);
      s:=s+' Actual CRC = '+inttohex(crc,8);
      Memo.Lines.Add(s);
      s:='Bloc Name = '+BufferGetString(ptr+16);
      s:=s+' Version = '+BufferGetString(ptr+32);
      s:=s+' Date = '+BufferGetString(ptr+48);
      Memo.Lines.Add(s);
      newcrc:=CalculateCRC(ptr+16,ptr+16+len-1);
      s:='Calculate CRC = ' + inttohex(newcrc,8);
      if newCRC = CRC then
        s:=s+' - CRC OK!'
      else
        s:=s+' - CRC FAIL!';
      memo.Lines.Add(s);
      // Fix CRC
      if offset=0 then
       ptr:=ptr+len
      else
       ptr:=ptr+offset;
    end;

cet algo permet le decryptage du crc de plusieurs fichiers sur lesquels je bosse en ce moment
merci encore

@+
greg38bj

2 réponses

cs_cantador Messages postés 4720 Date d'inscription dimanche 26 février 2006 Statut Modérateur Dernière intervention 31 juillet 2021 13
3 mars 2008 à 20:51
çà c'est pour foxi.

cantador
0
greg38bj Messages postés 83 Date d'inscription jeudi 11 mars 2004 Statut Membre Dernière intervention 17 novembre 2008
3 mars 2008 à 21:26
merci de porter interêt à ma question
Casy m'a répondu sur vbfrance
maintenant, je n'ai plus qu'à essayer de résoudre les bugs dûs au vb

@+
greg38bj
0
Rejoignez-nous