рефераты конспекты курсовые дипломные лекции шпоры

Реферат Курсовая Конспект

AddRef_Pointer typedef PROTO :DWORD Release_Pointer typedef PROTO :DWORD

AddRef_Pointer typedef PROTO :DWORD Release_Pointer typedef PROTO :DWORD - раздел Образование, Accessing COM Objects from Assembly   In Keeping With The Masm32 Practice Of "loose" Type...

 

In keeping with the MASM32 practice of "loose" type checking, function parameters are just defined as DWORDs. Lots of work to set things up, but it does keeps lots of errors confined to compile time, not run time. In practice, we will wrap up these interface definitions in include files and keep them from cluttering up the source code.

 

One rather big compilation on defining an interface: MASM cannot resolve forward references like this, so we have to define them backwards, by defining the function prototype typedefs first, and the interface table last. The include files for the example program later on defines the interfaces this way.

 

To actually use an interface, you need a pointer to it.

 

The CoCreateInstance API can be used to return us this indirect pointer to an interface structure. It is one level removed from the vtable itself, and actually points to the "object" that holds the interface. The final structure looks like this:

 
 

 

There is a lot of indirection using this structure, it can drive you batty trying to write code to properly reference and de-reference these elements. Macros to simplify this task will be defined.

 

When the client makes a call to the COM library to create a COM object, it passes in the address where it wants the object pointer to be placed. This initial pointer is generically referred to as "ppv," from the C++ speak "pointer to pointer to (void)," where (void) means an unspecified type. It holds the address of another pointer ("pv"), and this pointer refers to a whole table of pointers, one table entry for each function of the interface.

 

For example, say we used CoCreateInstance and successfully got an interface pointer ppv, and wanted to see if it supports some other interface. We can call its QueryInterface method and request a new ppv (ppv2, pointer to an Interface) to the other interface (pIID, pointer to a Interface Identifying GUID) we are interested in. In C, QueryInterface has a prototype that would look like so:

 

(HRESULT) SomeObject::QueryInterface (this:pObject, IID:pGUID, ppv2:pInterface)

 

 

Such a call would look like this:


; get pointer to the object
mov eax, ppv

– Конец работы –

Эта тема принадлежит разделу:

Accessing COM Objects from Assembly

IUnknown methods IUnknown QueryInterface QueryInterface Pointer IUnknown AddRef AddRef Pointer IUnknown Release Release Pointer... AddRef Pointer typedef ptr AddRef Proto Release Pointer typedef ptr...

Если Вам нужно дополнительный материал на эту тему, или Вы не нашли то, что искали, рекомендуем воспользоваться поиском по нашей базе работ: AddRef_Pointer typedef PROTO :DWORD Release_Pointer typedef PROTO :DWORD

Что будем делать с полученным материалом:

Если этот материал оказался полезным ля Вас, Вы можете сохранить его на свою страничку в социальных сетях:

Все темы данного раздела:

Accessing COM Objects from Assembly
  Ernest Murphy ernie@surfree.com   Revised Dec 26 2000 for inclusion as part of MASM32 Revised July 10 2000 for the new form of coinvoke. &nb

IUnknown ENDS
  That's it, just 12 bytes long. It holds 3 DWORD pointers to the procedures that actually implement the methods. It is the infamous "vtable" you may have heard of. The poin

ADDR IID_SomeOtherInterface, ADDR ppv_new
  I hope you find this as wonderfully simple as I do.   Note we must pass in the pointer we used, this lets the interface know which object (literally &quo

ADDR ppnew
  Note that now the name decoration is done for us by the macro.   The only 'gotcha' (well, the most obvious) is that no parameters to a COM call should be pass

Хотите получать на электронную почту самые свежие новости?
Education Insider Sample
Подпишитесь на Нашу рассылку
Наша политика приватности обеспечивает 100% безопасность и анонимность Ваших E-Mail
Реклама
Соответствующий теме материал
  • Похожее
  • Популярное
  • Облако тегов
  • Здесь
  • Временно
  • Пусто
Теги