Note 62: This low-level checks are used also by my Memory Snap utility, mentioned in the respective section of chapter 11.

The most relevant of this "low-level checks" covered at page 152 is the following empirical test for determining whether a point is actually a reference to an object (yes, the code is quite cryptic... there is a limited description in the book, of course). If you can come up with a better / more robust solution, I'll be interested...

function IsPointerToObject (Address: Pointer): Boolean;
classPointer, vmtPointer: PChar;
instsize: Integer;
Result := False;
if (FindHInstance (Address) > 0) then
vmtpointer := pchar(Address^);
classpointer := vmtpointer + vmtSelfPtr;
if Assigned (vmtpointer) and
(FindHInstance (vmtpointer) > 0) then
instsize := (Pinteger(
vmtpointer + vmtInstanceSize))^;
// check self pointer and "reasonable" instance size
if (pointer(pointer(classpointer)^) =
pointer(vmtpointer)) and
(instsize > 0) and (instsize < 10000) then
Result := True;

This blog post is part of my "113 Delphi 2007 Handbook Notes" blogging project, to promote my new Delphi book.