Hi Mark,
Thanks for your replay Mark. It is of disk Mirror driver but very simple as
of now.
Our main aim to create two different IRPS using original IRP.
According to our understanding for buffered I/O IRP data can be accessed
using original_pIrp->AssociatedIrp.SystemBuffer, thats why we are using
system buffer to create new IRPS.
Following is the code snippet that we’ve:
*
<------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
/* 1st IRP creation */
newIrpDisk1 = IoBuildAsynchronousFsdRequest(IRP_MJ_WRITE,
pDevExt->pTargetDeviceObject1,
pOriginalIrp->AssociatedIrp.SystemBuffer,
pOriginalIrpStack->Parameters.Write.Length,
&lDiskOffset,
&ioStatus);
newIrp1stack =
IoGetNextIrpStackLocation(newIrpDisk1);
if (!newIrpDisk1) {
DbgPrint(“IoBuildSynchronousFsdRequest failed to crete new IRP %s 1 \n”,
FUNCTION);
status =
STATUS_INSUFFICIENT_RESOURCES;
goto end;
}
IoSetCompletionRoutine(newIrpDisk1,
WriteIoCompletion, Context, TRUE, TRUE, TRUE);
newIrp1stack->FileObject =
pDevExt->pFileObject1;
status =
IoCallDriver(pDevExt->pTargetDeviceObject1, newIrpDisk1);
/* 2nd IRP creation */
newIrpDisk2 = IoBuildAsynchronousFsdRequest(IRP_MJ_WRITE,
pDevExt->pTargetDeviceObject2,
pOriginalIrp->AssociatedIrp.SystemBuffer,
pOriginalIrpStack->Parameters.Write.Length,
&lDiskOffset,
&ioStatus);
newIrp2stack =
IoGetNextIrpStackLocation(newIrpDisk2);
if (!newIrpDisk2) {
DbgPrint(“IoBuildSynchronousFsdRequest failed to crete new IRP %s 2 \n”,
FUNCTION);
status =
STATUS_INSUFFICIENT_RESOURCES;
goto end;
}
IoSetCompletionRoutine(newIrpDisk2,
WriteIoCompletion, Context, TRUE, TRUE, TRUE);
newIrp2stack->FileObject =
pDevExt->pFileObject2;
status =
IoCallDriver(pDevExt->pTargetDeviceObject2, newIrpDisk2);
<------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
*
Above code is failing @2nd IoCallDriver with following crash dump message:
<----------------------------------------------------------------------------------------------------------->
PFN_LIST_CORRUPT (4e)
Typically caused by drivers passing bad memory descriptor lists (ie:
callingMmUnlockPages twice with the same list, etc). If a kernel debugger
is
available get the stack trace.
<----------------------------------------------------------------------------------------------------------->
According to our understanding we need to do MDL manipulation when direct
I/O in picture, but we are doing buffered I/O so we are
usingpOriginalIrp->AssociatedIrp.SystemBuffer.
Is this correct ?
Please correct me I am very new at windows kernel development.
On Thu, Aug 18, 2011 at 11:28 PM, Mark Roddy wrote:
> This is a disk mirror driver?
>
> In general you want to use MDL based operations and use IoBuildPartialMdl
> to correctly share the original MDL with one or more related IRPs.
>
> Mark Roddy
>
>
> On Thu, Aug 18, 2011 at 2:26 AM, chaitanya kulkarni <
> xxxxx@gmail.com> wrote:
>
>> Hi,
>>
>> I am new to windows kernel development.
>>
>> I am writing Simple Mirror driver in windows kernel.I am facing some
>> problem in write dispatch routine.
>>
>> Following are the steps:-
>>
>> 1. In DriverEntry virtual device is created using IoCreateDevice and
>> pointers to actual storage devices are stored in device extension using
>> IoGetDeviceObjectPointer.
>>
>> 2. In WriteDispatch routine after receiving the original IRP, two new IRPs
>> are created (with different IRP pointers) using
>> IoBuildAsynchronousFsdRequest.
>>
>> 3. For both calls to IoBuildAsynchronousFsdRequest, passing original IRPs
>> Associated.Systembuffer to create new IRP (for buffered IO).
>>
>> 4. Then initialize WriteCompletionRoutine followed by the call to
>> IoCallDriver with newly crated IRP, passing Original IRP as an argument
>> (Context) to completion routine.
>>
>> 5. In completion routine calling IoFreeIrp for new IRPs.
>>
>> 6. When Completion routine called last time for new IRP, completing
>> original IRP by calling IoCompleteRequest.
>>
>> Driver producing crash dump, after Crashdump analysis using WinDbg we
>> found that IoCallDriver for 2nd IRP is failing along with following message:
>>
>>
>> <----------------------------------------------------------------------------------------------------------->
>> PFN_LIST_CORRUPT (4e)
>> Typically caused by drivers passing bad memory descriptor lists (ie:
>> callingMmUnlockPages twice with the same list, etc). If a kernel debugger
>> is
>> available get the stack trace.
>>
>> <----------------------------------------------------------------------------------------------------------->
>>
>> I am speculating that using original IRP system buffer to create two IRPs
>> it is creating problem.
>>
>> So I created new two buffers( using ExAllocatePoolWithTag) and used those
>> to create new IRPs, and ReadDispatch and WriteDispatch is executed without
>> problem.
>>
>> We trying to find out appropriate way to solve this problem. (need to
>> avoid buffer creation inside kernel memory)
>>
>> We tried to follow this link to understand working of
>> IoBuildAsynchronousFsdRequest :
>> http://www.koders.com/c/fid7F69307699E37B3C069034986A8F8E97F6A41D66.aspx
>>
>> Can someone please help us on this issue ?
>>
>> –
>> Thanks and Regards,
>> Chaitanya Kulkarni
>> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
>> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
>> the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>
>
> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
> the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
–
Thanks and Regards,
Chaitanya Kulkarni