Index: /trunk/include/VBox/intnet.h
===================================================================
--- /trunk/include/VBox/intnet.h	(revision 28705)
+++ /trunk/include/VBox/intnet.h	(revision 28706)
@@ -39,7 +39,4 @@
 RT_C_DECLS_BEGIN
 
-
-/** Pointer to an internal network ring-0 instance. */
-typedef struct INTNET *PINTNET;
 
 /**
@@ -749,5 +746,5 @@
  * The trunk connection type.
  *
- * Used by INTNETR0Open and assoicated interfaces.
+ * Used by IntNetR0Open and assoicated interfaces.
  */
 typedef enum INTNETTRUNKTYPE
@@ -773,5 +770,5 @@
 } INTNETTRUNKTYPE;
 
-/** @name INTNETR0Open flags.
+/** @name IntNetR0Open flags.
  * @{ */
 /** Share the MAC address with the host when sending something to the wire via the trunk.
@@ -808,6 +805,6 @@
 
 /**
- * Request buffer for INTNETR0OpenReq / VMMR0_DO_INTNET_OPEN.
- * @see INTNETR0Open.
+ * Request buffer for IntNetR0OpenReq / VMMR0_DO_INTNET_OPEN.
+ * @see IntNetR0Open.
  */
 typedef struct INTNETOPENREQ
@@ -834,13 +831,13 @@
     INTNETIFHANDLE  hIf;
 } INTNETOPENREQ;
-/** Pointer to an INTNETR0OpenReq / VMMR0_DO_INTNET_OPEN request buffer. */
+/** Pointer to an IntNetR0OpenReq / VMMR0_DO_INTNET_OPEN request buffer. */
 typedef INTNETOPENREQ *PINTNETOPENREQ;
 
-INTNETR0DECL(int) INTNETR0OpenReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETOPENREQ pReq);
-
-
-/**
- * Request buffer for INTNETR0IfCloseReq / VMMR0_DO_INTNET_IF_CLOSE.
- * @see INTNETR0IfClose.
+INTNETR0DECL(int) IntNetR0OpenReq(PSUPDRVSESSION pSession, PINTNETOPENREQ pReq);
+
+
+/**
+ * Request buffer for IntNetR0IfCloseReq / VMMR0_DO_INTNET_IF_CLOSE.
+ * @see IntNetR0IfClose.
  */
 typedef struct INTNETIFCLOSEREQ
@@ -854,13 +851,15 @@
     INTNETIFHANDLE  hIf;
 } INTNETIFCLOSEREQ;
-/** Pointer to an INTNETR0IfCloseReq / VMMR0_DO_INTNET_IF_CLOSE request buffer. */
+/** Pointer to an IntNetR0IfCloseReq / VMMR0_DO_INTNET_IF_CLOSE request
+ *  buffer. */
 typedef INTNETIFCLOSEREQ *PINTNETIFCLOSEREQ;
 
-INTNETR0DECL(int) INTNETR0IfCloseReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFCLOSEREQ pReq);
-
-
-/**
- * Request buffer for INTNETR0IfGetRing3BufferReq / VMMR0_DO_INTNET_IF_GET_RING3_BUFFER.
- * @see INTNETR0IfGetRing3Buffer.
+INTNETR0DECL(int) IntNetR0IfCloseReq(PSUPDRVSESSION pSession, PINTNETIFCLOSEREQ pReq);
+
+
+/**
+ * Request buffer for IntNetR0IfGetRing3BufferReq /
+ * VMMR0_DO_INTNET_IF_GET_RING3_BUFFER.
+ * @see IntNetR0IfGetRing3Buffer.
  */
 typedef struct INTNETIFGETRING3BUFFERREQ
@@ -876,13 +875,15 @@
     R3PTRTYPE(PINTNETBUF)   pRing3Buf;
 } INTNETIFGETRING3BUFFERREQ;
-/** Pointer to an INTNETR0IfGetRing3BufferReq / VMMR0_DO_INTNET_IF_GET_RING3_BUFFER request buffer. */
+/** Pointer to an IntNetR0IfGetRing3BufferReq /
+ *  VMMR0_DO_INTNET_IF_GET_RING3_BUFFER request buffer. */
 typedef INTNETIFGETRING3BUFFERREQ *PINTNETIFGETRING3BUFFERREQ;
 
-INTNETR0DECL(int) INTNETR0IfGetRing3BufferReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFGETRING3BUFFERREQ pReq);
-
-
-/**
- * Request buffer for INTNETR0IfSetPromiscuousModeReq / VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE.
- * @see INTNETR0IfSetPromiscuousMode.
+INTNETR0DECL(int) IntNetR0IfGetRing3BufferReq(PSUPDRVSESSION pSession, PINTNETIFGETRING3BUFFERREQ pReq);
+
+
+/**
+ * Request buffer for IntNetR0IfSetPromiscuousModeReq /
+ * VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE.
+ * @see IntNetR0IfSetPromiscuousMode.
  */
 typedef struct INTNETIFSETPROMISCUOUSMODEREQ
@@ -898,13 +899,15 @@
     bool            fPromiscuous;
 } INTNETIFSETPROMISCUOUSMODEREQ;
-/** Pointer to an INTNETR0IfSetPromiscuousModeReq / VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE request buffer. */
+/** Pointer to an IntNetR0IfSetPromiscuousModeReq /
+ *  VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE request buffer. */
 typedef INTNETIFSETPROMISCUOUSMODEREQ *PINTNETIFSETPROMISCUOUSMODEREQ;
 
-INTNETR0DECL(int) INTNETR0IfSetPromiscuousModeReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFSETPROMISCUOUSMODEREQ pReq);
-
-
-/**
- * Request buffer for INTNETR0IfSetMacAddressReq / VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS.
- * @see INTNETR0IfSetMacAddress.
+INTNETR0DECL(int) IntNetR0IfSetPromiscuousModeReq(PSUPDRVSESSION pSession, PINTNETIFSETPROMISCUOUSMODEREQ pReq);
+
+
+/**
+ * Request buffer for IntNetR0IfSetMacAddressReq /
+ * VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS.
+ * @see IntNetR0IfSetMacAddress.
  */
 typedef struct INTNETIFSETMACADDRESSREQ
@@ -920,13 +923,14 @@
     RTMAC           Mac;
 } INTNETIFSETMACADDRESSREQ;
-/** Pointer to an INTNETR0IfSetMacAddressReq / VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS request buffer. */
+/** Pointer to an IntNetR0IfSetMacAddressReq /
+ *  VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS request buffer. */
 typedef INTNETIFSETMACADDRESSREQ *PINTNETIFSETMACADDRESSREQ;
 
-INTNETR0DECL(int) INTNETR0IfSetMacAddressReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFSETMACADDRESSREQ pReq);
-
-
-/**
- * Request buffer for INTNETR0IfSetActiveReq / VMMR0_DO_INTNET_IF_SET_ACTIVE.
- * @see INTNETR0IfSetActive.
+INTNETR0DECL(int) IntNetR0IfSetMacAddressReq(PSUPDRVSESSION pSession, PINTNETIFSETMACADDRESSREQ pReq);
+
+
+/**
+ * Request buffer for IntNetR0IfSetActiveReq / VMMR0_DO_INTNET_IF_SET_ACTIVE.
+ * @see IntNetR0IfSetActive.
  */
 typedef struct INTNETIFSETACTIVEREQ
@@ -942,13 +946,14 @@
     bool            fActive;
 } INTNETIFSETACTIVEREQ;
-/** Pointer to an INTNETR0IfSetActiveReq / VMMR0_DO_INTNET_IF_SET_ACTIVE request buffer. */
+/** Pointer to an IntNetR0IfSetActiveReq / VMMR0_DO_INTNET_IF_SET_ACTIVE
+ *  request buffer. */
 typedef INTNETIFSETACTIVEREQ *PINTNETIFSETACTIVEREQ;
 
-INTNETR0DECL(int) INTNETR0IfSetActiveReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFSETACTIVEREQ pReq);
-
-
-/**
- * Request buffer for INTNETR0IfSendReq / VMMR0_DO_INTNET_IF_SEND.
- * @see INTNETR0IfSend.
+INTNETR0DECL(int) IntNetR0IfSetActiveReq(PSUPDRVSESSION pSession, PINTNETIFSETACTIVEREQ pReq);
+
+
+/**
+ * Request buffer for IntNetR0IfSendReq / VMMR0_DO_INTNET_IF_SEND.
+ * @see IntNetR0IfSend.
  */
 typedef struct INTNETIFSENDREQ
@@ -962,13 +967,13 @@
     INTNETIFHANDLE  hIf;
 } INTNETIFSENDREQ;
-/** Pointer to an INTNETR0IfSend() argument package. */
+/** Pointer to an IntNetR0IfSend() argument package. */
 typedef INTNETIFSENDREQ *PINTNETIFSENDREQ;
 
-INTNETR0DECL(int) INTNETR0IfSendReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFSENDREQ pReq);
-
-
-/**
- * Request buffer for INTNETR0IfWaitReq / VMMR0_DO_INTNET_IF_WAIT.
- * @see INTNETR0IfWait.
+INTNETR0DECL(int) IntNetR0IfSendReq(PSUPDRVSESSION pSession, PINTNETIFSENDREQ pReq);
+
+
+/**
+ * Request buffer for IntNetR0IfWaitReq / VMMR0_DO_INTNET_IF_WAIT.
+ * @see IntNetR0IfWait.
  */
 typedef struct INTNETIFWAITREQ
@@ -984,8 +989,8 @@
     uint32_t        cMillies;
 } INTNETIFWAITREQ;
-/** Pointer to an INTNETR0IfWaitReq / VMMR0_DO_INTNET_IF_WAIT request buffer. */
+/** Pointer to an IntNetR0IfWaitReq / VMMR0_DO_INTNET_IF_WAIT request buffer. */
 typedef INTNETIFWAITREQ *PINTNETIFWAITREQ;
 
-INTNETR0DECL(int) INTNETR0IfWaitReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFWAITREQ pReq);
+INTNETR0DECL(int) IntNetR0IfWaitReq(PSUPDRVSESSION pSession, PINTNETIFWAITREQ pReq);
 
 
@@ -995,110 +1000,19 @@
  */
 
-/**
- * Create an instance of the Ring-0 internal networking service.
- *
- * @returns VBox status code.
- * @param   ppIntNet    Where to store the instance pointer.
- */
-INTNETR0DECL(int) INTNETR0Create(PINTNET *ppIntNet);
-
-/**
- * Destroys an instance of the Ring-0 internal networking service.
- *
- * @param   pIntNet     Pointer to the instance data.
- */
-INTNETR0DECL(void) INTNETR0Destroy(PINTNET pIntNet);
-
-/**
- * Opens a network interface and connects it to the specified network.
- *
- * @returns VBox status code.
- * @param   pIntNet         The internal network instance.
- * @param   pSession        The session handle.
- * @param   pszNetwork      The network name.
- * @param   enmTrunkType    The trunk type.
- * @param   pszTrunk        The trunk name. Its meaning is specfic to the type.
- * @param   fFlags          Flags, see INTNET_OPEN_FLAGS_*.
- * @param   fRestrictAccess Whether new participants should be subjected to access check or not.
- * @param   cbSend          The send buffer size.
- * @param   cbRecv          The receive buffer size.
- * @param   phIf            Where to store the handle to the network interface.
- */
-INTNETR0DECL(int) INTNETR0Open(PINTNET pIntNet, PSUPDRVSESSION pSession, const char *pszNetwork,
-                               INTNETTRUNKTYPE enmTrunkType, const char *pszTrunk, uint32_t fFlags,
-                               unsigned cbSend, unsigned cbRecv, PINTNETIFHANDLE phIf);
-
-/**
- * Close an interface.
- *
- * @returns VBox status code.
- * @param   pIntNet     The instance handle.
- * @param   hIf         The interface handle.
- * @param   pSession        The caller's session.
- */
-INTNETR0DECL(int) INTNETR0IfClose(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession);
-
-/**
- * Gets the ring-0 address of the current buffer.
- *
- * @returns VBox status code.
- * @param   pIntNet     The instance data.
- * @param   hIf         The interface handle.
- * @param   pSession        The caller's session.
- * @param   ppRing0Buf  Where to store the address of the ring-3 mapping.
- */
-INTNETR0DECL(int) INTNETR0IfGetRing0Buffer(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, PINTNETBUF *ppRing0Buf);
-
-/**
- * Maps the default buffer into ring 3.
- *
- * @returns VBox status code.
- * @param   pIntNet         The instance data.
- * @param   hIf             The interface handle.
- * @param   pSession        The caller's session.
- * @param   ppRing3Buf      Where to store the address of the ring-3 mapping.
- */
-INTNETR0DECL(int) INTNETR0IfGetRing3Buffer(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, R3PTRTYPE(PINTNETBUF) *ppRing3Buf);
-
-/**
- * Sets the promiscuous mode property of an interface.
- *
- * @returns VBox status code.
- * @param   pIntNet         The instance handle.
- * @param   hIf             The interface handle.
- * @param   pSession        The caller's session.
- * @param   fPromiscuous    Set if the interface should be in promiscuous mode, clear if not.
- */
-INTNETR0DECL(int) INTNETR0IfSetPromiscuousMode( PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, bool fPromiscuous);
-INTNETR0DECL(int) INTNETR0IfSetMacAddress(      PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, PCRTMAC pMac);
-INTNETR0DECL(int) INTNETR0IfSetActive(          PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, bool fActive);
-
-/**
- * Sends one or more frames.
- *
- * The function will first the frame which is passed as the optional
- * arguments pvFrame and cbFrame. These are optional since it also
- * possible to chain together one or more frames in the send buffer
- * which the function will process after considering it's arguments.
- *
- * @returns VBox status code.
- * @param   pIntNet     The instance data.
- * @param   hIf         The interface handle.
- * @param   pSession    The caller's session.
- */
-INTNETR0DECL(int) INTNETR0IfSend(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession);
-
-/**
- * Wait for the interface to get signaled.
- * The interface will be signaled when is put into the receive buffer.
- *
- * @returns VBox status code.
- * @param   pIntNet         The instance handle.
- * @param   hIf             The interface handle.
- * @param   pSession        The caller's session.
- * @param   cMillies        Number of milliseconds to wait. RT_INDEFINITE_WAIT should be
- *                          used if indefinite wait is desired.
- */
-INTNETR0DECL(int) INTNETR0IfWait(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, uint32_t cMillies);
+INTNETR0DECL(int)      IntNetR0Init(void);
+INTNETR0DECL(void)     IntNetR0Term(void);
+INTNETR0DECL(int)      IntNetR0Open(PSUPDRVSESSION pSession, const char *pszNetwork,
+                                    INTNETTRUNKTYPE enmTrunkType, const char *pszTrunk, uint32_t fFlags,
+                                    uint32_t cbSend, uint32_t cbRecv, PINTNETIFHANDLE phIf);
+INTNETR0DECL(uint32_t) IntNetR0GetNetworkCount(void);
+
+INTNETR0DECL(int) IntNetR0IfClose(             INTNETIFHANDLE hIf, PSUPDRVSESSION pSession);
+INTNETR0DECL(int) IntNetR0IfGetRing0Buffer(    INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, PINTNETBUF *ppRing0Buf);
+INTNETR0DECL(int) IntNetR0IfGetRing3Buffer(    INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, R3PTRTYPE(PINTNETBUF) *ppRing3Buf);
+INTNETR0DECL(int) IntNetR0IfSetPromiscuousMode(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, bool fPromiscuous);
+INTNETR0DECL(int) IntNetR0IfSetMacAddress(     INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, PCRTMAC pMac);
+INTNETR0DECL(int) IntNetR0IfSetActive(         INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, bool fActive);
+INTNETR0DECL(int) IntNetR0IfSend(              INTNETIFHANDLE hIf, PSUPDRVSESSION pSession);
+INTNETR0DECL(int) IntNetR0IfWait(              INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, uint32_t cMillies);
 
 /** @} */
Index: /trunk/include/VBox/vmm.h
===================================================================
--- /trunk/include/VBox/vmm.h	(revision 28705)
+++ /trunk/include/VBox/vmm.h	(revision 28706)
@@ -325,19 +325,19 @@
     /** The start of the R0 service operations. */
     VMMR0_DO_SRV_START,
-    /** Call INTNETR0Open(). */
+    /** Call IntNetR0Open(). */
     VMMR0_DO_INTNET_OPEN,
-    /** Call INTNETR0IfClose(). */
+    /** Call IntNetR0IfClose(). */
     VMMR0_DO_INTNET_IF_CLOSE,
-    /** Call INTNETR0IfGetRing3Buffer(). */
+    /** Call IntNetR0IfGetRing3Buffer(). */
     VMMR0_DO_INTNET_IF_GET_RING3_BUFFER,
-    /** Call INTNETR0IfSetPromiscuousMode(). */
+    /** Call IntNetR0IfSetPromiscuousMode(). */
     VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE,
-    /** Call INTNETR0IfSetMacAddress(). */
+    /** Call IntNetR0IfSetMacAddress(). */
     VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS,
-    /** Call INTNETR0IfSetActive(). */
+    /** Call IntNetR0IfSetActive(). */
     VMMR0_DO_INTNET_IF_SET_ACTIVE,
-    /** Call INTNETR0IfSend(). */
+    /** Call IntNetR0IfSend(). */
     VMMR0_DO_INTNET_IF_SEND,
-    /** Call INTNETR0IfWait(). */
+    /** Call IntNetR0IfWait(). */
     VMMR0_DO_INTNET_IF_WAIT,
     /** The end of the R0 service operations. */
Index: /trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp
===================================================================
--- /trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp	(revision 28705)
+++ /trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp	(revision 28706)
@@ -385,4 +385,6 @@
 typedef struct INTNET
 {
+    /** Magic number (INTNET_MAGIC). */
+    uint32_t volatile       u32Magic;
     /** Mutex protecting the creation, opening and destruction of both networks and
      * interfaces.  (This means all operations affecting the pNetworks list.) */
@@ -393,5 +395,16 @@
     RTHANDLETABLE           hHtIfs;
 } INTNET;
-
+/** Pointer to an internal network ring-0 instance. */
+typedef struct INTNET *PINTNET;
+
+/** Magic number for the internal network instance data (Hayao Miyazaki). */
+#define INTNET_MAGIC        UINT32_C(0x19410105)
+
+
+/*******************************************************************************
+*   Global Variables                                                           *
+*******************************************************************************/
+/** Pointer to the internal network instance data. */
+static PINTNET volatile g_pIntNet = NULL;
 
 
@@ -2553,5 +2566,5 @@
          * Edit the source address so that it it's the same as the host.
          */
-        /* ASSUME frame from INTNETR0IfSend! */
+        /* ASSUME frame from IntNetR0IfSend! */
         AssertReturnVoid(pSG->cSegsUsed == 1);
         AssertReturnVoid(pSG->cbTotal >= sizeof(RTNETETHERHDR));
@@ -3227,16 +3240,18 @@
  *
  * @returns VBox status code.
- * @param   pIntNet     The instance data.
  * @param   hIf         The interface handle.
  * @param   pSession    The caller's session.
  */
-INTNETR0DECL(int) INTNETR0IfSend(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession)
-{
-    Log5(("INTNETR0IfSend: pIntNet=%p hIf=%RX32\n", pIntNet, hIf));
+INTNETR0DECL(int) IntNetR0IfSend(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession)
+{
+    Log5(("IntNetR0IfSend: hIf=%RX32\n", hIf));
 
     /*
      * Validate input and translate the handle.
      */
-    AssertReturn(pIntNet, VERR_INVALID_PARAMETER);
+    PINTNET pIntNet = g_pIntNet;
+    AssertPtrReturn(pIntNet, VERR_INVALID_PARAMETER);
+    AssertReturn(pIntNet->u32Magic, VERR_INVALID_MAGIC);
+
     PINTNETIF pIf = (PINTNETIF)RTHandleTableLookupWithCtx(pIntNet->hHtIfs, hIf, pSession);
     if (!pIf)
@@ -3335,16 +3350,15 @@
 
 /**
- * VMMR0 request wrapper for INTNETR0IfSend.
- *
- * @returns see INTNETR0IfSend.
- * @param   pIntNet         The internal networking instance.
+ * VMMR0 request wrapper for IntNetR0IfSend.
+ *
+ * @returns see IntNetR0IfSend.
  * @param   pSession        The caller's session.
  * @param   pReq            The request packet.
  */
-INTNETR0DECL(int) INTNETR0IfSendReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFSENDREQ pReq)
+INTNETR0DECL(int) IntNetR0IfSendReq(PSUPDRVSESSION pSession, PINTNETIFSENDREQ pReq)
 {
     if (RT_UNLIKELY(pReq->Hdr.cbReq != sizeof(*pReq)))
         return VERR_INVALID_PARAMETER;
-    return INTNETR0IfSend(pIntNet, pReq->hIf, pSession);
+    return IntNetR0IfSend(pReq->hIf, pSession);
 }
 
@@ -3354,17 +3368,19 @@
  *
  * @returns VBox status code.
- * @param   pIntNet         The instance data.
  * @param   hIf             The interface handle.
  * @param   pSession        The caller's session.
  * @param   ppRing3Buf      Where to store the address of the ring-3 mapping.
  */
-INTNETR0DECL(int) INTNETR0IfGetRing3Buffer(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, R3PTRTYPE(PINTNETBUF) *ppRing3Buf)
-{
-    LogFlow(("INTNETR0IfGetRing3Buffer: pIntNet=%p hIf=%RX32 ppRing3Buf=%p\n", pIntNet, hIf, ppRing3Buf));
+INTNETR0DECL(int) IntNetR0IfGetRing3Buffer(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, R3PTRTYPE(PINTNETBUF) *ppRing3Buf)
+{
+    LogFlow(("IntNetR0IfGetRing3Buffer: hIf=%RX32 ppRing3Buf=%p\n", hIf, ppRing3Buf));
 
     /*
      * Validate input.
      */
-    AssertReturn(pIntNet, VERR_INVALID_PARAMETER);
+    PINTNET pIntNet = g_pIntNet;
+    AssertPtrReturn(pIntNet, VERR_INVALID_PARAMETER);
+    AssertReturn(pIntNet->u32Magic, VERR_INVALID_MAGIC);
+
     AssertPtrReturn(ppRing3Buf, VERR_INVALID_PARAMETER);
     *ppRing3Buf = 0;
@@ -3387,5 +3403,5 @@
 
     intnetR0IfRelease(pIf, pSession);
-    LogFlow(("INTNETR0IfGetRing3Buffer: returns %Rrc *ppRing3Buf=%p\n", rc, *ppRing3Buf));
+    LogFlow(("IntNetR0IfGetRing3Buffer: returns %Rrc *ppRing3Buf=%p\n", rc, *ppRing3Buf));
     return rc;
 }
@@ -3393,16 +3409,15 @@
 
 /**
- * VMMR0 request wrapper for INTNETR0IfGetRing3Buffer.
- *
- * @returns see INTNETR0IfGetRing3Buffer.
- * @param   pIntNet         The internal networking instance.
+ * VMMR0 request wrapper for IntNetR0IfGetRing3Buffer.
+ *
+ * @returns see IntNetR0IfGetRing3Buffer.
  * @param   pSession        The caller's session.
  * @param   pReq            The request packet.
  */
-INTNETR0DECL(int) INTNETR0IfGetRing3BufferReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFGETRING3BUFFERREQ pReq)
+INTNETR0DECL(int) IntNetR0IfGetRing3BufferReq(PSUPDRVSESSION pSession, PINTNETIFGETRING3BUFFERREQ pReq)
 {
     if (RT_UNLIKELY(pReq->Hdr.cbReq != sizeof(*pReq)))
         return VERR_INVALID_PARAMETER;
-    return INTNETR0IfGetRing3Buffer(pIntNet, pReq->hIf, pSession, &pReq->pRing3Buf);
+    return IntNetR0IfGetRing3Buffer(pReq->hIf, pSession, &pReq->pRing3Buf);
 }
 
@@ -3412,19 +3427,21 @@
  *
  * @returns VBox status code.
- * @param   pIntNet         The instance data.
  * @param   hIf             The interface handle.
  * @param   pSession        The caller's session.
  * @param   ppRing0Buf      Where to store the address of the ring-3 mapping.
  */
-INTNETR0DECL(int) INTNETR0IfGetRing0Buffer(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, PINTNETBUF *ppRing0Buf)
-{
-    LogFlow(("INTNETR0IfGetRing0Buffer: pIntNet=%p hIf=%RX32 ppRing0Buf=%p\n", pIntNet, hIf, ppRing0Buf));
+INTNETR0DECL(int) IntNetR0IfGetRing0Buffer(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, PINTNETBUF *ppRing0Buf)
+{
+    LogFlow(("IntNetR0IfGetRing0Buffer: hIf=%RX32 ppRing0Buf=%p\n", hIf, ppRing0Buf));
 
     /*
      * Validate input.
      */
+    PINTNET pIntNet = g_pIntNet;
+    AssertPtrReturn(pIntNet, VERR_INVALID_PARAMETER);
+    AssertReturn(pIntNet->u32Magic, VERR_INVALID_MAGIC);
+
     AssertPtrReturn(ppRing0Buf, VERR_INVALID_PARAMETER);
     *ppRing0Buf = NULL;
-    AssertPtrReturn(pIntNet, VERR_INVALID_PARAMETER);
     PINTNETIF pIf = (PINTNETIF)RTHandleTableLookupWithCtx(pIntNet->hHtIfs, hIf, pSession);
     if (!pIf)
@@ -3443,5 +3460,5 @@
     }
     intnetR0IfRelease(pIf, pSession);
-    LogFlow(("INTNETR0IfGetRing0Buffer: returns %Rrc *ppRing0Buf=%p\n", rc, *ppRing0Buf));
+    LogFlow(("IntNetR0IfGetRing0Buffer: returns %Rrc *ppRing0Buf=%p\n", rc, *ppRing0Buf));
     return rc;
 }
@@ -3453,15 +3470,17 @@
  *
  * @returns VBox status code.
- * @param   pIntNet     The instance data.
  * @param   hIF         The interface handle.
  * @param   paPages     Where to store the addresses. (The reserved fields will be set to zero.)
  * @param   cPages
  */
-INTNETR0DECL(int) INTNETR0IfGetPhysBuffer(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPPAGE paPages, unsigned cPages)
+INTNETR0DECL(int) IntNetR0IfGetPhysBuffer(INTNETIFHANDLE hIf, PSUPPAGE paPages, unsigned cPages)
 {
     /*
      * Validate input.
      */
-    AssertReturn(pIntNet, VERR_INVALID_PARAMETER);
+    PINTNET pIntNet = g_pIntNet;
+    AssertPtrReturn(pIntNet, VERR_INVALID_PARAMETER);
+    AssertReturn(pIntNet->u32Magic, VERR_INVALID_MAGIC);
+
     AssertPtrReturn(paPages, VERR_INVALID_PARAMETER);
     AssertPtrReturn((uint8_t *)&paPages[cPages] - 1, VERR_INVALID_PARAMETER);
@@ -3492,21 +3511,23 @@
  *
  * @returns VBox status code.
- * @param   pIntNet         The instance handle.
  * @param   hIf             The interface handle.
  * @param   pSession        The caller's session.
  * @param   fPromiscuous    Set if the interface should be in promiscuous mode, clear if not.
  */
-INTNETR0DECL(int) INTNETR0IfSetPromiscuousMode(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, bool fPromiscuous)
-{
-    LogFlow(("INTNETR0IfSetPromiscuousMode: pIntNet=%p hIf=%RX32 fPromiscuous=%d\n", pIntNet, hIf, fPromiscuous));
+INTNETR0DECL(int) IntNetR0IfSetPromiscuousMode(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, bool fPromiscuous)
+{
+    LogFlow(("IntNetR0IfSetPromiscuousMode: hIf=%RX32 fPromiscuous=%d\n", hIf, fPromiscuous));
 
     /*
      * Validate & translate input.
      */
-    AssertReturn(pIntNet, VERR_INVALID_PARAMETER);
+    PINTNET pIntNet = g_pIntNet;
+    AssertPtrReturn(pIntNet, VERR_INVALID_PARAMETER);
+    AssertReturn(pIntNet->u32Magic, VERR_INVALID_MAGIC);
+
     PINTNETIF pIf = (PINTNETIF)RTHandleTableLookupWithCtx(pIntNet->hHtIfs, hIf, pSession);
     if (!pIf)
     {
-        Log(("INTNETR0IfSetPromiscuousMode: returns VERR_INVALID_HANDLE\n"));
+        Log(("IntNetR0IfSetPromiscuousMode: returns VERR_INVALID_HANDLE\n"));
         return VERR_INVALID_HANDLE;
     }
@@ -3526,5 +3547,5 @@
         if (pIf->fPromiscuous != fPromiscuous)
         {
-            Log(("INTNETR0IfSetPromiscuousMode: hIf=%RX32: Changed from %d -> %d\n",
+            Log(("IntNetR0IfSetPromiscuousMode: hIf=%RX32: Changed from %d -> %d\n",
                  hIf, !fPromiscuous, !!fPromiscuous));
             ASMAtomicUoWriteBool(&pIf->fPromiscuous, fPromiscuous);
@@ -3548,16 +3569,15 @@
 
 /**
- * VMMR0 request wrapper for INTNETR0IfSetPromiscuousMode.
- *
- * @returns see INTNETR0IfSetPromiscuousMode.
- * @param   pIntNet         The internal networking instance.
+ * VMMR0 request wrapper for IntNetR0IfSetPromiscuousMode.
+ *
+ * @returns see IntNetR0IfSetPromiscuousMode.
  * @param   pSession        The caller's session.
  * @param   pReq            The request packet.
  */
-INTNETR0DECL(int) INTNETR0IfSetPromiscuousModeReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFSETPROMISCUOUSMODEREQ pReq)
+INTNETR0DECL(int) IntNetR0IfSetPromiscuousModeReq(PSUPDRVSESSION pSession, PINTNETIFSETPROMISCUOUSMODEREQ pReq)
 {
     if (RT_UNLIKELY(pReq->Hdr.cbReq != sizeof(*pReq)))
         return VERR_INVALID_PARAMETER;
-    return INTNETR0IfSetPromiscuousMode(pIntNet, pReq->hIf, pSession, pReq->fPromiscuous);
+    return IntNetR0IfSetPromiscuousMode(pReq->hIf, pSession, pReq->fPromiscuous);
 }
 
@@ -3567,22 +3587,24 @@
  *
  * @returns VBox status code.
- * @param   pIntNet         The instance handle.
  * @param   hIf             The interface handle.
  * @param   pSession        The caller's session.
  * @param   pMAC            The new MAC address.
  */
-INTNETR0DECL(int) INTNETR0IfSetMacAddress(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, PCRTMAC pMac)
-{
-    LogFlow(("INTNETR0IfSetMacAddress: pIntNet=%p hIf=%RX32 pMac=%p:{%.6Rhxs}\n", pIntNet, hIf, pMac, pMac));
+INTNETR0DECL(int) IntNetR0IfSetMacAddress(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, PCRTMAC pMac)
+{
+    LogFlow(("IntNetR0IfSetMacAddress: hIf=%RX32 pMac=%p:{%.6Rhxs}\n", hIf, pMac, pMac));
 
     /*
      * Validate & translate input.
      */
+    PINTNET pIntNet = g_pIntNet;
     AssertPtrReturn(pIntNet, VERR_INVALID_PARAMETER);
+    AssertReturn(pIntNet->u32Magic, VERR_INVALID_MAGIC);
+
     AssertPtrReturn(pMac, VERR_INVALID_PARAMETER);
     PINTNETIF pIf = (PINTNETIF)RTHandleTableLookupWithCtx(pIntNet->hHtIfs, hIf, pSession);
     if (!pIf)
     {
-        Log(("INTNETR0IfSetMacAddress: returns VERR_INVALID_HANDLE\n"));
+        Log(("IntNetR0IfSetMacAddress: returns VERR_INVALID_HANDLE\n"));
         return VERR_INVALID_HANDLE;
     }
@@ -3602,5 +3624,5 @@
         if (memcmp(&pIf->MacAddr, pMac, sizeof(pIf->MacAddr)))
         {
-            Log(("INTNETR0IfSetMacAddress: hIf=%RX32: Changed from %.6Rhxs -> %.6Rhxs\n",
+            Log(("IntNetR0IfSetMacAddress: hIf=%RX32: Changed from %.6Rhxs -> %.6Rhxs\n",
                  hIf, &pIf->MacAddr, pMac));
 
@@ -3624,16 +3646,15 @@
 
 /**
- * VMMR0 request wrapper for INTNETR0IfSetMacAddress.
- *
- * @returns see INTNETR0IfSetMacAddress.
- * @param   pIntNet         The internal networking instance.
+ * VMMR0 request wrapper for IntNetR0IfSetMacAddress.
+ *
+ * @returns see IntNetR0IfSetMacAddress.
  * @param   pSession        The caller's session.
  * @param   pReq            The request packet.
  */
-INTNETR0DECL(int) INTNETR0IfSetMacAddressReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFSETMACADDRESSREQ pReq)
+INTNETR0DECL(int) IntNetR0IfSetMacAddressReq(PSUPDRVSESSION pSession, PINTNETIFSETMACADDRESSREQ pReq)
 {
     if (RT_UNLIKELY(pReq->Hdr.cbReq != sizeof(*pReq)))
         return VERR_INVALID_PARAMETER;
-    return INTNETR0IfSetMacAddress(pIntNet, pReq->hIf, pSession, &pReq->Mac);
+    return IntNetR0IfSetMacAddress(pReq->hIf, pSession, &pReq->Mac);
 }
 
@@ -3716,21 +3737,23 @@
  *
  * @returns VBox status code.
- * @param   pIntNet         The instance handle.
  * @param   hIf             The interface handle.
  * @param   pSession        The caller's session.
  * @param   fActive         The new state.
  */
-INTNETR0DECL(int) INTNETR0IfSetActive(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, bool fActive)
-{
-    LogFlow(("INTNETR0IfSetActive: pIntNet=%p hIf=%RX32 fActive=%RTbool\n", pIntNet, hIf, fActive));
+INTNETR0DECL(int) IntNetR0IfSetActive(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, bool fActive)
+{
+    LogFlow(("IntNetR0IfSetActive: hIf=%RX32 fActive=%RTbool\n", hIf, fActive));
 
     /*
      * Validate & translate input.
      */
+    PINTNET pIntNet = g_pIntNet;
     AssertPtrReturn(pIntNet, VERR_INVALID_PARAMETER);
+    AssertReturn(pIntNet->u32Magic, VERR_INVALID_MAGIC);
+
     PINTNETIF pIf = (PINTNETIF)RTHandleTableLookupWithCtx(pIntNet->hHtIfs, hIf, pSession);
     if (!pIf)
     {
-        Log(("INTNETR0IfSetActive: returns VERR_INVALID_HANDLE\n"));
+        Log(("IntNetR0IfSetActive: returns VERR_INVALID_HANDLE\n"));
         return VERR_INVALID_HANDLE;
     }
@@ -3759,16 +3782,16 @@
 
 /**
- * VMMR0 request wrapper for INTNETR0IfSetActive.
- *
- * @returns see INTNETR0IfSetActive.
+ * VMMR0 request wrapper for IntNetR0IfSetActive.
+ *
+ * @returns see IntNetR0IfSetActive.
  * @param   pIntNet         The internal networking instance.
  * @param   pSession        The caller's session.
  * @param   pReq            The request packet.
  */
-INTNETR0DECL(int) INTNETR0IfSetActiveReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFSETACTIVEREQ pReq)
+INTNETR0DECL(int) IntNetR0IfSetActiveReq(PSUPDRVSESSION pSession, PINTNETIFSETACTIVEREQ pReq)
 {
     if (RT_UNLIKELY(pReq->Hdr.cbReq != sizeof(*pReq)))
         return VERR_INVALID_PARAMETER;
-    return INTNETR0IfSetActive(pIntNet, pReq->hIf, pSession, pReq->fActive);
+    return IntNetR0IfSetActive(pReq->hIf, pSession, pReq->fActive);
 }
 
@@ -3779,5 +3802,4 @@
  *
  * @returns VBox status code.
- * @param   pIntNet         The instance handle.
  * @param   hIf             The interface handle.
  * @param   pSession        The caller's session.
@@ -3785,16 +3807,19 @@
  *                          used if indefinite wait is desired.
  */
-INTNETR0DECL(int) INTNETR0IfWait(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, uint32_t cMillies)
-{
-    Log4(("INTNETR0IfWait: pIntNet=%p hIf=%RX32 cMillies=%u\n", pIntNet, hIf, cMillies));
+INTNETR0DECL(int) IntNetR0IfWait(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession, uint32_t cMillies)
+{
+    Log4(("IntNetR0IfWait: hIf=%RX32 cMillies=%u\n", hIf, cMillies));
 
     /*
      * Get and validate essential handles.
      */
+    PINTNET pIntNet = g_pIntNet;
     AssertPtrReturn(pIntNet, VERR_INVALID_PARAMETER);
+    AssertReturn(pIntNet->u32Magic, VERR_INVALID_MAGIC);
+
     PINTNETIF pIf = (PINTNETIF)RTHandleTableLookupWithCtx(pIntNet->hHtIfs, hIf, pSession);
     if (!pIf)
     {
-        Log(("INTNETR0IfWait: returns VERR_INVALID_HANDLE\n"));
+        Log(("IntNetR0IfWait: returns VERR_INVALID_HANDLE\n"));
         return VERR_INVALID_HANDLE;
     }
@@ -3804,5 +3829,5 @@
         &&  hRecvEvent != NIL_RTSEMEVENT)
     {
-        Log(("INTNETR0IfWait: returns VERR_SEM_DESTROYED\n"));
+        Log(("IntNetR0IfWait: returns VERR_SEM_DESTROYED\n"));
         return VERR_SEM_DESTROYED;
     }
@@ -3836,5 +3861,5 @@
     else
         rc = VERR_SEM_DESTROYED;
-    Log4(("INTNETR0IfWait: returns %Rrc\n", rc));
+    Log4(("IntNetR0IfWait: returns %Rrc\n", rc));
     return rc;
 }
@@ -3842,16 +3867,15 @@
 
 /**
- * VMMR0 request wrapper for INTNETR0IfWait.
- *
- * @returns see INTNETR0IfWait.
- * @param   pIntNet         The internal networking instance.
+ * VMMR0 request wrapper for IntNetR0IfWait.
+ *
+ * @returns see IntNetR0IfWait.
  * @param   pSession        The caller's session.
  * @param   pReq            The request packet.
  */
-INTNETR0DECL(int) INTNETR0IfWaitReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFWAITREQ pReq)
+INTNETR0DECL(int) IntNetR0IfWaitReq(PSUPDRVSESSION pSession, PINTNETIFWAITREQ pReq)
 {
     if (RT_UNLIKELY(pReq->Hdr.cbReq != sizeof(*pReq)))
         return VERR_INVALID_PARAMETER;
-    return INTNETR0IfWait(pIntNet, pReq->hIf, pSession, pReq->cMillies);
+    return IntNetR0IfWait(pReq->hIf, pSession, pReq->cMillies);
 }
 
@@ -3865,12 +3889,15 @@
  * @param   pSession        The caller's session.
  */
-INTNETR0DECL(int) INTNETR0IfClose(PINTNET pIntNet, INTNETIFHANDLE hIf, PSUPDRVSESSION pSession)
-{
-    LogFlow(("INTNETR0IfClose: pIntNet=%p hIf=%RX32\n", pIntNet, hIf));
+INTNETR0DECL(int) IntNetR0IfClose(INTNETIFHANDLE hIf, PSUPDRVSESSION pSession)
+{
+    LogFlow(("IntNetR0IfClose: hIf=%RX32\n", hIf));
 
     /*
      * Validate and free the handle.
      */
+    PINTNET pIntNet = g_pIntNet;
     AssertPtrReturn(pIntNet, VERR_INVALID_PARAMETER);
+    AssertReturn(pIntNet->u32Magic, VERR_INVALID_MAGIC);
+
     PINTNETIF pIf = (PINTNETIF)RTHandleTableFreeWithCtx(pIntNet->hHtIfs, hIf, pSession);
     if (!pIf)
@@ -3897,5 +3924,5 @@
 
     int rc = SUPR0ObjRelease(pvObj, pSession);
-    LogFlow(("INTNETR0IfClose: returns %Rrc\n", rc));
+    LogFlow(("IntNetR0IfClose: returns %Rrc\n", rc));
     return rc;
 }
@@ -3903,16 +3930,15 @@
 
 /**
- * VMMR0 request wrapper for INTNETR0IfCloseReq.
- *
- * @returns see INTNETR0IfClose.
- * @param   pIntNet         The internal networking instance.
+ * VMMR0 request wrapper for IntNetR0IfCloseReq.
+ *
+ * @returns see IntNetR0IfClose.
  * @param   pSession        The caller's session.
  * @param   pReq            The request packet.
  */
-INTNETR0DECL(int) INTNETR0IfCloseReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETIFCLOSEREQ pReq)
+INTNETR0DECL(int) IntNetR0IfCloseReq(PSUPDRVSESSION pSession, PINTNETIFCLOSEREQ pReq)
 {
     if (RT_UNLIKELY(pReq->Hdr.cbReq != sizeof(*pReq)))
         return VERR_INVALID_PARAMETER;
-    return INTNETR0IfClose(pIntNet, pReq->hIf, pSession);
+    return IntNetR0IfClose(pReq->hIf, pSession);
 }
 
@@ -5179,5 +5205,4 @@
  *
  * @returns VBox status code.
- * @param   pIntNet         The internal network instance.
  * @param   pSession        The session handle.
  * @param   pszNetwork      The network name.
@@ -5190,15 +5215,17 @@
  * @param   phIf            Where to store the handle to the network interface.
  */
-INTNETR0DECL(int) INTNETR0Open(PINTNET pIntNet, PSUPDRVSESSION pSession, const char *pszNetwork,
+INTNETR0DECL(int) IntNetR0Open(PSUPDRVSESSION pSession, const char *pszNetwork,
                                INTNETTRUNKTYPE enmTrunkType, const char *pszTrunk, uint32_t fFlags,
-                               unsigned cbSend, unsigned cbRecv, PINTNETIFHANDLE phIf)
-{
-    LogFlow(("INTNETR0Open: pIntNet=%p pSession=%p pszNetwork=%p:{%s} enmTrunkType=%d pszTrunk=%p:{%s} fFlags=%#x cbSend=%u cbRecv=%u phIf=%p\n",
-             pIntNet, pSession, pszNetwork, pszNetwork, enmTrunkType, pszTrunk, pszTrunk, fFlags, cbSend, cbRecv, phIf));
+                               uint32_t cbSend, uint32_t cbRecv, PINTNETIFHANDLE phIf)
+{
+    LogFlow(("IntNetR0Open: pSession=%p pszNetwork=%p:{%s} enmTrunkType=%d pszTrunk=%p:{%s} fFlags=%#x cbSend=%u cbRecv=%u phIf=%p\n",
+             pSession, pszNetwork, pszNetwork, enmTrunkType, pszTrunk, pszTrunk, fFlags, cbSend, cbRecv, phIf));
 
     /*
      * Validate input.
      */
+    PINTNET pIntNet = g_pIntNet;
     AssertPtrReturn(pIntNet, VERR_INVALID_PARAMETER);
+    AssertReturn(pIntNet->u32Magic, VERR_INVALID_MAGIC);
 
     AssertPtrReturn(pszNetwork, VERR_INVALID_PARAMETER);
@@ -5273,5 +5300,5 @@
 
     RTSemMutexRelease(pIntNet->hMtxCreateOpenDestroy);
-    LogFlow(("INTNETR0Open: return %Rrc *phIf=%RX32\n", rc, *phIf));
+    LogFlow(("IntNetR0Open: return %Rrc *phIf=%RX32\n", rc, *phIf));
     return rc;
 }
@@ -5282,13 +5309,12 @@
  *
  * @returns see GMMR0MapUnmapChunk.
- * @param   pIntNet         The internal networking instance.
  * @param   pSession        The caller's session.
  * @param   pReq            The request packet.
  */
-INTNETR0DECL(int) INTNETR0OpenReq(PINTNET pIntNet, PSUPDRVSESSION pSession, PINTNETOPENREQ pReq)
+INTNETR0DECL(int) IntNetR0OpenReq(PSUPDRVSESSION pSession, PINTNETOPENREQ pReq)
 {
     if (RT_UNLIKELY(pReq->Hdr.cbReq != sizeof(*pReq)))
         return VERR_INVALID_PARAMETER;
-    return INTNETR0Open(pIntNet, pSession, &pReq->szNetwork[0], pReq->enmTrunkType, pReq->szTrunk,
+    return IntNetR0Open(pSession, &pReq->szNetwork[0], pReq->enmTrunkType, pReq->szTrunk,
                         pReq->fFlags, pReq->cbSend, pReq->cbRecv, &pReq->hIf);
 }
@@ -5296,22 +5322,61 @@
 
 /**
+ * Count the internal networks.
+ *
+ * This is mainly for providing the testcase with some introspection to validate
+ * behavior when closing interfaces.
+ *
+ * @returns The number of networks.
+ */
+INTNETR0DECL(uint32_t) IntNetR0GetNetworkCount(void)
+{
+    /*
+     * Grab the instance.
+     */
+    PINTNET pIntNet = g_pIntNet;
+    if (!pIntNet)
+        return 0;
+    AssertPtrReturn(pIntNet, 0);
+    AssertReturn(pIntNet->u32Magic == INTNET_MAGIC, 0);
+
+    /*
+     * Grab the mutex and count the networks.
+     */
+    int rc = RTSemMutexRequest(pIntNet->hMtxCreateOpenDestroy, RT_INDEFINITE_WAIT);
+    if (RT_FAILURE(rc))
+        return 0;
+
+    uint32_t cNetworks = 0;
+    for (PINTNETNETWORK pCur = pIntNet->pNetworks; pCur; pCur = pCur->pNext)
+        cNetworks++;
+
+    RTSemMutexRelease(pIntNet->hMtxCreateOpenDestroy);
+
+    return cNetworks;
+}
+
+
+
+/**
  * Destroys an instance of the Ring-0 internal networking service.
- *
- * @param   pIntNet     Pointer to the instance data.
- */
-INTNETR0DECL(void) INTNETR0Destroy(PINTNET pIntNet)
-{
-    LogFlow(("INTNETR0Destroy: pIntNet=%p\n", pIntNet));
-
-    /*
-     * Allow NULL pointers.
-     */
+ */
+INTNETR0DECL(void) IntNetR0Term(void)
+{
+    LogFlow(("IntNetR0Term:\n"));
+
+    /*
+     * Zap the global pointer and validate it.
+     */
+    PINTNET pIntNet = g_pIntNet;
+    g_pIntNet = NULL;
     if (!pIntNet)
         return;
     AssertPtrReturnVoid(pIntNet);
+    AssertReturnVoid(pIntNet->u32Magic == INTNET_MAGIC);
 
     /*
      * There is not supposed to be any networks hanging around at this time.
      */
+    AssertReturnVoid(ASMAtomicCmpXchgU32(&pIntNet->u32Magic, ~INTNET_MAGIC, INTNET_MAGIC));
     Assert(pIntNet->pNetworks == NULL);
     if (pIntNet->hMtxCreateOpenDestroy != NIL_RTSEMMUTEX)
@@ -5332,12 +5397,11 @@
 
 /**
- * Create an instance of the Ring-0 internal networking service.
+ * Initalizes the internal network ring-0 service.
  *
  * @returns VBox status code.
- * @param   ppIntNet    Where to store the instance pointer.
- */
-INTNETR0DECL(int) INTNETR0Create(PINTNET *ppIntNet)
-{
-    LogFlow(("INTNETR0Create: ppIntNet=%p\n", ppIntNet));
+ */
+INTNETR0DECL(int) IntNetR0Init(void)
+{
+    LogFlow(("IntNetR0Init:\n"));
     int rc = VERR_NO_MEMORY;
     PINTNET pIntNet = (PINTNET)RTMemAllocZ(sizeof(*pIntNet));
@@ -5353,6 +5417,7 @@
             if (RT_SUCCESS(rc))
             {
-                *ppIntNet = pIntNet;
-                LogFlow(("INTNETR0Create: returns VINF_SUCCESS *ppIntNet=%p\n", pIntNet));
+                pIntNet->u32Magic = INTNET_MAGIC;
+                g_pIntNet = pIntNet;
+                LogFlow(("IntNetR0Init: returns VINF_SUCCESS pIntNet=%p\n", pIntNet));
                 return VINF_SUCCESS;
             }
@@ -5362,6 +5427,5 @@
         RTMemFree(pIntNet);
     }
-    *ppIntNet = NULL;
-    LogFlow(("INTNETR0Create: returns %Rrc\n", rc));
+    LogFlow(("IntNetR0Init: returns %Rrc\n", rc));
     return rc;
 }
Index: /trunk/src/VBox/Devices/Network/testcase/tstIntNetR0.cpp
===================================================================
--- /trunk/src/VBox/Devices/Network/testcase/tstIntNetR0.cpp	(revision 28705)
+++ /trunk/src/VBox/Devices/Network/testcase/tstIntNetR0.cpp	(revision 28706)
@@ -190,5 +190,5 @@
  * Sends the data @a pvBuf points to.
  */
-static int tstIntNetSendBuf(PINTNET pIntNet, PINTNETRINGBUF pRingBuf, INTNETIFHANDLE hIf,
+static int tstIntNetSendBuf(PINTNETRINGBUF pRingBuf, INTNETIFHANDLE hIf,
                             PSUPDRVSESSION pSession, void const *pvBuf, size_t cbBuf)
 {
@@ -197,5 +197,5 @@
     int rc = intnetR0RingWriteFrame(pRingBuf, &Sg, NULL);
     if (RT_SUCCESS(rc))
-        rc = INTNETR0IfSend(pIntNet, hIf, pSession);
+        rc = IntNetR0IfSend(hIf, pSession);
     return rc;
 }
@@ -204,5 +204,4 @@
 typedef struct MYARGS
 {
-    PINTNET         pIntNet;
     PINTNETBUF      pBuf;
     INTNETIFHANDLE  hIf;
@@ -258,5 +257,5 @@
         RTTEST_CHECK_RC_OK(g_hTest, rc = intnetR0RingWriteFrame(&pArgs->pBuf->Send, &Sg, NULL));
         if (RT_SUCCESS(rc))
-            RTTEST_CHECK_RC_OK(g_hTest, rc = INTNETR0IfSend(pArgs->pIntNet, pArgs->hIf, g_pSession));
+            RTTEST_CHECK_RC_OK(g_hTest, rc = IntNetR0IfSend(pArgs->hIf, g_pSession));
         cbSent += cb;
     }
@@ -271,5 +270,5 @@
     for (unsigned c = 0; c < 20; c++)
     {
-        RTTEST_CHECK_RC_OK(g_hTest, rc = tstIntNetSendBuf(pArgs->pIntNet, &pArgs->pBuf->Send, pArgs->hIf, g_pSession,
+        RTTEST_CHECK_RC_OK(g_hTest, rc = tstIntNetSendBuf(&pArgs->pBuf->Send, pArgs->hIf, g_pSession,
                                                           abBuf, sizeof(RTMAC) * 2 + sizeof(unsigned) * 4));
         RTThreadSleep(1);
@@ -363,5 +362,5 @@
          * Wait for data.
          */
-        int rc = INTNETR0IfWait(pArgs->pIntNet, pArgs->hIf, g_pSession, RT_INDEFINITE_WAIT);
+        int rc = IntNetR0IfWait(pArgs->hIf, g_pSession, RT_INDEFINITE_WAIT);
         switch (rc)
         {
@@ -390,6 +389,4 @@
 typedef struct TSTSTATE
 {
-    PINTNET         pIntNet;
-
     PINTNETBUF      pBuf0;
     INTNETIFHANDLE  hIf0;
@@ -410,16 +407,16 @@
 {
     pThis->hIf0 = INTNET_HANDLE_INVALID;
-    RTTESTI_CHECK_RC_OK_RET(INTNETR0Open(pThis->pIntNet, g_pSession, pszNetwork, kIntNetTrunkType_None, "",
+    RTTESTI_CHECK_RC_OK_RET(IntNetR0Open(g_pSession, pszNetwork, kIntNetTrunkType_None, "",
                                          0/*fFlags*/, cbSend, cbRecv, &pThis->hIf0), rcCheck);
     RTTESTI_CHECK_RET(pThis->hIf0 != INTNET_HANDLE_INVALID, VERR_INTERNAL_ERROR);
-    RTTESTI_CHECK_RC_RET(INTNETR0IfGetRing0Buffer(pThis->pIntNet, pThis->hIf0, g_pSession, &pThis->pBuf0), VINF_SUCCESS, rcCheck);
+    RTTESTI_CHECK_RC_RET(IntNetR0IfGetRing0Buffer(pThis->hIf0, g_pSession, &pThis->pBuf0), VINF_SUCCESS, rcCheck);
     RTTESTI_CHECK_RET(pThis->pBuf0, VERR_INTERNAL_ERROR);
 
 
     pThis->hIf1 = INTNET_HANDLE_INVALID;
-    RTTESTI_CHECK_RC_OK_RET(INTNETR0Open(pThis->pIntNet, g_pSession, pszNetwork, kIntNetTrunkType_None, "",
+    RTTESTI_CHECK_RC_OK_RET(IntNetR0Open(g_pSession, pszNetwork, kIntNetTrunkType_None, "",
                                          0/*fFlags*/, cbSend, cbRecv, &pThis->hIf1), rcCheck);
     RTTESTI_CHECK_RET(pThis->hIf1 != INTNET_HANDLE_INVALID, VERR_INTERNAL_ERROR);
-    RTTESTI_CHECK_RC_RET(INTNETR0IfGetRing0Buffer(pThis->pIntNet, pThis->hIf1, g_pSession, &pThis->pBuf1), VINF_SUCCESS, rcCheck);
+    RTTESTI_CHECK_RC_RET(IntNetR0IfGetRing0Buffer(pThis->hIf1, g_pSession, &pThis->pBuf1), VINF_SUCCESS, rcCheck);
     RTTESTI_CHECK_RET(pThis->pBuf1, VERR_INTERNAL_ERROR);
 
@@ -435,5 +432,5 @@
 {
     int rc;
-    RTTESTI_CHECK_RC_OK(rc = INTNETR0IfClose(pThis->pIntNet, pThis->hIf0, g_pSession));
+    RTTESTI_CHECK_RC_OK(rc = IntNetR0IfClose(pThis->hIf0, g_pSession));
     if (RT_SUCCESS(rc))
     {
@@ -442,5 +439,5 @@
     }
 
-    RTTESTI_CHECK_RC_OK(rc = INTNETR0IfClose(pThis->pIntNet, pThis->hIf1, g_pSession));
+    RTTESTI_CHECK_RC_OK(rc = IntNetR0IfClose(pThis->hIf1, g_pSession));
     if (RT_SUCCESS(rc))
     {
@@ -450,5 +447,5 @@
 
     /* The network should be dead now. */
-    RTTESTI_CHECK(pThis->pIntNet->pNetworks == NULL);
+    RTTESTI_CHECK(IntNetR0GetNetworkCount() == 0);
 }
 
@@ -462,5 +459,4 @@
     Args0.hIf         = pThis->hIf0;
     Args0.pBuf        = pThis->pBuf0;
-    Args0.pIntNet     = pThis->pIntNet;
     Args0.Mac.au16[0] = 0x8086;
     Args0.Mac.au16[1] = 0;
@@ -471,5 +467,4 @@
     Args1.hIf         = pThis->hIf1;
     Args1.pBuf        = pThis->pBuf1;
-    Args1.pIntNet     = pThis->pIntNet;
     Args1.Mac.au16[0] = 0x8086;
     Args1.Mac.au16[1] = 0;
@@ -592,14 +587,14 @@
     static uint16_t const s_au16Frame[7] = { /* dst:*/ 0xffff, 0xffff, 0xffff, /*src:*/0x8086, 0, 0, 0x0800 };
 
-    RTTESTI_CHECK_RC_RETV(tstIntNetSendBuf(pThis->pIntNet, &pThis->pBuf0->Send, pThis->hIf0,
+    RTTESTI_CHECK_RC_RETV(tstIntNetSendBuf(&pThis->pBuf0->Send, pThis->hIf0,
                                            g_pSession, &s_au16Frame, sizeof(s_au16Frame)),
                           VINF_SUCCESS);
 
     /* No echo, please */
-    RTTESTI_CHECK_RC_RETV(INTNETR0IfWait(pThis->pIntNet, pThis->hIf0, g_pSession, 1), VERR_TIMEOUT);
+    RTTESTI_CHECK_RC_RETV(IntNetR0IfWait(pThis->hIf0, g_pSession, 1), VERR_TIMEOUT);
 
     /* The other interface should see it though.  But Wait should only return once, thank you. */
-    RTTESTI_CHECK_RC_RETV(INTNETR0IfWait(pThis->pIntNet, pThis->hIf1, g_pSession, 1), VINF_SUCCESS);
-    RTTESTI_CHECK_RC_RETV(INTNETR0IfWait(pThis->pIntNet, pThis->hIf1, g_pSession, 0), VERR_TIMEOUT);
+    RTTESTI_CHECK_RC_RETV(IntNetR0IfWait(pThis->hIf1, g_pSession, 1), VINF_SUCCESS);
+    RTTESTI_CHECK_RC_RETV(IntNetR0IfWait(pThis->hIf1, g_pSession, 0), VERR_TIMEOUT);
 
     /* Receive the data. */
@@ -631,14 +626,14 @@
     static uint16_t const s_au16Frame[7] = { /* dst:*/ 0x8086, 0, 0,      /*src:*/0x8086, 0, 1, 0x0800 };
 
-    RTTESTI_CHECK_RC_RETV(tstIntNetSendBuf(pThis->pIntNet, &pThis->pBuf1->Send, pThis->hIf1,
+    RTTESTI_CHECK_RC_RETV(tstIntNetSendBuf(&pThis->pBuf1->Send, pThis->hIf1,
                                            g_pSession, s_au16Frame, sizeof(s_au16Frame)),
                           VINF_SUCCESS);
 
     /* No echo, please */
-    RTTESTI_CHECK_RC_RETV(INTNETR0IfWait(pThis->pIntNet, pThis->hIf1, g_pSession, 1), VERR_TIMEOUT);
+    RTTESTI_CHECK_RC_RETV(IntNetR0IfWait(pThis->hIf1, g_pSession, 1), VERR_TIMEOUT);
 
     /* The other interface should see it though.  But Wait should only return once, thank you. */
-    RTTESTI_CHECK_RC_RETV(INTNETR0IfWait(pThis->pIntNet, pThis->hIf0, g_pSession, 1), VINF_SUCCESS);
-    RTTESTI_CHECK_RC_RETV(INTNETR0IfWait(pThis->pIntNet, pThis->hIf0, g_pSession, 0), VERR_TIMEOUT);
+    RTTESTI_CHECK_RC_RETV(IntNetR0IfWait(pThis->hIf0, g_pSession, 1), VINF_SUCCESS);
+    RTTESTI_CHECK_RC_RETV(IntNetR0IfWait(pThis->hIf0, g_pSession, 0), VERR_TIMEOUT);
 
     /* Receive the data. */
@@ -666,6 +661,6 @@
      * Create an INTNET instance.
      */
-    RTTestISub("INTNETR0Create");
-    RTTESTI_CHECK_RC_RETV(INTNETR0Create(&pThis->pIntNet), VINF_SUCCESS);
+    RTTestISub("IntNetR0Init");
+    RTTESTI_CHECK_RC_RETV(IntNetR0Init(), VINF_SUCCESS);
 
     /*
@@ -676,15 +671,15 @@
     if (RT_FAILURE(rc))
         return;
-    RTTESTI_CHECK_RC(INTNETR0IfSetActive(pThis->pIntNet, pThis->hIf0, g_pSession, true), VINF_SUCCESS);
-    RTTESTI_CHECK_RC(INTNETR0IfSetActive(pThis->pIntNet, pThis->hIf1, g_pSession, true), VINF_SUCCESS);
+    RTTESTI_CHECK_RC(IntNetR0IfSetActive(pThis->hIf0, g_pSession, true), VINF_SUCCESS);
+    RTTESTI_CHECK_RC(IntNetR0IfSetActive(pThis->hIf1, g_pSession, true), VINF_SUCCESS);
 
     /*
      * Test basic waiting.
      */
-    RTTestISub("INTNETR0IfWait");
-    RTTESTI_CHECK_RC(INTNETR0IfWait(pThis->pIntNet, pThis->hIf0, g_pSession, 1), VERR_TIMEOUT);
-    RTTESTI_CHECK_RC(INTNETR0IfWait(pThis->pIntNet, pThis->hIf0, g_pSession, 0), VERR_TIMEOUT);
-    RTTESTI_CHECK_RC(INTNETR0IfWait(pThis->pIntNet, pThis->hIf1, g_pSession, 1), VERR_TIMEOUT);
-    RTTESTI_CHECK_RC(INTNETR0IfWait(pThis->pIntNet, pThis->hIf1, g_pSession, 0), VERR_TIMEOUT);
+    RTTestISub("IntNetR0IfWait");
+    RTTESTI_CHECK_RC(IntNetR0IfWait(pThis->hIf0, g_pSession, 1), VERR_TIMEOUT);
+    RTTESTI_CHECK_RC(IntNetR0IfWait(pThis->hIf0, g_pSession, 0), VERR_TIMEOUT);
+    RTTESTI_CHECK_RC(IntNetR0IfWait(pThis->hIf1, g_pSession, 1), VERR_TIMEOUT);
+    RTTESTI_CHECK_RC(IntNetR0IfWait(pThis->hIf1, g_pSession, 0), VERR_TIMEOUT);
 
     /*
@@ -718,5 +713,5 @@
      */
     tstCloseInterfaces(pThis);
-    INTNETR0Destroy(pThis->pIntNet);
+    IntNetR0Term();
 }
 
Index: /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp	(revision 28705)
+++ /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp	(revision 28706)
@@ -70,7 +70,6 @@
 *   Global Variables                                                           *
 *******************************************************************************/
-/** Pointer to the internal networking service instance. */
-PINTNET g_pIntNet = 0;
-
+/** Drag in necessary library bits.
+ * The runtime lives here (in VMMR0.r0) and VBoxDD*R0.r0 links against us. */
 PFNRT g_VMMGCDeps[] =
 {
@@ -110,16 +109,12 @@
                     if (RT_SUCCESS(rc))
                     {
-                        LogFlow(("ModuleInit: g_pIntNet=%p\n", g_pIntNet));
-                        g_pIntNet = NULL;
-                        LogFlow(("ModuleInit: g_pIntNet=%p should be NULL now...\n", g_pIntNet));
-                        rc = INTNETR0Create(&g_pIntNet);
+                        rc = IntNetR0Init();
                         if (RT_SUCCESS(rc))
                         {
-                            LogFlow(("ModuleInit: returns success. g_pIntNet=%p\n", g_pIntNet));
+                            LogFlow(("ModuleInit: returns success.\n"));
                             return VINF_SUCCESS;
                         }
 
                         /* bail out */
-                        g_pIntNet = NULL;
                         LogFlow(("ModuleTerm: returns %Rrc\n", rc));
 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
@@ -150,15 +145,10 @@
 
     /*
-     * Destroy the internal networking instance.
-     */
-    if (g_pIntNet)
-    {
-        INTNETR0Destroy(g_pIntNet);
-        g_pIntNet = NULL;
-    }
+     * Terminate the internal network service.
+     */
+    IntNetR0Term();
 
     /*
      * PGM (Darwin) and HWACCM global cleanup.
-     * Destroy the GMM and GVMM instances.
      */
 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
@@ -168,4 +158,7 @@
     HWACCMR0Term();
 
+    /*
+     * Destroy the GMM and GVMM instances.
+     */
     GMMR0Term();
     GVMMR0Term();
@@ -998,7 +991,5 @@
             if (u64Arg || !pReq || !vmmR0IsValidSession(pVM, pReq->pSession, pSession) || idCpu != NIL_VMCPUID)
                 return VERR_INVALID_PARAMETER;
-            if (!g_pIntNet)
-                return VERR_NOT_SUPPORTED;
-            return INTNETR0OpenReq(g_pIntNet, pSession, pReq);
+            return IntNetR0OpenReq(pSession, pReq);
         }
 
@@ -1006,49 +997,35 @@
             if (u64Arg || !pReqHdr || !vmmR0IsValidSession(pVM, ((PINTNETIFCLOSEREQ)pReqHdr)->pSession, pSession) || idCpu != NIL_VMCPUID)
                 return VERR_INVALID_PARAMETER;
-            if (!g_pIntNet)
-                return VERR_NOT_SUPPORTED;
-            return INTNETR0IfCloseReq(g_pIntNet, pSession, (PINTNETIFCLOSEREQ)pReqHdr);
+            return IntNetR0IfCloseReq(pSession, (PINTNETIFCLOSEREQ)pReqHdr);
 
         case VMMR0_DO_INTNET_IF_GET_RING3_BUFFER:
             if (u64Arg || !pReqHdr || !vmmR0IsValidSession(pVM, ((PINTNETIFGETRING3BUFFERREQ)pReqHdr)->pSession, pSession) || idCpu != NIL_VMCPUID)
                 return VERR_INVALID_PARAMETER;
-            if (!g_pIntNet)
-                return VERR_NOT_SUPPORTED;
-            return INTNETR0IfGetRing3BufferReq(g_pIntNet, pSession, (PINTNETIFGETRING3BUFFERREQ)pReqHdr);
+            return IntNetR0IfGetRing3BufferReq(pSession, (PINTNETIFGETRING3BUFFERREQ)pReqHdr);
 
         case VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE:
             if (u64Arg || !pReqHdr || !vmmR0IsValidSession(pVM, ((PINTNETIFSETPROMISCUOUSMODEREQ)pReqHdr)->pSession, pSession) || idCpu != NIL_VMCPUID)
                 return VERR_INVALID_PARAMETER;
-            if (!g_pIntNet)
-                return VERR_NOT_SUPPORTED;
-            return INTNETR0IfSetPromiscuousModeReq(g_pIntNet, pSession, (PINTNETIFSETPROMISCUOUSMODEREQ)pReqHdr);
+            return IntNetR0IfSetPromiscuousModeReq(pSession, (PINTNETIFSETPROMISCUOUSMODEREQ)pReqHdr);
 
         case VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS:
             if (u64Arg || !pReqHdr || !vmmR0IsValidSession(pVM, ((PINTNETIFSETMACADDRESSREQ)pReqHdr)->pSession, pSession) || idCpu != NIL_VMCPUID)
                 return VERR_INVALID_PARAMETER;
-            if (!g_pIntNet)
-                return VERR_NOT_SUPPORTED;
-            return INTNETR0IfSetMacAddressReq(g_pIntNet, pSession, (PINTNETIFSETMACADDRESSREQ)pReqHdr);
+            return IntNetR0IfSetMacAddressReq(pSession, (PINTNETIFSETMACADDRESSREQ)pReqHdr);
 
         case VMMR0_DO_INTNET_IF_SET_ACTIVE:
             if (u64Arg || !pReqHdr || !vmmR0IsValidSession(pVM, ((PINTNETIFSETACTIVEREQ)pReqHdr)->pSession, pSession) || idCpu != NIL_VMCPUID)
                 return VERR_INVALID_PARAMETER;
-            if (!g_pIntNet)
-                return VERR_NOT_SUPPORTED;
-            return INTNETR0IfSetActiveReq(g_pIntNet, pSession, (PINTNETIFSETACTIVEREQ)pReqHdr);
+            return IntNetR0IfSetActiveReq(pSession, (PINTNETIFSETACTIVEREQ)pReqHdr);
 
         case VMMR0_DO_INTNET_IF_SEND:
             if (u64Arg || !pReqHdr || !vmmR0IsValidSession(pVM, ((PINTNETIFSENDREQ)pReqHdr)->pSession, pSession) || idCpu != NIL_VMCPUID)
                 return VERR_INVALID_PARAMETER;
-            if (!g_pIntNet)
-                return VERR_NOT_SUPPORTED;
-            return INTNETR0IfSendReq(g_pIntNet, pSession, (PINTNETIFSENDREQ)pReqHdr);
+            return IntNetR0IfSendReq(pSession, (PINTNETIFSENDREQ)pReqHdr);
 
         case VMMR0_DO_INTNET_IF_WAIT:
             if (u64Arg || !pReqHdr || !vmmR0IsValidSession(pVM, ((PINTNETIFWAITREQ)pReqHdr)->pSession, pSession) || idCpu != NIL_VMCPUID)
                 return VERR_INVALID_PARAMETER;
-            if (!g_pIntNet)
-                return VERR_NOT_SUPPORTED;
-            return INTNETR0IfWaitReq(g_pIntNet, pSession, (PINTNETIFWAITREQ)pReqHdr);
+            return IntNetR0IfWaitReq(pSession, (PINTNETIFWAITREQ)pReqHdr);
 
         /*
