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
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 ?
Hi ToutEnMasm,
I was just bored, I don't generally use any macros other than CoInvoke, don't like them much.
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 ?
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]
Hi Edgar
I'm looking into this one, and will come back to you.
Edgar
Thanks for the bug report and the fix is here (http://www.jorgon.freeserve.co.uk/Goasm.zip) (GoAsm version 0.56.5b).