VirtualBox

Changeset 68553 in vbox for trunk


Ignore:
Timestamp:
Aug 31, 2017 12:09:51 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
117770
Message:

merging vbglioc r117699: vbglR0IdcNtCallInternal: We don't need a completion callback when we've got an event associated with the IRP (see description of the 'Event' parameter here: https://msdn.microsoft.com/en-us/library/windows/hardware/ff548318(v=vs.85).aspx ). In any case, returning STATUS_MORE_PROCESSING_REQUIRED sabotaged the copy back of the buffers during IoCompleteRequest by triggering an early exit. Current code is doing some trickery to avoid double buffering.

File:
1 edited

Legend:

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

    r68550 r68553  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
     31#include <iprt/nt/nt.h>
    3132#include "VBoxGuestR0LibInternal.h"
    3233#include <VBox/VBoxGuest.h>
    3334#include <VBox/err.h>
    3435#include <VBox/log.h>
    35 
    36 
    37 /**
    38  * Implementation of a IO_COMPLETION_ROUTINE.
    39  *
    40  * @returns STATUS_MORE_PROCESSING_REQUIRED
    41  * @param   pDeviceObject   The device object.
    42  * @param   pIrp            The request.
    43  * @param   pvUser          The event object.
    44  */
    45 static NTSTATUS vbglR0NtDriverIoCtlCompletion(IN PDEVICE_OBJECT pDeviceObject, IN PIRP pIrp, IN PVOID pvUser)
    46 {
    47     PKEVENT pEvent = (PKEVENT )pvUser;
    48     Log(("vbglR0NtDriverIoCtlCompletion: pIrp=%p pEvent=%p\n", pIrp, pEvent));
    49     RT_NOREF2(pDeviceObject, pIrp);
    50 
    51     KeSetEvent(pEvent, IO_NO_INCREMENT, FALSE /*fWait*/);
    52     return STATUS_MORE_PROCESSING_REQUIRED;
    53 }
    5436
    5537
     
    6547static int vbglR0IdcNtCallInternal(PDEVICE_OBJECT pDeviceObject, PFILE_OBJECT pFileObject, uint32_t uReq, PVBGLREQHDR pReq)
    6648{
    67     int                 rc;
    68     IO_STATUS_BLOCK     IoStatusBlock;
    69     KEVENT              Event;
    70     PIRP                pIrp;
    71     NTSTATUS            rcNt;
     49    int      rc;
     50    NTSTATUS rcNt;
    7251
    7352    /*
    7453     * Build the request.
     54     *
     55     * We want to avoid double buffering of the request, therefore we don't
     56     * specify any request pointers or sizes when asking the kernel to build
     57     * the IRP for us, but instead do that part our selves.
    7558     */
     59    KEVENT Event;
    7660    KeInitializeEvent(&Event, NotificationEvent, FALSE);
    77     pIrp = IoBuildDeviceIoControlRequest(uReq,              /* IoControlCode */
    78                                          pDeviceObject,
    79                                          pReq,              /* InputBuffer */
    80                                          pReq->cbIn,        /* InputBufferLength */
    81                                          pReq,              /* OutputBuffer */
    82                                          pReq->cbOut,       /* OutputBufferLength */
    83                                          TRUE,              /* InternalDeviceIoControl (=> IRP_MJ_INTERNAL_DEVICE_CONTROL) */
    84                                          &Event,            /* Event */
    85                                          &IoStatusBlock);   /* IoStatusBlock */
     61
     62    IO_STATUS_BLOCK IoStatusBlock = RTNT_IO_STATUS_BLOCK_INITIALIZER;
     63#if 0
     64    PIRP pIrp = IoBuildDeviceIoControlRequest(uReq,              /* IoControlCode */
     65                                              pDeviceObject,
     66                                              pReq,              /* InputBuffer */
     67                                              pReq->cbIn,        /* InputBufferLength */
     68                                              pReq,              /* OutputBuffer */
     69                                              pReq->cbOut,       /* OutputBufferLength */
     70                                              TRUE,              /* InternalDeviceIoControl (=> IRP_MJ_INTERNAL_DEVICE_CONTROL) */
     71                                              &Event,            /* Event */
     72                                              &IoStatusBlock);   /* IoStatusBlock */
     73#else
     74    PIRP pIrp = IoBuildDeviceIoControlRequest(uReq,              /* IoControlCode */
     75                                              pDeviceObject,
     76                                              NULL,              /* InputBuffer */
     77                                              0,                 /* InputBufferLength */
     78                                              NULL,              /* OutputBuffer */
     79                                              0,                 /* OutputBufferLength */
     80                                              TRUE,              /* InternalDeviceIoControl (=> IRP_MJ_INTERNAL_DEVICE_CONTROL) */
     81                                              &Event,            /* Event */
     82                                              &IoStatusBlock);   /* IoStatusBlock */
     83#endif
    8684    if (pIrp)
    8785    {
     86#if 0
    8887        IoGetNextIrpStackLocation(pIrp)->FileObject = pFileObject;
    89 
    90         /* A completion routine is required to signal the Event. */
    91         IoSetCompletionRoutine(pIrp, vbglR0NtDriverIoCtlCompletion, &Event,
    92                                TRUE /* InvokeOnSuccess */, TRUE /* InvokeOnError */, TRUE /* InvokeOnCancel */);
     88#else
     89        pIrp->Flags                                          |= IRP_SYNCHRONOUS_API;
     90        pIrp->UserBuffer                                      = pReq;
     91        pIrp->AssociatedIrp.SystemBuffer                      = pReq;
     92        PIO_STACK_LOCATION pStack = IoGetNextIrpStackLocation(pIrp);
     93        pStack->FileObject                                    = pFileObject;
     94        pStack->Parameters.DeviceIoControl.OutputBufferLength = pReq->cbOut;
     95        pStack->Parameters.DeviceIoControl.InputBufferLength  = pReq->cbIn;
     96#endif
    9397
    9498        /*
     
    97101        rcNt = IoCallDriver(pDeviceObject, pIrp);
    98102        if (rcNt == STATUS_PENDING)
    99         {
    100103            rcNt = KeWaitForSingleObject(&Event,            /* Object */
    101104                                         Executive,         /* WaitReason */
     
    103106                                         FALSE,             /* Alertable */
    104107                                         NULL);             /* TimeOut */
     108        if (NT_SUCCESS(rcNt))
    105109            rcNt = IoStatusBlock.Status;
    106         }
    107110        if (NT_SUCCESS(rcNt))
    108111            rc = pReq->rc;
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