Реферат Курсовая Конспект
Accessing COM Objects from Assembly - раздел Образование, Accessing Com Objects From Assemb...
|
IUnknown STRUCT DWORD
IUnknown methods IUnknown_QueryInterface QueryInterface_Pointer ? IUnknown_AddRef AddRef_Pointer ? IUnknown_Release Release_Pointer ?
AddRef_Pointer typedef ptr AddRef_Proto Release_Pointer typedef ptr Release_Proto
Finally, we define the function prototypes as follows:
QueryInterface_Proto typedef PROTO :DWORD, :DWORD, :DWORD
And use it to find the interface structure
mov edx, [eax]
Push the function parameters onto the stack
Push OFFSET ppv2
Push OFFSET IID_ISomeOtherInterface
Push dword ppv
And then call that method
call dword ptr [eax + 0]
This may be accomplished using the built-in MASM 'invoke' macro as such:
Get pointer to the object mov eax, ppv
And use it to find the interface structure
mov edx, [eax]
; and then call that method
invoke (IUnknown PTR [edx]).IUnknown_QueryInterface, ppv,
Coinvoke MACRO
;
Invokes an arbitrary COM interface
;
Revised 12/29/00 to check for edx as a param and force compilation error
; (thanks to Andy Car for a how-to suggestion)
Revised 7/18/00 to pass pointer in edx (not eax) to avoid confusion with
; parmas passed with ADDR (Jeremy Collake's excellent suggestion)
Revised 5/4/00 for member function name decoration
See http://ourworld.compuserve.com/homepages/ernies_world/coinvoke.htm
;
PInterface pointer to a specific interface instance
Interface the Interface's struct typedef
Function which function or method of the interface to perform
Args all required arguments
; (type, kind and count determined by the function)
;
Coinvoke MACRO pInterface:REQ, Interface:REQ, Function:REQ, args:VARARG
LOCAL istatement, arg
FOR arg, <args> ;; run thru args to see if edx is lurking in there
IFIDNI <&arg>, <edx>
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
ENDM
istatement CATSTR <invoke (Interface PTR[edx]).&Interface>,<_>,<&Function, pInterface>
IFNB <args> ;; add the list of parameter arguments if any
istatement CATSTR istatement, <, >, <&args>
ENDIF
Mov edx, pInterface
mov edx, [edx]
Istatement
ENDM
;---------------------------------------------------------------------
Thus, the same QueryInterface method as before can be invoked in a single line:
coinvoke ppv ,IUnknown, QueryInterface, ADDR IID_SomeOtherInterface,
– Конец работы –
Используемые теги: Accessing, com, Objects, from, Assembly0.08
Если Вам нужно дополнительный материал на эту тему, или Вы не нашли то, что искали, рекомендуем воспользоваться поиском по нашей базе работ: Accessing COM Objects from Assembly
Если этот материал оказался полезным для Вас, Вы можете сохранить его на свою страничку в социальных сетях:
Твитнуть |
Новости и инфо для студентов