MmunMapLockedPages Causing Bugcheck B8

Hello Guys
My MmunMapLockedPages in IoCompletion routine is giving me Bugcheck B8 with
all the Args being NULL.
and moreever this happens only when the File system is NTFS.
Any ideas on how to proceed?
Has anyone come across these…

Sample code is as follows…

ASSERT((ewData->User)!=NULL);
ASSERT(Irp->MdlAddress!=NULL);
__try{
MmUnmapLockedPages(ewData->User, Irp->MdlAddress);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
KdPrint((“\nError in MmUnmapLockedPages”));
}

Regards
Shal

why this assertions are != NULL ???

-pro

Shal,
Are the pages mapped to system space, or to a user space? Is the
IRQL at which you are unmapping < DISPATCH_LEVEL or <= DISPATCH_LEVEL?

-Srin.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Shalini
Sent: Monday, June 28, 2004 7:56 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] MmunMapLockedPages Causing Bugcheck B8

Hello Guys
My MmunMapLockedPages in IoCompletion routine is giving me
Bugcheck B8 with all the Args being NULL.
and moreever this happens only when the File system is NTFS.
Any ideas on how to proceed?
Has anyone come across these…

Sample code is as follows…

ASSERT((ewData->User)!=NULL);
ASSERT(Irp->MdlAddress!=NULL);
__try{
MmUnmapLockedPages(ewData->User, Irp->MdlAddress);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
KdPrint((“\nError in MmUnmapLockedPages”));
}

Regards
Shal


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

Sorry, I got the first response wrong -pro

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
></dispatch_level>

I would be bit careful about your plan. U’r unlocking since U locked it, so there is a case when Ur routine is hitting at > dispatch_level. What do you do in that case. Usually you should cover that too, create an workitem and queue it…

-pro

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</dispatch_level>

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</dispatch_level>

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>

Call IoMarkIrpPending on the IRP before sending it to the work item.
Return STATUS_PENDING from the dispatch routine.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

“Shalini” wrote in message
news:…
> 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@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com</dispatch_level>

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>

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>

Hi Guys
I am completing my IRP in the Work Item function.
This work item function is initiated in the MyIOCompletion function.
Everthing works good but sometimes i
see that the work item function is not called. This makes my IRP always in
the Pending state. This occurs “very very rarely”.
What cud cause the work item to be lost?

Thanks for ur help…
Regards
Shal

“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>

Shal,
Check all the system threads, I am doubting if all your work
item routines are waiting for something to happen, and there are no more
worker threads to schedule your work item.

-Srin.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Shalini
Sent: Tuesday, July 13, 2004 2:32 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] MmunMapLockedPages Causing Bugcheck B8

Hi Guys
I am completing my IRP in the Work Item function.
This work item function is initiated in the MyIOCompletion function.
Everthing works good but sometimes i see that the work item function is
not called. This makes my IRP always in the Pending state. This occurs
“very very rarely”. What cud cause the work item to be lost?

Thanks for ur help…
Regards
Shal

“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
> >
>
>
>


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</dispatch_level>

Like the system boots fine and all the work items are deleted perfectly in
the work item function.
But once the system boots and i open the disk management application and try
to create a partition i get an irp which is queued but it never makes up
to the work item function. Hence its never completed. I have seen this only
when i create a new partition with the driver loaded.

wrote in message news:xxxxx@ntdev…
Shal,
Check all the system threads, I am doubting if all your work
item routines are waiting for something to happen, and there are no more
worker threads to schedule your work item.

-Srin.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Shalini
Sent: Tuesday, July 13, 2004 2:32 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] MmunMapLockedPages Causing Bugcheck B8

Hi Guys
I am completing my IRP in the Work Item function.
This work item function is initiated in the MyIOCompletion function.
Everthing works good but sometimes i see that the work item function is
not called. This makes my IRP always in the Pending state. This occurs
“very very rarely”. What cud cause the work item to be lost?

Thanks for ur help…
Regards
Shal

“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
> >
>
>
>


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</dispatch_level>

Srin_Kumar,
In one of ur previous response u said me to use KeStackAttachProcess and
KeunStackDetachProcess.
This is because when my Irp->RequestorMode is Usermode my MmUnMapLockedPages
in Worker function never returns so
i have a totally pending irp. This pending irp happens only when the
Irp->requestoMode is usermode while doing a MmMapLockedPages. Could u please
tell me how to use KeStackAttach and KeUnStackDetachProcess.

Actually when i use that i find some problems and i get the Bugcheck CC

in my Dispatch function

pWC->oMyProcess = IoGetCurrentProcess();
pWC->User = MmMapLockedPagesSpecifyCache(Irp->MdlAddress,
Irp->RequestorMode,
MmNonCached,
NULL,
FALSE,
NormalPagePriority);
ASSERT(pWC->User!=NULL);
ASSERT(pWC->oMyProcess!=NULL);

In my Worker function to Unmap i am doing it like this

//ewData is actually pWC passed in the worker func

else if((pWI->Irp)->RequestorMode==UserMode)
{
if (IoGetCurrentProcess() != ewData->oMyProcess)
{
KeStackAttachProcess(ewData->oMyProcess,&Apc_State);
AssociatedToSystemState=TRUE;
}

if((ewData->User))
{
MmUnmapLockedPages(ewData->User, (pWI->Irp)->MdlAddress);
}

if(AssociatedToSystemState)
{
KeUnstackDetachProcess(&Apc_State);
AssociatedToSystemState=FALSE;
}

//freeing all mdls and other stuffs
(pWI->Irp)->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest((pWI->Irp), IO_NO_INCREMENT);
ExFreePool(pWI);
pWI=NULL;

}

Is this correct? I am getting a Bugcheck CC
(PAGE_FAULT_IN_FREED_SPECIAL_POOL ).

if(irp-
wrote in message news:xxxxx@ntdev…
Shal,
Check all the system threads, I am doubting if all your work
item routines are waiting for something to happen, and there are no more
worker threads to schedule your work item.

-Srin.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Shalini
Sent: Tuesday, July 13, 2004 2:32 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] MmunMapLockedPages Causing Bugcheck B8

Hi Guys
I am completing my IRP in the Work Item function.
This work item function is initiated in the MyIOCompletion function.
Everthing works good but sometimes i see that the work item function is
not called. This makes my IRP always in the Pending state. This occurs
“very very rarely”. What cud cause the work item to be lost?

Thanks for ur help…
Regards
Shal

“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
> >
>
>
>


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</dispatch_level>