program hexfind; uses math; type tByteArray = array of byte; procedure loadFile(out ar: tByteArray; nam: string); var f: file; begin assignfile(f,nam); reset(f,1); setlength(ar,filesize(f)); blockread(f,ar[0],length(ar)); closefile(f); end; function inttohex(b: byte): string; const h2s = '0123456789abcdef'; begin result:= h2s[1 + ((b and $f0) shr 4)] + h2s[1 + (b and $f)]; end; var haystack,needle: tByteArray; iHay,iNee,i: longint; const matchLen = 10; begin if paramcount<>2 then begin writeln('usage: '+paramstr(0)+' haystack needle'); halt(1); end; loadFile(haystack,paramstr(1)); loadFile(needle,paramstr(2)); for iHay:=1 to length(haystack)-matchlen do for iNee:=0 to min(length(needle)-1,length(haystack)-iHay) do if haystack[length(haystack)-iHay-iNee] <> needle[length(needle)-1-iNee] then begin if iNee'); for i:=0 to length(needle)-1-iNee do write(' '+inttohex(needle[i])); writeln; for i:=0 to 79 do write('-'); writeln; write('<'); for i:=length(haystack)-iHay+1 to length(haystack)-1 do write(' '+inttohex(haystack[i])); writeln; setlength(haystack,0); setlength(needle,0); halt; end; setlength(haystack,0); setlength(needle,0); end.