HGCMInternal.cpp revision b1c1aaea5cf2f5540a82ee84f0913df6f4f30d0e
/** @file
*
* VBoxGuestLib - A support library for VirtualBox guest additions:
* Host-Guest Communication Manager internal functions, implemented by VBoxGuest
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
/* Entire file is ifdef'ed with VBGL_VBOXGUEST */
#ifdef VBGL_VBOXGUEST
#include <VBox/VBoxGuestLib.h>
#include "VBGLInternal.h"
/* These functions can be only used by VBoxGuest. */
{
int rc;
if (!pConnectInfo || !pAsyncCallback)
return VERR_INVALID_PARAMETER;
pHGCMConnect = NULL;
/* Allocate request */
rc = VbglGRAlloc ((VMMDevRequestHeader **)&pHGCMConnect, sizeof (VMMDevHGCMConnect), VMMDevReq_HGCMConnect);
if (VBOX_SUCCESS(rc))
{
/* Initialize request memory */
pHGCMConnect->u32ClientID = 0;
/* Issue request */
if (VBOX_SUCCESS(rc))
{
/* Check if host decides to process the request asynchronously. */
if (rc == VINF_HGCM_ASYNC_EXECUTE)
{
/* Wait for request completion interrupt notification from host */
}
}
}
return rc;
}
{
int rc;
if (!pDisconnectInfo || !pAsyncCallback)
return VERR_INVALID_PARAMETER;
/* Allocate request */
rc = VbglGRAlloc ((VMMDevRequestHeader **)&pHGCMDisconnect, sizeof (VMMDevHGCMDisconnect), VMMDevReq_HGCMDisconnect);
if (VBOX_SUCCESS(rc))
{
/* Initialize request memory */
/* Issue request */
if (VBOX_SUCCESS(rc))
{
/* Check if host decides to process the request asynchronously. */
if (rc == VINF_HGCM_ASYNC_EXECUTE)
{
/* Wait for request completion interrupt notification from host */
}
}
}
return rc;
}
{
int rc;
if (!pCallInfo || !pAsyncCallback)
return VERR_INVALID_PARAMETER;
dprintf (("VbglHGCMCall: pCallInfo->cParms = %d, pHGCMCall->u32Function = %d\n", pCallInfo->cParms, pCallInfo->u32Function));
/* Allocate request */
rc = VbglGRAlloc ((VMMDevRequestHeader **)&pHGCMCall, sizeof (VMMDevHGCMCall) + cbParms, VMMDevReq_HGCMCall);
if (VBOX_SUCCESS(rc))
{
/* Initialize request memory */
if (cbParms)
{
}
dprintf (("calling VbglGRPerform\n"));
/* Issue request */
/** If the call failed, but as a result of the request itself, then pretend success
* Upper layers will interpret the result code in the packet.
*/
{
rc = VINF_SUCCESS;
}
if (VBOX_SUCCESS(rc))
{
/* Check if host decides to process the request asynchronously. */
if (rc == VINF_HGCM_ASYNC_EXECUTE)
{
/* Wait for request completion interrupt notification from host */
}
{
if (cbParms)
{
}
}
else
{
/* The callback returns without completing the request,
* that means the wait was interrrupted. That can happen
* if system reboots or the VBoxService ended abnormally.
* In both cases it is OK to just leave the allocated memory
* in the physical heap. The memory leak does not affect normal
* operations.
* @todo VbglGRCancel (&pHGCMCall->header.header) need to be implemented.
* The host will not write to the cancelled memory.
*/
}
}
else
}
return rc;
}
#endif /* VBGL_VBOXGUEST */