Autor Beitrag
Biarchiv
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: So 02.03.03 11:32 
Hallo,

Folgendes: Ich will eine Datei Patchen mit Text eingabe von Edit2.Text! Es solten nur 8 Ziffern oder Zahlen möglich sein. Dieser Dateipatch funktioniert aber nur wenn neustring und altstring gleich groß sind! Sonst crach.

Wie kann ich es machen wenn jemand nur 6 oder 7 möglichkeiten eingibtd das bei altstring .data + #00#00 dazu in den String geschrieben wird?

Also altstring muß gleich groß sein.

Danke
ausblenden volle Höhe Quelltext
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:
46:
47:
48:
if RadioButton1.checked = true then
  begin
 if not (Edit1.Text = '') then
   begin
  altstring := '.data' +#00#00#00;



  neustring := #00#00#00#00#00#00#00#00;
  neustring := Edit2.Text[1];
  neustring := Edit2.Text[2];
  neustring := Edit2.Text[3];
  neustring := Edit2.Text[4];
  neustring := Edit2.Text[5];
  neustring := Edit2.Text[6];
  neustring := Edit2.Text[7];
  neustring := Edit2.Text[8];

  showmessage(neustring);
  exit;
  datei := Edit1.Text;
  s := altstring;
  assignFile(f, datei);
  reset(f,1);
  for l := 0 to filesize(f)-length(altstring)-1 do
    begin
      Application.ProcessMessages;
      seek(f,l);
      blockread(f,altstring[1],length(altstring));
      if altstring = s then
        begin
          seek(f,l);
          blockwrite(f,neustring[1],length(neustring));
          CloseFile(f);
          messagebox(0,'Now you can protect this file with EXE Stealth.','Patched...',MB_OK);
          exit;
        end;

      Application.ProcessMessages;
    end;
  closeFile(f);
   end
  else
  begin
  showmessage('Please select a file.');
  exit;
  end;
end;
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: So 02.03.03 11:42 
Also diese Zeilen
Zitat:
neustring := #00#00#00#00#00#00#00#00;
neustring := Edit2.Text[1];
neustring := Edit2.Text[2];
neustring := Edit2.Text[3];
neustring := Edit2.Text[4];
neustring := Edit2.Text[5];
neustring := Edit2.Text[6];
neustring := Edit2.Text[7];
neustring := Edit2.Text[8];

Kannst du auf eine reduzieren:
ausblenden Quelltext
1:
neustring := Edit2.Text[8];					

Das ist das Ergebnis dass du auch mit deinem Code bekommst. Aber das ist sicherlich nicht, dass was du dir wünscht.


Wenn ich dich richtig verstanden habe, dann willst du sowas:
ausblenden Quelltext
1:
2:
3:
SetLength(neustring, 8);                          // Platz für 8 Zeichen schaffen
FillChar(neustring[1], Length(neustring), 0);     // mit #0 füllen
StrLCopy(PChar(neustring), PChar(Edit2.Text), 8); // max 8 Zeichen kopieren

_________________
Ist Zeit wirklich Geld?