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
This commit is contained in:
parent
5bca4ba6a2
commit
bcf576576f
@ -114,8 +114,8 @@ IncludeVerInfo=1
|
|||||||
AutoIncBuild=1
|
AutoIncBuild=1
|
||||||
MajorVer=1
|
MajorVer=1
|
||||||
MinorVer=0
|
MinorVer=0
|
||||||
Release=0
|
Release=1
|
||||||
Build=5
|
Build=6
|
||||||
Debug=0
|
Debug=0
|
||||||
PreRelease=0
|
PreRelease=0
|
||||||
Special=1
|
Special=1
|
||||||
@ -126,13 +126,13 @@ CodePage=1252
|
|||||||
[Version Info Keys]
|
[Version Info Keys]
|
||||||
CompanyName=riddick
|
CompanyName=riddick
|
||||||
FileDescription=SmartPatcher for new versions of cracked software.
|
FileDescription=SmartPatcher for new versions of cracked software.
|
||||||
FileVersion=1.0.0.5
|
FileVersion=1.0.1.6
|
||||||
InternalName=SmartPatcher
|
InternalName=SmartPatcher
|
||||||
LegalCopyright=
|
LegalCopyright=
|
||||||
LegalTrademarks=
|
LegalTrademarks=
|
||||||
OriginalFilename=SmartPatcher.exe
|
OriginalFilename=SmartPatcher.exe
|
||||||
ProductName=SmartPatcher
|
ProductName=SmartPatcher
|
||||||
ProductVersion=1.0.0.0
|
ProductVersion=1.0
|
||||||
Comments=SmartPatcher for new versions of already cracked software.
|
Comments=SmartPatcher for new versions of already cracked software.
|
||||||
SpecialBuild=
|
SpecialBuild=
|
||||||
[HistoryLists\hlUnitAliases]
|
[HistoryLists\hlUnitAliases]
|
||||||
|
@ -1296,6 +1296,16 @@ object FPatcher: TFPatcher
|
|||||||
5454543A3A585858463B063D00045A5A5A47045A00074758475847474700095A
|
5454543A3A585858463B063D00045A5A5A47045A00074758475847474700095A
|
||||||
000B7B664747475A6666596558000001}
|
000B7B664747475A6666596558000001}
|
||||||
end
|
end
|
||||||
|
object Gauge: TGauge
|
||||||
|
Left = 96
|
||||||
|
Top = 383
|
||||||
|
Width = 441
|
||||||
|
Height = 15
|
||||||
|
BackColor = clMenu
|
||||||
|
ForeColor = clNavy
|
||||||
|
Progress = 0
|
||||||
|
Visible = False
|
||||||
|
end
|
||||||
object GroupOrigFileset: TGroupBox
|
object GroupOrigFileset: TGroupBox
|
||||||
Left = 0
|
Left = 0
|
||||||
Top = 72
|
Top = 72
|
||||||
|
@ -3,7 +3,8 @@ unit USmartPatcher;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Windows, SysUtils, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Classes, Graphics, StrUtils;
|
Windows, SysUtils, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Classes, Graphics, StrUtils, Math,
|
||||||
|
Gauges;
|
||||||
|
|
||||||
type
|
type
|
||||||
TFPatcher = class(TForm)
|
TFPatcher = class(TForm)
|
||||||
@ -29,6 +30,7 @@ type
|
|||||||
ButtExit: TButton;
|
ButtExit: TButton;
|
||||||
ImgLogoRiddickLeft: TImage;
|
ImgLogoRiddickLeft: TImage;
|
||||||
CheckExtSearch: TCheckBox;
|
CheckExtSearch: TCheckBox;
|
||||||
|
Gauge: TGauge;
|
||||||
procedure ButBrowseOrigClick(Sender: TObject);
|
procedure ButBrowseOrigClick(Sender: TObject);
|
||||||
procedure ButtExitClick(Sender: TObject);
|
procedure ButtExitClick(Sender: TObject);
|
||||||
procedure ButBrowseModClick(Sender: TObject);
|
procedure ButBrowseModClick(Sender: TObject);
|
||||||
@ -40,6 +42,8 @@ type
|
|||||||
public
|
public
|
||||||
{ Public declarations }
|
{ Public declarations }
|
||||||
end;
|
end;
|
||||||
|
type
|
||||||
|
CharFile = file of char;
|
||||||
|
|
||||||
var
|
var
|
||||||
FPatcher: TFPatcher;
|
FPatcher: TFPatcher;
|
||||||
@ -48,6 +52,8 @@ implementation
|
|||||||
|
|
||||||
{$R *.dfm}
|
{$R *.dfm}
|
||||||
|
|
||||||
|
uses VersionInfo;
|
||||||
|
|
||||||
const
|
const
|
||||||
PreAftLen: integer = 10;
|
PreAftLen: integer = 10;
|
||||||
PreAftSrc: integer = $4000;
|
PreAftSrc: integer = $4000;
|
||||||
@ -65,15 +71,36 @@ type
|
|||||||
|
|
||||||
var
|
var
|
||||||
Mods: TModRecA;
|
Mods: TModRecA;
|
||||||
|
Ver: TVersionInfo;
|
||||||
|
|
||||||
procedure Log(x: string);
|
procedure Log(x: string);
|
||||||
var i: integer;
|
var i: integer;
|
||||||
begin
|
begin
|
||||||
while (FPatcher.LogBox.Count>500) do begin
|
while (FPatcher.LogBox.Count>1000) do begin
|
||||||
FPatcher.LogBox.Items.Delete(0);
|
FPatcher.LogBox.Items.Delete(0);
|
||||||
end;
|
end;
|
||||||
i := FPatcher.LogBox.Items.Add(x);
|
i := FPatcher.LogBox.Items.Add(x);
|
||||||
FPatcher.LogBox.TopIndex := i;
|
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;
|
end;
|
||||||
|
|
||||||
function Dec2Hex(d: longint): string;
|
function Dec2Hex(d: longint): string;
|
||||||
@ -90,7 +117,7 @@ end;
|
|||||||
|
|
||||||
function FindModsInFiles(g1,g2: string): TModRecA;
|
function FindModsInFiles(g1,g2: string): TModRecA;
|
||||||
var f1,f2: file of char;
|
var f1,f2: file of char;
|
||||||
Buf1, Buf2: array[1..64] of char;
|
Buf1, Buf2: array[1..1024] of char;
|
||||||
i, i1, i2: integer;
|
i, i1, i2: integer;
|
||||||
o: longint;
|
o: longint;
|
||||||
lastinequal: boolean;
|
lastinequal: boolean;
|
||||||
@ -101,9 +128,14 @@ begin
|
|||||||
AssignFile(f1,g1);
|
AssignFile(f1,g1);
|
||||||
AssignFile(f2,g2);
|
AssignFile(f2,g2);
|
||||||
FileMode := fmOpenRead;
|
FileMode := fmOpenRead;
|
||||||
|
lastinequal := false;
|
||||||
Reset(f1);
|
Reset(f1);
|
||||||
Reset(f2);
|
Reset(f2);
|
||||||
|
Log('Now parsing files for changes ... ');
|
||||||
|
FPatcher.Gauge.Visible := true;
|
||||||
|
FPatcher.Gauge.Progress := 0;
|
||||||
repeat
|
repeat
|
||||||
|
PosUpd(FilePos(f1), FileSize(f1));
|
||||||
if (FilePos(f1)<>FilePos(f2)) then begin
|
if (FilePos(f1)<>FilePos(f2)) then begin
|
||||||
Log('ERROR while reading! File positions are different. Aborting.');
|
Log('ERROR while reading! File positions are different. Aborting.');
|
||||||
CloseFile(f1);
|
CloseFile(f1);
|
||||||
@ -119,7 +151,6 @@ begin
|
|||||||
CloseFile(f2);
|
CloseFile(f2);
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
lastinequal := false;
|
|
||||||
for i:=1 to i1 do begin
|
for i:=1 to i1 do begin
|
||||||
if (Buf1[i]<>Buf2[i]) then begin
|
if (Buf1[i]<>Buf2[i]) then begin
|
||||||
if (lastinequal) then begin
|
if (lastinequal) then begin
|
||||||
@ -142,13 +173,14 @@ begin
|
|||||||
if (lastinequal) then begin
|
if (lastinequal) then begin
|
||||||
Last10 := '';
|
Last10 := '';
|
||||||
resi := Length(Result)-1;
|
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;
|
end;
|
||||||
lastinequal := false;
|
lastinequal := false;
|
||||||
end;
|
end;
|
||||||
if (Length(Last10)<PreAftLen) then Last10 := Last10 + Buf1[i] else Last10 := RightBStr(Last10, PreAftLen - 1) + Buf1[i];
|
if (Length(Last10)<PreAftLen) then Last10 := Last10 + Buf1[i] else Last10 := RightBStr(Last10, PreAftLen - 1) + Buf1[i];
|
||||||
end;
|
end;
|
||||||
until (i1=0) OR (i2=0);
|
until (i1=0) OR (i2=0);
|
||||||
|
FPatcher.Gauge.Visible := false;
|
||||||
CloseFile(f1);
|
CloseFile(f1);
|
||||||
CloseFile(f2);
|
CloseFile(f2);
|
||||||
Log('>>> Found '+IntToStr(Length(Result))+' different areas.');
|
Log('>>> Found '+IntToStr(Length(Result))+' different areas.');
|
||||||
@ -172,20 +204,29 @@ begin
|
|||||||
FileMode := fmOpenReadWrite;
|
FileMode := fmOpenReadWrite;
|
||||||
Reset(f);
|
Reset(f);
|
||||||
Last := '';
|
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;
|
lo := 0;
|
||||||
if (o<0) then o := 0;
|
|
||||||
Seek(f,o);
|
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
|
for i:=0 to Length(Mods)-1 do begin
|
||||||
foundit := false;
|
foundit := false;
|
||||||
NextTurn:
|
NextTurn:
|
||||||
if (FPatcher.CheckExtSearch.Checked) then mo := FileSize(f) else mo := Mods[i].Offset+2*PreAftSrc;
|
if (FPatcher.CheckExtSearch.Checked) then mo := FileSize(f) else mo := Mods[i].Offset+2*PreAftSrc;
|
||||||
while (FilePos(f)<mo) AND (NOT EOF(f)) do begin
|
while (FilePos(f)<mo) AND (NOT EOF(f)) do begin
|
||||||
|
// if (FilePos(f) MOD 1024 = 0) then LogL('Now scanning pos. '+IntToStr(FilePos(f))+'/'+IntToStr(FileSize(f))+' ('+FloatToStr(SimpleRoundTo(FilePos(f)*100/FileSize(f),-2))+'%) ... ');
|
||||||
|
PosUpd(FilePos(f), FileSize(f));
|
||||||
BlockRead(f,Buf,1);
|
BlockRead(f,Buf,1);
|
||||||
if (RightBStr(Last, Length(Mods[i].Pre)) = Mods[i].Pre) then begin
|
if (RightBStr(Last, Length(Mods[i].Pre)) = Mods[i].Pre) then begin
|
||||||
if (Buf = Mods[i].Orig[1]) then begin
|
if (Buf = Mods[i].Orig[1]) then begin
|
||||||
Seek(f,FilePos(f)-1);
|
Seek(f,FilePos(f)-1);
|
||||||
Log('Found pos at Offset 0x'+Dec2Hex(FilePos(f))+' - changing from '+Dec2Hex(Ord(Buf))+' to '+Dec2Hex(Ord(Mods[i].New[1])));
|
Log('Found pos at Offset 0x'+Dec2Hex(FilePos(f))+' ('+FloatToStr(SimpleRoundTo(FilePos(f)*100/FileSize(f),-2))+'%) - changing from '+Dec2Hex(Ord(Buf))+' to '+Dec2Hex(Ord(Mods[i].New[1])));
|
||||||
for j:=1 to Length(Mods[i].New) do begin
|
for j:=1 to Length(Mods[i].New) do begin
|
||||||
Read(f,Buf);
|
Read(f,Buf);
|
||||||
if (Buf=Mods[i].Orig[j]) then begin
|
if (Buf=Mods[i].Orig[j]) then begin
|
||||||
@ -193,12 +234,12 @@ begin
|
|||||||
Seek(f,FilePos(f)-1);
|
Seek(f,FilePos(f)-1);
|
||||||
Write(f,Mods[i].New[j]);
|
Write(f,Mods[i].New[j]);
|
||||||
lo := FilePos(f);
|
lo := FilePos(f);
|
||||||
end else Log('Bytes different at Offset 0x'+Dec2Hex(FilePos(f)));
|
end else Log('Bytes different at Offset 0x'+UpperCase(Dec2Hex(FilePos(f))));
|
||||||
end;
|
end;
|
||||||
Break;
|
Break;
|
||||||
end else begin
|
end else begin
|
||||||
foundit := false;
|
foundit := false;
|
||||||
Log('Found pos, but different original first byte. Searching further...');
|
Log('Found pos at 0x'+UpperCase(Dec2Hex(FilePos(f)))+', but different original first byte. Searching further...');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if (Length(Last)<PreAftLen) then Last := Last + Buf else Last := RightBStr(Last, PreAftLen-1) + Buf;
|
if (Length(Last)<PreAftLen) then Last := Last + Buf else Last := RightBStr(Last, PreAftLen-1) + Buf;
|
||||||
@ -206,8 +247,14 @@ begin
|
|||||||
if (NOT foundit) AND (Length(Mods[i].Pre)>2) then begin
|
if (NOT foundit) AND (Length(Mods[i].Pre)>2) then begin
|
||||||
Mods[i].Pre := RightBStr(Mods[i].Pre,Length(Mods[i].Pre)-1);
|
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)');
|
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 (lo>0) then o := lo else begin
|
||||||
if (o<0) then o:=0;
|
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);
|
Seek(f,o);
|
||||||
goto NextTurn;
|
goto NextTurn;
|
||||||
end else if (NOT foundit) then begin
|
end else if (NOT foundit) then begin
|
||||||
@ -215,6 +262,7 @@ begin
|
|||||||
missedany := true;
|
missedany := true;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
FPatcher.Gauge.Visible := false;
|
||||||
CloseFile(f);
|
CloseFile(f);
|
||||||
if (NOT missedany) then Result := true else Result := false;
|
if (NOT missedany) then Result := true else Result := false;
|
||||||
except
|
except
|
||||||
@ -340,10 +388,15 @@ end;
|
|||||||
|
|
||||||
procedure TFPatcher.FormCreate(Sender: TObject);
|
procedure TFPatcher.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
Ver := TVersionInfo.Create(Application.ExeName);
|
||||||
|
Application.Title := 'SmartPatcher '+Ver.FileVersion;
|
||||||
|
FPatcher.Caption := 'SmartPatcher '+Ver.FileVersion;
|
||||||
Log('Welcome to SmartPatcher by riddick');
|
Log('Welcome to SmartPatcher by riddick');
|
||||||
Log('');
|
Log('');
|
||||||
Log('NOTE: You can damage your files - use this app wisely!');
|
Log('NOTE: You can damage your files - use this app wisely!');
|
||||||
Log(DupeString('-',140));
|
Log(DupeString('-',140));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Reference in New Issue
Block a user