//
// Get the address creation mutex to block multiple threads
// creating or deleting address space at the same time.
//
LOCK_ADDRESS_SPACE (Process); 它是这里加的锁
//
// Make sure the address space was not deleted, if so, return an error.
//
if (Process->Flags & PS_PROCESS_FLAGS_VM_DELETED) {
status = STATUS_PROCESS_IS_TERMINATING;
goto ErrorReturn;
}
//
// Map the view base on the type.
//
if (ControlArea->u.Flags.PhysicalMemory) {
// 这个函数发起的模块回调
status = MiMapViewOfPhysicalSection (ControlArea,
Process,
CapturedBase,
SectionOffset,
CapturedViewSize,
ProtectionMask,
ZeroBits,
AllocationType);
}
else if (ControlArea->u.Flags.Image) {
if (AllocationType & MEM_RESERVE) {
status = STATUS_INVALID_PARAMETER_9;
}
else if (Win32Protect & PAGE_WRITECOMBINE) {
status = STATUS_INVALID_PARAMETER_10;
}
else {
ImageCommitment = Section->Segment->u1.ImageCommitment;
status = MiMapViewOfImageSection (ControlArea,
Process,
CapturedBase,
SectionOffset,
CapturedViewSize,
Section,
InheritDisposition,
ZeroBits,
AllocationType,
ImageCommitment);
}
}
else {
//
// Not an image section, therefore it is a data section.
//
if (Win32Protect & PAGE_WRITECOMBINE) {
status = STATUS_INVALID_PARAMETER_10;
}
else {
status = MiMapViewOfDataSection (ControlArea,
Process,
CapturedBase,
SectionOffset,
CapturedViewSize,
Section,
InheritDisposition,
ProtectionMask,
CommitSize,
ZeroBits,
AllocationType);
}
}
ErrorReturn:
UNLOCK_ADDRESS_SPACE (Process); 这里解锁