How does Memory Validator track COM objects?
Memory Validator hooks COM objects by hooking the Win32 functions that return COM objects. These objects are then queried for their QueryInterface, AddRef and Release function pointers. These functions are then hooked by rewriting the instruction stream using some proprietary code. The hooks then examine the return values to detect the reference count or returned object. Note that because rewriting the instruction stream is not a generally recommended practice this can sometimes fail (typically when the compiler optimises two functions to share some common code). Memory Validator tries to detect when hooking will fail and refuses to hook any functions that it knows it cannot hook safely. However some COM objects cannot be hooked safely – we have found that you can debug some COM objects using Memory Validator, and not others because of the internal structure of the COM objects. Memory Validator provides some controls for the COM hooking procedure. See the section entitled Instruction S