1 Attachment(s)
[Delphi Source] Main.exe Checksum Generator
Credits goes to: spezi
@ http://forum.ragezone.com/f197/multi...erator-662748/
I simple ported it from C# to Delphi
Code:
{*******************************************************}
{ }
{ Main.exe checksum generator }
{ }
{ Copyright (C) 2010 Gunz @ www.cheats.lv }
{ }
{*******************************************************}
unit Unit16;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TForm16 = class(TForm)
Button1: TButton;
Open: TOpenDialog;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
function GetChecksum(Buffer: TBytes; Size: Cardinal; Key: Cardinal): Cardinal;
public
{ Public declarations }
end;
type
TDWORDS = array[0..1024] of Cardinal;
var
Form16: TForm16;
implementation
{$R *.dfm}
function TForm16.GetChecksum(Buffer: TBytes; Size: Cardinal; Key: Cardinal): Cardinal;
var
i: Cardinal;
FKey: Cardinal;
FResult: Cardinal;
begin
i := 0;
FResult := Key shl 9;
while i <= (Size - 4) do
begin
FKey := PDWORD(@Buffer[i])^;
case ((( i shr 2 ) + Key) mod 3 ) of
0: FResult := FResult xor FKey;
1: FResult := FResult + FKey;
2: FResult := (FResult shl (FKey mod 11)) xor FKey;
end;
if (i mod 4) = 0 then
FResult := FResult xor (Key + FResult) shr ((i shr 2) mod 16 + 3);
inc(i,4);
end;
Result := FResult;
end;
procedure TForm16.Button1Click(Sender: TObject);
var
Fs: TStream;
Buffer: TBytes;
i: Integer;
FResult: TDWORDS;
begin
if Open.Execute then
begin
try
Fs := TFileStream.Create(Open.FileName,fmOpenRead);
try
SetLength(Buffer,Fs.Size);
Fs.ReadBuffer(Buffer[0],Length(Buffer));
finally
Fs.Free;
end;
Label1.Caption := 'Processing..';
Fs := TFileStream.Create(ExtractFilePath(Open.FileName)+'Main.dat',fmCreate or fmShareExclusive);
try
for i := 0 to 1024 do
begin
FResult[i] := GetChecksum(Buffer,Length(Buffer),i);
end;
Fs.Write(FResult,Length(FResult));
Label1.Caption := 'Finished!';
finally
Fs.Free;
end;
except
on E: Exception do
begin
MessageDlg('Error: '+E.Message, mtError, [mbOK], 0);
Exit;
end;
end;
end;
end;
end.
In atachaments are binary and project source code (DELPHI)
Re: [Delphi Source] Main.exe Checksum Generator