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



BeitragVerfasst: Fr 28.03.03 21:15 
Hallo,

Habe folgenden Code. Diese Suche nach PE addiert die richtige Größe dazu. Mit diesen Code wird aber die 512 Bytes überschrieben.
Wie geht das das die 512 Bytes da eingefügt werden?

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:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
  AssignFile(f, Edit1.Text);
  Reset(f,1);
  lPos := 0;
  if (IOResult = 0) then begin
    repeat
{     If (Button2.Caption = '&Stop') and (Button2.
     begin
     CloseFile(f);
     exit;
     end;  }
//    If RadioButton1.Checked = false then
    lPos := filepos(f);
//    if RadioButton1.Checked = true then lPos := lPos + 16;
    BlockRead(f,u,2,iRead);
    if (iRead = 2) then
      begin
      if(lstrcmp(u,'PE') = 0) then
      begin
      Seek(f,lPos + 5);
      BlockRead(f,u,1,iRead);
      sectionnum := iRead;
      sectionheadersize := sectionnum * 40;
      headersize := sectionheadersize + 241;
      Seek (f, headersize);
      FillChar(u,sizeof(u),#00);
      BlockWrite(f,u,512,iWrite);
      if (iWrite <> 512) then break;




//      Seek(f,lPos + 1);
//      BlockRead(f,u,1,iRead);
//      sectionnum := iRead + sectionnum;
//      showmessage(IntToStr(sectionnum));

      //      Showmessage(Format('"%s" at position %d',[u,lPos]));
//      showmessage('BlockWrite' + IntToStr(lPos));
//      fillchar(u,sizeof(u),'f');
//      BlockWrite(f,u,110000,iWrite);
///      if (iWrite <> 110000) then break;
//      fillchar(u,sizeof(u),#0);
//      Label3.Caption := filelabel3 + '1';
      end
      else
//      If RadioButton1.Checked = true then Seek(f,lPos);
//      If RadioButton1.Checked = false then
//      Seek(f,lPos + 1);
//      Label1.Caption := IntToStr(lPos) + ' / ' + InttoStr(sizeprogress) + ' bytes';
      randomize;
      rand := random(50);
      if (rand = 29) then Application.ProcessMessages;
      end
      until(iRead = 0);
      CloseFile(f);
      end;
      {$S+}

  end;


Danke
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Fr 28.03.03 22:33 
Hallo Bitarchiv!

Da wirst du wohl nicht drumrumkommen, den letzten Teil in einen Buffer zu laden und ihn danach wieder daranhängen, denn es gibt (so viel ich weiss) keine "Insert"-Methode in Delphi. Auch mit Streams geht das nicht.

Gruß wulfskin!

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
Biarchiv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Sa 29.03.03 19:42 
Hallo wulfskin,

Danke für Deine Antwort.
Das ist irrgendwie schwach von Borland.

Gibts eine andere Möglichkeit Bytes einzufügen?

Danke..
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: So 30.03.03 01:09 
Zitat:
Das ist irrgendwie schwach von Borland.

Aus der Sicht wie die Daten auf der Festplatte abgelegt sind, ist es logisch, dass Borland keine solche Funktion eingebaut hat. Diese Funktion würde auch nichts anderes machen, als den ersten Teil stehen lassen und den zweiten Teil neu zu schreiben.

Wenn Borland für jedes Problem schon eine Lösung parat hätte, dann bräuchte man keine anderen Programmierer mehr.

_________________
Ist Zeit wirklich Geld?