Skip to content

Commit 24d6848

Browse files
committed
[NTOS/MM]
- Implement MmProbeAndLockProcessPages svn path=/branches/TransitionPte/; revision=71391
1 parent 1d67427 commit 24d6848

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

ntoskrnl/mm/ARM3/mdlsup.c

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,16 +1326,56 @@ MmProtectMdlSystemAddress(IN PMDL MemoryDescriptorList,
13261326
}
13271327

13281328
/*
1329-
* @unimplemented
1329+
* @implemented
13301330
*/
13311331
VOID
13321332
NTAPI
1333-
MmProbeAndLockProcessPages(IN OUT PMDL MemoryDescriptorList,
1333+
MmProbeAndLockProcessPages(IN OUT PMDL Mdl,
13341334
IN PEPROCESS Process,
13351335
IN KPROCESSOR_MODE AccessMode,
13361336
IN LOCK_OPERATION Operation)
13371337
{
1338-
UNIMPLEMENTED;
1338+
PVOID Address;
1339+
NTSTATUS Status = STATUS_SUCCESS;
1340+
1341+
BOOLEAN Attach;
1342+
KAPC_STATE ApcState;
1343+
1344+
DPRINT("Probing MDL: %p for process %p\n", Mdl, Process);
1345+
//
1346+
// Get address information, to see if we really need to attach
1347+
//
1348+
Address = (PVOID)((ULONG_PTR)Mdl->StartVa + Mdl->ByteOffset);
1349+
1350+
Attach = ((Process != PsGetCurrentProcess()) && (Address <= (PVOID)MM_USER_PROBE_ADDRESS));
1351+
if (Attach)
1352+
{
1353+
KeStackAttachProcess(&Process->Pcb, &ApcState);
1354+
}
1355+
1356+
_SEH2_TRY
1357+
{
1358+
MmProbeAndLockPages(Mdl, AccessMode, Operation);
1359+
}
1360+
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
1361+
{
1362+
//
1363+
// Oops :(
1364+
//
1365+
Status = _SEH2_GetExceptionCode();
1366+
}
1367+
_SEH2_END;
1368+
1369+
if (Attach)
1370+
{
1371+
KeUnstackDetachProcess(&ApcState);
1372+
}
1373+
1374+
if (!NT_SUCCESS(Status))
1375+
{
1376+
/* If the operation failed while we were attached, forward it to the caller */
1377+
ExRaiseStatus(Status);
1378+
}
13391379
}
13401380

13411381

0 commit comments

Comments
 (0)