Пример из
[1] надо слегка дополнить
procedure TfMain.PaintBoxSelectedMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
EntryIndex, EntryX, EntryY : Integer;
GridHeight: Integer;
GridWidth : Integer;
PaintBox : TPaintBox;
Address: DWORD;
begin
PaintBox := Sender as TPaintBox;
if Button = mbLeft then begin
GridHeight := PaintBox.Height div 32;
GridWidth := PaintBox.Width div 32;
EntryX := (X div GridWidth);
EntryY := (Y div GridHeight);
EntryIndex := EntryY * 32 + EntryX;
Address := DWORD(DWORD(EntryIndex) * FSelectedMemory.EntrySize) +
FSelectedMemory.StartAddress;
lbSelectedPage.Caption := Format('%.8x', [Address]);
if FSelectedMemory.Map[EntryIndex] = MemImage then
lbContents.Caption := GetModuleFileNameForAddress(Address)
else if FSelectedMemory.Map[EntryIndex] = MemMapped then
lbContents.Caption := GetMappedFileNameForAddress(Address)
else
lbContents.Caption := 'Unknown';
end;
end;
function TfMain.GetMappedFileNameForAddress(Address: DWORD): string;
var
ModuleName: array[0..1024] of char;
rc: DWORD;
mbi : TMemoryBasicInformation;
begin
rc := VirtualQueryEx(FCurrentProcess, Pointer(Address), mbi, SizeOf(mbi));
if rc <> SizeOf(mbi) then
raise Exception.Create(SysErrorMessage(GetLastError));
rc := GetMappedFileName(FCurrentProcess, Pointer(mbi.AllocationBase),
ModuleName, SizeOf(ModuleName));
if rc > 0 then
Result := ModuleName
else
Result := SysErrorMessage(GetLastError);
end;