Thema: Delphi Patcher

Einzelnen Beitrag anzeigen

Benutzerbild von ErazerZ
ErazerZ

Registriert seit: 27. Mai 2005
Ort: Baden
315 Beiträge
 
Delphi 2007 Enterprise
 
#25

Re: Patcher

  Alt 18. Sep 2005, 00:33
Delphi-Quellcode:
program Patch;

{$APPTYPE CONSOLE}

uses
  Windows;

procedure PatchOffset(Handle: Cardinal; Offset: LongInt; NewCode: LongInt);
var
  Buffer: Pointer;
  FileSizeA: Cardinal;
begin
  FileSizeA := GetFileSize(Handle, nil);
  Buffer := Pointer(LocalAlloc(0, FileSizeA));
  _lread(Handle, Buffer, FileSizeA);
  _llseek(Handle, 0, FILE_BEGIN);
  PByte(Cardinal(Buffer) + Offset)^ := NewCode;
  _lwrite(Handle, Buffer, FileSizeA);
end;

var
  h: Cardinal;
begin
  h := _lopen(PChar(ParamStr(1)), OF_READWRITE);
  if h <> INVALID_HANDLE_VALUE then
  begin
    PatchOffset(h, $1, $90);
  end;
  _lclose(h);
end.
  Mit Zitat antworten Zitat