Context:
I'm trying to use a few COM Interface (Direct2D 1.1) from a Delphi application. For that purpose, I have to port the interfaces to Delphi. I have done that but I have a problem with one of the interfaces: the method I call is not the correct one. I verified that by writing the exact same piece of code in C++ and in Delphi. Running both under the debugger, I see that the code called by Delphi is not the same as the code called by C++. So I made a mistake in porting that interface.
To find out where my error is, I have the idea to dump all method pointers to compare the address shown by C++ and by Delphi. They should be the same as the point to the same DLL.
I don't know how to get hand on the VMT! I have read this but it is not applicable in my case: the .h file do not contain the C equivalent.
I'm looking for something similar to offsetof() and sizeof() that I use to check structures. And something to get the address of a given interface method.
Any help appreciated. PS: I hope that my English is understandable.
I found the solution, so I will answer my own question:
Below is the code required to load the VMT of interface whose pointer is variable "Screen" into array of pointers VMT. The code assume there are 93 methods (That is actually the case). I have yet to know how to get the count of methods in a given interface to fully automate the process.
I verifyed that this code is OK by using the debugger and loading Windows symbols. This gives the following result in VMT:
You can see that the 3 first entries are QueryInterface, AddRef and Release method which is what all interfaces have in their VMT.