I am not quick sure about "this" in COM,

what does it usually hold ??

hehe I can't help it, I am newbie to COM so I will have lots more questions to come ^_^

but thankx in advance for all the help!

Posted on 2001-12-06 19:12:14 by Masata
"THIS" is the mysterious object reference. C++ silently, automatically passes THIS to the methods of a class. Straight C users (MASM too) have to pass it manually.

"Reference" just means the same as "AddressOf" in VB speak, or ADDR in MASM. It is the physical address where something is found.

By object reference I mean the address where the object is stored. An object is just a series of define bytes or structure. Each time an object is created, another chunk of memory is set aside for it, and the address where each one starts is called THIS.

Each object has it's own THIS. Since THIS is passed into each method (procedure) of the object/class, the proc code knows which object to work on.

It always works on THIS object.

Sorry, THIS is C++ speak, and a bit obscure. But it is very powerful, and it's how object orientated code works on an internal level.

Now THIS specifically points to the "vtable" pointer (reference) (address) inside the object. This dword holds the address of a series of dwords, each dword pointing to the starting address of each and every method/procedure of the object/class.

So, armed with a THIS, you can execute a procedure (let's do the third proc) of that class like so:

{push required parameters}
{also push THIS}
mov eax, THIS ; get address of the object, also address of vtable
mov eax, [eax + 3*SIZEOF DWORD] ; get address of third procedure
call [eax] ; do that proc/method

In practice, you don't really need to follow all this; the coinvoke macro follows this pattern to set up the call for you.

Hope this helps.
Posted on 2001-12-06 19:37:07 by Ernie
thank you!

Posted on 2001-12-07 01:27:25 by Masata

It is the physical address where something is found.

Actually it's the *logical* place where something is found, virtual
after going through the descriptor tables, and finally physical when
the page table translations are done :).

Sorry Ernie, just had to write that =).
Posted on 2001-12-07 10:57:01 by f0dder
... compiler! its a compiler!

Heheheheheh. I dont think i would like to work for you.. :grin: your toooo picky..


Posted on 2001-12-07 11:43:21 by NaN
;) NaN ;).
Only picky about some things. Pretty relaxed with a lot of things.
Totally gestapo about some things. Oi, I'm just human. I think.
Posted on 2001-12-07 11:51:01 by f0dder