mirror of
https://github.com/reactos/reactos.git
synced 2024-07-27 22:58:42 +00:00
Implemented MmMapViewInSystemSpace() and MmUnmapViewInSystemSpace().
svn path=/trunk/; revision=4683
This commit is contained in:
parent
10f9688a17
commit
9fef3a18ee
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
@ -2620,12 +2620,12 @@ MmCreateImageSection(PHANDLE SectionHandle,
|
||||||
SectionSegments[i].WriteCopy =
|
SectionSegments[i].WriteCopy =
|
||||||
!(Characteristics & IMAGE_SECTION_CHAR_SHARED);
|
!(Characteristics & IMAGE_SECTION_CHAR_SHARED);
|
||||||
}
|
}
|
||||||
else if (Characteristics & IMAGE_SECTION_CHAR_CODE)
|
else if (Characteristics & IMAGE_SECTION_CHAR_CODE)
|
||||||
{
|
{
|
||||||
SectionSegments[i].Protection = PAGE_EXECUTE_READ;
|
SectionSegments[i].Protection = PAGE_EXECUTE_READ;
|
||||||
SectionSegments[i].WriteCopy = TRUE;
|
SectionSegments[i].WriteCopy = TRUE;
|
||||||
}
|
}
|
||||||
else if (Characteristics & IMAGE_SECTION_CHAR_DATA)
|
else if (Characteristics & IMAGE_SECTION_CHAR_DATA)
|
||||||
{
|
{
|
||||||
SectionSegments[i].Protection = PAGE_READWRITE;
|
SectionSegments[i].Protection = PAGE_READWRITE;
|
||||||
SectionSegments[i].WriteCopy = TRUE;
|
SectionSegments[i].WriteCopy = TRUE;
|
||||||
|
@ -2644,11 +2644,11 @@ MmCreateImageSection(PHANDLE SectionHandle,
|
||||||
/*
|
/*
|
||||||
* Set up the attributes.
|
* Set up the attributes.
|
||||||
*/
|
*/
|
||||||
if (Characteristics & IMAGE_SECTION_CHAR_CODE)
|
if (Characteristics & IMAGE_SECTION_CHAR_CODE)
|
||||||
{
|
{
|
||||||
SectionSegments[i].Attributes = 0;
|
SectionSegments[i].Attributes = 0;
|
||||||
}
|
}
|
||||||
else if (Characteristics & IMAGE_SECTION_CHAR_DATA)
|
else if (Characteristics & IMAGE_SECTION_CHAR_DATA)
|
||||||
{
|
{
|
||||||
SectionSegments[i].Attributes = 0;
|
SectionSegments[i].Attributes = 0;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
|
|
||||||
Status = ObOpenObjectByName(ObjectAttributes,
|
*SectionHandle = 0;
|
||||||
MmSectionObjectType,
|
|
||||||
NULL,
|
|
||||||
UserMode,
|
|
||||||
DesiredAccess,
|
|
||||||
NULL,
|
|
||||||
SectionHandle);
|
|
||||||
|
|
||||||
return(Status);
|
Status = ObOpenObjectByName(ObjectAttributes,
|
||||||
|
MmSectionObjectType,
|
||||||
|
NULL,
|
||||||
|
UserMode,
|
||||||
|
DesiredAccess,
|
||||||
|
NULL,
|
||||||
|
SectionHandle);
|
||||||
|
|
||||||
|
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,
|
||||||
|
@ -2808,12 +2808,12 @@ MmMapViewOfSegment(PEPROCESS Process,
|
||||||
(*BaseAddress), (*BaseAddress) + ViewSize);
|
(*BaseAddress), (*BaseAddress) + ViewSize);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeAcquireSpinLock(&Section->ViewListLock, &oldIrql);
|
KeAcquireSpinLock(&Section->ViewListLock, &oldIrql);
|
||||||
InsertTailList(&Section->ViewListHead,
|
InsertTailList(&Section->ViewListHead,
|
||||||
&MArea->Data.SectionData.ViewListEntry);
|
&MArea->Data.SectionData.ViewListEntry);
|
||||||
KeReleaseSpinLock(&Section->ViewListLock, oldIrql);
|
KeReleaseSpinLock(&Section->ViewListLock, oldIrql);
|
||||||
|
|
||||||
ObReferenceObjectByPointer((PVOID)Section,
|
ObReferenceObjectByPointer((PVOID)Section,
|
||||||
SECTION_MAP_READ,
|
SECTION_MAP_READ,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -2824,7 +2824,7 @@ MmMapViewOfSegment(PEPROCESS Process,
|
||||||
MArea->Data.SectionData.WriteCopyView = FALSE;
|
MArea->Data.SectionData.WriteCopyView = FALSE;
|
||||||
MmInitialiseRegion(&MArea->Data.SectionData.RegionListHead,
|
MmInitialiseRegion(&MArea->Data.SectionData.RegionListHead,
|
||||||
ViewSize, 0, Protect);
|
ViewSize, 0, Protect);
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3379,13 +3379,13 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
||||||
AddressSpace = &Process->AddressSpace;
|
AddressSpace = &Process->AddressSpace;
|
||||||
|
|
||||||
MmLockSection(SectionObject);
|
MmLockSection(SectionObject);
|
||||||
|
|
||||||
if (Section->AllocationAttributes & SEC_IMAGE)
|
if (Section->AllocationAttributes & SEC_IMAGE)
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
PVOID ImageBase;
|
PVOID ImageBase;
|
||||||
ULONG ImageSize;
|
ULONG ImageSize;
|
||||||
|
|
||||||
MmLockAddressSpace(AddressSpace);
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
|
||||||
ImageBase = *BaseAddress;
|
ImageBase = *BaseAddress;
|
||||||
|
@ -3393,7 +3393,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
||||||
{
|
{
|
||||||
ImageBase = Section->ImageBase;
|
ImageBase = Section->ImageBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageSize = 0;
|
ImageSize = 0;
|
||||||
for (i = 0; i < Section->NrSegments; i++)
|
for (i = 0; i < Section->NrSegments; i++)
|
||||||
{
|
{
|
||||||
|
@ -3426,11 +3426,11 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < Section->NrSegments; i++)
|
for (i = 0; i < Section->NrSegments; i++)
|
||||||
{
|
{
|
||||||
PVOID SBaseAddress;
|
PVOID SBaseAddress;
|
||||||
|
|
||||||
if (!(Section->Segments[i].Characteristics & IMAGE_SECTION_NOLOAD))
|
if (!(Section->Segments[i].Characteristics & IMAGE_SECTION_NOLOAD))
|
||||||
{
|
{
|
||||||
SBaseAddress = (PVOID)
|
SBaseAddress = (PVOID)
|
||||||
|
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -3494,7 +3494,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
||||||
{
|
{
|
||||||
ViewOffset = SectionOffset->u.LowPart;
|
ViewOffset = SectionOffset->u.LowPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ViewOffset % PAGE_SIZE) != 0)
|
if ((ViewOffset % PAGE_SIZE) != 0)
|
||||||
{
|
{
|
||||||
MmUnlockSection(Section);
|
MmUnlockSection(Section);
|
||||||
|
@ -3510,7 +3510,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
||||||
{
|
{
|
||||||
(*ViewSize) = Section->MaximumSize.u.LowPart - ViewOffset;
|
(*ViewSize) = Section->MaximumSize.u.LowPart - ViewOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
MmLockSectionSegment(Section->Segments);
|
MmLockSectionSegment(Section->Segments);
|
||||||
Status = MmMapViewOfSegment(Process,
|
Status = MmMapViewOfSegment(Process,
|
||||||
&Process->AddressSpace,
|
&Process->AddressSpace,
|
||||||
|
@ -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 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue