Virtual Method Tables (VMT)
Category: https://www.freepascal.org/docs-html/current/prog/progse32.html
Object Memory Layout
When you create an instance (object) of a VMT, the first value in memory may be a pointer to the VMT itself.
Offset (x86) | Offset (x64) | What |
---|---|---|
+0 | +0 | Pointer to VMT (optional). |
+4 | +8 | Data. All fields in the order they've been declared. |
Object VMT Layout
Offset (x86) | Offset (x64) | What |
---|---|---|
+0 | +0 | Size of object type data. |
+4 | +8 | Minus the size of object type data. Enables determining of valid VMT pointers. |
+8 | +16 | Pointer to ancestor VMT. Nil if no ancestor available. |
+12 | +24 | Pointers to the virtual methods. |
Source: https://www.freepascal.org/docs-html/prog/progsu165.html
Dynamic Array Types
The reference count and memory size are stored in memory just before the actual start of the array, at a negative offset relative to the address the pointer refers to
Source: https://www.freepascal.org/docs-html/current/prog/progsu163.html