The System.pas file contains a fair amount of information on hard-coded VMT offsets, but it doesn't seem to actually say much about the structure of the VMT itself. What I'd really like to know is, is there any way to find out the size of a VMT at runtime, or in other words, how many virtual methods exist for a given class?
相关问题
- Is there a Delphi 5 component that can handle .png
- Is there a way to install Delphi 2010 on Windows 2
- Is TWebBrowser dependant on IE version?
- iOS objective-c object: When to use release and wh
- DBGrid - How to set an individual background color
相关文章
- Best way to implement MVVM bindings (View <-> V
- Windows EventLog: How fast are operations with it?
- How to force Delphi compiler to display all hints
- Coloring cell background on firemonkey stringgrid
- HelpInsight documentation in Delphi 2007
- Can RTTI interrogate types from project code at de
- What specifically causes EPrivilege to be raised?
- Equivalent to designer guidelines in code
What about the VMT structure are you wanting to know? You also do know that it is an internal implementation detail that is subject to change (and has changed over time).
To answer your specific question, here is a simple way to find the number of virtual methods for a given class:
This works because I happen to know that the string representing the class name is placed immediately following all the virtual method vectors in the VMT.
I also know that there are 11 virtual methods (for D2009, 9 for D2007 and prior) on all TObjects that are negatively offset from the VMT pointer itself.
That is the reason for the vmtParent reference.
Finally, by using a TClass class reference, you can pass any TObject derived class into this function and get the number of virtual methods.
I was pretty sure Hallvard had something on the VMT. Sure enough, he has Hack #8: Explicit VMT calls which references Ray Lischner Secrets of Delphi 2 and Delphi in a Nutshell.
Here is his hacked up version of the VMT
You will need to read his article for more on the hack though.
I'll plug my own site for this one:
What is the virtual-method table?
It's accurate as of Delphi 2005, I think.
The VMT does not have any value giving the number of virtual-method pointers it holds. Nothing but the compiler needs to know that information, so there's no reason to record it for use at run time.
i remember there was some information about delphi vmt in "delphi in a nutshell" book. u can start from delphi in a nutshell chapter 2 or this
Googling :-P for "delphi vmt" yields this. Maybe this gives you a start.