Costruiamo il nostro primo auto cracker in delphi (funziona con semplici applicazioni shareware)

[code linenumbers=false]unit code;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
fichier: TOpenDialog;
Button1: TButton;
Info: TButton;
Quit: TButton;
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
procedure Button1Click(Sender: TObject);
procedure InfoClick(Sender: TObject);
procedure QuitClick(Sender: TObject);
private
{ Déclarations privées}
public
{ Déclarations publiques}
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject); //Inception

Const // we declare constants
FileN : String = 'MySoftware.exe'; // File Name to pacth
BytesToChange : Integer = 2; // number of bytes to amend
FileS : LongInt = 564132; // File size
A : Array[1..2] of Record // By changing 2 bytes
A : Longint; // length limit 2147483647
B : Byte; // limit of 255 bytes
End = // end statements

(
(A:$303E6;B:$90), //Hexadecimal to change addresses and their octects
(A:$303E6;B:$90) // Attention! on the last row => no comma!);
);

Var // declaration of variables
F : File; // F for the file
Ch : Char; // Ch octet for a patch
I : LongInt; // and I for the length

Begin // Begins
fichier.filename := '*.exe'; // Seeking an exe file
fichier.filter := FileN; // file Mysoftware.exe
if fichier.execute then // if the file is found, then ...
begin // opens a command
AssignFile(F, fichier.filename); // target file
Reset(F,1); // open the existing file
If FileSize(F)<>FileS then // if the file is a size <or> that indicated, then ...
begin // Opens a command
ShowMessage('File is incorrect size'); // displays the text as what it is not the right size
halt(1); // and was stopped while
end // end of the function which measures the size
else // if everything went well, then ...
begin // Opens a command
end; // n the end to move to what am
For I := 1 to BytesToChange do // for I, I loop as many times there to make modification
begin // will indicate how
Seek(F,A[i].A); //>
Ch:=Char(A[i].B); //>
Blockwrite(F,Ch,1); // registered bytes
end; // end of the procedure
ShowMessage ('File successfully cracked!'); // Displays a message of success
end; //>
end; // Closing[/code]Auto Cracker
Source viewer