News:

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

OLE/COM from win32asm?

Started by w0lfshad3, August 28, 2006, 04:33:07 PM

Previous topic - Next topic

w0lfshad3

Or at least C; any1 got any links on documentation?

ToutEnMasm

Hello,
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q141549

I have written(in masm32) a richedit that accept images with it. It's only the start of what can do the sample.
If you progress more than me , give me news.
                                          ToutEnMasm


ToutEnMasm

Hello,
Perhaps your link need more explain,I don't see in what it relate to OLE.
                                    ToutEnMasm

w0lfshad3

Don't know i didn't learn OLE/COM arhitecture yet. Perhaps this will help me translate code from c++ while i learn it. It was recomended when i asked about OLE/COM.

Your example is nice but i need theory. I got more examples in RADAsm and masm32 they won't help much w/o some theory.

Last chapter in the help file treats COM.

ToutEnMasm


For com, I can put this one,usage is simple
get the pointer of interface and call it ppvinterface
Instead  of calling invoke call the macro folowed by the named function and this arguments
IRichEditOle Release
          That all,
                             ToutEnMasm


ex:
.data
ppvIRichEditOle dd 0




STIRichEditOle STRUCT
;---** IUnknown methods ***
; Iunknown commune a toutes les interfaces
QueryInterface       comethod3       ?
AddRef               comethod1       ?
Release              comethod1       ?
;*** IRichEditOle methods ***
GetClientSite comethod2       ?                 ;lplpolesite) PURE;
GetObjectCount comethod1       ?
GetLinkCount comethod1       ?
GetObject comethod4       ?
InsertObject comethod2       ?
ConvertObject comethod4       ? ;iob, REFCLSID rclsidNew,LPCSTR lpstrUserTypeNew) PURE;
ActivateAs comethod3       ? ;(REFCLSID rclsid, REFCLSID rclsidAs) PURE;
SetHostNames comethod3       ?          ;(lpstrContainerApp,lpstrContainerObj) PURE;
SetLinkAvailable comethod3       ? ;LONG iob, BOOL fAvailable) PURE;
SetDvaspect comethod3       ? ; LONG iob, DWORD dvaspect) PURE;
HandsOffStorage comethod2       ?          ; LONG iob) PURE;
SaveCompleted comethod3       ? ;LONG iob, LPSTORAGE lpstg) PURE;
InPlaceDeactivate comethod1       ?
ContextSensitiveHelp comethod1       ? ;BOOL fEnterMode) PURE;
GetClipboardData comethod4       ? ;* lpchrg, DWORD reco,LPDATAOBJECT FAR * lplpdataobj) PURE;
ImportDataObject comethod4       ? ;(lpdataobj,CLIPFORMAT cf, HGLOBAL hMetaPict) PURE;
STIRichEditOle ENDS

IRichEditOle MACRO  Function:REQ, args:VARARG
; definition de la macro locale InvokeInterface
    LOCAL InvokeInterface, arg
    FOR arg, <args>     ;verifier que edx n'est pas dans la liste d'arguments args
        IFIDNI <&arg>, <edx> ;
            .ERR <edx is not allowed as a coinvoke parameter>
        ENDIF
    ENDM

    IFIDNI <&pInterface>, <edx>
        .ERR <edx is not allowed as a coinvoke parameter>
    ENDIF
;InvokeInterface = concatene ...CATSTR(concatene) MACRO instruction MASM32
;---------- on doit mettre ppv en premier argument -----------------------------------
    InvokeInterface CATSTR <invoke (STIRichEditOle PTR[edx]).>,<&Function,ppvIRichEditOle>
    IFNB <args>     ; add the list of parameter arguments if any
        InvokeInterface CATSTR InvokeInterface, <, >, <&args>
    ENDIF
;   forme les lignes de codes
    mov edx, ppvIRichEditOle
    mov edx, [edx]
    InvokeInterface
ENDM


pcomcallback   TYPEDEF PROTO :DWORD, :WORD, :DWORD, :DWORD , :DWORD
comcallback           TYPEDEF PTR pcomcallback
;
; IRichEditOleCallback
;
; Purpose:
; Interface used by the RichEdit to get OLE-related stuff from the
; application using RichEdit.
;
; C:\Program Files\Microsoft SDK\include\RichOle.h

;

STIRichEditOleCallback STRUCT
;----- Iunknown commune a toutes les interfaces
QueryInterface       comethod3       ?
AddRef               comethod1       ?
Release              comethod1       ?
;----- IRichEditOleCallback methods ***
GetNewStorage comethod2    ? ;STORAGE FAR * lplpstg) PURE;
GetInPlaceContext comethod4       ? ;lplpFrame,* lplpDoc,lpFrameInfo
ShowContainerUI comethod2       ? ;BOOL fShow
QueryInsertObject comethod4       ? ;lpclsid,lpstg,LONG cp
DeleteObject comethod2       ? ;lpoleobj
QueryAcceptData comethod6       ? ;lpdataobj,lpcfFormat,reco,fReally,hMetaPict
ContextSensitiveHelp comethod3       ? ;fEnterMode
GetClipboardData comethod4       ? ;CHARRANGE * lpchrg,reco,lplpdataobj
GetDragDropEffect comethod4       ? ;fDrag,grfKeyState,pdwEffect
GetContextMenu comcallback    ? ;WORD seltype,lpoleobj,CHARRANGE * lpchrg,HMENU lphmenu
STIRichEditOleCallback ENDS



IRichEditOleCallback MACRO  Function:REQ, args:VARARG
; definition de la macro locale InvokeInterface
    LOCAL InvokeInterface, arg
    FOR arg, <args>     ;verifier que edx n'est pas dans la liste d'arguments args
        IFIDNI <&arg>, <edx> ;
            .ERR <edx is not allowed as a coinvoke parameter>
        ENDIF
    ENDM

    IFIDNI <&pInterface>, <edx>
        .ERR <edx is not allowed as a coinvoke parameter>
    ENDIF
;InvokeInterface = concatene ...CATSTR(concatene) MACRO instruction MASM32
;---------- on doit mettre ppv en premier argument -----------------------------------
    InvokeInterface CATSTR <invoke (STIRichEditOleCallback PTR[edx]).>,<&Function,ppvIRichEditOleCallback>
    IFNB <args>     ; add the list of parameter arguments if any
        InvokeInterface CATSTR InvokeInterface, <, >, <&args>
    ENDIF
;   forme les lignes de codes
    mov edx, ppvIRichEditOleCallback
    mov edx, [edx]
    InvokeInterface
ENDM

w0lfshad3

lol ok you can, i can't; i need theory to understand what is going on.

ToutEnMasm


Ok,i must provided some explain.

First , are you easy with calling an API ?,if yes,you are easy with com.

What is COM ?
COM can be see as two structures in memory.
   The first structure is a table of vectors (Functions) and to call them you have to made an indirect call.
      When you write a proc,the final instruction is a call to the adress of the PROC

Quote
  PUSH ....
...

call eax          ;eax = adress of the function in the source code

If the adress of the call is a table of vector , you have to get the adress in the table
    TABLE STRUCT
       MyFunction dd myproc             ;put the offset of my proc in MyFunction
       Second  dd Anotherproc
    TABLE ENDS
.data
     table TABLE <>

If you want to call MyFunction,you have to get the adress of my function
     lea eax,table
calling MyFunction
    call [eax]
calling Second
   call [eax+4]          ; the +4 is the index on the TABLE
                  ;----------------------------------------------------------------------------------
The second structure in memory give you the adress of a dword containing the pointer on the vector table,like that
      SOMEWHERE STRUCT
         ppv  dd TableOfvector ;the adress of the table of vector
         count dd 0
     SOMEWHERE  ENDS

This structure isn't in your code,and you have to call an api to find it
    cocreateinstance is the more common,but there is many others.
The api return to you the address of the ppv DWORD,and you have to made a little coding before to have the adress of the vtable.
     mov edx,ppv
     mov edx,[edx]
    call [edx+index]
That all you have to understand,other things added are to use the invoke that provided a more usable form of call.Invoke is here to verify that you put the corrects parameters when calling the function.

                                             ToutEnMasm























w0lfshad3

ok thanks sounds simple enough at first alltough:
1. not beeing familiar with OLE/COM i don't know to call "multiple APIs"
2. i have no ideea what "MyFunction" should be in there
3. i'm just trying to create drag and drop functionality, and i'm seriously wondering about doing it w/o OLE/COM :lol

ToutEnMasm


The Myfunction is only a general term to designe a proc in your source
Myfunction proc Parm1:DWORD,...
ret
Myfunction

The drag and drop ,without ole (drop only text who can be a path) can be perform modifying style of the control.
                                  ToutEnMasm

P1

Quote from: w0lfshad3 on August 29, 2006, 11:54:17 AMlol ok you can, i can't; i need theory to understand what is going on.
Your going to need to do the research on COM.  It's an advanced Assembler Topic.  The C folks just use wrappers to reduce the complexities.  First determine, are you going use a COM interface or make one?  Then go from there.

Answer this question and we will point you to some assembler references to start your quest.

Regards,  P1  :8)

w0lfshad3

I tought of a way to duplicate drag and drop in my own window but theres another story when it comes to drag and drop between apps, i have no clue on how to duplicate OLE/COM logic from the clean WINAPI yet between apps. I better start reading on COM :)

Thank you for the info.

w0lfshad3

#12
QuoteFirst determine, are you going use a COM interface or make one?
Actually i'm aiming to leech OLE/COMs functionality with the least memorizing overhead for meĀ  :lol
For now its drag and drop but MS puts too much weight on this to stop at only a few uses for this, so i might need to learn the OLE/COM arhitecture. From this point of view i want to learn to make one and use an existign one as well.

My ideea is to set drag and drop between child windows since it would be easier to perform operations on them(since i'll have a lot of them) and even include the ChildWndProc for example in a separate thread. So mainly i'm thinking of drag ad drop from one child window to another wich is kind of one app to another except all childs derive from my parent window wich is in the same app; btw this leads me to this question: isn't the desktop and windows the parent window and app for all the apps? If yes how would i use this to my advantage implementing drag and drop w/o ole/com? Currently i'm looking at Iczelion's tuts chapter 19 tree view, it only needs some more logic to bypass ole/com(use child windows and/or drag&drop between apps).

By overhead i mean MFC wich is as much overhead as assembly is; and since MFC is not a language(alltough it somewhat resembles scripting for WINAPI ) i rather do it from assembly or C. I just hate encapsulation, i regard the overhead of creating a window or some other(otherwise encapsulated) piece of code as a copy/paste object to whom i have much more control than an OOP HLL would give.

ToutEnMasm

OleDragDrop in masm32
http://www.japheth.de/Download/DragDrop.zip
                      ToutEnMasm