VirtualBox

Ignore:
Timestamp:
Aug 5, 2011 10:27:14 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
73339
Message:

VBoxDrv: Don't create a session for ring-0 client that will be destroyed immeidately. Drop the windows specific cleanup hack.

Location:
trunk/src/VBox/HostDrivers/Support
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r38321 r38323  
    19131913            REQ_CHECK_IDC_SIZE(SUPDRV_IDC_REQ_DISCONNECT, sizeof(*pReqHdr));
    19141914
    1915 #ifdef RT_OS_WINDOWS
    1916             /* Windows will destroy the session when the file object is destroyed. */
    1917 #else
    19181915            supdrvCloseSession(pDevExt, pSession);
    1919 #endif
    19201916            return pReqHdr->rc = VINF_SUCCESS;
    19211917        }
  • trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp

    r38321 r38323  
    232232NTSTATUS _stdcall VBoxDrvNtCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    233233{
    234     Log(("VBoxDrvNtCreate\n"));
     234    Log(("VBoxDrvNtCreate: RequestorMode=%d\n", pIrp->RequestorMode));
    235235    PIO_STACK_LOCATION  pStack = IoGetCurrentIrpStackLocation(pIrp);
    236236    PFILE_OBJECT        pFileObj = pStack->FileObject;
     
    250250
    251251    /*
    252      * Call common code for the rest.
     252     * Don't create a session for kernel clients, they'll close the handle
     253     * immediately and work with the file object via
     254     * VBoxDrvNtInternalDeviceControl.  The first request will there be one
     255     * to create a session.
    253256     */
    254     pFileObj->FsContext = NULL;
    255     PSUPDRVSESSION pSession;
    256 //#if 0 /** @todo check if this works, consider OBJ_KERNEL_HANDLE too. */
    257     bool fUser = pIrp->RequestorMode != KernelMode;
    258 //#else
    259  //   bool fUser = true;
    260 //#endif
    261     int rc = supdrvCreateSession(pDevExt, fUser, &pSession);
    262     if (!rc)
    263         pFileObj->FsContext = pSession;
    264 
    265     NTSTATUS    rcNt = pIrp->IoStatus.Status = VBoxDrvNtErr2NtStatus(rc);
     257    NTSTATUS rcNt;
     258    if (pIrp->RequestorMode == KernelMode)
     259        rcNt = STATUS_SUCCESS;
     260    else
     261    {
     262        /*
     263         * Call common code for the rest.
     264         */
     265        pFileObj->FsContext = NULL;
     266        PSUPDRVSESSION pSession;
     267        int rc = supdrvCreateSession(pDevExt, true /*fUser*/, &pSession);
     268        if (!rc)
     269            pFileObj->FsContext = pSession;
     270        rcNt = pIrp->IoStatus.Status = VBoxDrvNtErr2NtStatus(rc);
     271    }
     272
    266273    pIrp->IoStatus.Information  = 0;
    267274    IoCompleteRequest(pIrp, IO_NO_INCREMENT);
     
    496503            {
    497504                /*
    498                  * Do the job.
     505                 * Call the generic code.
     506                 * 
     507                 * Note! Connect and disconnect requires some extra attention
     508                 *       in order to get the session handling right.
    499509                 */
     510                if (pStack->Parameters.DeviceIoControl.IoControlCode == SUPDRV_IDC_REQ_DISCONNECT)
     511                    pFileObj->FsContext = NULL;
     512
    500513                rc = supdrvIDC(pStack->Parameters.DeviceIoControl.IoControlCode, pDevExt, pSession, pHdr);
    501514                if (!rc)
     
    503516                    if (pStack->Parameters.DeviceIoControl.IoControlCode == SUPDRV_IDC_REQ_CONNECT)
    504517                        pFileObj->FsContext = ((PSUPDRVIDCREQCONNECT)pHdr)->u.Out.pSession;
    505                     /** @todo Handle SUPDRV_IDC_REQ_DISCONNECT and drop the
    506                      *        windows hack in the generic code. */
    507518
    508519                    rcNt = STATUS_SUCCESS;
     
    510521                }
    511522                else
     523                {
    512524                    rcNt = STATUS_INVALID_PARAMETER;
     525                    if (pStack->Parameters.DeviceIoControl.IoControlCode == SUPDRV_IDC_REQ_DISCONNECT)
     526                        pFileObj->FsContext = pSession;
     527                }
    513528                Log2(("VBoxDrvNtInternalDeviceControl: returns %#x/rc=%#x\n", rcNt, rc));
    514529            }
Note: See TracChangeset for help on using the changeset viewer.

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