VirtualBox

Changeset 37474 in vbox for trunk


Ignore:
Timestamp:
Jun 15, 2011 4:38:56 PM (13 years ago)
Author:
vboxsync
Message:

hrmpf.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp

    r37226 r37474  
    2626#include <VBox/VBoxGuestLib.h>
    2727
    28 #include <VBoxGuestInternal.h>
    29 
    30 #ifdef TARGET_NT4
    3128/*
    3229 * XP DDK #defines ExFreePool to ExFreePoolWithTag. The latter does not exist
    3330 * on NT4, so... The same for ExAllocatePool.
    3431 */
    35 #undef ExAllocatePool
    36 #undef ExFreePool
     32#ifdef TARGET_NT4
     33# undef ExAllocatePool
     34# undef ExFreePool
    3735#endif
    3836
    3937/*******************************************************************************
    40 *   Defined Constants And Macros                                               *
    41 *******************************************************************************/
    42 
    43 
    44 /*******************************************************************************
    45 *   Entry Points                                                               *
     38*   Internal Functions                                                         *
    4639*******************************************************************************/
    4740RT_C_DECLS_BEGIN
     
    5548static NTSTATUS vboxguestwinShutdown(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    5649static NTSTATUS vboxguestwinNotSupportedStub(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    57 RT_C_DECLS_END
    58 
    59 
    60 /*******************************************************************************
    61 *   Internal Functions                                                         *
    62 *******************************************************************************/
    63 RT_C_DECLS_BEGIN
    6450#ifdef DEBUG
    65  static void    vboxguestwinDoTests(void);
     51static void     vboxguestwinDoTests(void);
    6652#endif
    6753RT_C_DECLS_END
     
    544530 * @param   pDrvObj     Driver object.
    545531 */
    546 void vboxguestwinUnload(PDRIVER_OBJECT pDrvObj)
     532static void vboxguestwinUnload(PDRIVER_OBJECT pDrvObj)
    547533{
    548534    Log(("VBoxGuest::vboxguestwinGuestUnload\n"));
     
    579565 * @param   pIrp        Request packet.
    580566 */
    581 NTSTATUS vboxguestwinCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     567static NTSTATUS vboxguestwinCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    582568{
    583569    /** @todo AssertPtrReturn(pIrp); */
     
    648634 * @param   pIrp        Request packet.
    649635 */
    650 NTSTATUS vboxguestwinClose(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     636static NTSTATUS vboxguestwinClose(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    651637{
    652638    PVBOXGUESTDEVEXT   pDevExt  = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension;
     
    679665 * @param   pIrp        Request packet.
    680666 */
    681 NTSTATUS vboxguestwinIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    682 {
    683     NTSTATUS Status = STATUS_SUCCESS;
    684     PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension;
    685     PIO_STACK_LOCATION pStack = IoGetCurrentIrpStackLocation(pIrp);
    686     unsigned int uCmd = (unsigned int)pStack->Parameters.DeviceIoControl.IoControlCode;
    687 
    688     char *pBuf = (char *)pIrp->AssociatedIrp.SystemBuffer; /* All requests are buffered. */
    689     size_t cbData = pStack->Parameters.DeviceIoControl.InputBufferLength;
    690     unsigned cbOut = 0;
     667static NTSTATUS vboxguestwinIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     668{
     669    NTSTATUS            Status  = STATUS_SUCCESS;
     670    PVBOXGUESTDEVEXT    pDevExt = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension;
     671    PIO_STACK_LOCATION  pStack  = IoGetCurrentIrpStackLocation(pIrp);
     672    unsigned int        uCmd    = (unsigned int)pStack->Parameters.DeviceIoControl.IoControlCode;
     673
     674    char               *pBuf    = (char *)pIrp->AssociatedIrp.SystemBuffer; /* All requests are buffered. */
     675    size_t              cbData  = pStack->Parameters.DeviceIoControl.InputBufferLength;
     676    unsigned            cbOut    = 0;
    691677
    692678    /* Do we have a file object associated?*/
    693     PFILE_OBJECT pFileObj = pStack->FileObject;
    694     PVBOXGUESTSESSION pSession = NULL;
     679    PFILE_OBJECT        pFileObj = pStack->FileObject;
     680    PVBOXGUESTSESSION   pSession = NULL;
    695681    if (pFileObj) /* ... then we might have a session object as well! */
    696682        pSession = (PVBOXGUESTSESSION)pFileObj->FsContext;
     
    701687    /* We don't have a session associated with the file object? So this seems
    702688     * to be a kernel call then. */
     689    /** @todo r=bird: What on earth is this supposed to be? Each kernel session
     690     *        shall have its own context of course, no hacks, pleeease. */
    703691    if (pSession == NULL)
    704692    {
     
    758746             */
    759747            size_t cbDataReturned;
    760             int vrc = VBoxGuestCommonIOCtl(uCmd, pDevExt, pSession, (void*)pBuf, cbData, &cbDataReturned);
     748            int vrc = VBoxGuestCommonIOCtl(uCmd, pDevExt, pSession, pBuf, cbData, &cbDataReturned);
    761749
    762750            Log(("VBoxGuest::vboxguestwinGuestDeviceControl: rc=%Rrc, pBuf=0x%p, cbData=%u, cbDataReturned=%u\n",
     
    797785}
    798786
    799 /* we do not want to allow some IOCTLs to be originated from user mode,
    800  * this is why we have a separate vboxguestwinInternalIOCtl for internal IOCTLs */
    801 NTSTATUS vboxguestwinInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    802 {
    803     NTSTATUS Status = STATUS_SUCCESS;
    804     PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension;
    805     PIO_STACK_LOCATION pStack = IoGetCurrentIrpStackLocation(pIrp);
    806     unsigned int uCmd = (unsigned int)pStack->Parameters.DeviceIoControl.IoControlCode;
    807     BOOLEAN fProcessed = FALSE;
    808     unsigned Info = 0;
     787/**
     788 * Internal Device I/O Control entry point.
     789 *
     790 * We do not want to allow some IOCTLs to be originated from user mode, this is
     791 * why we have a different entry point for internal IOCTLs.
     792 *
     793 * @param   pDevObj     Device object.
     794 * @param   pIrp        Request packet.
     795 *
     796 * @todo r=bird: This is no need for this extra function for the purpose of
     797 *       securing an IOCTL from user space access.  VBoxGuestCommonIOCtl
     798 *       has a way to do this already, see VBOXGUEST_IOCTL_GETVMMDEVPORT.
     799 */
     800static NTSTATUS vboxguestwinInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     801{
     802    NTSTATUS            Status      = STATUS_SUCCESS;
     803    PVBOXGUESTDEVEXT    pDevExt     = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension;
     804    PIO_STACK_LOCATION  pStack      = IoGetCurrentIrpStackLocation(pIrp);
     805    unsigned int        uCmd        = (unsigned int)pStack->Parameters.DeviceIoControl.IoControlCode;
     806    bool                fProcessed  = false;
     807    unsigned            Info        = 0;
    809808
    810809    switch (uCmd)
     
    12651264}
    12661265
    1267 
    12681266#ifdef DEBUG
    1269 /** A quick implementation of AtomicTestAndClear for uint32_t and multiple
    1270  *  bits.
     1267
     1268/**
     1269 * A quick implementation of AtomicTestAndClear for uint32_t and multiple bits.
    12711270 */
    12721271static uint32_t vboxugestwinAtomicBitsTestAndClear(void *pu32Bits, uint32_t u32Mask)
     
    13171316    vboxguestwinTestAtomicTestAndClearBitsU32(0x22, 0x23, 0x22);
    13181317}
    1319 #endif
     1318
     1319#endif /* DEBUG */
     1320
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