SysHlp.cpp revision bfd2448384a97d1c16a54af5d1523ae1b861ce26
/* $Revision$ */
/** @file
* VBoxGuestLib - IDC with VBoxGuest and HGCM helpers.
*/
/*
* Copyright (C) 2006-2009 Sun Microsystems, Inc.
*
* 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 (GPL) 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#define LOG_GROUP LOG_GROUP_HGCM
#include <VBox/VBoxGuestLib.h>
#include "SysHlp.h"
#if !defined (RT_OS_WINDOWS) \
&& (!defined (RT_OS_LINUX) || defined (VBOX_WITH_COMMON_VBOXGUEST_ON_LINUX))
#endif
{
int rc = VINF_SUCCESS;
/* Zero size buffers shouldn't be locked. */
if (u32Size == 0)
{
#ifdef RT_OS_WINDOWS
#else
*ppvCtx = NIL_RTR0MEMOBJ;
#endif
return VINF_SUCCESS;
}
#ifdef RT_OS_WINDOWS
{
}
else
{
__try {
}
}
/** @todo r=frank: Linux: pv is at least in some cases, e.g. with VBoxMapFolder,
* an R0 address -- the memory was allocated with kmalloc(). I don't know
* if this is true in any case.
* r=michael: on Linux, we sometimes have R3 addresses (e.g. shared
* clipboard) and sometimes R0 (e.g. shared folders). We really ought
* to have two separate paths here - at any rate, Linux R0 shouldn't
* end up calling this API. In practice, Linux R3 does it's own thing
* before winding up in the R0 path - which calls this stub API.
*/
#else
/* Default to IPRT - this ASSUMES that it is USER addresses we're locking. */
if (RT_SUCCESS(rc))
else
*ppvCtx = NIL_RTR0MEMOBJ;
#endif
return rc;
}
{
#ifdef RT_OS_WINDOWS
{
}
#else
/* default to IPRT */
#endif
}
#ifndef VBGL_VBOXGUEST
# include <unistd.h>
# include <errno.h>
# endif
# if defined (RT_OS_LINUX) && !defined (VBOX_WITH_COMMON_VBOXGUEST_ON_LINUX)
extern DECLVBGL(void *) vboxadd_cmc_open (void);
extern DECLVBGL(void) vboxadd_cmc_close (void *);
# endif /* RT_OS_LINUX */
# ifdef RT_OS_OS2
/*
* On OS/2 we'll do the connecting in the assembly code of the
* client driver, exporting a g_VBoxGuestIDC symbol containing
* the connection information obtained from the 16-bit IDC.
*/
extern VBOXGUESTOS2IDCCONNECT g_VBoxGuestIDC;
# endif
# if !defined(RT_OS_OS2) \
&& !defined(RT_OS_WINDOWS) \
&& (!defined (RT_OS_LINUX) || defined (VBOX_WITH_COMMON_VBOXGUEST_ON_LINUX))
extern DECLVBGL(int) VBoxGuestIDCCall (void *pvOpaque, unsigned int iCmd, void *pvData, size_t cbSize, size_t *pcbReturn);
# endif
{
# ifdef RT_OS_WINDOWS
&pFileObject, &pDeviceObject);
if (NT_SUCCESS (rc))
{
return VINF_SUCCESS;
}
/** @todo return RTErrConvertFromNtStatus(rc)! */
return rc;
void *opaque;
opaque = (void *) vboxadd_cmc_open ();
if (!opaque)
{
return VERR_NOT_IMPLEMENTED;
}
return VINF_SUCCESS;
/*
* Just check whether the connection was made or not.
*/
{
return VINF_SUCCESS;
}
Log(("vbglDriverOpen: failed\n"));
return VERR_FILE_NOT_FOUND;
# else
&& u32VMMDevVersion == VMMDEV_VERSION)
return VINF_SUCCESS;
Log(("vbglDriverOpen: failed\n"));
return VERR_FILE_NOT_FOUND;
# endif
}
# ifdef RT_OS_WINDOWS
{
return STATUS_MORE_PROCESSING_REQUIRED;
}
# endif
{
Log(("vbglDriverIOCtl: pDriver: %p, Func: %x, pvData: %p, cbData: %d\n", pDriver, u32Function, pvData, cbData));
# ifdef RT_OS_WINDOWS
/* Have to use the IoAllocateIRP method because this code is generic and
* must work in any thread context.
* The IoBuildDeviceIoControlRequest, which was used here, does not work
* when APCs are disabled, for example.
*/
{
Log(("vbglDriverIOCtl: IRP allocation failed!\n"));
return VERR_NO_MEMORY;
}
/*
* Setup the IRP_MJ_DEVICE_CONTROL IRP.
*/
nextStack->MinorFunction = 0;
/* A completion routine is required to signal the Event. */
if (NT_SUCCESS (rc))
{
/* Wait the event to be signalled by the completion routine. */
NULL);
}
if (rc != STATUS_SUCCESS)
if ( pDriver->u32Session
Log(("vbglDriverIOCtl: No connection\n"));
return VERR_WRONG_ORDER;
# else
# endif
}
{
# ifdef RT_OS_WINDOWS
pDriver->u32Session = 0;
# else
# endif
}
#endif /* !VBGL_VBOXGUEST */