Index: trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 51095)
+++ trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 51096)
@@ -9999,5 +9999,5 @@
 DECLCALLBACK(void) Console::drvStatus_UnitChanged(PPDMILEDCONNECTORS pInterface, unsigned iLUN)
 {
-    PDRVMAINSTATUS pThis = (PDRVMAINSTATUS)((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINSTATUS, ILedConnectors));
+    PDRVMAINSTATUS pThis = RT_FROM_MEMBER(pInterface, DRVMAINSTATUS, ILedConnectors);
     if (iLUN >= pThis->iFirstLUN && iLUN <= pThis->iLastLUN)
     {
@@ -10021,5 +10021,5 @@
 DECLCALLBACK(int) Console::drvStatus_MediumEjected(PPDMIMEDIANOTIFY pInterface, unsigned uLUN)
 {
-    PDRVMAINSTATUS pThis = (PDRVMAINSTATUS)((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINSTATUS, IMediaNotify));
+    PDRVMAINSTATUS pThis = RT_FROM_MEMBER(pInterface, DRVMAINSTATUS, IMediaNotify);
     PPDMDRVINS pDrvIns = pThis->pDrvIns;
     LogFunc(("uLUN=%d\n", uLUN));
Index: trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp	(revision 51095)
+++ trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp	(revision 51096)
@@ -284,7 +284,4 @@
 typedef VRDEVoiceOut * PVRDEVoiceOut;
 
-/** Makes a PDRVBLOCK out of a PPDMIBLOCK. */
-#define PDMIHOSTAUDIO_2_DRVAUDIOVRDE(pInterface)        ( (PDRVAUDIOVRDE)((uintptr_t)pInterface - RT_OFFSETOF(DRVAUDIOVRDE, IHostAudioR3)) )
-
 AudioVRDE::AudioVRDE(Console *console)
     : mpDrv(NULL),
@@ -684,5 +681,6 @@
 static DECLCALLBACK(int)  drvAudioVRDEInitOut(PPDMIHOSTAUDIO pInterface, PPDMHOSTVOICEOUT pHostVoiceOut, audsettings_t *as)
 {
-    PDRVAUDIOVRDE pDrv =  PDMIHOSTAUDIO_2_DRVAUDIOVRDE(pInterface);
+    PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudioR3);
+
     PVRDEVoiceOut pVRDEVoiceOut = (PVRDEVoiceOut)pHostVoiceOut;
     LogFlow(("DrvAudioVRDEInitOut: audio input begin cShift=%d\n", pHostVoiceOut->Props.cShift));
@@ -696,5 +694,5 @@
 {
     LogFlow(("DrvAudioVRDE: drvAudioVRDEInitIn \n"));
-    PDRVAUDIOVRDE pDrv =  PDMIHOSTAUDIO_2_DRVAUDIOVRDE(pInterface);
+    PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudioR3);
     PVRDEVoice pVRDEVoice = (PVRDEVoice)pHostVoiceIn;
     pHostVoiceIn->cSamples =  6174;
@@ -781,5 +779,5 @@
 static DECLCALLBACK(int) drvAudioVRDEPlayOut(PPDMIHOSTAUDIO pInterface, PPDMHOSTVOICEOUT pHostVoiceOut)
 {
-    PDRVAUDIOVRDE pDrv = PDMIHOSTAUDIO_2_DRVAUDIOVRDE(pInterface);
+    PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudioR3);
     PVRDEVoiceOut pVRDEVoiceOut = (PVRDEVoiceOut)pHostVoiceOut;
     int live;
@@ -834,5 +832,5 @@
 static DECLCALLBACK(void) drvAudioVRDEFiniIn(PPDMIHOSTAUDIO pInterface, PPDMHOSTVOICEIN hw)
 {
-    PDRVAUDIOVRDE pDrv = PDMIHOSTAUDIO_2_DRVAUDIOVRDE(pInterface);
+    PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudioR3);
     LogFlow(("DrvAudioVRDE: drvAudioVRDEFiniIn \n"));
     pDrv->pConsoleVRDPServer->SendAudioInputEnd(NULL);
@@ -841,5 +839,5 @@
 static DECLCALLBACK(void) drvAudioVRDEFiniOut(PPDMIHOSTAUDIO pInterface, PPDMHOSTVOICEOUT pHostVoiceOut)
 {
-    PDRVAUDIOVRDE pDrv = PDMIHOSTAUDIO_2_DRVAUDIOVRDE(pInterface);
+    PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudioR3);
     LogFlow(("DrvAudioVRDE: audio input end\n"));
 }
@@ -853,5 +851,5 @@
 static DECLCALLBACK(int) drvAudioVRDEDisableEnableIn(PPDMIHOSTAUDIO pInterface, PPDMHOSTVOICEIN pHostVoiceIn, int cmd)
 {
-    PDRVAUDIOVRDE pDrv = PDMIHOSTAUDIO_2_DRVAUDIOVRDE(pInterface);
+    PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudioR3);
 
     /* Initialize  VRDEVoice and return to VRDP server which returns this struct back to us
Index: trunk/src/VBox/Main/src-client/KeyboardImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/KeyboardImpl.cpp	(revision 51095)
+++ trunk/src/VBox/Main/src-client/KeyboardImpl.cpp	(revision 51096)
@@ -61,7 +61,4 @@
 } DRVMAINKEYBOARD, *PDRVMAINKEYBOARD;
 
-/** Converts PDMIVMMDEVCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
-#define PPDMIKEYBOARDCONNECTOR_2_MAINKEYBOARD(pInterface) ( (PDRVMAINKEYBOARD) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINKEYBOARD, IConnector)) )
-
 
 // constructor / destructor
@@ -287,5 +284,5 @@
 DECLCALLBACK(void) Keyboard::keyboardLedStatusChange(PPDMIKEYBOARDCONNECTOR pInterface, PDMKEYBLEDS enmLeds)
 {
-    PDRVMAINKEYBOARD pDrv = PPDMIKEYBOARDCONNECTOR_2_MAINKEYBOARD(pInterface);
+    PDRVMAINKEYBOARD pDrv = RT_FROM_MEMBER(pInterface, DRVMAINKEYBOARD, IConnector);
     pDrv->pKeyboard->getParent()->onKeyboardLedsChange(RT_BOOL(enmLeds & PDMKEYBLEDS_NUMLOCK),
                                                        RT_BOOL(enmLeds & PDMKEYBLEDS_CAPSLOCK),
@@ -298,5 +295,5 @@
 DECLCALLBACK(void) Keyboard::keyboardSetActive(PPDMIKEYBOARDCONNECTOR pInterface, bool fActive)
 {
-    PDRVMAINKEYBOARD pDrv = PPDMIKEYBOARDCONNECTOR_2_MAINKEYBOARD(pInterface);
+    PDRVMAINKEYBOARD pDrv = RT_FROM_MEMBER(pInterface, DRVMAINKEYBOARD, IConnector);
     if (fActive)
         pDrv->u32DevCaps |= KEYBOARD_DEVCAP_ENABLED;
Index: trunk/src/VBox/Main/src-client/VMMDevInterface.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/VMMDevInterface.cpp	(revision 51095)
+++ trunk/src/VBox/Main/src-client/VMMDevInterface.cpp	(revision 51096)
@@ -74,12 +74,4 @@
 } DRVMAINVMMDEV, *PDRVMAINVMMDEV;
 
-/** Converts PDMIVMMDEVCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
-#define PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, Connector)) )
-
-#ifdef VBOX_WITH_HGCM
-/** Converts PDMIHGCMCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
-#define PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, HGCMConnector)) )
-#endif
-
 //
 // constructor / destructor
@@ -164,12 +156,10 @@
                                            uint32_t fFlags, PCRTTIMESPEC pTimeSpecTS)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     Console *pConsole = pDrv->pVMMDev->getParent();
 
     /* Store that information in IGuest */
     Guest* guest = pConsole->getGuest();
-    Assert(guest);
-    if (!guest)
-        return;
+    AssertPtrReturnVoid(guest);
 
     guest->setAdditionsStatus((VBoxGuestFacilityType)uFacility, (VBoxGuestFacilityStatus)uStatus, fFlags, pTimeSpecTS);
@@ -186,5 +176,5 @@
                                               const uint8_t *puDetails, uint32_t cbDetails)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     AssertPtr(pDrv);
     Console *pConsole = pDrv->pVMMDev->getParent();
@@ -193,7 +183,5 @@
     /* Store that information in IGuest. */
     Guest* pGuest = pConsole->getGuest();
-    AssertPtr(pGuest);
-    if (!pGuest)
-        return;
+    AssertPtrReturnVoid(pGuest);
 
     pGuest->onUserStateChange(Bstr(pszUser), Bstr(pszDomain), (VBoxGuestUserState)uState,
@@ -214,17 +202,12 @@
 DECLCALLBACK(void) vmmdevUpdateGuestInfo(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestInfo *guestInfo)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
-
-    Assert(guestInfo);
-    if (!guestInfo)
-        return;
-
+    AssertPtrReturnVoid(guestInfo);
+    
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     Console *pConsole = pDrv->pVMMDev->getParent();
 
     /* Store that information in IGuest */
     Guest* guest = pConsole->getGuest();
-    Assert(guest);
-    if (!guest)
-        return;
+    AssertPtrReturnVoid(guest);
 
     if (guestInfo->interfaceVersion != 0)
@@ -266,5 +249,5 @@
                                           const char *pszName, uint32_t uRevision, uint32_t fFeatures)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     AssertPtr(pszName);
     Assert(uFullVersion);
@@ -272,7 +255,5 @@
     /* Store that information in IGuest. */
     Guest *pGuest = pDrv->pVMMDev->getParent()->getGuest();
-    Assert(pGuest);
-    if (!pGuest)
-        return;
+    AssertPtrReturnVoid(pGuest);
 
     /* Just pass it on... */
@@ -297,5 +278,5 @@
 DECLCALLBACK(void) vmmdevUpdateGuestCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     AssertPtr(pDrv);
     Console *pConsole = pDrv->pVMMDev->getParent();
@@ -303,7 +284,5 @@
     /* store that information in IGuest */
     Guest* pGuest = pConsole->getGuest();
-    AssertPtr(pGuest);
-    if (!pGuest)
-        return;
+    AssertPtrReturnVoid(pGuest);
 
     /*
@@ -330,5 +309,5 @@
 DECLCALLBACK(void) vmmdevUpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fNewCaps)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     Console *pConsole = pDrv->pVMMDev->getParent();
 
@@ -363,5 +342,5 @@
                                             void *pShape)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     Console *pConsole = pDrv->pVMMDev->getParent();
 
@@ -382,5 +361,5 @@
 DECLCALLBACK(int) iface_VideoAccelEnable(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, VBVAMEMORY *pVbvaMemory)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     Console *pConsole = pDrv->pVMMDev->getParent();
 
@@ -397,5 +376,5 @@
 DECLCALLBACK(void) iface_VideoAccelFlush(PPDMIVMMDEVCONNECTOR pInterface)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     Console *pConsole = pDrv->pVMMDev->getParent();
 
@@ -412,5 +391,5 @@
                                            uint32_t bpp, bool *fSupported)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     Console *pConsole = pDrv->pVMMDev->getParent();
 
@@ -441,5 +420,5 @@
 DECLCALLBACK(int) vmmdevGetHeightReduction(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *heightReduction)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     Console *pConsole = pDrv->pVMMDev->getParent();
 
@@ -456,5 +435,5 @@
 DECLCALLBACK(int) vmmdevSetCredentialsJudgementResult(PPDMIVMMDEVCONNECTOR pInterface, uint32_t u32Flags)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
 
     if (pDrv->pVMMDev)
@@ -466,5 +445,5 @@
 DECLCALLBACK(int) vmmdevSetVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cRect, PRTRECT pRect)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     Console *pConsole = pDrv->pVMMDev->getParent();
 
@@ -477,5 +456,5 @@
 DECLCALLBACK(int) vmmdevQueryVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcRect, PRTRECT pRect)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     Console *pConsole = pDrv->pVMMDev->getParent();
 
@@ -496,5 +475,5 @@
 DECLCALLBACK(int) vmmdevQueryStatisticsInterval(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pulInterval)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     Console *pConsole = pDrv->pVMMDev->getParent();
     ULONG          val = 0;
@@ -505,7 +484,5 @@
     /* store that information in IGuest */
     Guest* guest = pConsole->getGuest();
-    Assert(guest);
-    if (!guest)
-        return VERR_GENERAL_FAILURE;
+    AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
 
     guest->COMGETTER(StatisticsUpdateInterval)(&val);
@@ -524,5 +501,5 @@
 DECLCALLBACK(int) vmmdevQueryBalloonSize(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcbBalloon)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     Console *pConsole = pDrv->pVMMDev->getParent();
     ULONG          val = 0;
@@ -533,7 +510,5 @@
     /* store that information in IGuest */
     Guest* guest = pConsole->getGuest();
-    Assert(guest);
-    if (!guest)
-        return VERR_GENERAL_FAILURE;
+    AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
 
     guest->COMGETTER(MemoryBalloonSize)(&val);
@@ -552,5 +527,5 @@
 DECLCALLBACK(int) vmmdevIsPageFusionEnabled(PPDMIVMMDEVCONNECTOR pInterface, bool *pfPageFusionEnabled)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     Console *pConsole = pDrv->pVMMDev->getParent();
     BOOL           val = 0;
@@ -561,7 +536,5 @@
     /* store that information in IGuest */
     Guest* guest = pConsole->getGuest();
-    Assert(guest);
-    if (!guest)
-        return VERR_GENERAL_FAILURE;
+    AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
 
     *pfPageFusionEnabled = !!guest->isPageFusionEnabled();
@@ -579,16 +552,12 @@
 DECLCALLBACK(int) vmmdevReportStatistics(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestStatistics *pGuestStats)
 {
-    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
-    Console *pConsole = pDrv->pVMMDev->getParent();
-
-    Assert(pGuestStats);
-    if (!pGuestStats)
-        return VERR_INVALID_POINTER;
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
+    Console *pConsole = pDrv->pVMMDev->getParent();
+
+    AssertPtrReturn(pGuestStats, VERR_INVALID_POINTER);
 
     /* store that information in IGuest */
     Guest* guest = pConsole->getGuest();
-    Assert(guest);
-    if (!guest)
-        return VERR_GENERAL_FAILURE;
+    AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
 
     if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_IDLE)
@@ -633,5 +602,5 @@
     LogSunlover(("Enter\n"));
 
-    PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
 
     if (    !pServiceLocation
@@ -652,5 +621,5 @@
     LogSunlover(("Enter\n"));
 
-    PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
 
     if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
@@ -665,5 +634,5 @@
     LogSunlover(("Enter\n"));
 
-    PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
+    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
 
     if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
