mirror of
https://github.com/reactos/reactos.git
synced 2024-06-30 01:42:30 +00:00
Address PR review
This commit is contained in:
parent
c0bf352069
commit
b7eb0fddf3
4
ntoskrnl/cache/newcc.h
vendored
4
ntoskrnl/cache/newcc.h
vendored
|
@ -62,10 +62,6 @@ NTAPI
|
||||||
CcpUnpinData(PNOCC_BCB Bcb,
|
CcpUnpinData(PNOCC_BCB Bcb,
|
||||||
BOOLEAN ActuallyRelease);
|
BOOLEAN ActuallyRelease);
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
NTAPI
|
|
||||||
CcInitializeCacheManager(VOID);
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CcShutdownSystem(VOID);
|
CcShutdownSystem(VOID);
|
||||||
|
|
|
@ -42,7 +42,6 @@ CcPfInitializePrefetcher(VOID)
|
||||||
|
|
||||||
CODE_SEG("INIT")
|
CODE_SEG("INIT")
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
|
||||||
CcInitializeCacheManager(VOID)
|
CcInitializeCacheManager(VOID)
|
||||||
{
|
{
|
||||||
ULONG Thread;
|
ULONG Thread;
|
||||||
|
|
|
@ -110,7 +110,6 @@ ULONG CcRosVacbGetRefCount_(PROS_VACB vacb, PCSTR file, INT line)
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
|
||||||
CcRosTraceCacheMap (
|
CcRosTraceCacheMap (
|
||||||
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
||||||
BOOLEAN Trace )
|
BOOLEAN Trace )
|
||||||
|
@ -157,14 +156,6 @@ CcRosTraceCacheMap (
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
MmFlushVirtualMemory(IN PEPROCESS Process,
|
|
||||||
IN OUT PVOID *BaseAddress,
|
|
||||||
IN OUT PSIZE_T RegionSize,
|
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock);
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
CcRosFlushVacb (
|
CcRosFlushVacb (
|
||||||
_In_ PROS_VACB Vacb,
|
_In_ PROS_VACB Vacb,
|
||||||
_In_ PIO_STATUS_BLOCK Iosb)
|
_In_ PIO_STATUS_BLOCK Iosb)
|
||||||
|
@ -210,7 +201,6 @@ quit:
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
CcRosFlushDirtyPages (
|
CcRosFlushDirtyPages (
|
||||||
ULONG Target,
|
ULONG Target,
|
||||||
PULONG Count,
|
PULONG Count,
|
||||||
|
@ -349,7 +339,6 @@ CcRosFlushDirtyPages (
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
CcRosReleaseVacb (
|
CcRosReleaseVacb (
|
||||||
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
||||||
PROS_VACB Vacb,
|
PROS_VACB Vacb,
|
||||||
|
@ -382,7 +371,6 @@ CcRosReleaseVacb (
|
||||||
|
|
||||||
/* Returns with VACB Lock Held! */
|
/* Returns with VACB Lock Held! */
|
||||||
PROS_VACB
|
PROS_VACB
|
||||||
NTAPI
|
|
||||||
CcRosLookupVacb (
|
CcRosLookupVacb (
|
||||||
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
||||||
LONGLONG FileOffset)
|
LONGLONG FileOffset)
|
||||||
|
@ -426,7 +414,6 @@ CcRosLookupVacb (
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
|
||||||
CcRosMarkDirtyVacb (
|
CcRosMarkDirtyVacb (
|
||||||
PROS_VACB Vacb)
|
PROS_VACB Vacb)
|
||||||
{
|
{
|
||||||
|
@ -463,7 +450,6 @@ CcRosMarkDirtyVacb (
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
|
||||||
CcRosUnmarkDirtyVacb (
|
CcRosUnmarkDirtyVacb (
|
||||||
PROS_VACB Vacb,
|
PROS_VACB Vacb,
|
||||||
BOOLEAN LockViews)
|
BOOLEAN LockViews)
|
||||||
|
@ -617,7 +603,7 @@ CcRosCreateVacb (
|
||||||
Retried = FALSE;
|
Retried = FALSE;
|
||||||
Retry:
|
Retry:
|
||||||
/* Map VACB in system space */
|
/* Map VACB in system space */
|
||||||
Status = MmMapViewInSystemSpaceEx(SharedCacheMap->Section, ¤t->BaseAddress, &ViewSize, ¤t->FileOffset);
|
Status = MmMapViewInSystemSpaceEx(SharedCacheMap->Section, ¤t->BaseAddress, &ViewSize, ¤t->FileOffset, 0);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -735,7 +721,6 @@ Retry:
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
|
||||||
CcRosEnsureVacbResident(
|
CcRosEnsureVacbResident(
|
||||||
_In_ PROS_VACB Vacb,
|
_In_ PROS_VACB Vacb,
|
||||||
_In_ BOOLEAN Wait,
|
_In_ BOOLEAN Wait,
|
||||||
|
@ -783,7 +768,6 @@ CcRosEnsureVacbResident(
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
CcRosGetVacb (
|
CcRosGetVacb (
|
||||||
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
||||||
LONGLONG FileOffset,
|
LONGLONG FileOffset,
|
||||||
|
@ -835,7 +819,6 @@ CcRosGetVacb (
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
CcRosRequestVacb (
|
CcRosRequestVacb (
|
||||||
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
||||||
LONGLONG FileOffset,
|
LONGLONG FileOffset,
|
||||||
|
@ -1032,7 +1015,6 @@ quit:
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
CcRosDeleteFileCache (
|
CcRosDeleteFileCache (
|
||||||
PFILE_OBJECT FileObject,
|
PFILE_OBJECT FileObject,
|
||||||
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
||||||
|
@ -1085,11 +1067,10 @@ CcRosDeleteFileCache (
|
||||||
/* Flush to disk, if needed */
|
/* Flush to disk, if needed */
|
||||||
if (Vacb->Dirty)
|
if (Vacb->Dirty)
|
||||||
{
|
{
|
||||||
SIZE_T FlushSize = VACB_MAPPING_GRANULARITY;
|
|
||||||
IO_STATUS_BLOCK Iosb;
|
IO_STATUS_BLOCK Iosb;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
Status = MmFlushVirtualMemory(NULL, &Vacb->BaseAddress, &FlushSize, &Iosb);
|
Status = MmFlushSegment(FileObject->SectionObjectPointer, &Vacb->FileOffset, VACB_MAPPING_GRANULARITY, &Iosb);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Complain. There's not much we can do */
|
/* Complain. There's not much we can do */
|
||||||
|
@ -1134,7 +1115,6 @@ CcRosDeleteFileCache (
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
|
||||||
CcRosReferenceCache (
|
CcRosReferenceCache (
|
||||||
PFILE_OBJECT FileObject)
|
PFILE_OBJECT FileObject)
|
||||||
{
|
{
|
||||||
|
@ -1150,7 +1130,6 @@ CcRosReferenceCache (
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
CcRosReleaseFileCache (
|
CcRosReleaseFileCache (
|
||||||
PFILE_OBJECT FileObject)
|
PFILE_OBJECT FileObject)
|
||||||
/*
|
/*
|
||||||
|
@ -1207,7 +1186,6 @@ CcRosReleaseFileCache (
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
CcRosInitializeFileCache (
|
CcRosInitializeFileCache (
|
||||||
PFILE_OBJECT FileObject,
|
PFILE_OBJECT FileObject,
|
||||||
PCC_FILE_SIZES FileSizes,
|
PCC_FILE_SIZES FileSizes,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
//
|
//
|
||||||
// Define this if you want debugging support
|
// Define this if you want debugging support
|
||||||
//
|
//
|
||||||
#define _CC_DEBUG_ 0x0
|
#define _CC_DEBUG_ 0x00
|
||||||
|
|
||||||
//
|
//
|
||||||
// These define the Debug Masks Supported
|
// These define the Debug Masks Supported
|
||||||
|
@ -309,11 +309,9 @@ CcMdlWriteComplete2(
|
||||||
);
|
);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
CcRosFlushVacb(PROS_VACB Vacb, PIO_STATUS_BLOCK Iosb);
|
CcRosFlushVacb(PROS_VACB Vacb, PIO_STATUS_BLOCK Iosb);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
CcRosGetVacb(
|
CcRosGetVacb(
|
||||||
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
||||||
LONGLONG FileOffset,
|
LONGLONG FileOffset,
|
||||||
|
@ -321,7 +319,6 @@ CcRosGetVacb(
|
||||||
);
|
);
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
|
||||||
CcRosEnsureVacbResident(
|
CcRosEnsureVacbResident(
|
||||||
_In_ PROS_VACB Vacb,
|
_In_ PROS_VACB Vacb,
|
||||||
_In_ BOOLEAN Wait,
|
_In_ BOOLEAN Wait,
|
||||||
|
@ -339,11 +336,9 @@ NTAPI
|
||||||
CcShutdownLazyWriter(VOID);
|
CcShutdownLazyWriter(VOID);
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
|
||||||
CcInitializeCacheManager(VOID);
|
CcInitializeCacheManager(VOID);
|
||||||
|
|
||||||
PROS_VACB
|
PROS_VACB
|
||||||
NTAPI
|
|
||||||
CcRosLookupVacb(
|
CcRosLookupVacb(
|
||||||
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
||||||
LONGLONG FileOffset
|
LONGLONG FileOffset
|
||||||
|
@ -354,18 +349,15 @@ NTAPI
|
||||||
CcInitCacheZeroPage(VOID);
|
CcInitCacheZeroPage(VOID);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
|
||||||
CcRosMarkDirtyVacb(
|
CcRosMarkDirtyVacb(
|
||||||
PROS_VACB Vacb);
|
PROS_VACB Vacb);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
|
||||||
CcRosUnmarkDirtyVacb(
|
CcRosUnmarkDirtyVacb(
|
||||||
PROS_VACB Vacb,
|
PROS_VACB Vacb,
|
||||||
BOOLEAN LockViews);
|
BOOLEAN LockViews);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
CcRosFlushDirtyPages(
|
CcRosFlushDirtyPages(
|
||||||
ULONG Target,
|
ULONG Target,
|
||||||
PULONG Count,
|
PULONG Count,
|
||||||
|
@ -374,15 +366,12 @@ CcRosFlushDirtyPages(
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
|
||||||
CcRosDereferenceCache(PFILE_OBJECT FileObject);
|
CcRosDereferenceCache(PFILE_OBJECT FileObject);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
|
||||||
CcRosReferenceCache(PFILE_OBJECT FileObject);
|
CcRosReferenceCache(PFILE_OBJECT FileObject);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
CcRosReleaseVacb(
|
CcRosReleaseVacb(
|
||||||
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
||||||
PROS_VACB Vacb,
|
PROS_VACB Vacb,
|
||||||
|
@ -391,7 +380,6 @@ CcRosReleaseVacb(
|
||||||
);
|
);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
CcRosRequestVacb(
|
CcRosRequestVacb(
|
||||||
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
PROS_SHARED_CACHE_MAP SharedCacheMap,
|
||||||
LONGLONG FileOffset,
|
LONGLONG FileOffset,
|
||||||
|
@ -399,7 +387,6 @@ CcRosRequestVacb(
|
||||||
);
|
);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
CcRosInitializeFileCache(
|
CcRosInitializeFileCache(
|
||||||
PFILE_OBJECT FileObject,
|
PFILE_OBJECT FileObject,
|
||||||
PCC_FILE_SIZES FileSizes,
|
PCC_FILE_SIZES FileSizes,
|
||||||
|
@ -409,7 +396,6 @@ CcRosInitializeFileCache(
|
||||||
);
|
);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
CcRosReleaseFileCache(
|
CcRosReleaseFileCache(
|
||||||
PFILE_OBJECT FileObject
|
PFILE_OBJECT FileObject
|
||||||
);
|
);
|
||||||
|
|
|
@ -224,7 +224,7 @@ typedef struct _MEMORY_AREA
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
LARGE_INTEGER ViewOffset;
|
LONGLONG ViewOffset;
|
||||||
PMM_SECTION_SEGMENT Segment;
|
PMM_SECTION_SEGMENT Segment;
|
||||||
LIST_ENTRY RegionListHead;
|
LIST_ENTRY RegionListHead;
|
||||||
} SectionData;
|
} SectionData;
|
||||||
|
@ -770,15 +770,6 @@ MmAccessFault(
|
||||||
IN PVOID TrapInformation
|
IN PVOID TrapInformation
|
||||||
);
|
);
|
||||||
|
|
||||||
/* kmap.c ********************************************************************/
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
MiCopyFromUserPage(
|
|
||||||
PFN_NUMBER DestPage,
|
|
||||||
const VOID *SrcAddress
|
|
||||||
);
|
|
||||||
|
|
||||||
/* process.c *****************************************************************/
|
/* process.c *****************************************************************/
|
||||||
|
|
||||||
PVOID
|
PVOID
|
||||||
|
@ -1359,7 +1350,8 @@ MmMapViewInSystemSpaceEx (
|
||||||
_In_ PVOID Section,
|
_In_ PVOID Section,
|
||||||
_Outptr_result_bytebuffer_ (*ViewSize) PVOID *MappedBase,
|
_Outptr_result_bytebuffer_ (*ViewSize) PVOID *MappedBase,
|
||||||
_Inout_ PSIZE_T ViewSize,
|
_Inout_ PSIZE_T ViewSize,
|
||||||
_Inout_ PLARGE_INTEGER SectionOffset
|
_Inout_ PLARGE_INTEGER SectionOffset,
|
||||||
|
_In_ ULONG_PTR Flags
|
||||||
);
|
);
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
|
|
|
@ -412,19 +412,19 @@ MiInsertInSystemSpace(IN PMMSESSION Session,
|
||||||
return Base;
|
return Base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
MiAddMappedPtes(IN PMMPTE FirstPte,
|
MiAddMappedPtes(IN PMMPTE FirstPte,
|
||||||
IN PFN_NUMBER PteCount,
|
IN PFN_NUMBER PteCount,
|
||||||
IN PCONTROL_AREA ControlArea,
|
IN PCONTROL_AREA ControlArea,
|
||||||
IN PLARGE_INTEGER SectionOffset)
|
IN LONGLONG SectionOffset)
|
||||||
{
|
{
|
||||||
MMPTE TempPte;
|
MMPTE TempPte;
|
||||||
PMMPTE PointerPte, ProtoPte, LastProtoPte, LastPte;
|
PMMPTE PointerPte, ProtoPte, LastProtoPte, LastPte;
|
||||||
PSUBSECTION Subsection;
|
PSUBSECTION Subsection;
|
||||||
|
|
||||||
/* Mapping at offset not supported yet */
|
/* Mapping at offset not supported yet */
|
||||||
ASSERT(SectionOffset->QuadPart == 0);
|
ASSERT(SectionOffset == 0);
|
||||||
|
|
||||||
/* ARM3 doesn't support this yet */
|
/* ARM3 doesn't support this yet */
|
||||||
ASSERT(ControlArea->u.Flags.GlobalOnlyPerSession == 0);
|
ASSERT(ControlArea->u.Flags.GlobalOnlyPerSession == 0);
|
||||||
|
@ -1054,12 +1054,12 @@ _WARN("MiSessionCommitPageTables halfplemented for amd64")
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
MiMapViewInSystemSpace(
|
||||||
MiMapViewInSystemSpace(IN PVOID Section,
|
_In_ PVOID Section,
|
||||||
IN PMMSESSION Session,
|
_In_ PMMSESSION Session,
|
||||||
OUT PVOID *MappedBase,
|
_Outptr_result_bytebuffer_ (*ViewSize) PVOID *MappedBase,
|
||||||
IN OUT PSIZE_T ViewSize,
|
_Inout_ PSIZE_T ViewSize,
|
||||||
IN PLARGE_INTEGER SectionOffset)
|
_Inout_ PLARGE_INTEGER SectionOffset)
|
||||||
{
|
{
|
||||||
PVOID Base;
|
PVOID Base;
|
||||||
PCONTROL_AREA ControlArea;
|
PCONTROL_AREA ControlArea;
|
||||||
|
@ -1156,7 +1156,7 @@ MiMapViewInSystemSpace(IN PVOID Section,
|
||||||
Status = MiAddMappedPtes(MiAddressToPte(Base),
|
Status = MiAddMappedPtes(MiAddressToPte(Base),
|
||||||
BYTES_TO_PAGES(*ViewSize),
|
BYTES_TO_PAGES(*ViewSize),
|
||||||
ControlArea,
|
ControlArea,
|
||||||
SectionOffset);
|
SectionOffset->QuadPart);
|
||||||
ASSERT(NT_SUCCESS(Status));
|
ASSERT(NT_SUCCESS(Status));
|
||||||
|
|
||||||
/* Return the base adress of the mapping and success */
|
/* Return the base adress of the mapping and success */
|
||||||
|
|
|
@ -128,7 +128,7 @@ GetEntry:
|
||||||
LARGE_INTEGER Offset;
|
LARGE_INTEGER Offset;
|
||||||
BOOLEAN Released;
|
BOOLEAN Released;
|
||||||
|
|
||||||
Offset.QuadPart = MemoryArea->SectionData.ViewOffset.QuadPart +
|
Offset.QuadPart = MemoryArea->SectionData.ViewOffset +
|
||||||
((ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea));
|
((ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea));
|
||||||
|
|
||||||
Segment = MemoryArea->SectionData.Segment;
|
Segment = MemoryArea->SectionData.Segment;
|
||||||
|
|
|
@ -125,7 +125,6 @@ PMM_IMAGE_SECTION_OBJECT ImageSectionObjectFromSegment(PMM_SECTION_SEGMENT Segme
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
MiMapViewInSystemSpace(IN PVOID Section,
|
MiMapViewInSystemSpace(IN PVOID Section,
|
||||||
IN PVOID Session,
|
IN PVOID Session,
|
||||||
OUT PVOID *MappedBase,
|
OUT PVOID *MappedBase,
|
||||||
|
@ -1160,8 +1159,8 @@ MmUnsharePageEntrySectionSegment(PMEMORY_AREA MemoryArea,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
|
||||||
MiCopyFromUserPage(PFN_NUMBER DestPage, const VOID *SrcAddress)
|
MiCopyFromUserPage(PFN_NUMBER DestPage, const VOID *SrcAddress)
|
||||||
{
|
{
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
|
@ -1172,13 +1171,13 @@ MiCopyFromUserPage(PFN_NUMBER DestPage, const VOID *SrcAddress)
|
||||||
DestAddress = MiMapPageInHyperSpace(Process, DestPage, &Irql);
|
DestAddress = MiMapPageInHyperSpace(Process, DestPage, &Irql);
|
||||||
if (DestAddress == NULL)
|
if (DestAddress == NULL)
|
||||||
{
|
{
|
||||||
return(STATUS_NO_MEMORY);
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
ASSERT((ULONG_PTR)DestAddress % PAGE_SIZE == 0);
|
ASSERT((ULONG_PTR)DestAddress % PAGE_SIZE == 0);
|
||||||
ASSERT((ULONG_PTR)SrcAddress % PAGE_SIZE == 0);
|
ASSERT((ULONG_PTR)SrcAddress % PAGE_SIZE == 0);
|
||||||
RtlCopyMemory(DestAddress, SrcAddress, PAGE_SIZE);
|
RtlCopyMemory(DestAddress, SrcAddress, PAGE_SIZE);
|
||||||
MiUnmapPageInHyperSpace(Process, DestAddress, Irql);
|
MiUnmapPageInHyperSpace(Process, DestAddress, Irql);
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -1465,7 +1464,7 @@ MmAlterViewAttributes(PMMSUPPORT AddressSpace,
|
||||||
PFN_NUMBER Page;
|
PFN_NUMBER Page;
|
||||||
|
|
||||||
Offset.QuadPart = (ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)
|
Offset.QuadPart = (ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)
|
||||||
+ MemoryArea->SectionData.ViewOffset.QuadPart;
|
+ MemoryArea->SectionData.ViewOffset;
|
||||||
Entry = MmGetPageEntrySectionSegment(Segment, &Offset);
|
Entry = MmGetPageEntrySectionSegment(Segment, &Offset);
|
||||||
/*
|
/*
|
||||||
* An MM_WAIT_ENTRY is ok in this case... It'll just count as
|
* An MM_WAIT_ENTRY is ok in this case... It'll just count as
|
||||||
|
@ -1518,12 +1517,12 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
*/
|
*/
|
||||||
if (MmIsPagePresent(Process, Address))
|
if (MmIsPagePresent(Process, Address))
|
||||||
{
|
{
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MmIsDisabledPage(Process, Address))
|
if (MmIsDisabledPage(Process, Address))
|
||||||
{
|
{
|
||||||
return(STATUS_ACCESS_VIOLATION);
|
return STATUS_ACCESS_VIOLATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1531,12 +1530,12 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
*/
|
*/
|
||||||
if (MemoryArea->DeleteInProgress)
|
if (MemoryArea->DeleteInProgress)
|
||||||
{
|
{
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
|
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
|
||||||
Offset.QuadPart = (ULONG_PTR)PAddress - MA_GetStartingAddress(MemoryArea)
|
Offset.QuadPart = (ULONG_PTR)PAddress - MA_GetStartingAddress(MemoryArea)
|
||||||
+ MemoryArea->SectionData.ViewOffset.QuadPart;
|
+ MemoryArea->SectionData.ViewOffset;
|
||||||
|
|
||||||
Segment = MemoryArea->SectionData.Segment;
|
Segment = MemoryArea->SectionData.Segment;
|
||||||
Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea),
|
Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea),
|
||||||
|
@ -1596,7 +1595,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
MiWaitForPageEvent(NULL, NULL);
|
MiWaitForPageEvent(NULL, NULL);
|
||||||
MmLockAddressSpace(AddressSpace);
|
MmLockAddressSpace(AddressSpace);
|
||||||
DPRINT("Address 0x%p\n", Address);
|
DPRINT("Address 0x%p\n", Address);
|
||||||
return(STATUS_MM_RESTART_OPERATION);
|
return STATUS_MM_RESTART_OPERATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
HasSwapEntry = MmIsPageSwapEntry(Process, Address);
|
HasSwapEntry = MmIsPageSwapEntry(Process, Address);
|
||||||
|
@ -1660,7 +1659,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
{
|
{
|
||||||
DPRINT("MmCreateVirtualMapping failed, not out of memory\n");
|
DPRINT("MmCreateVirtualMapping failed, not out of memory\n");
|
||||||
KeBugCheck(MEMORY_MANAGEMENT);
|
KeBugCheck(MEMORY_MANAGEMENT);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1678,7 +1677,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
*/
|
*/
|
||||||
MiSetPageEvent(Process, Address);
|
MiSetPageEvent(Process, Address);
|
||||||
DPRINT("Address 0x%p\n", Address);
|
DPRINT("Address 0x%p\n", Address);
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1700,7 +1699,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
{
|
{
|
||||||
DPRINT("MmCreateVirtualMappingUnsafe failed, not out of memory\n");
|
DPRINT("MmCreateVirtualMappingUnsafe failed, not out of memory\n");
|
||||||
KeBugCheck(MEMORY_MANAGEMENT);
|
KeBugCheck(MEMORY_MANAGEMENT);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1708,7 +1707,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
*/
|
*/
|
||||||
MiSetPageEvent(Process, Address);
|
MiSetPageEvent(Process, Address);
|
||||||
DPRINT("Address 0x%p\n", Address);
|
DPRINT("Address 0x%p\n", Address);
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1743,7 +1742,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
|
|
||||||
MiSetPageEvent(Process, Address);
|
MiSetPageEvent(Process, Address);
|
||||||
DPRINT("Address 0x%p\n", Address);
|
DPRINT("Address 0x%p\n", Address);
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
MmUnlockSectionSegment(Segment);
|
MmUnlockSectionSegment(Segment);
|
||||||
|
@ -1853,7 +1852,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
|
|
||||||
MiSetPageEvent(Process, Address);
|
MiSetPageEvent(Process, Address);
|
||||||
DPRINT("Address 0x%p\n", Address);
|
DPRINT("Address 0x%p\n", Address);
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1880,7 +1879,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
|
|
||||||
MiSetPageEvent(Process, Address);
|
MiSetPageEvent(Process, Address);
|
||||||
DPRINT("Address 0x%p\n", Address);
|
DPRINT("Address 0x%p\n", Address);
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1916,7 +1915,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
if (MmGetPageProtect(Process, Address) & PAGE_READWRITE)
|
if (MmGetPageProtect(Process, Address) & PAGE_READWRITE)
|
||||||
{
|
{
|
||||||
DPRINT("Address 0x%p\n", Address);
|
DPRINT("Address 0x%p\n", Address);
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1924,7 +1923,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
*/
|
*/
|
||||||
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
|
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
|
||||||
Offset.QuadPart = (ULONG_PTR)PAddress - MA_GetStartingAddress(MemoryArea)
|
Offset.QuadPart = (ULONG_PTR)PAddress - MA_GetStartingAddress(MemoryArea)
|
||||||
+ MemoryArea->SectionData.ViewOffset.QuadPart;
|
+ MemoryArea->SectionData.ViewOffset;
|
||||||
|
|
||||||
Segment = MemoryArea->SectionData.Segment;
|
Segment = MemoryArea->SectionData.Segment;
|
||||||
Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea),
|
Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea),
|
||||||
|
@ -1940,7 +1939,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
Region->Protect == PAGE_EXECUTE_READWRITE)))
|
Region->Protect == PAGE_EXECUTE_READWRITE)))
|
||||||
{
|
{
|
||||||
DPRINT("Address 0x%p\n", Address);
|
DPRINT("Address 0x%p\n", Address);
|
||||||
return(STATUS_ACCESS_VIOLATION);
|
return STATUS_ACCESS_VIOLATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the page mapping this section offset. */
|
/* Get the page mapping this section offset. */
|
||||||
|
@ -1958,7 +1957,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
MmUnlockSectionSegment(Segment);
|
MmUnlockSectionSegment(Segment);
|
||||||
/* This is a private page. We must only change the page protection. */
|
/* This is a private page. We must only change the page protection. */
|
||||||
MmSetPageProtect(Process, PAddress, Region->Protect);
|
MmSetPageProtect(Process, PAddress, Region->Protect);
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2000,7 +1999,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
{
|
{
|
||||||
DPRINT1("MmCreateVirtualMapping failed, unable to create virtual mapping, not out of memory\n");
|
DPRINT1("MmCreateVirtualMapping failed, unable to create virtual mapping, not out of memory\n");
|
||||||
KeBugCheck(MEMORY_MANAGEMENT);
|
KeBugCheck(MEMORY_MANAGEMENT);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Process)
|
if (Process)
|
||||||
|
@ -2008,7 +2007,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
|
|
||||||
MiSetPageEvent(Process, Address);
|
MiSetPageEvent(Process, Address);
|
||||||
DPRINT("Address 0x%p\n", Address);
|
DPRINT("Address 0x%p\n", Address);
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -2045,7 +2044,7 @@ MmProtectSectionView(PMMSUPPORT AddressSpace,
|
||||||
BaseAddress, Length, Region->Type, Protect,
|
BaseAddress, Length, Region->Type, Protect,
|
||||||
MmAlterViewAttributes);
|
MmAlterViewAttributes);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
|
@ -2084,7 +2083,7 @@ MmQuerySectionView(PMEMORY_AREA MemoryArea,
|
||||||
Info->Protect = Region->Protect;
|
Info->Protect = Region->Protect;
|
||||||
|
|
||||||
*ResultLength = sizeof(MEMORY_BASIC_INFORMATION);
|
*ResultLength = sizeof(MEMORY_BASIC_INFORMATION);
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID NTAPI
|
VOID NTAPI
|
||||||
|
@ -2180,7 +2179,7 @@ MmCreatePhysicalMemorySection(VOID)
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("MmCreatePhysicalMemorySection: failed to create object (0x%lx)\n", Status);
|
DPRINT1("MmCreatePhysicalMemorySection: failed to create object (0x%lx)\n", Status);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2198,7 +2197,7 @@ MmCreatePhysicalMemorySection(VOID)
|
||||||
if (Segment == NULL)
|
if (Segment == NULL)
|
||||||
{
|
{
|
||||||
ObDereferenceObject(PhysSection);
|
ObDereferenceObject(PhysSection);
|
||||||
return(STATUS_NO_MEMORY);
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
RtlZeroMemory(Segment, sizeof(MM_SECTION_SEGMENT));
|
RtlZeroMemory(Segment, sizeof(MM_SECTION_SEGMENT));
|
||||||
PhysSection->Segment = (PSEGMENT)Segment;
|
PhysSection->Segment = (PSEGMENT)Segment;
|
||||||
|
@ -2231,7 +2230,7 @@ MmCreatePhysicalMemorySection(VOID)
|
||||||
}
|
}
|
||||||
ObCloseHandle(Handle, KernelMode);
|
ObCloseHandle(Handle, KernelMode);
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
CODE_SEG("INIT")
|
CODE_SEG("INIT")
|
||||||
|
@ -2264,7 +2263,7 @@ MmInitSectionImplementation(VOID)
|
||||||
|
|
||||||
MmCreatePhysicalMemorySection();
|
MmCreatePhysicalMemorySection();
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -2302,7 +2301,7 @@ MmCreateDataFileSection(PSECTION *SectionObject,
|
||||||
(PVOID*)&Section);
|
(PVOID*)&Section);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Initialize it
|
* Initialize it
|
||||||
|
@ -2363,7 +2362,7 @@ MmCreateDataFileSection(PSECTION *SectionObject,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
ObDereferenceObject(Section);
|
ObDereferenceObject(Section);
|
||||||
return(STATUS_SECTION_NOT_EXTENDED);
|
return STATUS_SECTION_NOT_EXTENDED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2381,7 +2380,7 @@ MmCreateDataFileSection(PSECTION *SectionObject,
|
||||||
if (Status != STATUS_SUCCESS)
|
if (Status != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
ObDereferenceObject(Section);
|
ObDereferenceObject(Section);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lock the PFN lock while messing with Section Object pointers */
|
/* Lock the PFN lock while messing with Section Object pointers */
|
||||||
|
@ -2390,10 +2389,8 @@ MmCreateDataFileSection(PSECTION *SectionObject,
|
||||||
|
|
||||||
while (Segment && (Segment->SegFlags & (MM_SEGMENT_INDELETE | MM_SEGMENT_INCREATE)))
|
while (Segment && (Segment->SegFlags & (MM_SEGMENT_INDELETE | MM_SEGMENT_INCREATE)))
|
||||||
{
|
{
|
||||||
LARGE_INTEGER ShortTime = {{-10 * 100 * 1000, -1}};
|
|
||||||
|
|
||||||
MiReleasePfnLock(OldIrql);
|
MiReleasePfnLock(OldIrql);
|
||||||
KeDelayExecutionThread(KernelMode, FALSE, &ShortTime);
|
KeDelayExecutionThread(KernelMode, FALSE, &TinyTime);
|
||||||
OldIrql = MiAcquirePfnLock();
|
OldIrql = MiAcquirePfnLock();
|
||||||
Segment = FileObject->SectionObjectPointer->DataSectionObject;
|
Segment = FileObject->SectionObjectPointer->DataSectionObject;
|
||||||
}
|
}
|
||||||
|
@ -2411,7 +2408,7 @@ MmCreateDataFileSection(PSECTION *SectionObject,
|
||||||
//KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE);
|
//KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE);
|
||||||
MiReleasePfnLock(OldIrql);
|
MiReleasePfnLock(OldIrql);
|
||||||
ObDereferenceObject(Section);
|
ObDereferenceObject(Section);
|
||||||
return(STATUS_NO_MEMORY);
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We are creating it */
|
/* We are creating it */
|
||||||
|
@ -2481,7 +2478,7 @@ MmCreateDataFileSection(PSECTION *SectionObject,
|
||||||
|
|
||||||
//KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE);
|
//KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE);
|
||||||
*SectionObject = Section;
|
*SectionObject = Section;
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3145,7 +3142,7 @@ MmCreateImageSection(PSECTION *SectionObject,
|
||||||
(PVOID*)(PVOID)&Section);
|
(PVOID*)(PVOID)&Section);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3168,12 +3165,9 @@ MmCreateImageSection(PSECTION *SectionObject,
|
||||||
ImageSectionObject = FileObject->SectionObjectPointer->ImageSectionObject;
|
ImageSectionObject = FileObject->SectionObjectPointer->ImageSectionObject;
|
||||||
while(ImageSectionObject && (ImageSectionObject->SegFlags & (MM_SEGMENT_INDELETE | MM_SEGMENT_INCREATE)))
|
while(ImageSectionObject && (ImageSectionObject->SegFlags & (MM_SEGMENT_INDELETE | MM_SEGMENT_INCREATE)))
|
||||||
{
|
{
|
||||||
LARGE_INTEGER ShortTime;
|
|
||||||
|
|
||||||
MiReleasePfnLock(OldIrql);
|
MiReleasePfnLock(OldIrql);
|
||||||
|
|
||||||
ShortTime.QuadPart = - 10 * 100 * 1000;
|
KeDelayExecutionThread(KernelMode, FALSE, &TinyTime);
|
||||||
KeDelayExecutionThread(KernelMode, FALSE, &ShortTime);
|
|
||||||
|
|
||||||
OldIrql = MiAcquirePfnLock();
|
OldIrql = MiAcquirePfnLock();
|
||||||
ImageSectionObject = FileObject->SectionObjectPointer->ImageSectionObject;
|
ImageSectionObject = FileObject->SectionObjectPointer->ImageSectionObject;
|
||||||
|
@ -3188,7 +3182,7 @@ MmCreateImageSection(PSECTION *SectionObject,
|
||||||
{
|
{
|
||||||
MiReleasePfnLock(OldIrql);
|
MiReleasePfnLock(OldIrql);
|
||||||
ObDereferenceObject(Section);
|
ObDereferenceObject(Section);
|
||||||
return(STATUS_NO_MEMORY);
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageSectionObject->SegFlags = MM_SEGMENT_INCREATE;
|
ImageSectionObject->SegFlags = MM_SEGMENT_INCREATE;
|
||||||
|
@ -3223,7 +3217,7 @@ MmCreateImageSection(PSECTION *SectionObject,
|
||||||
|
|
||||||
ExFreePoolWithTag(ImageSectionObject, TAG_MM_SECTION_SEGMENT);
|
ExFreePoolWithTag(ImageSectionObject, TAG_MM_SECTION_SEGMENT);
|
||||||
ObDereferenceObject(Section);
|
ObDereferenceObject(Section);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Section->Segment = (PSEGMENT)ImageSectionObject;
|
Section->Segment = (PSEGMENT)ImageSectionObject;
|
||||||
|
@ -3244,7 +3238,7 @@ MmCreateImageSection(PSECTION *SectionObject,
|
||||||
ExFreePool(ImageSectionObject->Segments);
|
ExFreePool(ImageSectionObject->Segments);
|
||||||
ExFreePool(ImageSectionObject);
|
ExFreePool(ImageSectionObject);
|
||||||
ObDereferenceObject(Section);
|
ObDereferenceObject(Section);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
OldIrql = MiAcquirePfnLock();
|
OldIrql = MiAcquirePfnLock();
|
||||||
|
@ -3272,7 +3266,7 @@ MmCreateImageSection(PSECTION *SectionObject,
|
||||||
*SectionObject = Section;
|
*SectionObject = Section;
|
||||||
ASSERT(ImageSectionObject->RefCount > 0);
|
ASSERT(ImageSectionObject->RefCount > 0);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3337,13 +3331,13 @@ MmMapViewOfSegment(
|
||||||
{
|
{
|
||||||
DPRINT1("Mapping between 0x%p and 0x%p failed (%X).\n",
|
DPRINT1("Mapping between 0x%p and 0x%p failed (%X).\n",
|
||||||
(*BaseAddress), (char*)(*BaseAddress) + ViewSize, Status);
|
(*BaseAddress), (char*)(*BaseAddress) + ViewSize, Status);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterlockedIncrement64(Segment->ReferenceCount);
|
InterlockedIncrement64(Segment->ReferenceCount);
|
||||||
|
|
||||||
MArea->SectionData.Segment = Segment;
|
MArea->SectionData.Segment = Segment;
|
||||||
MArea->SectionData.ViewOffset.QuadPart = ViewOffset;
|
MArea->SectionData.ViewOffset = ViewOffset;
|
||||||
if (AsImage)
|
if (AsImage)
|
||||||
{
|
{
|
||||||
MArea->VadNode.u.VadFlags.VadType = VadImageMap;
|
MArea->VadNode.u.VadFlags.VadType = VadImageMap;
|
||||||
|
@ -3352,7 +3346,7 @@ MmMapViewOfSegment(
|
||||||
MmInitializeRegion(&MArea->SectionData.RegionListHead,
|
MmInitializeRegion(&MArea->SectionData.RegionListHead,
|
||||||
ViewSize, 0, Protect);
|
ViewSize, 0, Protect);
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3373,7 +3367,7 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
|
||||||
Address = (PVOID)PAGE_ROUND_DOWN(Address);
|
Address = (PVOID)PAGE_ROUND_DOWN(Address);
|
||||||
|
|
||||||
Offset.QuadPart = ((ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)) +
|
Offset.QuadPart = ((ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)) +
|
||||||
MemoryArea->SectionData.ViewOffset.QuadPart;
|
MemoryArea->SectionData.ViewOffset;
|
||||||
|
|
||||||
Segment = MemoryArea->SectionData.Segment;
|
Segment = MemoryArea->SectionData.Segment;
|
||||||
|
|
||||||
|
@ -3455,7 +3449,7 @@ MmUnmapViewOfSegment(PMMSUPPORT AddressSpace,
|
||||||
BaseAddress);
|
BaseAddress);
|
||||||
if (MemoryArea == NULL)
|
if (MemoryArea == NULL)
|
||||||
{
|
{
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Segment = MemoryArea->SectionData.Segment;
|
Segment = MemoryArea->SectionData.Segment;
|
||||||
|
@ -3499,7 +3493,7 @@ MmUnmapViewOfSegment(PMMSUPPORT AddressSpace,
|
||||||
}
|
}
|
||||||
MmUnlockSectionSegment(Segment);
|
MmUnlockSectionSegment(Segment);
|
||||||
MmDereferenceSegment(Segment);
|
MmDereferenceSegment(Segment);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This functions must be called with a locked address space */
|
/* This functions must be called with a locked address space */
|
||||||
|
@ -3596,7 +3590,7 @@ MiRosUnmapViewOfSection(IN PEPROCESS Process,
|
||||||
/* Notify debugger */
|
/* Notify debugger */
|
||||||
if (ImageBaseAddress && !SkipDebuggerNotify) DbgkUnMapViewOfSection(ImageBaseAddress);
|
if (ImageBaseAddress && !SkipDebuggerNotify) DbgkUnMapViewOfSection(ImageBaseAddress);
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3801,7 +3795,7 @@ NtQuerySection(
|
||||||
|
|
||||||
ObDereferenceObject(Section);
|
ObDereferenceObject(Section);
|
||||||
|
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
@ -3959,14 +3953,14 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
||||||
if ((*BaseAddress) != NULL)
|
if ((*BaseAddress) != NULL)
|
||||||
{
|
{
|
||||||
MmUnlockAddressSpace(AddressSpace);
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
return(STATUS_CONFLICTING_ADDRESSES);
|
return STATUS_CONFLICTING_ADDRESSES;
|
||||||
}
|
}
|
||||||
/* Otherwise find a gap to map the image. */
|
/* Otherwise find a gap to map the image. */
|
||||||
ImageBase = (ULONG_PTR)MmFindGap(AddressSpace, PAGE_ROUND_UP(ImageSize), MM_VIRTMEM_GRANULARITY, FALSE);
|
ImageBase = (ULONG_PTR)MmFindGap(AddressSpace, PAGE_ROUND_UP(ImageSize), MM_VIRTMEM_GRANULARITY, FALSE);
|
||||||
if (ImageBase == 0)
|
if (ImageBase == 0)
|
||||||
{
|
{
|
||||||
MmUnlockAddressSpace(AddressSpace);
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
return(STATUS_CONFLICTING_ADDRESSES);
|
return STATUS_CONFLICTING_ADDRESSES;
|
||||||
}
|
}
|
||||||
/* Remember that we loaded image at a different base address */
|
/* Remember that we loaded image at a different base address */
|
||||||
NotAtBase = TRUE;
|
NotAtBase = TRUE;
|
||||||
|
@ -3998,7 +3992,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
MmUnlockAddressSpace(AddressSpace);
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4046,7 +4040,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
||||||
if ((ViewOffset % PAGE_SIZE) != 0)
|
if ((ViewOffset % PAGE_SIZE) != 0)
|
||||||
{
|
{
|
||||||
MmUnlockAddressSpace(AddressSpace);
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
return(STATUS_MAPPED_ALIGNMENT);
|
return STATUS_MAPPED_ALIGNMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*ViewSize) == 0)
|
if ((*ViewSize) == 0)
|
||||||
|
@ -4076,7 +4070,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
MmUnlockAddressSpace(AddressSpace);
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4115,7 +4109,8 @@ MmCanFileBeTruncated (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
|
||||||
}
|
}
|
||||||
|
|
||||||
MmLockSectionSegment(Segment);
|
MmLockSectionSegment(Segment);
|
||||||
if ((Segment->SectionCount == 0) || ((Segment->SectionCount == 1) && (SectionObjectPointer->SharedCacheMap != NULL)))
|
if ((Segment->SectionCount == 0) ||
|
||||||
|
((Segment->SectionCount == 1) && (SectionObjectPointer->SharedCacheMap != NULL)))
|
||||||
{
|
{
|
||||||
/* If the cache is the only one holding a reference to the segment, then it's fine to resize */
|
/* If the cache is the only one holding a reference to the segment, then it's fine to resize */
|
||||||
Ret = TRUE;
|
Ret = TRUE;
|
||||||
|
@ -4171,7 +4166,8 @@ MmFlushImageSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
NTSTATUS NTAPI
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
MmMapViewInSystemSpace (IN PVOID SectionObject,
|
MmMapViewInSystemSpace (IN PVOID SectionObject,
|
||||||
OUT PVOID * MappedBase,
|
OUT PVOID * MappedBase,
|
||||||
IN OUT PSIZE_T ViewSize)
|
IN OUT PSIZE_T ViewSize)
|
||||||
|
@ -4180,7 +4176,7 @@ MmMapViewInSystemSpace (IN PVOID SectionObject,
|
||||||
|
|
||||||
SectionOffset.QuadPart = 0;
|
SectionOffset.QuadPart = 0;
|
||||||
|
|
||||||
return MmMapViewInSystemSpaceEx(SectionObject, MappedBase, ViewSize, &SectionOffset);
|
return MmMapViewInSystemSpaceEx(SectionObject, MappedBase, ViewSize, &SectionOffset, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -4189,7 +4185,8 @@ MmMapViewInSystemSpaceEx (
|
||||||
_In_ PVOID SectionObject,
|
_In_ PVOID SectionObject,
|
||||||
_Outptr_result_bytebuffer_ (*ViewSize) PVOID *MappedBase,
|
_Outptr_result_bytebuffer_ (*ViewSize) PVOID *MappedBase,
|
||||||
_Inout_ PSIZE_T ViewSize,
|
_Inout_ PSIZE_T ViewSize,
|
||||||
_Inout_ PLARGE_INTEGER SectionOffset
|
_Inout_ PLARGE_INTEGER SectionOffset,
|
||||||
|
_In_ ULONG_PTR Flags
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
PSECTION Section = SectionObject;
|
PSECTION Section = SectionObject;
|
||||||
|
@ -4197,6 +4194,8 @@ MmMapViewInSystemSpaceEx (
|
||||||
PMMSUPPORT AddressSpace;
|
PMMSUPPORT AddressSpace;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
UNREFERENCED_PARAMETER(Flags);
|
||||||
|
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
if (MiIsRosSectionObject(SectionObject) == FALSE)
|
if (MiIsRosSectionObject(SectionObject) == FALSE)
|
||||||
|
@ -4523,9 +4522,9 @@ MmArePagesResident(
|
||||||
MmLockSectionSegment(Segment);
|
MmLockSectionSegment(Segment);
|
||||||
|
|
||||||
SegmentOffset.QuadPart = PAGE_ROUND_DOWN(Address) - MA_GetStartingAddress(MemoryArea)
|
SegmentOffset.QuadPart = PAGE_ROUND_DOWN(Address) - MA_GetStartingAddress(MemoryArea)
|
||||||
+ MemoryArea->SectionData.ViewOffset.QuadPart;
|
+ MemoryArea->SectionData.ViewOffset;
|
||||||
RangeEnd.QuadPart = PAGE_ROUND_UP((ULONG_PTR)Address + Length) - MA_GetStartingAddress(MemoryArea)
|
RangeEnd.QuadPart = PAGE_ROUND_UP((ULONG_PTR)Address + Length) - MA_GetStartingAddress(MemoryArea)
|
||||||
+ MemoryArea->SectionData.ViewOffset.QuadPart;
|
+ MemoryArea->SectionData.ViewOffset;
|
||||||
|
|
||||||
while (SegmentOffset.QuadPart < RangeEnd.QuadPart)
|
while (SegmentOffset.QuadPart < RangeEnd.QuadPart)
|
||||||
{
|
{
|
||||||
|
@ -4576,9 +4575,9 @@ MmRosFlushVirtualMemory(
|
||||||
Segment = MemoryArea->SectionData.Segment;
|
Segment = MemoryArea->SectionData.Segment;
|
||||||
|
|
||||||
SegmentOffset.QuadPart = PAGE_ROUND_DOWN(*Address) - MA_GetStartingAddress(MemoryArea)
|
SegmentOffset.QuadPart = PAGE_ROUND_DOWN(*Address) - MA_GetStartingAddress(MemoryArea)
|
||||||
+ MemoryArea->SectionData.ViewOffset.QuadPart;
|
+ MemoryArea->SectionData.ViewOffset;
|
||||||
RangeEnd.QuadPart = PAGE_ROUND_UP((ULONG_PTR)*Address + *Length) - MA_GetStartingAddress(MemoryArea)
|
RangeEnd.QuadPart = PAGE_ROUND_UP((ULONG_PTR)*Address + *Length) - MA_GetStartingAddress(MemoryArea)
|
||||||
+ MemoryArea->SectionData.ViewOffset.QuadPart;
|
+ MemoryArea->SectionData.ViewOffset;
|
||||||
|
|
||||||
CurrentAddress = *Address;
|
CurrentAddress = *Address;
|
||||||
|
|
||||||
|
@ -4990,9 +4989,9 @@ MmMakePagesDirty(
|
||||||
MmLockSectionSegment(Segment);
|
MmLockSectionSegment(Segment);
|
||||||
|
|
||||||
SegmentOffset.QuadPart = PAGE_ROUND_DOWN(Address) - MA_GetStartingAddress(MemoryArea)
|
SegmentOffset.QuadPart = PAGE_ROUND_DOWN(Address) - MA_GetStartingAddress(MemoryArea)
|
||||||
+ MemoryArea->SectionData.ViewOffset.QuadPart;
|
+ MemoryArea->SectionData.ViewOffset;
|
||||||
RangeEnd.QuadPart = PAGE_ROUND_UP((ULONG_PTR)Address + Length) - MA_GetStartingAddress(MemoryArea)
|
RangeEnd.QuadPart = PAGE_ROUND_UP((ULONG_PTR)Address + Length) - MA_GetStartingAddress(MemoryArea)
|
||||||
+ MemoryArea->SectionData.ViewOffset.QuadPart;
|
+ MemoryArea->SectionData.ViewOffset;
|
||||||
|
|
||||||
DPRINT("MmMakePagesResident: Segment %p, 0x%I64x -> 0x%I64x\n", Segment, SegmentOffset.QuadPart, RangeEnd.QuadPart);
|
DPRINT("MmMakePagesResident: Segment %p, 0x%I64x -> 0x%I64x\n", Segment, SegmentOffset.QuadPart, RangeEnd.QuadPart);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue