Saudações! :)
Este código aqui serve para alterar o endereço de memória de um determinado programa através do nome do exe !!
Segue aqui o código:unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, tlhelp32, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetProcessID(Const ExeFileName: string; var ProcessId: integer): boolean;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
result := false;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while integer(ContinueLoop) <> 0 do begin
if (StrIComp(PChar(ExtractFileName(FProcessEntry32.szExeFile)), PChar(ExeFileName)) = 0)
or (StrIComp(FProcessEntry32.szExeFile, PChar(ExeFileName)) = 0) then begin
ProcessId:= FProcessEntry32.th32ProcessID;
result := true;
break;
end;
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;
procedure TForm1.Button1Click(Sender: TObject);
var valorEndereco, retornoEscrita: Cardinal;
var processoId, tempProcess: integer;
begin
if GetProcessID('EXECUTAVEL.exe', tempProcess) then
begin
valorEndereco := $a; // NOVO VALOR PARA O ENDERÇO
processoId := OpenProcess(PROCESS_ALL_ACCESS, False, tempProcess);
// ========================
WriteProcessMemory(processoId, Pointer($00AA6A34), @valorEndereco, Sizeof(valorEndereco), retornoEscrita); // $00AA6A34 em HEXADECIMAL ($ = 0x)
// ========================
closehandle(processoId);
end else
begin
MessageDlg('Abra o programa primeiro', mtwarning, [mbOK],0);
end;
end;
end.
Criadores
Criado por Bruno da Silva
Obs:
GetProcessID (eu modifiquei a partir dela)
Abraços