VirtualBox

Ignore:
Timestamp:
Mar 13, 2009 9:51:35 PM (16 years ago)
Author:
vboxsync
Message:

Additions/common/VBoxGuestLib: add support for the new user guest device to the R3 guest library

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp

    r17196 r17858  
    7878
    7979
     80static int vbglR3Init(char *pszDeviceName);
     81
     82/**
     83 * Open the VBox R3 Guest Library.  This should be called by system daemons
     84 * and processes.
     85 */
    8086VBGLR3DECL(int) VbglR3Init(void)
     87{
     88    return vbglR3Init(VBOXGUEST_DEVICE_NAME);
     89}
     90
     91/**
     92 * Open the VBox R3 Guest Library.  Equivalent to VbglR3Init, but for user
     93 * session processes.
     94 */
     95VBGLR3DECL(int) VbglR3InitUser(void)
     96{
     97    return vbglR3Init(VBOXGUEST_USER_DEVICE_NAME);
     98}
     99
     100/**
     101 * Implementation of VbglR3Init and VbglR3InitUser
     102 */
     103int vbglR3Init(char *pszDeviceName)
    81104{
    82105    uint32_t cInits = ASMAtomicIncU32(&g_cInits);
     
    115138     * and possible some other bits not availble thru iprt/file.h.
    116139     */
    117     HANDLE hFile = CreateFile(VBOXGUEST_DEVICE_NAME,
     140    HANDLE hFile = CreateFile(pszDeviceName,
    118141                              GENERIC_READ | GENERIC_WRITE,
    119142                              FILE_SHARE_READ | FILE_SHARE_WRITE,
     
    135158    HFILE hf = NULLHANDLE;
    136159    ULONG ulAction = 0;
    137     APIRET rc = DosOpen((PCSZ)VBOXGUEST_DEVICE_NAME, &hf, &ulAction, 0, FILE_NORMAL,
     160    APIRET rc = DosOpen((PCSZ)pszDeviceName, &hf, &ulAction, 0, FILE_NORMAL,
    138161                        OPEN_ACTION_OPEN_IF_EXISTS,
    139162                        OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
     
    188211# endif
    189212    int rc;
    190     char szDevice[sizeof(VBOXGUEST_DEVICE_NAME) + 16];
     213    char szDevice[RT_MAX(sizeof(VBOXGUEST_DEVICE_NAME),
     214                         sizeof(VBOXGUEST_USER_DEVICE_NAME)) + 16];
    191215    for (unsigned iUnit = 0; iUnit < 1024; iUnit++)
    192216    {
    193         RTStrPrintf(szDevice, sizeof(szDevice), VBOXGUEST_DEVICE_NAME "%d", iUnit);
     217        RTStrPrintf(szDevice, sizeof(szDevice), pszDeviceName "%d", iUnit);
    194218# if defined(VBOX_VBGLR3_XFREE86)
    195219        File = xf86open(szDevice, XF86_O_RDWR);
     
    214238
    215239#elif defined(VBOX_VBGLR3_XFREE86) && !defined(RT_OS_FREEBSD)
    216     int File = xf86open(VBOXGUEST_DEVICE_NAME, XF86_O_RDWR);
     240    int File = xf86open(pszDeviceName, XF86_O_RDWR);
    217241    if (File == -1)
    218242        return VERR_OPEN_FAILED;
     
    223247    /* The default implemenation. (linux, solaris) */
    224248    RTFILE File;
    225     int rc = RTFileOpen(&File, VBOXGUEST_DEVICE_NAME, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     249    int rc = RTFileOpen(&File, pszDeviceName, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    226250    if (RT_FAILURE(rc))
    227251        return rc;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette