News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

COM with Poasm

Started by Vortex, May 22, 2011, 08:52:59 AM

Previous topic - Next topic

Vortex

Here is a quick COM example displaying the Windows shutdown options box.

coinvoke macro to call COM methods :


coinvoke MACRO ppv:REQ,interface:REQ,member:REQ,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16

   FOR arg,<p16,p15,p14,p13,p12,p11,p10,p9,p8,p7,p6,p5,p4,p3,p2,p1>

       IFNB <arg>

           push arg

       ENDIF

   ENDM

   mov     eax,ppv
   push    eax
   mov     eax,DWORD PTR [eax]
   call    @CatStr(interface,<.>,member)[eax]

ENDM


Example project :


include       ShutdownWinBox.inc

.data

CLSID_Shell   GUID sCLSID_Shell

IID_IDispatch GUID sIID_IDispatch


.data?

pShell         dd ?

.code

start:

   invoke      CoInitialize,0

   invoke      CoCreateInstance,ADDR CLSID_Shell,0,\
               CLSCTX_INPROC_SERVER,ADDR IID_IDispatch,ADDR pShell            

   coinvoke    pShell,IShellDispatch,ShutdownWindows

   coinvoke    pShell,IShellDispatch,Release

   invoke      CoUninitialize
   
   invoke      ExitProcess,0

END start