Implemented MmMapViewInSystemSpace() and MmUnmapViewInSystemSpace().

svn path=/trunk/; revision=4683
This commit is contained in:
Eric Kohl 2003-05-14 10:52:46 +00:00
parent 10f9688a17
commit 9fef3a18ee
2 changed files with 139 additions and 48 deletions

View file

@ -1,6 +1,6 @@
#ifndef _INCLUDE_DDK_MMFUNCS_H #ifndef _INCLUDE_DDK_MMFUNCS_H
#define _INCLUDE_DDK_MMFUNCS_H #define _INCLUDE_DDK_MMFUNCS_H
/* $Id: mmfuncs.h,v 1.14 2002/10/01 19:27:19 chorns Exp $ */ /* $Id: mmfuncs.h,v 1.15 2003/05/14 10:51:26 ekohl Exp $ */
/* MEMORY MANAGMENT ******************************************************/ /* MEMORY MANAGMENT ******************************************************/
@ -362,7 +362,7 @@ MmMapVideoDisplay (
NTSTATUS NTSTATUS
STDCALL STDCALL
MmMapViewInSystemSpace ( MmMapViewInSystemSpace (
IN PVOID Section, IN PVOID SectionObject,
OUT PVOID * MappedBase, OUT PVOID * MappedBase,
IN PULONG ViewSize IN PULONG ViewSize
); );
@ -535,7 +535,7 @@ MmUnmapVideoDisplay (
NTSTATUS NTSTATUS
STDCALL STDCALL
MmUnmapViewInSystemSpace ( MmUnmapViewInSystemSpace (
DWORD Unknown0 IN PVOID MappedBase
); );
#if 0 #if 0
NTSTATUS NTSTATUS

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: section.c,v 1.109 2003/05/13 21:28:26 chorns Exp $ /* $Id: section.c,v 1.110 2003/05/14 10:52:46 ekohl Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/section.c * FILE: ntoskrnl/mm/section.c
@ -2765,19 +2765,19 @@ NtOpenSection(PHANDLE SectionHandle,
ACCESS_MASK DesiredAccess, ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes) POBJECT_ATTRIBUTES ObjectAttributes)
{ {
NTSTATUS Status; NTSTATUS Status;
*SectionHandle = 0; *SectionHandle = 0;
Status = ObOpenObjectByName(ObjectAttributes, Status = ObOpenObjectByName(ObjectAttributes,
MmSectionObjectType, MmSectionObjectType,
NULL, NULL,
UserMode, UserMode,
DesiredAccess, DesiredAccess,
NULL, NULL,
SectionHandle); SectionHandle);
return(Status); return(Status);
} }
NTSTATUS STATIC NTSTATUS STATIC
@ -2795,7 +2795,7 @@ MmMapViewOfSegment(PEPROCESS Process,
KIRQL oldIrql; KIRQL oldIrql;
Status = MmCreateMemoryArea(Process, Status = MmCreateMemoryArea(Process,
&Process->AddressSpace, AddressSpace,
MEMORY_AREA_SECTION_VIEW, MEMORY_AREA_SECTION_VIEW,
BaseAddress, BaseAddress,
ViewSize, ViewSize,
@ -3466,7 +3466,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
for (i = 0; i < Section->NrSegments; i++) for (i = 0; i < Section->NrSegments; i++)
{ {
if (IMAGE_SECTION_INITIALIZED_DATA == if (IMAGE_SECTION_INITIALIZED_DATA ==
(Section->Segments[i].Characteristics & (Section->Segments[i].Characteristics &
(IMAGE_SECTION_NOLOAD | IMAGE_SECTION_INITIALIZED_DATA)) && (IMAGE_SECTION_NOLOAD | IMAGE_SECTION_INITIALIZED_DATA)) &&
Section->Segments[i].RawLength < Section->Segments[i].Length) Section->Segments[i].RawLength < Section->Segments[i].Length)
{ {
@ -3527,7 +3527,6 @@ MmMapViewOfSection(IN PVOID SectionObject,
MmUnlockSection(Section); MmUnlockSection(Section);
return(Status); return(Status);
} }
} }
MmUnlockSection(Section); MmUnlockSection(Section);
@ -3581,19 +3580,117 @@ MmForceSectionClosed (DWORD Unknown0,
NTSTATUS STDCALL NTSTATUS STDCALL
MmMapViewInSystemSpace (IN PVOID Section, MmMapViewInSystemSpace (IN PVOID SectionObject,
OUT PVOID * MappedBase, OUT PVOID * MappedBase,
IN PULONG ViewSize) IN OUT PULONG ViewSize)
{ {
UNIMPLEMENTED; PSECTION_OBJECT Section;
return (STATUS_NOT_IMPLEMENTED); PMADDRESS_SPACE AddressSpace;
NTSTATUS Status;
DPRINT("MmMapViewInSystemSpace() called\n");
Section = (PSECTION_OBJECT)SectionObject;
AddressSpace = MmGetKernelAddressSpace();
MmLockSection(SectionObject);
MmLockAddressSpace(AddressSpace);
if ((*ViewSize) == 0)
{
(*ViewSize) = Section->MaximumSize.u.LowPart;
}
else if ((*ViewSize) > Section->MaximumSize.u.LowPart)
{
(*ViewSize) = Section->MaximumSize.u.LowPart;
}
MmLockSectionSegment(Section->Segments);
Status = MmMapViewOfSegment(NULL,
AddressSpace,
Section,
Section->Segments,
MappedBase,
*ViewSize,
PAGE_READWRITE,
0);
MmUnlockSectionSegment(Section->Segments);
MmUnlockAddressSpace(AddressSpace);
MmUnlockSection(Section);
return Status;
} }
NTSTATUS STDCALL NTSTATUS STDCALL
MmUnmapViewInSystemSpace (DWORD Unknown0) MmUnmapViewInSystemSpace (IN PVOID MappedBase)
{ {
UNIMPLEMENTED; PMEMORY_AREA MemoryArea;
return (STATUS_NOT_IMPLEMENTED); PMADDRESS_SPACE AddressSpace;
PSECTION_OBJECT Section;
PMM_SECTION_SEGMENT Segment;
KIRQL oldIrql;
PLIST_ENTRY CurrentEntry;
PMM_REGION CurrentRegion;
NTSTATUS Status;
DPRINT("MmUnmapViewInSystemSpace() called\n");
AddressSpace = MmGetKernelAddressSpace();
DPRINT("Opening memory area at base address %x\n",
MappedBase);
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
MappedBase);
if (MemoryArea == NULL)
{
return STATUS_UNSUCCESSFUL;
}
MemoryArea->DeleteInProgress = TRUE;
MmLockSection(MemoryArea->Data.SectionData.Section);
MmLockSectionSegment(MemoryArea->Data.SectionData.Segment);
Section = MemoryArea->Data.SectionData.Section;
Segment = MemoryArea->Data.SectionData.Segment;
KeAcquireSpinLock(&Section->ViewListLock, &oldIrql);
RemoveEntryList(&MemoryArea->Data.SectionData.ViewListEntry);
KeReleaseSpinLock(&Section->ViewListLock, oldIrql);
CurrentEntry = MemoryArea->Data.SectionData.RegionListHead.Flink;
while (CurrentEntry != &MemoryArea->Data.SectionData.RegionListHead)
{
CurrentRegion =
CONTAINING_RECORD(CurrentEntry, MM_REGION, RegionListEntry);
CurrentEntry = CurrentEntry->Flink;
ExFreePool(CurrentRegion);
}
if (MemoryArea->Data.SectionData.Section->AllocationAttributes &
SEC_PHYSICALMEMORY)
{
Status = MmFreeMemoryArea(AddressSpace,
MappedBase,
0,
NULL,
NULL);
}
else
{
Status = MmFreeMemoryArea(AddressSpace,
MappedBase,
0,
MmFreeSectionPage,
MemoryArea);
}
MmUnlockSectionSegment(Segment);
MmUnlockSection(Section);
ObDereferenceObject(Section);
return(STATUS_SUCCESS);
} }
@ -3677,9 +3774,3 @@ MmCreateSection (OUT PSECTION_OBJECT * SectionObject,
} }
/* EOF */ /* EOF */