Hallo,
folgendes Problem.
Ich habe bis jetzt leider noch keine Lösung gefunden.
Folgendes soll passieren. Ich will einen Filemodifiezierer schreiben
der folgendes macht. Er sucht nach Dateinamen die in einer Memo1 unter-
einander eingegeben werden müssen.
Nun soll nach diesen Namen in einer Datei gesucht werden allerdings muss
dazwischen überall ein #00 rein. Da es so gespeichert ist.
Er soll 24 und Dateinamenlänge x2 zurück gehen und dort 3 Bytes ändern und
zur nächsten Memo1 zeile. Zuletzt speichern.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45:
| var filer, stelle : String; x : widestring; f : file; u : array[0..65535] of char; i, i1, iRead, iWrite, found : integer; begin found := 2; filer := EmptyStr;
{$I-} AssignFile(f, Form1.Edit1.Text); Reset(f,1); filer := ''; for i := 0 to (Memo1.lines.count -1) do begin stelle := Memo1.lines[i]; for i1 := 0 to (Length(Memo1.lines[i])) do begin if not (i1 = 0) then begin filer := filer + stelle[i1] + #0; end; end; repeat BlockRead(f , u, sizeof(u), iRead); if (iRead = Length(filer)) then begin If (Length(filer) = Length(u)) and CompareMem(PChar(filer), @u, Length(filer)) Then found := 1; If (Length(filer) = Length(u)) and CompareMem(@filer, @u, Length(filer)) Then found := 1; If (Length(filer) <> Length(u)) or not CompareMem(PChar(filer), @u, Length(filer)) Then found := 0; If (Length(filer) <> Length(u)) or not CompareMem(@filer, @u, Length(filer)) Then found := 0; if (found = 0) then begin Seek(f, FilePos(F) - Length(filer) - 24); showmessage(IntToStr(FilePos(f))); fillchar(u,sizeof(u),$ff); BlockWrite(f,u,3,iWrite); Seek(f, FilePos(f) + Length(filer) + 25); end; end; until(iRead = 0); end; CloseFile(f); {$S+} |
Beispiel: setup.exe wird gesucht.
Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20:
| 0000c080h: AF 01 00 00 00 00 01 AF B5 B7 0F 00 00 0F B7 B5 ; ¯......¯µ·....·µ 0000c090h: 69 02 0C 14 27 37 04 00 00 00 01 00 00 01 1C 00 ; i...'7.......... 0000c0a0h: 73 00 65 00 74 00 75 00 70 00 2E 00 65 00 78 00 ; s.e.t.u.p...e.x. 0000c0b0h: 65 00 20 00 20 00 20 00 3B 00 31 00 3E 00 A6 03 ; e. . . .;.1.>.¦. 0000c0c0h: 00 00 00 00 03 A6 15 15 02 00 00 02 15 15 68 0C ; .....¦........h. 0000c0d0h: 1F 0E 38 0C 04 00 00 00 01 00 00 01 1C 00 78 00 ; ..8...........x. 0000c0e0h: 78 00 78 00 78 00 78 00 78 00 78 00 78 00 2E 00 ; x.x.x.x.x.x.x... 0000c0f0h: 65 00 78 00 65 00 3B 00 31 00 42 00 E9 03 00 00 ; e.x.e.;.1.B.é... 0000c100h: 00 00 03 E9 46 01 04 00 00 04 01 46 68 09 0C 08 ; ...éF......Fh... 0000c110h: 19 1C 04 00 00 00 01 00 00 01 20 00 78 00 78 00 ; .......... .x.x. 0000c120h: 78 00 78 00 78 00 78 00 78 00 78 00 78 00 78 00 ; x.x.x.x.x.x.x.x. 0000c130h: 2E 00 65 00 78 00 65 00 3B 00 31 00 44 00 6A 04 ; ..e.x.e.;.1.D.j. 0000c140h: 00 00 00 00 04 6A 00 FA 01 00 00 01 FA 00 68 0B ; .....j.ú....ú.h. 0000c150h: 1A 13 00 0C 04 00 00 00 01 00 00 01 22 00 78 00 ; ............".x. 0000c160h: 78 00 78 00 78 00 78 00 78 00 78 00 78 00 78 00 ; x.x.x.x.x.x.x.x. 0000c170h: 69 00 74 00 2E 00 65 00 78 00 65 00 3B 00 31 00 ; i.t...e.x.e.;.1. 0000c180h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 0000c190h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 0000c1a0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 0000c1b0h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ............... |
Es soll nach setup.exe gesucht und in der ersten Zeile
AF B5 B7 in FF FF FF geändert werden.
Moderiert von
Christian S.: Code- durch Delphi-Tags ersetzt.