Problem in calling the IoBuildAsynchronousFsdRequest.

Discussion in 'Windows Vista Drivers' started by Peter Wieland [MSFT], Jul 30, 2004.

  1. why not just use the IRP you received in your dispatch routine instead of
    allocating a new one each time?

    -p
     
    Peter Wieland [MSFT], Jul 30, 2004
    #1
    1. Advertisements

  2. Can you use IoBuildSynchronousFsdRequest instead? For your particular case,
    this function is very much suitable.
     
    Maxim S. Shatskih, Jul 31, 2004
    #2
    1. Advertisements

  3. Hi,
    I am trying to use the IoBuildAsynchronousFsdRequest funtion inside my
    IRP_MJ_READ dispatcher function. When i call the IoCallDriver , i am getting
    BSOD. Can anybody help me out ? i have attached the source code here with.


    ----------------------------------------------------------------------------
    ---
    {
    StartingOffset.HighPart = StartingOffset.LowPart = 0;

    m_WriteBuffer = ExAllocatePool( NonPagedPool, BUFFER_SIZE );
    // Build asynchronous Irp request
    localIrp = IoBuildAsynchronousFsdRequest(
    IRP_MJ_READ,
    deviceExtension->FileSystemDeviceObject,
    m_WriteBuffer,
    512,
    &StartingOffset,
    &ioStatusBlock);
    if (!localIrp)
    {
    return STATUS_UNSUCCESSFUL;
    }


    // Set completion routine to validate finishing request.
    KeInitializeEvent(&event,NotificationEvent,FALSE);
    localIrp->UserEvent = &event;
    localIrp->Tail.Overlay.OriginalFileObject = current->FileObject;
    localIrp->RequestorMode = KernelMode;

    IoSetCompletionRoutine(
    localIrp,
    MyComplete,
    0,
    TRUE,
    TRUE,
    TRUE);
    status = IoCallDriver(deviceExtension->FileSystemDeviceObject, localIrp);
    // Set Irp stack frame to the next loweer one.
    localIrp->CurrentLocation--;
    localIrp->Tail.Overlay.CurrentStackLocation
    = IoGetNextIrpStackLocation(localIrp);

    if (status == STATUS_PENDING)
    {
    KeWaitForSingleObject(&event,
    Executive,
    KernelMode,
    FALSE,
    NULL);
    }

    }

    TSTATUS
    MyComplete(
    PDEVICE_OBJECT DeviceObject,
    PIRP Irp,
    PVOID Context
    )
    {
    //
    *Irp->UserIosb = Irp->IoStatus;
    if( !NT_SUCCESS(Irp->IoStatus.Status) ) {

    DbgPrint(" ERROR ON IRP: %x\n", Irp->IoStatus.Status );
    }

    //
    // Set the user event - wakes up the mainline code doing this.
    //
    KeSetEvent(Irp->UserEvent, 0, FALSE);

    //
    // Free the IRP now that we are done with it.
    DbgPrint("IMP : Inside Completion routine \n");
    //
    IoFreeIrp(Irp);
    return STATUS_MORE_PROCESSING_REQUIRED;
    }
     
    A.Ilamparithi, Jul 31, 2004
    #3
  4. Actually i want to make more than one IRPs and get data from different
    offsets. Thats why i am creating IRPs inside the IRP_MJ_READ.

    Thankx in Advance,
    Ilam parithi.
     
    A.Ilamparithi, Jul 31, 2004
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.