Hi Guys
I did the same thing that u guys said and it worked great…with Windows XP
But i am witnessing some problems when it is windows2000.
For example in Windows 2000 once i load the driver then go to disk managment
and create a new partition it sits there for ever.
I dont get any bug checks nothing at all.but the operation never terminates
at all.I think it might be the case of Irp not being completed at all may
be.
But for windows xp there is no problem at all…My Sample code is as follows
Is it okay if we complete the Irp in the WorkerItem function??? Do i have to
return any other status codes in my MyReadWrite() function other than
STATUS_PENDING.
Thanks for ur help…
Regards
Shal
MyIoCompletion()
{
pWData = (WORKDATA *)ExAllocatePool( NonPagedPool, sizeof(WORKDATA));
//__debugbreak();
ASSERT(pWData!=NULL);
if (pWData)
{
pIOWorkItem = IoAllocateWorkItem( filterDeviceObject );
//FILL THE PWDATA STRUCTURE HERE//
//Mark it as pending
IoMarkIrpPending(Irp);
//QUEUE THE WORK ITEM
IoQueueWorkItem( pIOWorkItem, (PIO_WORKITEM_ROUTINE)ReadWriteWorkitem,
DelayedWorkQueue,pWData);
return STATUS_MORE_PROCESSING_REQUIRED;
}
}
MyReadWrite()
{
//Do everthing here
//build a new MDL
// fill the pWriteContext.
*nextIrpStack = *currentIrpStack;
IoMarkIrpPending(Irp);
IoSetCompletionRoutine(Irp,
MyIoCompletion,
pWriteContext,
TRUE,
TRUE,
TRUE);
rc1 = IoCallDriver(deviceExtension->TargetDeviceObject,Irp);
return STATUS_PENDING;
}
ReadWriteWorkitem()
{
MmUnmapLockedPages(ewData->User, (pWI->Irp)->MdlAddress);
IoFreeMdl((pWI->Irp)->MdlAddress);
(pWI->Irp)->MdlAddress=ewData->MdlAddress;
(pWI->Irp)->UserBuffer=ewData->DuplicateUserBuffer;
ExFreePool(ewData->DuplicateInputBuffer);
ewData->DuplicateInputBuffer=NULL;
ExFreePool(ewData);
ewData=NULL;
IoFreeWorkItem(pWI->pIOWorkItem);
(pWI->Irp)->IoStatus.Status = STATUS_SUCCESS;
//Complete the Irp Here
IoCompleteRequest((pWI->Irp), IO_NO_INCREMENT);
ExFreePool(pWI);
}
“Shalini” wrote in message news:xxxxx@ntdev…
> Awesome!!It worked great…
> Thanks Mark and Max!
>
>
> “Roddy, Mark” wrote in message
news:xxxxx@ntdev…
> > You need to study the irp completion rules documented here in the
> microsoft
> > KB articles:
> > http://support.microsoft.com/default.aspx?scid=kb;EN-US;320275
> >
> >
> >
> >
> > =====================
> > Mark Roddy
> >
> > -----Original Message-----
> > From: Shalini [mailto:xxxxx@yahoo.com]
> > Sent: Wednesday, June 30, 2004 9:55 AM
> > To: Windows System Software Devs Interest List
> > Subject: Re:[ntdev] MmunMapLockedPages Causing Bugcheck B8
> >
> > Hi Guys
> > I did as you guys said me to create a Work Queue and do the processing
> > there…
> > But however i added the last statement in the Workerfunction as
> >
> > IoCompleteRequest(Irp, IO_NO_INCREMENT); and from the IoCompletion
routine
> i
> > return STATUS_MORE_PROCESSING_REQUIRED.
> > But i get the Bugcheck 44
> >
> > MULTIPLE complete requests…
> > If i dont add IoCompleteRequest as the last statement in the workerfnc
the
> > OS calls it just once…i think Irp is not completed and hence it does
not
> > call once again at all…So the system never boots…
> > Any ideas on this?
> > I also came across a post which says we have to return STATUS_PENDING
from
> > dispatch function but i am not sure abt that…cud u give me some hints
on
> > how to do the same?
> >
> > Thanks
> >
> >
> >
> >
> > wrote in message news:xxxxx@ntdev…
> > Shalini,
> > You have still long way to go. It is right that you have to check the
IRQL
> > before calling MmUnmapLockedPages while unmapping user address space. If
> the
> > IRQL is DISPATCH_LEVEL you have to do couple of more things.
> > 1. Because you are doing this in CompletionRoutine you have to return
> > STATUS_MORE_PROCESSING_REQUIRED. This is needed so that Completion of
IRP
> is
> > pended.
> > 2. You have to queue an Work Queue item.
> > 3. In the work queue item, you have to unmap the locked pages and
complete
> > the IRP.
> >
> > Above would be right, only if you specified AccessMode as KernelMode
when
> > you mapped the pages. If you specified AccessMode as UserMode then you
> have
> > to set the correct process context before calling MmUnmapLockedPages in
> work
> > queue item. Not only that you have to check the process context in
> addition
> > to IRQL in completion routine before calling MmUnmapLockedPages
> >
> > Look at KeStackAttackProcess and KeUnstackDetachProcess for changing
> address
> > context.
> >
> > -Srin.
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of Shalini
> > Sent: Monday, June 28, 2004 9:45 AM
> > To: Windows System Software Devs Interest List
> > Subject: Re:[ntdev] MmunMapLockedPages Causing Bugcheck B8
> >
> >
> > Pro>> thats ok no problems.
> > Srin_Kumar>> I just added an If condition
> >
> > if(KeGetCurrentIrql()<dispatch_level>> > {
> > MmUnmapLockedPages(ewData->User, Irp->MdlAddress); }
> >
> > and it works fine and good with no bugcheck… but cud u tell me is it a
> > correct way of proceeding??
> >
> >
> > “Programmers Society Prokash Sinha” wrote in
message
> > news:xxxxx@ntdev…
> > > Sorry, I got the first response wrong -pro
> > >
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: xxxxx@nai.com To
> unsubscribe
> > send a blank email to xxxxx@lists.osr.com
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: xxxxx@stratus.com To
> > unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
></dispatch_level>