D
ddev
Unregistered / Unconfirmed
GUEST, unregistred user!
下面的例程为何不能正常运行?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
buffer: array[0..255] of byte;
BaseAddr: Longword;
buf_size: Longword;
read_size: Longword;
I: Longint;
ln: string;
begin
BaseAddr := $400000;
buf_size := 255;
for I := 0 to 255 do buffer := $00;
ReadProcessMemory(hInstance, @BaseAddr, @Buffer, buf_size, read_size);
ln := '';
Memo1.Lines.Clear ;
for I := 0 to 255 do
begin
if (I > 0) and (I mod 15 = 0) then
begin
Memo1.Lines.Add(ln);
ln := '';
end;
if ln = '' then
ln := IntToHex(buffer, 2) else
ln := ln + ' ' + IntToHex(buffer, 2);
end;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
buffer: array[0..255] of byte;
BaseAddr: Longword;
buf_size: Longword;
read_size: Longword;
I: Longint;
ln: string;
begin
BaseAddr := $400000;
buf_size := 255;
for I := 0 to 255 do buffer := $00;
ReadProcessMemory(hInstance, @BaseAddr, @Buffer, buf_size, read_size);
ln := '';
Memo1.Lines.Clear ;
for I := 0 to 255 do
begin
if (I > 0) and (I mod 15 = 0) then
begin
Memo1.Lines.Add(ln);
ln := '';
end;
if ln = '' then
ln := IntToHex(buffer, 2) else
ln := ln + ' ' + IntToHex(buffer, 2);
end;
end;
end.