The MASM Forum Archive 2004 to 2012

Project Support Forums => GoAsm Assembler and Tools => Topic started by: donkey on February 12, 2009, 06:30:45 AM

Title: Macro question
Post by: donkey on February 12, 2009, 06:30:45 AM
Hi Jeremy,

I was a little bored tonight and thought I would write a useless macro. I should say that I would never plan on using this macro in any code I write but some might. It automates instantiating simple COM interfaces with the addition of the New macro that wraps the CoCreateInstance API. I was wondering why it has problems with the GUID structure...

New(%1) MACRO
#IFNDEF CLSID_%1
constant section
CLSID_%1 GUID GUID_CLSID_%1
IID_I%1 GUID GUID_IID_I%1
code section
#ENDIF
sub esp,4
mov D[esp],0
push esp
push offset IID_I%1
push CLSCTX_ALL
push NULL
push offset CLSID_%1
call CoCreateInstance
pop eax
ENDM


GUID is defined as follows...

GUID STRUCT
Data1 dd
Data2 dw
Data3 dw
Data4 db
db
db
db
db
db
db
db
ENDS

A typical GUID would be defined as follows in the headers:

#define GUID_CLSID_HxSession <0x31411198,0xA502,0x11D2,0xBB,0xCA,0x00,0xC0,0x4F,0x8E,0xC2,0x94>
#define GUID_IID_IHxSession <0x31411192,0xA502,0x11D2,0xBB,0xCA,0x00,0xC0,0x4F,0x8E,0xC2,0x94>


Since all of my headers use the syntax GUID_IID_Interface and GUID_CLSID_Class, the usage for New would look like this

New(HxSession)
mov [pIHxSession], eax


However I get the following error when I try to assemble it...

QuoteInvalid data declaration:-
dd
Defined in Line 30 of assembler source file (HxSessionDemo.asm):
New(%1) MACRO

Just wondering where logic failed me here, as long as the CLSID/IID is defined there is no problem and the macro works as advertised, however when #IFNDEF is true then I get the error.

Edgar
Title: Re: Macro question
Post by: ToutEnMasm on February 14, 2009, 04:32:14 PM
Hello,
If you are able to make a routine as GetObject in the vb,wmi,... langage I will help you.
But this one seems to be only another syntax of cocreateinstance.
I try to make a real translate of GetObject (in vb,wmi,..),but seems that knowledge of the registry key go to a wall.
Searching to the registry base seems to be the soluce,I am right ?.
For example CLSID are all  in HKEY_CLASSES_ROOT\CLSID,perhaps GetObject make a search in it ?

Title: Re: Macro question
Post by: donkey on February 14, 2009, 06:35:45 PM
Hi ToutEnMasm,

I was just bored, I don't generally use any macros other than CoInvoke, don't like them much.
Title: Re: Macro question
Post by: ToutEnMasm on February 14, 2009, 07:16:36 PM

Too bad, i was just searching a help to write something useful for com connection.
I am writing something to find a CLSID with an interface registry key.
What I search to made,is a proc that replace the Getobject,New... of basic,script ...langage.
Seems to me is it possible,not ?
Title: Re: Macro question
Post by: donkey on February 14, 2009, 08:49:54 PM
Hi ToutEnMasm,

Here's something I started a while back as a RadASM addin, I don't know the state of the project anymore but its a start for you. It enumerates all interfaces and output a GUID for that particular IID, it is no great leap to have it do the TLBID and CLSID as well but I lost interest in the project as I have most interfaces defined already in the header project.



[attachment deleted by admin]
Title: Re: Macro question
Post by: jorgon on February 28, 2009, 07:16:48 PM
Hi Edgar

I'm looking into this one, and will come back to you.

Title: Re: Macro question
Post by: jorgon on March 03, 2009, 08:55:30 PM
Edgar

Thanks for the bug report and the fix is here (http://www.jorgon.freeserve.co.uk/Goasm.zip) (GoAsm version 0.56.5b).