From bcf576576f165f9586b8177a6ada8918fad18fe9 Mon Sep 17 00:00:00 2001 From: mbirth Date: Wed, 8 Dec 2004 09:42:22 +0000 Subject: [PATCH] modified SmartPatcher.dof modified USmartPatcher.dfm modified USmartPatcher.pas + ProgressGauge while scanning and modifying * Extended Search now starts at FilePos 0 instead of ModPos-Offset + Version number is displayed in Title bar --- SmartPatcher.dof | 8 ++--- USmartPatcher.dfm | 10 ++++++ USmartPatcher.pas | 77 +++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 79 insertions(+), 16 deletions(-) diff --git a/SmartPatcher.dof b/SmartPatcher.dof index f01e3ac..8bdaa3b 100644 --- a/SmartPatcher.dof +++ b/SmartPatcher.dof @@ -114,8 +114,8 @@ IncludeVerInfo=1 AutoIncBuild=1 MajorVer=1 MinorVer=0 -Release=0 -Build=5 +Release=1 +Build=6 Debug=0 PreRelease=0 Special=1 @@ -126,13 +126,13 @@ CodePage=1252 [Version Info Keys] CompanyName=riddick FileDescription=SmartPatcher for new versions of cracked software. -FileVersion=1.0.0.5 +FileVersion=1.0.1.6 InternalName=SmartPatcher LegalCopyright= LegalTrademarks= OriginalFilename=SmartPatcher.exe ProductName=SmartPatcher -ProductVersion=1.0.0.0 +ProductVersion=1.0 Comments=SmartPatcher for new versions of already cracked software. SpecialBuild= [HistoryLists\hlUnitAliases] diff --git a/USmartPatcher.dfm b/USmartPatcher.dfm index 95945af..f902402 100644 --- a/USmartPatcher.dfm +++ b/USmartPatcher.dfm @@ -1296,6 +1296,16 @@ object FPatcher: TFPatcher 5454543A3A585858463B063D00045A5A5A47045A00074758475847474700095A 000B7B664747475A6666596558000001} end + object Gauge: TGauge + Left = 96 + Top = 383 + Width = 441 + Height = 15 + BackColor = clMenu + ForeColor = clNavy + Progress = 0 + Visible = False + end object GroupOrigFileset: TGroupBox Left = 0 Top = 72 diff --git a/USmartPatcher.pas b/USmartPatcher.pas index 8923638..6d02419 100644 --- a/USmartPatcher.pas +++ b/USmartPatcher.pas @@ -3,7 +3,8 @@ unit USmartPatcher; interface uses - Windows, SysUtils, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Classes, Graphics, StrUtils; + Windows, SysUtils, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Classes, Graphics, StrUtils, Math, + Gauges; type TFPatcher = class(TForm) @@ -29,6 +30,7 @@ type ButtExit: TButton; ImgLogoRiddickLeft: TImage; CheckExtSearch: TCheckBox; + Gauge: TGauge; procedure ButBrowseOrigClick(Sender: TObject); procedure ButtExitClick(Sender: TObject); procedure ButBrowseModClick(Sender: TObject); @@ -40,6 +42,8 @@ type public { Public declarations } end; +type + CharFile = file of char; var FPatcher: TFPatcher; @@ -48,6 +52,8 @@ implementation {$R *.dfm} +uses VersionInfo; + const PreAftLen: integer = 10; PreAftSrc: integer = $4000; @@ -65,15 +71,36 @@ type var Mods: TModRecA; + Ver: TVersionInfo; procedure Log(x: string); var i: integer; begin - while (FPatcher.LogBox.Count>500) do begin + while (FPatcher.LogBox.Count>1000) do begin FPatcher.LogBox.Items.Delete(0); end; i := FPatcher.LogBox.Items.Add(x); FPatcher.LogBox.TopIndex := i; + Application.ProcessMessages; +end; + +procedure LogL(x: string); +begin + FPatcher.LogBox.Items.BeginUpdate; + FPatcher.LogBox.Items.Strings[FPatcher.LogBox.Items.Count-1] := x; + FPatcher.LogBox.Items.EndUpdate; + FPatcher.LogBox.TopIndex := FPatcher.LogBox.Items.Count-1; + Application.ProcessMessages; +end; + +procedure PosUpd(fpos, fsize: integer); +var i: integer; +begin + i := Round(fpos*100/fsize); + if (FPatcher.Gauge.Progress<>i) then begin + FPatcher.Gauge.Progress := i; + Application.ProcessMessages; + end; end; function Dec2Hex(d: longint): string; @@ -90,7 +117,7 @@ end; function FindModsInFiles(g1,g2: string): TModRecA; var f1,f2: file of char; - Buf1, Buf2: array[1..64] of char; + Buf1, Buf2: array[1..1024] of char; i, i1, i2: integer; o: longint; lastinequal: boolean; @@ -101,9 +128,14 @@ begin AssignFile(f1,g1); AssignFile(f2,g2); FileMode := fmOpenRead; + lastinequal := false; Reset(f1); Reset(f2); + Log('Now parsing files for changes ... '); + FPatcher.Gauge.Visible := true; + FPatcher.Gauge.Progress := 0; repeat + PosUpd(FilePos(f1), FileSize(f1)); if (FilePos(f1)<>FilePos(f2)) then begin Log('ERROR while reading! File positions are different. Aborting.'); CloseFile(f1); @@ -119,7 +151,6 @@ begin CloseFile(f2); Exit; end; - lastinequal := false; for i:=1 to i1 do begin if (Buf1[i]<>Buf2[i]) then begin if (lastinequal) then begin @@ -142,13 +173,14 @@ begin if (lastinequal) then begin Last10 := ''; resi := Length(Result)-1; - Log('Found '+IntToStr(Result[resi].Length)+' different Byte(s) at Offset 0x'+UpperCase(Dec2Hex(Result[resi].Offset))); + Log('Found '+IntToStr(Result[resi].Length)+' diff. Byte(s) at Offset 0x'+UpperCase(Dec2Hex(Result[resi].Offset))+' ('+FloatToStr(SimpleRoundTo(FilePos(f1)*100/FileSize(f1),-2))+'%)'); end; lastinequal := false; end; if (Length(Last10)>> Found '+IntToStr(Length(Result))+' different areas.'); @@ -172,20 +204,29 @@ begin FileMode := fmOpenReadWrite; Reset(f); Last := ''; - o := Mods[0].Offset - PreAftSrc; + if (FPatcher.CheckExtSearch.Checked) then begin + o := 0; + end else begin + o := Mods[0].Offset - PreAftSrc; + if (o<0) then o := 0; + end; lo := 0; - if (o<0) then o := 0; Seek(f,o); + Log('Now scanning new file to apply changes ... '); + FPatcher.Gauge.Progress := 0; + FPatcher.Gauge.Visible := true; for i:=0 to Length(Mods)-1 do begin foundit := false; NextTurn: if (FPatcher.CheckExtSearch.Checked) then mo := FileSize(f) else mo := Mods[i].Offset+2*PreAftSrc; while (FilePos(f)2) then begin Mods[i].Pre := RightBStr(Mods[i].Pre,Length(Mods[i].Pre)-1); Log('Pre not found. Dropping one byte... (now '+IntToStr(Length(Mods[i].Pre))+' bytes)'); - if (lo>0) then o := lo else o := Mods[i].Offset - PreAftSrc; - if (o<0) then o:=0; + if (lo>0) then o := lo else begin + if FPatcher.CheckExtSearch.Checked then begin + o := 0; + end else begin + o := Mods[i].Offset - PreAftSrc; + if (o<0) then o:=0; + end; + end; Seek(f,o); goto NextTurn; end else if (NOT foundit) then begin @@ -215,6 +262,7 @@ begin missedany := true; end; end; + FPatcher.Gauge.Visible := false; CloseFile(f); if (NOT missedany) then Result := true else Result := false; except @@ -340,10 +388,15 @@ end; procedure TFPatcher.FormCreate(Sender: TObject); begin + Ver := TVersionInfo.Create(Application.ExeName); + Application.Title := 'SmartPatcher '+Ver.FileVersion; + FPatcher.Caption := 'SmartPatcher '+Ver.FileVersion; Log('Welcome to SmartPatcher by riddick'); Log(''); Log('NOTE: You can damage your files - use this app wisely!'); Log(DupeString('-',140)); end; +begin + end.