Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

Overlapped object not detecting requrests with failed statut

aditya_guptaaditya_gupta Member Posts: 2
I am sending a DeviceIoControl request from an user application with overlapped object.

DeviceIoControl(hScsiDriver, IOCTL_SCSI_MINIPORT, ScsiRequestBuffer, InputLength, ScsiReplyBuffer, OutputLength, &ReturnLength, pOverlappedObject);

Later I am checking status of the Ioctl using GetOverlappedResult.

status = GetOverlappedResult(pVMstruct->hScsiDriver[pVMstruct->activatedDrive],
pOverlappedObject , &returnLength, TRUE);


The request is completed by a storport miniport driver. The problem is if I set srbStatus in SRB as SRB_STATUS_SUCCESS or SRB_STATUS_BUSY, everything works fine. But if I set the status as anything else(like SRB_STATUS_ERROR), GetOverlappedResult never returns. This causes my application to hang. Where am I going wrong ?

Comments

  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,373
    In this case, what does the DeviceIoControl call return? Are you checking the return value?

    Bent from my phone

    ________________________________
    From: 30231624400n behalf of
    Sent: Thursday, September 13, 2018 10:23 PM
    To: Windows System Software Devs Interest List
    Subject: [ntdev] Overlapped object not detecting requrests with failed statut

    I am sending a DeviceIoControl request from an user application with overlapped object.

    DeviceIoControl(hScsiDriver, IOCTL_SCSI_MINIPORT, ScsiRequestBuffer, InputLength, ScsiReplyBuffer, OutputLength, &ReturnLength, pOverlappedObject);

    Later I am checking status of the Ioctl using GetOverlappedResult.

    status = GetOverlappedResult(pVMstruct->hScsiDriver[pVMstruct->activatedDrive],
    pOverlappedObject , &returnLength, TRUE);


    The request is completed by a storport miniport driver. The problem is if I set srbStatus in SRB as SRB_STATUS_SUCCESS or SRB_STATUS_BUSY, everything works fine. But if I set the status as anything else(like SRB_STATUS_ERROR), GetOverlappedResult never returns. This causes my application to hang. Where am I going wrong ?

    ---
    NTDEV is sponsored by OSR

    Visit the list online at:

    MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
    Details at

    To unsubscribe, visit the List Server section of OSR Online at
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 12,667
    xxxxx@gmail.com wrote:
    > I am sending a DeviceIoControl request from an user application with overlapped object.
    >
    > DeviceIoControl(hScsiDriver, IOCTL_SCSI_MINIPORT, ScsiRequestBuffer, InputLength, ScsiReplyBuffer, OutputLength, &ReturnLength, pOverlappedObject);
    >
    > Later I am checking status of the Ioctl using GetOverlappedResult.
    >
    > status = GetOverlappedResult(pVMstruct->hScsiDriver[pVMstruct->activatedDrive],
    > pOverlappedObject , &returnLength, TRUE);
    >
    > The request is completed by a storport miniport driver. The problem is if I set srbStatus in SRB as SRB_STATUS_SUCCESS or SRB_STATUS_BUSY, everything works fine. But if I set the status as anything else(like SRB_STATUS_ERROR), GetOverlappedResult never returns. This causes my application to hang. Where am I going wrong ?

    There is a subtlety to overlapped I/O that many programmers miss. If the
    driver completes the request with a non-success status during the first
    contact, then DeviceIoControl will return an error immediately.  In that
    case, you do NOT call GetOverlappedResult.

    There are three possible result paths for overlapped I/O:

        result = DeviceIoControl( );
        if result is non-zero
            request is complete, no further checking needed
        else if GetLastError is not ERROR_IO_PENDING
            request failed already, no further checking needed
        else
           GetOverlappedResult

    Many people skip that second outcome.

    --
    Tim Roberts, xxxxx@probo.com
    Providenza & Boekelheide, Inc.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • MBondMBond Member - All Emails Posts: 846
    Also remember SetFileCompletionNotificationModes. This only applies to overlapped IO with handles associated with IO completion ports, but except for IO during some initialization phase, that should be all of your overlapped IO.



    New development should probably use the thread pool APIs (IIRC available since Vista?) but there are many applications that use the raw ICOP APIs and manage the threads directly.



    Sent from Mail for Windows 10



    ________________________________
    From: xxxxx@lists.osr.com on behalf of xxxxx@probo.com
    Sent: Friday, September 14, 2018 12:55:46 PM
    To: Windows System Software Devs Interest List
    Subject: Re: [ntdev] Overlapped object not detecting requrests with failed statut

    xxxxx@gmail.com wrote:
    > I am sending a DeviceIoControl request from an user application with overlapped object.
    >
    > DeviceIoControl(hScsiDriver, IOCTL_SCSI_MINIPORT, ScsiRequestBuffer, InputLength, ScsiReplyBuffer, OutputLength, &ReturnLength, pOverlappedObject);
    >
    > Later I am checking status of the Ioctl using GetOverlappedResult.
    >
    > status = GetOverlappedResult(pVMstruct->hScsiDriver[pVMstruct->activatedDrive],
    > pOverlappedObject , &returnLength, TRUE);
    >
    > The request is completed by a storport miniport driver. The problem is if I set srbStatus in SRB as SRB_STATUS_SUCCESS or SRB_STATUS_BUSY, everything works fine. But if I set the status as anything else(like SRB_STATUS_ERROR), GetOverlappedResult never returns. This causes my application to hang. Where am I going wrong ?

    There is a subtlety to overlapped I/O that many programmers miss. If the
    driver completes the request with a non-success status during the first
    contact, then DeviceIoControl will return an error immediately. In that
    case, you do NOT call GetOverlappedResult.

    There are three possible result paths for overlapped I/O:

    result = DeviceIoControl( );
    if result is non-zero
    request is complete, no further checking needed
    else if GetLastError is not ERROR_IO_PENDING
    request failed already, no further checking needed
    else
    GetOverlappedResult

    Many people skip that second outcome.

    --
    Tim Roberts, xxxxx@probo.com
    Providenza & Boekelheide, Inc.


    ---
    NTDEV is sponsored by OSR

    Visit the list online at:

    MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
    Details at

    To unsubscribe, visit the List Server section of OSR Online at
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!