The MASM Forum

General => The Workshop => Topic started by: K_F on August 14, 2013, 05:18:30 PM

Title: COM - Looking for the vf(..) macro/function
Post by: K_F on August 14, 2013, 05:18:30 PM
Hi.. I'm looking at some Direct2D examples and cannot find this.. function macro/listing.

example:>> invoke vf(g_brush,......)

If anyone knows which file it's in... pleeeeze show me!!

thanks
Van
Title: Re: COM - Looking for the vf(..) macro/function
Post by: qWord on August 15, 2013, 02:04:47 AM
For the case that the WinInc (http://www.japheth.de/) include files are used, take a look in winasm.inc (which is included through windows.inc).
;-------------------------------------------------------------------
; vf() is used to call a virtual method.
; it is intended to be used internally. MIDL will create C helper
; macros to access virtual methods with the following syntax:
;   #define Interface_Method() (This)->lpVtbl->Method(This,...)
; h2incx will translate this to:
;   Interface_Method macro This, ...
;   exitm <vf(This, Interface, Method), ...>
;   endm
;-------------------------------------------------------------------
; edx/r11 is used, so it cannot be used as a parameter!
; and global textequate ??thisreg is used
;-------------------------------------------------------------------
vf macro @this:req,interface,func:req
ifdef _WIN64
ifidni <@this>,<r11>
  ??thisreg equ <r10>
else
  ??thisreg equ <r11>
endif
else
ifidni <@this>,<edx>
  ??thisreg equ <ecx>
else
  ??thisreg equ <edx>
endif
endif
mov ??thisreg,@this
mov ??thisreg,[??thisreg].interface.lpVtbl
exitm <[??thisreg].&interface&Vtbl.&func&,@this>
endm

Title: Re: COM - Looking for the vf(..) macro/function
Post by: K_F on August 15, 2013, 03:17:06 AM
Quote from: qWord on August 15, 2013, 02:04:47 AM
.. take a look in winasm.inc (which is included through windows.inc).
Ah!!! thanks.. I missed that one... Thought I was really losing it !!
:t