VirtualBox

Ignore:
Timestamp:
Jul 10, 2008 4:09:21 PM (16 years ago)
Author:
vboxsync
Message:

Guest Lib R3: IOCTL handling for Windows (not tested yet!) to simplify logging / communication.

File:
1 edited

Legend:

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

    r9140 r10476  
    6161#ifdef VBOX_VBGLR3_XFREE86
    6262static int g_File = -1;
     63#elif defined(RT_OS_WINDOWS)
     64static HANDLE g_hFile = INVALID_HANDLE_VALUE;
    6365#else
    6466static RTFILE g_File = NIL_RTFILE;
     
    8587         * processed calling us more than once.
    8688         */
    87 #ifndef VBOX_VBGLR3_XFREE86
     89#ifndef RT_OS_WINDOWS
     90    #ifndef VBOX_VBGLR3_XFREE86
    8891        if (g_File == NIL_RTFILE)
    89 #else
     92    #else
    9093        if (g_File == -1)
    91 #endif
     94    #endif
    9295            return VERR_INTERNAL_ERROR;
     96#else
     97    if (g_hFile == NULL)
     98        return VERR_INTERNAL_ERROR;
     99#endif
    93100        return VINF_SUCCESS;
    94101    }
    95 #ifndef VBOX_VBGLR3_XFREE86
    96     if (g_File != NIL_RTFILE)
    97 #else
    98     if (g_File != -1)
    99 #endif
     102
     103#ifndef RT_OS_WINDOWS
     104    #ifndef VBOX_VBGLR3_XFREE86
     105        if (g_File != NIL_RTFILE)
     106    #else
     107        if (g_File != -1)
     108    #endif
     109            return VERR_INTERNAL_ERROR;
     110#else
     111    if (g_hFile != INVALID_HANDLE_VALUE)
    100112        return VERR_INTERNAL_ERROR;
     113#endif
    101114
    102115#if defined(RT_OS_OS2)
     
    192205    g_File = File;
    193206
    194 #else
    195     /* the default implemenation. (linux, solaris) */
     207#elif defined(RT_OS_WINDOWS)
     208
     209    /*
     210     * Open a handle to the shadow device.
     211     */
     212    g_hFile = CreateFile(VBOXGUEST_DEVICE_NAME,
     213                         GENERIC_READ | GENERIC_WRITE,
     214                         FILE_SHARE_READ | FILE_SHARE_WRITE,
     215                         NULL,
     216                         OPEN_EXISTING,
     217                         FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
     218                         NULL);
     219
     220    if (g_hFile == INVALID_HANDLE_VALUE)
     221        return VERR_OPEN_FAILED;
     222
     223#else
     224
     225    /* The default implemenation. (linux, solaris) */
    196226    RTFILE File;
    197227    int rc = RTFileOpen(&File, VBOXGUEST_DEVICE_NAME, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     
    223253    if (cInits > 0)
    224254        return;
    225 #ifndef VBOX_VBGLR3_XFREE86
    226     AssertReturnVoid(!cInits);
    227     RTFILE File = g_File;
    228     g_File = NIL_RTFILE;
    229     AssertReturnVoid(File != NIL_RTFILE);
    230 
    231 #else
    232     int File = g_File;
    233     g_File = -1;
    234     if (File == -1)
    235         return;
     255#ifndef RT_OS_WINDOWS
     256    #ifndef VBOX_VBGLR3_XFREE86
     257        AssertReturnVoid(!cInits);
     258        RTFILE File = g_File;
     259        g_File = NIL_RTFILE;
     260        AssertReturnVoid(File != NIL_RTFILE);
     261    #else
     262        int File = g_File;
     263        g_File = -1;
     264        if (File == -1)
     265            return;
     266    #endif
     267#else
     268    /* Nothing to do here yet. */
     269
    236270#endif
    237271
     
    243277    xf86close(File);
    244278    File = -1;
     279
     280#elif defined(RT_OS_WINDOWS)
     281   if (INVALID_HANDLE_VALUE != g_hFile)
     282   {
     283       CloseHandle (g_hFile);
     284       g_hFile = INVALID_HANDLE_VALUE;
     285   }
    245286
    246287#else
     
    293334    return VINF_SUCCESS;
    294335
     336#elif defined(RT_OS_WINDOWS)
     337
     338    DWORD cbReturned = 0;
     339    if (FALSE == DeviceIoControl(g_hFile, iFunction, pvData, cbData,
     340                                 pvData, cbData, &cbReturned, NULL))
     341        return GetLastError();      /* @todo Add better error lookup. */
     342
     343    return VINF_SUCCESS;
     344
    295345#elif defined(VBOX_VBGLR3_XFREE86)
    296346    /* PORTME - This is preferred over the RTFileIOCtl variant below, just be careful with the (int). */
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