The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: jag on January 18, 2007, 04:26:18 AM

Title: ObjAsm32 COM method address
Post by: jag on January 18, 2007, 04:26:18 AM
Hi. I know there is a macro in ObjAsm32 called MethodAddr.
However, when trying with a COM method like:

mov ebx, $MethodAddr(d3d::IDirect3D9.CreateDevice)

..I get an error

Does ObjAsm32 have any mechanism to do so? or will I have to do it manually by looking at the vtable?

Thanks!
Title: Re: ObjAsm32 COM method address
Post by: Biterider on January 18, 2007, 08:12:52 AM
Hi jag
The MethodAddr and the new DbgIMT macros are intended for interface objects created with ObjAsm32. This is this way, since the compiler knows all about the internals of these objects.
For foreign objects/interfaces you have to extract the data by yourself, which is not too hard to do. Basically follow the interface pointer to the VMT and add the offset of the method you want to know. Finally read the value at this location and voila.

Regards,

Biterider

Title: Re: ObjAsm32 COM method address
Post by: jag on January 19, 2007, 12:17:27 AM
Okay, but is there a way I can use the DirectX Inc files to get the offset, rather than counting lines and multiplying by 4?
I would suspect your ObjAsm32 does this, as I see this is in ICall:

call (??Txo ptr [edx]).??MName

I am new to masm though and I can't figure out what those two question marks do or how you override the dot operator.
Title: Re: ObjAsm32 COM method address
Post by: jag on January 19, 2007, 12:26:02 AM
I figured it out if anyone wants to know:

mov eax, (IDirect3DDevice9_VMT PTR [eax]).EndScene

However, I'm still curious as to the question marks in your macro.
Title: Re: ObjAsm32 COM method address
Post by: Biterider on January 19, 2007, 07:04:24 AM
Hi jag
The 2 question marks are part of the symbol name. I use them for all ObjAsm32 internal symbols that I can reuse. Reusing symbols has 2 big advantages: you can speedup the compilation time and you will stay away from an internal ML bug. The other side of the coin is that you must pay attention with nested macros that use the same symbol!

Regards,

Biterider