NO

Author Topic: COM with Poasm  (Read 4453 times)

Offline Vortex

  • Member
  • *
  • Posts: 797
    • http://www.vortex.masmcode.com
COM with Poasm
« on: May 19, 2011, 10:08:45 PM »
Here is a quick COM example displaying the Windows shutdown options box.

coinvoke macro to call COM methods :

Code: [Select]
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 :

Code: [Select]
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
Code it... That's all...

Offline Vortex

  • Member
  • *
  • Posts: 797
    • http://www.vortex.masmcode.com
Re: COM with Poasm
« Reply #1 on: June 04, 2012, 08:18:06 PM »
This example is modifying the wallpaper :

Code: [Select]
.386
.model flat,stdcall
option casemap:none

include     Wallpaper.inc

includelib  \PellesC\lib\Win\kernel32.lib
includelib  \PellesC\lib\Win\ole32.lib

.data

CLSID_IActiveDesktop    GUID sCLSID_IActiveDesktop
IID_IActiveDesktop      GUID sIID_IActiveDesktop

DesktopImg      dw 'test.bmp',0

.data?

wpo             WALLPAPEROPT <>
pAD             dd ?

.code

start:

    invoke      CoInitialize,NULL

    invoke      CoCreateInstance,ADDR CLSID_IActiveDesktop,NULL,\
                CLSCTX_INPROC_SERVER,ADDR IID_IActiveDesktop,ADDR pAD           

    mov         edx,OFFSET wpo
    mov         WALLPAPEROPT.dwSize[edx],SIZEOF WALLPAPEROPT
    mov         WALLPAPEROPT.dwStyle[edx],WPSTYLE_CENTER

    coinvoke    pAD,IActiveDesktop,SetWallpaper,<OFFSET DesktopImg>,0

    coinvoke    pAD,IActiveDesktop,SetWallpaperOptions,<OFFSET wpo>,0

    coinvoke    pAD,IActiveDesktop,ApplyChanges,AD_APPLY_ALL

    coinvoke    pAD,IActiveDesktop,IUnknown.Release

    invoke      CoUninitialize
   
    invoke      ExitProcess,0

END start
Code it... That's all...

CommonTater

  • Guest
Re: COM with Poasm
« Reply #2 on: June 04, 2012, 10:36:14 PM »
This example is modifying the wallpaper :

:D Showoff! :D

Very interesting stuff...

Offline Vortex

  • Member
  • *
  • Posts: 797
    • http://www.vortex.masmcode.com
Re: COM with Poasm
« Reply #3 on: June 05, 2012, 08:34:07 PM »
This example runs cmd.exe under local system account associated with the highest user privileges. Some COM interfaces are required here to accomplish the task. The code works only in Windows XP 32-bit.
Code it... That's all...