DECLVBGL(int) VbglHGCMConnect (VBGLHGCMHANDLE *pHandle, VBoxGuestHGCMConnectInfo *pData) { int rc; struct VBGLHGCMHANDLEDATA *pHandleData; if (!pHandle || !pData) return VERR_INVALID_PARAMETER; pHandleData = vbglHGCMHandleAlloc(); if (!pHandleData) rc = VERR_NO_MEMORY; else { rc = vbglDriverOpen (&pHandleData->driver); if (RT_SUCCESS(rc)) { rc = vbglDriverIOCtl (&pHandleData->driver, VBOXGUEST_IOCTL_HGCM_CONNECT, pData, sizeof (*pData)); if (RT_SUCCESS(rc)) rc = pData->result; if (RT_SUCCESS(rc)) { *pHandle = pHandleData; return rc; } vbglDriverClose (&pHandleData->driver); } vbglHGCMHandleFree (pHandleData); } return rc; }
DECLVBGL(int) VbglR0CrCtlDestroy(VBGLCRCTLHANDLE hCtl) { vbglDriverClose(&hCtl->driver); vbglHGCMHandleFree(hCtl); return VINF_SUCCESS; }
DECLVBGL(int) vboxCrCtlDestroy(HVBOXCRCTL hCtl) { vbglDriverClose(&hCtl->driver); vbglHGCMHandleFree(hCtl); return VINF_SUCCESS; }
DECLVBGL(int) VbglHGCMDisconnect (VBGLHGCMHANDLE handle, VBoxGuestHGCMDisconnectInfo *pData) { int rc = VINF_SUCCESS; rc = vbglDriverIOCtl (&handle->driver, VBOXGUEST_IOCTL_HGCM_DISCONNECT, pData, sizeof (*pData)); vbglDriverClose (&handle->driver); vbglHGCMHandleFree (handle); return rc; }
DECLVBGL(void) VbglTerminate (void) { # ifdef VBOX_WITH_HGCM vbglR0HGCMTerminate (); # endif /* driver open could fail, which does not prevent VbglInit from succeeding, * close the driver only if it is opened */ if (vbglDriverIsOpened(&g_vbgldata.driver)) vbglDriverClose(&g_vbgldata.driver); RTSemMutexDestroy(g_vbgldata.mutexDriverInit); g_vbgldata.mutexDriverInit = NIL_RTSEMMUTEX; /* note: do vbglTerminateCommon as a last step since it zeroez up the g_vbgldata * conceptually, doing vbglTerminateCommon last is correct * since this is the reverse order to how init is done */ vbglTerminateCommon (); return; }