Here's my source code to patch a file made in Delphi 7.
I've just started learning Delphi two months ago so it woudn't be the best writen code you've seen:
Code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ComboBox1: TComboBox;
Image1: TImage;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
FileName : File Of Byte;
WByte01, WByte02, WByte03, WByte04 : Byte;
WByte05, WByte06, WByte07, WByte08 : Byte;
WByte09, WByte10, WByte11, WByte12 : Byte;
WByte13, WByte14, WByte15, WByte16 : Byte;
WByte17, WByte18, WByte19, WByte20 : Byte;
WByte21, WByte22, WByte23, WByte24 : Byte;
WByte25, WByte26, WByte27, WByte28 : Byte;
WByte29, WByte30, WByte31, WByte32 : Byte;
WByte33, WByte34, WByte35, WByte36 : Byte;
WByte37, WByte38, WByte39, WByte40 : Byte;
WByte41, WByte42, WByte43, WByte44 : Byte;
WByte45, WByte46, WByte47, WByte48 : Byte;
WByte49, WByte50, WByte51, WByte52 : Byte;
WByte53, WByte54, WByte55, WByte56 : Byte;
WByte57, WByte58, WByte59, WByte60 : Byte;
Position01, Position02, Position03, Position04 : Longint ;
Position05, Position06, Position07, Position08 : Longint ;
Position09, Position10, Position11, Position12 : Longint ;
FileSource, FileDest: string;
begin
WByte01 := $C0; { 960x600 }
WByte02 := $03;
WByte03 := $58;
WByte04 := $02;
WByte05 := $00; { 1280x720 }
WByte06 := $05;
WByte07 := $D0;
WByte08 := $02;
WByte09 := $00; { 1280x768 }
WByte10 := $05;
WByte11 := $00;
WByte12 := $03;
WByte13 := $00; { 1280x800 }
WByte14 := $05;
WByte15 := $20;
WByte16 := $03;
WByte17 := $00; { 1280x1024 }
WByte18 := $05;
WByte19 := $00;
WByte20 := $04;
WByte21 := $50; { 1360x768 }
WByte22 := $05;
WByte23 := $00;
WByte24 := $03;
WByte25 := $A0; { 1440x900 }
WByte26 := $05;
WByte27 := $84;
WByte28 := $03;
WByte29 := $90; { 1680x1050 }
WByte30 := $06;
WByte31 := $1A;
WByte32 := $04;
WByte33 := $80; { 1920x480 }
WByte34 := $07;
WByte35 := $E0;
WByte36 := $01;
WByte37 := $80; { 1920x1080 }
WByte38 := $07;
WByte39 := $38;
WByte40 := $04;
WByte41 := $80; { 1920x1200 }
WByte42 := $07;
WByte43 := $B0;
WByte44 := $04;
WByte45 := $60; { 2400x600 }
WByte46 := $09;
WByte47 := $58;
WByte48 := $02;
WByte49 := $00; { 2560x1600 }
WByte50 := $0A;
WByte51 := $40;
WByte52 := $06;
WByte53 := $00; { 3072x768 }
WByte54 := $0C;
WByte55 := $00;
WByte56 := $03;
WByte57 := $00; { 3840x1024 }
WByte58 := $0F;
WByte59 := $00;
WByte60 := $04;
Position01 := $35E4E;
Position02 := $35E4F;
Position03 := $35E54;
Position04 := $35E55;
AssignFile(FileName, 'At Worlds End.exe');
If Not FileExists ('At Worlds End.exe') Then
Begin
ShowMessage('File Not Found ! ');
Exit;
End;
Reset(FileName);
If ComboBox1.Text='' then
ShowMessage('Please Select A Resolution..');
If ComboBox1.Text='960x600' then
Begin
FileSource := 'At Worlds End.exe';
FileDest := 'At Worlds End.bak';
CopyFile(PChar(FileSource), PChar(FileDest), False);
Seek(FileName, Position01);
Write(FileName, WByte01);
Seek(FileName, Position02);
Write(FileName, WByte02);
Seek(FileName, Position03);
Write(FileName, WByte03);
Seek(FileName, Position04);
Write(FileName, WByte04);
CloseFile(FileName);
ShowMessage('Resolution Set To: 960x600');
End;
Reset(FileName);
If ComboBox1.Text='1280x720' then
Begin
FileSource := 'At Worlds End.exe';
FileDest := 'At Worlds End.bak';
CopyFile(PChar(FileSource), PChar(FileDest), False);
Seek(FileName, Position01);
Write(FileName, WByte05);
Seek(FileName, Position02);
Write(FileName, WByte06);
Seek(FileName, Position03);
Write(FileName, WByte07);
Seek(FileName, Position04);
Write(FileName, WByte08);
CloseFile(FileName);
ShowMessage('Resolution Set To: 1280x720');
End;
Reset(FileName);
If ComboBox1.Text='1280x768' then
Begin
FileSource := 'At Worlds End.exe';
FileDest := 'At Worlds End.bak';
CopyFile(PChar(FileSource), PChar(FileDest), False);
Seek(FileName, Position01);
Write(FileName, WByte09);
Seek(FileName, Position02);
Write(FileName, WByte10);
Seek(FileName, Position03);
Write(FileName, WByte11);
Seek(FileName, Position04);
Write(FileName, WByte12);
CloseFile(FileName);
ShowMessage('Resolution Set To: 1280x768');
End;
Reset(FileName);
If ComboBox1.Text='1280x800' then
Begin
FileSource := 'At Worlds End.exe';
FileDest := 'At Worlds End.bak';
CopyFile(PChar(FileSource), PChar(FileDest), False);
Seek(FileName, Position01);
Write(FileName, WByte13);
Seek(FileName, Position02);
Write(FileName, WByte14);
Seek(FileName, Position03);
Write(FileName, WByte15);
Seek(FileName, Position04);
Write(FileName, WByte16);
CloseFile(FileName);
ShowMessage('Resolution Set To: 1280x800');
End;
Reset(FileName);
If ComboBox1.Text='1280x1024' then
Begin
FileSource := 'At Worlds End.exe';
FileDest := 'At Worlds End.bak';
CopyFile(PChar(FileSource), PChar(FileDest), False);
Seek(FileName, Position01);
Write(FileName, WByte17);
Seek(FileName, Position02);
Write(FileName, WByte18);
Seek(FileName, Position03);
Write(FileName, WByte19);
Seek(FileName, Position04);
Write(FileName, WByte20);
CloseFile(FileName);
ShowMessage('Resolution Set To: 1280x1024');
End;
Reset(FileName);
If ComboBox1.Text='1360x768' then
Begin
FileSource := 'At Worlds End.exe';
FileDest := 'At Worlds End.bak';
CopyFile(PChar(FileSource), PChar(FileDest), False);
Seek(FileName, Position01);
Write(FileName, WByte21);
Seek(FileName, Position02);
Write(FileName, WByte22);
Seek(FileName, Position03);
Write(FileName, WByte23);
Seek(FileName, Position04);
Write(FileName, WByte24);
CloseFile(FileName);
ShowMessage('Resolution Set To: 1360x768');
End;
Reset(FileName);
If ComboBox1.Text='1440x900' then
Begin
FileSource := 'At Worlds End.exe';
FileDest := 'At Worlds End.bak';
CopyFile(PChar(FileSource), PChar(FileDest), False);
Seek(FileName, Position01);
Write(FileName, WByte25);
Seek(FileName, Position02);
Write(FileName, WByte26);
Seek(FileName, Position03);
Write(FileName, WByte27);
Seek(FileName, Position04);
Write(FileName, WByte28);
CloseFile(FileName);
ShowMessage('Resolution Set To: 1440x900');
End;
Reset(FileName);
If ComboBox1.Text='1680x1050' then
Begin
FileSource := 'At Worlds End.exe';
FileDest := 'At Worlds End.bak';
CopyFile(PChar(FileSource), PChar(FileDest), False);
Seek(FileName, Position01);
Write(FileName, WByte29);
Seek(FileName, Position02);
Write(FileName, WByte30);
Seek(FileName, Position03);
Write(FileName, WByte31);
Seek(FileName, Position04);
Write(FileName, WByte32);
CloseFile(FileName);
ShowMessage('Resolution Set To: 1680x1050');
End;
Reset(FileName);
If ComboBox1.Text='1920x480' then
Begin
FileSource := 'At Worlds End.exe';
FileDest := 'At Worlds End.bak';
CopyFile(PChar(FileSource), PChar(FileDest), False);
Seek(FileName, Position01);
Write(FileName, WByte33);
Seek(FileName, Position02);
Write(FileName, WByte34);
Seek(FileName, Position03);
Write(FileName, WByte35);
Seek(FileName, Position04);
Write(FileName, WByte36);
CloseFile(FileName);
ShowMessage('Resolution Set To: 1920x480');
End;
Reset(FileName);
If ComboBox1.Text='1920x1080' then
Begin
FileSource := 'At Worlds End.exe';
FileDest := 'At Worlds End.bak';
CopyFile(PChar(FileSource), PChar(FileDest), False);
Seek(FileName, Position01);
Write(FileName, WByte37);
Seek(FileName, Position02);
Write(FileName, WByte38);
Seek(FileName, Position03);
Write(FileName, WByte39);
Seek(FileName, Position04);
Write(FileName, WByte40);
CloseFile(FileName);
ShowMessage('Resolution Set To: 1920x1080');
End;
Reset(FileName);
If ComboBox1.Text='1920x1200' then
Begin
FileSource := 'At Worlds End.exe';
FileDest := 'At Worlds End.bak';
CopyFile(PChar(FileSource), PChar(FileDest), False);
Seek(FileName, Position01);
Write(FileName, WByte41);
Seek(FileName, Position02);
Write(FileName, WByte42);
Seek(FileName, Position03);
Write(FileName, WByte43);
Seek(FileName, Position04);
Write(FileName, WByte44);
CloseFile(FileName);
ShowMessage('Resolution Set To: 1920x1200');
End;
Reset(FileName);
If ComboBox1.Text='2400x600' then
Begin
FileSource := 'At Worlds End.exe';
FileDest := 'At Worlds End.bak';
CopyFile(PChar(FileSource), PChar(FileDest), False);
Seek(FileName, Position01);
Write(FileName, WByte45);
Seek(FileName, Position02);
Write(FileName, WByte46);
Seek(FileName, Position03);
Write(FileName, WByte47);
Seek(FileName, Position04);
Write(FileName, WByte48);
CloseFile(FileName);
ShowMessage('Resolution Set To: 2400x600');
End;
Reset(FileName);
If ComboBox1.Text='2560x1600' then
Begin
FileSource := 'At Worlds End.exe';
FileDest := 'At Worlds End.bak';
CopyFile(PChar(FileSource), PChar(FileDest), False);
Seek(FileName, Position01);
Write(FileName, WByte49);
Seek(FileName, Position02);
Write(FileName, WByte50);
Seek(FileName, Position03);
Write(FileName, WByte51);
Seek(FileName, Position04);
Write(FileName, WByte52);
CloseFile(FileName);
ShowMessage('Resolution Set To: 2560x1600');
End;
Reset(FileName);
If ComboBox1.Text='3072x768' then
Begin
FileSource := 'At Worlds End.exe';
FileDest := 'At Worlds End.bak';
CopyFile(PChar(FileSource), PChar(FileDest), False);
Seek(FileName, Position01);
Write(FileName, WByte53);
Seek(FileName, Position02);
Write(FileName, WByte54);
Seek(FileName, Position03);
Write(FileName, WByte55);
Seek(FileName, Position04);
Write(FileName, WByte56);
CloseFile(FileName);
ShowMessage('Resolution Set To: 3072x768');
End;
Reset(FileName);
If ComboBox1.Text='3840x1024' then
Begin
FileSource := 'At Worlds End.exe';
FileDest := 'At Worlds End.bak';
CopyFile(PChar(FileSource), PChar(FileDest), False);
Seek(FileName, Position01);
Write(FileName, WByte57);
Seek(FileName, Position02);
Write(FileName, WByte58);
Seek(FileName, Position03);
Write(FileName, WByte59);
Seek(FileName, Position04);
Write(FileName, WByte60);
CloseFile(FileName);
ShowMessage('Resolution Set To: 3840x1024');
End;
End;
end.