News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Method to export virtual function table in a COM interface from dll file?

Started by enzechen, November 24, 2016, 02:18:14 AM

Previous topic - Next topic

enzechen

e.g. direct2d uses COM technology. It creates an object with pointer to its virtual function table.

Without checking the original include header file, is there any way to export this virtual function table from a dll file like d2d1.dll?
I checked the d2d1.lib file. It only export few functions used to create COM object. It does not contain any information of functions in the vtbl...

Anyone can teach me how to do?

jj2007


qWord

@enzechen

For the case that you need Direct2D includes and libs that work with the MASM32 SDK, see this post:
http://masm32.com/board/index.php?topic=3015.msg31568#msg31568
(see also the other post in that thread)

regards
MREAL macros - when you need floating point arithmetic while assembling!

Zen

ENZECHEN,
Typically when activating a COM interface (yes, even in MASM assembly), one uses CoCreateInstance. This function returns the address of the virtual function table (as, LPVOID *ppv). This is just an address (usually somewhere inside the DLL). The function table follows. The address for the QueryInterface implementation, is the same address as the virtual function table address returned from CoCreateInstance. What you really need is a header file (or, include file) that lists the names of all the implemented functions from the selected COM interface, in the correct order. Then it is simple to call the COM interface functions merely by knowing the virtual function table address and the function name (the offset to the implemented function of interest). In a 32-bit application, each address in the virtual function table is 4 bytes long, and so the offset to each successive function implementation is an additional 4 bytes in memory. It is even easier to call a COM interface method by pushing the required parameters onto the stack (in reverse order), then using the CALL syntax with the address of the virtual function table and the correct offset added to it.