Index: /trunk/src/VBox/Main/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Main/Makefile.kmk	(revision 76070)
+++ /trunk/src/VBox/Main/Makefile.kmk	(revision 76071)
@@ -303,5 +303,9 @@
  VBoxSDS_TEMPLATE = VBOXMAINEXE
  VBoxSDS_DEFS.win += VBOX_COM_OUTOFPROC_MODULE
- VBoxSDS_DEFS.win += _WIN32_WINNT=0x0510
+ if "$(KBUILD_TYPE)" == "debug" && "$(USERNAME)" == "bird"
+VBoxSDS_DEFS.win += _WIN32_WINNT=0x0610 # ClientPID query requires vista+
+ else
+VBoxSDS_DEFS.win += _WIN32_WINNT=0x0510
+ endif
  VBoxSDS_INCS = \
  	include \
@@ -378,5 +382,9 @@
 endif
 VBoxSVC_DEFS.win += VBOX_COM_OUTOFPROC_MODULE
+ if "$(KBUILD_TYPE)" == "debug" && "$(USERNAME)" == "bird"
+VBoxSVC_DEFS.win += _WIN32_WINNT=0x0610 # ClientPID query requires vista+
+ else
 VBoxSVC_DEFS.win += _WIN32_WINNT=0x0510
+ endif
 # Try to load and use libhal at runtime for probing removable media
 # VBoxSVC_DEFS.linux += VBOX_USE_LIBHAL
Index: /trunk/src/VBox/Main/src-global/VirtualBoxSDSImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-global/VirtualBoxSDSImpl.cpp	(revision 76070)
+++ /trunk/src/VBox/Main/src-global/VirtualBoxSDSImpl.cpp	(revision 76071)
@@ -149,4 +149,12 @@
 {
     LogRel(("VirtualBoxSDS::registerVBoxSVC: aVBoxSVC=%p aPid=%u (%#x)\n", (IVBoxSVCRegistration *)aVBoxSVC, aPid, aPid));
+#ifdef DEBUG_bird
+    RPC_CALL_ATTRIBUTES_V2_W CallAttribs = { RPC_CALL_ATTRIBUTES_VERSION, RPC_QUERY_CLIENT_PID | RPC_QUERY_IS_CLIENT_LOCAL};
+    RPC_STATUS rcRpc = RpcServerInqCallAttributesW(NULL, &CallAttribs);
+    LogRel(("RpcServerInqCallAttributesW -> %#x ClientPID=%#x IsClientLocal=%d ProtocolSequence=%#x CallStatus=%#x CallType=%#x OpNum=%#x InterfaceUuid=%RTuuid\n",
+            rcRpc, CallAttribs.ClientPID, CallAttribs.IsClientLocal, CallAttribs.ProtocolSequence, CallAttribs.CallStatus,
+            CallAttribs.CallType, CallAttribs.OpNum, &CallAttribs.InterfaceUuid));
+#endif
+
     HRESULT hrc;
     if (   RT_VALID_PTR(aVBoxSVC)
Index: /trunk/src/VBox/Main/src-server/win/svcmain.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/win/svcmain.cpp	(revision 76070)
+++ /trunk/src/VBox/Main/src-server/win/svcmain.cpp	(revision 76071)
@@ -20,8 +20,8 @@
 *   Header Files                                                                                                                 *
 *********************************************************************************************************************************/
-#include <iprt/win/windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <tchar.h>
+# include <iprt/win/windows.h>
+#ifdef DEBUG_bird
+# include <RpcAsync.h>
+#endif
 
 #include "VBox/com/defs.h"
@@ -39,5 +39,4 @@
 #include <iprt/initterm.h>
 #include <iprt/string.h>
-#include <iprt/uni.h>
 #include <iprt/path.h>
 #include <iprt/getopt.h>
@@ -45,5 +44,7 @@
 #include <iprt/asm.h>
 
-#include <TlHelp32.h>
+//#ifdef VBOX_WITH_SDS
+//# include <TlHelp32.h>
+//#endif
 
 
@@ -220,8 +221,8 @@
 
 
-/* Passed to CreateThread to monitor the shutdown event */
-static DWORD WINAPI MonitorProc(void* pv)
-{
-    CExeModule* p = (CExeModule*)pv;
+/** Passed to CreateThread to monitor the shutdown event. */
+static DWORD WINAPI MonitorProc(void *pv)
+{
+    CExeModule *p = (CExeModule *)pv;
     p->MonitorShutdown();
     return 0;
@@ -461,4 +462,12 @@
 HRESULT VirtualBoxClassFactory::i_registerWithSds(IUnknown **ppOtherVirtualBox)
 {
+# ifdef DEBUG_bird
+    RPC_CALL_ATTRIBUTES_V2_W CallAttribs = { RPC_CALL_ATTRIBUTES_VERSION, RPC_QUERY_CLIENT_PID | RPC_QUERY_IS_CLIENT_LOCAL };
+    RPC_STATUS rcRpc = RpcServerInqCallAttributesW(NULL, &CallAttribs);
+    LogRel(("i_registerWithSds: RpcServerInqCallAttributesW -> %#x ClientPID=%#x IsClientLocal=%d ProtocolSequence=%#x CallStatus=%#x CallType=%#x OpNum=%#x InterfaceUuid=%RTuuid\n",
+            rcRpc, CallAttribs.ClientPID, CallAttribs.IsClientLocal, CallAttribs.ProtocolSequence, CallAttribs.CallStatus,
+            CallAttribs.CallType, CallAttribs.OpNum, &CallAttribs.InterfaceUuid));
+# endif
+
     /*
      * Connect to VBoxSDS.
@@ -505,4 +514,11 @@
 HRESULT VirtualBoxClassFactory::i_getVirtualBox(IUnknown **ppResult)
 {
+# ifdef DEBUG_bird
+    RPC_CALL_ATTRIBUTES_V2_W CallAttribs = { RPC_CALL_ATTRIBUTES_VERSION, RPC_QUERY_CLIENT_PID | RPC_QUERY_IS_CLIENT_LOCAL };
+    RPC_STATUS rcRpc = RpcServerInqCallAttributesW(NULL, &CallAttribs);
+    LogRel(("i_getVirtualBox: RpcServerInqCallAttributesW -> %#x ClientPID=%#x IsClientLocal=%d ProtocolSequence=%#x CallStatus=%#x CallType=%#x OpNum=%#x InterfaceUuid=%RTuuid\n",
+            rcRpc, CallAttribs.ClientPID, CallAttribs.IsClientLocal, CallAttribs.ProtocolSequence, CallAttribs.CallStatus,
+            CallAttribs.CallType, CallAttribs.OpNum, &CallAttribs.InterfaceUuid));
+# endif
     IUnknown *pObj = m_pObj;
     if (pObj)
@@ -537,4 +553,99 @@
 }
 
+#ifdef DEBUG_bird
+# include <psapi.h> /* for GetProcessImageFileNameW */
+
+/** Logs the RPC caller info to the release log. */
+static void logCaller(const char *pszFormat, ...)
+{
+    char szTmp[80];
+    va_list va;
+    va_start(va, pszFormat);
+    RTStrPrintfV(szTmp, sizeof(szTmp), pszFormat, va);
+    va_end(va);
+
+    RPC_CALL_ATTRIBUTES_V2_W CallAttribs = { RPC_CALL_ATTRIBUTES_VERSION, RPC_QUERY_CLIENT_PID | RPC_QUERY_IS_CLIENT_LOCAL };
+    RPC_STATUS rcRpc = RpcServerInqCallAttributesW(NULL, &CallAttribs);
+
+    RTUTF16 wszProcName[256];
+    wszProcName[0] = '\0';
+    if (rcRpc == 0 && CallAttribs.ClientPID != 0)
+    {
+        HANDLE hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, (DWORD)(uintptr_t)CallAttribs.ClientPID);
+        if (hProcess)
+        {
+            RT_ZERO(wszProcName);
+            GetProcessImageFileNameW(hProcess, wszProcName, RT_ELEMENTS(wszProcName) - 1);
+            CloseHandle(hProcess);
+        }
+    }
+    LogRel(("%s [rcRpc=%#x ClientPID=%#zx/%zu (%ls) IsClientLocal=%d ProtocolSequence=%#x CallStatus=%#x CallType=%#x OpNum=%#x InterfaceUuid=%RTuuid]\n",
+            szTmp, rcRpc, CallAttribs.ClientPID, CallAttribs.ClientPID, wszProcName, CallAttribs.IsClientLocal,
+            CallAttribs.ProtocolSequence, CallAttribs.CallStatus, CallAttribs.CallType, CallAttribs.OpNum,
+            &CallAttribs.InterfaceUuid));
+}
+
+/**
+ * Caller watcher wrapper exploration wrapping CComObjectCached.
+ * @sa @bugref{3300}
+ */
+template <class Base> class DebugWatcher : public Base
+{
+public:
+    DebugWatcher(void *a_pWhatever = NULL) : Base(a_pWhatever)
+    {
+    }
+
+    virtual ~DebugWatcher()
+    {
+    }
+
+    STDMETHOD_(ULONG, AddRef)() throw()
+    {
+        ULONG cRefs = Base::AddRef();
+        logCaller("AddRef -> %u", cRefs);
+        return cRefs;
+    }
+
+    STDMETHOD_(ULONG, Release)() throw()
+    {
+        ULONG cRefs = Base::Release();
+        logCaller("Release -> %u", cRefs);
+        return cRefs;
+    }
+
+    STDMETHOD(QueryInterface)(REFIID iid, void **ppvObj) throw()
+    {
+        HRESULT hrc = Base::QueryInterface(iid, ppvObj);
+        logCaller("QueryInterface %RTuuid -> %Rhrc %p", iid, hrc, *ppvObj);
+        return hrc;
+    }
+
+    static HRESULT WINAPI CreateInstance(DebugWatcher<Base> **pp) throw()
+    {
+        AssertReturn(pp, E_POINTER);
+        *pp = NULL;
+
+        HRESULT hrc = E_OUTOFMEMORY;
+        DebugWatcher<Base> *p = new (std::nothrow) DebugWatcher<Base>();
+        if (p)
+        {
+            p->SetVoid(NULL);
+            p->InternalFinalConstructAddRef();
+            hrc = p->_AtlInitialConstruct();
+            if (SUCCEEDED(hrc))
+                hrc = p->FinalConstruct();
+            p->InternalFinalConstructRelease();
+            if (FAILED(hrc))
+                delete p;
+            else
+                *pp = p;
+        }
+        return hrc;
+    }
+
+};
+
+#endif /* DEBUG_bird */
 
 /**
@@ -553,4 +664,7 @@
 STDMETHODIMP VirtualBoxClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppvObj)
 {
+# ifdef DEBUG_bird
+    logCaller("VirtualBoxClassFactory::CreateInstance: %RTuuid", riid);
+# endif
     HRESULT hrc = E_POINTER;
     if (ppvObj != NULL)
@@ -589,6 +703,11 @@
                         {
                             ATL::_pAtlModule->Lock();
+#ifdef DEBUG_bird
+                            DebugWatcher<ATL::CComObjectCached<VirtualBox>> *p;
+                            m_hrcCreate = hrc = DebugWatcher<ATL::CComObjectCached<VirtualBox>>::CreateInstance(&p);
+#else
                             ATL::CComObjectCached<VirtualBox> *p;
                             m_hrcCreate = hrc = ATL::CComObjectCached<VirtualBox>::CreateInstance(&p);
+#endif
                             if (SUCCEEDED(hrc))
                             {
@@ -935,12 +1054,12 @@
             case 'h':
             {
-                TCHAR txt[]= L"Options:\n\n"
-                             L"/RegServer:\tregister COM out-of-proc server\n"
-                             L"/UnregServer:\tunregister COM out-of-proc server\n"
-                             L"/ReregServer:\tunregister and register COM server\n"
-                             L"no options:\trun the server";
-                TCHAR title[]=_T("Usage");
+                static const WCHAR s_wszText[]  = L"Options:\n\n"
+                                                  L"/RegServer:\tregister COM out-of-proc server\n"
+                                                  L"/UnregServer:\tunregister COM out-of-proc server\n"
+                                                  L"/ReregServer:\tunregister and register COM server\n"
+                                                  L"no options:\trun the server";
+                static const WCHAR s_wszTitle[] = L"Usage";
                 fRun = false;
-                MessageBox(NULL, txt, title, MB_OK);
+                MessageBoxW(NULL, s_wszText, s_wszTitle, MB_OK);
                 return 0;
             }
@@ -948,13 +1067,13 @@
             case 'V':
             {
-                char *psz = NULL;
-                RTStrAPrintf(&psz, "%sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr());
-                PRTUTF16 txt = NULL;
-                RTStrToUtf16(psz, &txt);
-                TCHAR title[]=_T("Version");
+                static const WCHAR s_wszTitle[] = L"Version";
+                char         *pszText = NULL;
+                RTStrAPrintf(&pszText, "%sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr());
+                PRTUTF16     pwszText = NULL;
+                RTStrToUtf16(pszText, &pwszText);
+                RTStrFree(pszText);
+                MessageBoxW(NULL, pwszText, s_wszTitle, MB_OK);
+                RTUtf16Free(pwszText);
                 fRun = false;
-                MessageBox(NULL, txt, title, MB_OK);
-                RTStrFree(psz);
-                RTUtf16Free(txt);
                 return 0;
             }
