Lock the kernel address space instead the process' one, if the pages are located in kernel space.

Unlock the address space on error.


svn path=/trunk/; revision=13963
This commit is contained in:
Hartmut Birr 2005-03-12 09:14:38 +00:00
parent 57787bb881
commit 653d79d129

View file

@ -361,6 +361,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
KPROCESSOR_MODE Mode; KPROCESSOR_MODE Mode;
PFN_TYPE Page; PFN_TYPE Page;
PEPROCESS CurrentProcess = PsGetCurrentProcess(); PEPROCESS CurrentProcess = PsGetCurrentProcess();
PMADDRESS_SPACE AddressSpace;
DPRINT("MmProbeAndLockPages(Mdl %x)\n", Mdl); DPRINT("MmProbeAndLockPages(Mdl %x)\n", Mdl);
@ -394,19 +395,21 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
//FIXME: why isn't AccessMode used? //FIXME: why isn't AccessMode used?
Mode = KernelMode; Mode = KernelMode;
Mdl->Process = NULL; Mdl->Process = NULL;
AddressSpace = MmGetKernelAddressSpace();
} }
else else
{ {
//FIXME: why isn't AccessMode used? //FIXME: why isn't AccessMode used?
Mode = UserMode; Mode = UserMode;
Mdl->Process = CurrentProcess; Mdl->Process = CurrentProcess;
AddressSpace = &CurrentProcess->AddressSpace;
} }
/* /*
* Lock the pages * Lock the pages
*/ */
MmLockAddressSpace(&CurrentProcess->AddressSpace); MmLockAddressSpace(AddressSpace);
for (i = 0; i < NrPages; i++) for (i = 0; i < NrPages; i++)
{ {
@ -430,6 +433,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
MmUnlockPage(Page); MmUnlockPage(Page);
MmDereferencePage(Page); MmDereferencePage(Page);
} }
MmUnlockAddressSpace(AddressSpace);
ExRaiseStatus(Status); ExRaiseStatus(Status);
} }
} }
@ -450,6 +454,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
MmUnlockPage(Page); MmUnlockPage(Page);
MmDereferencePage(Page); MmDereferencePage(Page);
} }
MmUnlockAddressSpace(AddressSpace);
ExRaiseStatus(Status); ExRaiseStatus(Status);
} }
} }
@ -458,7 +463,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
MmReferencePage(Page); MmReferencePage(Page);
} }
MmUnlockAddressSpace(&CurrentProcess->AddressSpace); MmUnlockAddressSpace(AddressSpace);
Mdl->MdlFlags |= MDL_PAGES_LOCKED; Mdl->MdlFlags |= MDL_PAGES_LOCKED;
} }