Irgendwie raff ich's nicht. Ich hab mal ein Testprojektchen gestrickt:
Delphi-Quellcode:
program OverwriteTest;
uses
FastMM4,
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
ReportMemoryLeaksOnShutdown := True;
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
Delphi-Quellcode:
unit Unit1;
interface
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
ExtCtrls,
StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
procedure Log(
const AMessage:
string);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
Start: Integer;
Victim: Integer;
procedure TForm1.Button1Click(Sender: TObject);
begin
Log('
before');
FillChar(Start, 2 * SizeOf(Start), 0);
Log('
after');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Start := 123;
Victim := 456;
Log('
ctor');
end;
procedure TForm1.Log(
const AMessage:
string);
begin
OutputDebugString(PChar(AMessage + '
: ' + IntToStr(Start) + '
/' + IntToStr(Victim)));
end;
end.
Wenn jetzt der Benutzer auf Button1 klickt, hätte ich gerne die Info, dass der FillChar-Aufruf im Speicherbereich von Victim rumgeschrieben hat.