Export (0) Print
Expand All
COM
Expand Minimize
0 out of 1 rated this helpful - Rate this topic

CoRegisterMallocSpy function

Registers an implementation of the IMallocSpy interface, thereafter requiring OLE to call its wrapper methods around every call to the corresponding IMalloc method.

Syntax


HRESULT CoRegisterMallocSpy(
  _In_  LPMALLOCSPY pMallocSpy
);

Parameters

pMallocSpy [in]

A pointer to an instance of the IMallocSpy implementation.

Return value

This function can return the standard return value E_INVALIDARG, as well as the following values.

Return codeDescription
S_OK

The object was successfully registered.

CO_E_OBJISREG

The object is already registered.

 

Remarks

The CoRegisterMallocSpy function registers the IMallocSpy object, which is used to debug calls to IMalloc methods. The function calls QueryInterface on the pointer pMallocSpy for the interface IID_IMallocSpy. This is to ensure that pMallocSpy really points to an implementation of IMallocSpy. By the rules of OLE, it is expected that a successful call to QueryInterface has added a reference (through the AddRef method) to the IMallocSpy object. That is, CoRegisterMallocSpy does not directly call AddRef on pMallocSpy, but fully expects that the QueryInterface call will.

When the IMallocSpy object is registered, whenever there is a call to one of the IMalloc methods, OLE first calls the corresponding IMallocSpy pre-method. Then, after executing the IMalloc method, OLE calls the corresponding IMallocSpy post-method. For example, whenever there is a call to IMalloc::Alloc, from whatever source, OLE calls IMallocSpy::PreAlloc, calls Alloc, and after that allocation is completed, calls IMallocSpy::PostAlloc.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Objbase.h

Library

Ole32.lib

DLL

Ole32.dll

See also

CoGetMalloc
CoRevokeMallocSpy
IMallocSpy

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.