Einzelnen Beitrag anzeigen

ripper8472

Registriert seit: 17. Aug 2003
275 Beiträge
 
#2

Re: find hex codes in files

  Alt 24. Jul 2004, 05:18
du musst zuerst die hex werte in normale binärdaten umwandeln. die prozedur dazu steht weiter unten.
wenn du deine hex werte in etwas brauchbares umgewandelt hast, dann lade die datei in einen string und benutze pos(), um nach deinem string zu suchen. du könntest auch selber eine suchfunktion schreiben, die direkt mit der datei arbeitet. such dazu nach vorkommen des ersten zeichens von deinem suchstring. wenn du ein vorkommen gefunden hast, dann prüfe, ob die folgenden zeichen in der datei auch übereinstimmen.

Gruß, Christoph



you first need to convert your hex data to binary as it is saved in your file.
use this procedure and extend it to your needs (it is not tested and may need modifications):
Delphi-Quellcode:
function hextochar(hexstring:string[2]):char;
var
  i:integer;
  c:char;
  hexchars:string;
begin
  hexchars:='0123456789ABCDEF';
  c:=char((pos(hexstring[2],hexchars)-1) or ((pos(hexstring[1],hexchars)-1) shr 4));
  result:=c;
end;
once you have converted your search data, you can load the file (hopefully not a large one) into a string and then use pos(yourdata,filedata).
you could also write a custom find function that works directly with that file. just read char by char and check if it matches yourdata[1] (first char of the string you want). if it matches, then proceed by checking the next char in file against yourdata[2] and so on.
Christoph
char l[]="\xd6N\x96\xa6\xe6\xce.\xa6\xe4\xce\x04N\x86\xae\ xce\xfc",I,*i=l-1;for(;I=3,*i
++;){while(*i=*i&~(1<<I|1<<7-I)|(*i&1<<I)<<7-2*I|(*i&1<<7-I)>>7-2*I,I--);}puts(l);
  Mit Zitat antworten Zitat