Calling Convention for Notifications

The preceding discussion covered the COM RPC debugging architecture in terms of six debugger-notification APIs (DebugORPC...()). However, rather than being actual API-entry points in a static-linked or dynamically-linked library, these notifications use a somewhat unusual calling convention to communicate with the notification implementations, which are found inside debugger products. This somewhat strange calling convention is used for the following reasons:

The actual calling convention used is by its nature inherently processor and operating-system specific. On Win32 implementations, the default calling convention for notifications takes the form of a software exception, which is raised by a call to the RaiseException Win32 API:


VOID RaiseException(
   DWORD  dwExceptionCode,      // exception code
   DWORD  dwExceptionFlags,      // continuable exception flag
   DWORD  cArguments,         // number of arguments in array
   CONST DWORD *  lpArguments    // address of array of arguments
   );   

As used here, the arguments to this raised exception call in order are:


 typedef struct ORPC_DBG_ALL  {
   BYTE *            pSignature;
   RPCOLEMESSAGE *   pMessage;
   const IID *          iid;
   void*               reserved1;
   void*               reserved2;
   void*               pInterface;
   IUnknown *         pUnkObject;
   HRESULT         hresult;
   void *            pvBuffer;
   ULONG            cbBuffer;   
   ULONG *            lpcbBuffer; 
   void *             reserved3;
   } ORPC_DBG_ALL;

The pSignature member of this structure points to a sequence of bytes which contains:

The notifications specified here pass their arguments by filling in the appropriate structure members. See each notification description for details.

Using software exceptions for COM debugging notifications is inconvenient for in-process debugging. In-process debuggers can alternately get these notifications via direct calls into the debugger's code. The debugger which wants to be notified by a direct call passes in an IOrpcDebugNotify interface in the LPORPC_INIT_ARGS argument to DllDebugObjectRPCHook. If this interface pointer is available, COM makes the debug notifications by calling the methods on this interface. The methods all take an LPORPC_DBG_ALL as the only argument. The information passed in this structure is identical to that passed when the notification is done by raising a software exception.