Address PR review

This commit is contained in:
Jérôme Gardou 2021-02-02 10:06:00 +01:00
parent c0bf352069
commit b7eb0fddf3
8 changed files with 85 additions and 135 deletions

View file

@ -62,10 +62,6 @@ NTAPI
CcpUnpinData(PNOCC_BCB Bcb,
BOOLEAN ActuallyRelease);
BOOLEAN
NTAPI
CcInitializeCacheManager(VOID);
VOID
NTAPI
CcShutdownSystem(VOID);

View file

@ -42,7 +42,6 @@ CcPfInitializePrefetcher(VOID)
CODE_SEG("INIT")
BOOLEAN
NTAPI
CcInitializeCacheManager(VOID)
{
ULONG Thread;

View file

@ -110,7 +110,6 @@ ULONG CcRosVacbGetRefCount_(PROS_VACB vacb, PCSTR file, INT line)
/* FUNCTIONS *****************************************************************/
VOID
NTAPI
CcRosTraceCacheMap (
PROS_SHARED_CACHE_MAP SharedCacheMap,
BOOLEAN Trace )
@ -157,14 +156,6 @@ CcRosTraceCacheMap (
}
NTSTATUS
NTAPI
MmFlushVirtualMemory(IN PEPROCESS Process,
IN OUT PVOID *BaseAddress,
IN OUT PSIZE_T RegionSize,
OUT PIO_STATUS_BLOCK IoStatusBlock);
NTSTATUS
NTAPI
CcRosFlushVacb (
_In_ PROS_VACB Vacb,
_In_ PIO_STATUS_BLOCK Iosb)
@ -210,7 +201,6 @@ quit:
}
NTSTATUS
NTAPI
CcRosFlushDirtyPages (
ULONG Target,
PULONG Count,
@ -349,7 +339,6 @@ CcRosFlushDirtyPages (
}
NTSTATUS
NTAPI
CcRosReleaseVacb (
PROS_SHARED_CACHE_MAP SharedCacheMap,
PROS_VACB Vacb,
@ -382,7 +371,6 @@ CcRosReleaseVacb (
/* Returns with VACB Lock Held! */
PROS_VACB
NTAPI
CcRosLookupVacb (
PROS_SHARED_CACHE_MAP SharedCacheMap,
LONGLONG FileOffset)
@ -426,7 +414,6 @@ CcRosLookupVacb (
}
VOID
NTAPI
CcRosMarkDirtyVacb (
PROS_VACB Vacb)
{
@ -463,7 +450,6 @@ CcRosMarkDirtyVacb (
}
VOID
NTAPI
CcRosUnmarkDirtyVacb (
PROS_VACB Vacb,
BOOLEAN LockViews)
@ -617,7 +603,7 @@ CcRosCreateVacb (
Retried = FALSE;
Retry:
/* Map VACB in system space */
Status = MmMapViewInSystemSpaceEx(SharedCacheMap->Section, &current->BaseAddress, &ViewSize, &current->FileOffset);
Status = MmMapViewInSystemSpaceEx(SharedCacheMap->Section, &current->BaseAddress, &ViewSize, &current->FileOffset, 0);
if (!NT_SUCCESS(Status))
{
@ -735,7 +721,6 @@ Retry:
}
BOOLEAN
NTAPI
CcRosEnsureVacbResident(
_In_ PROS_VACB Vacb,
_In_ BOOLEAN Wait,
@ -783,7 +768,6 @@ CcRosEnsureVacbResident(
NTSTATUS
NTAPI
CcRosGetVacb (
PROS_SHARED_CACHE_MAP SharedCacheMap,
LONGLONG FileOffset,
@ -835,7 +819,6 @@ CcRosGetVacb (
}
NTSTATUS
NTAPI
CcRosRequestVacb (
PROS_SHARED_CACHE_MAP SharedCacheMap,
LONGLONG FileOffset,
@ -1032,7 +1015,6 @@ quit:
}
NTSTATUS
NTAPI
CcRosDeleteFileCache (
PFILE_OBJECT FileObject,
PROS_SHARED_CACHE_MAP SharedCacheMap,
@ -1085,11 +1067,10 @@ CcRosDeleteFileCache (
/* Flush to disk, if needed */
if (Vacb->Dirty)
{
SIZE_T FlushSize = VACB_MAPPING_GRANULARITY;
IO_STATUS_BLOCK Iosb;
NTSTATUS Status;
Status = MmFlushVirtualMemory(NULL, &Vacb->BaseAddress, &FlushSize, &Iosb);
Status = MmFlushSegment(FileObject->SectionObjectPointer, &Vacb->FileOffset, VACB_MAPPING_GRANULARITY, &Iosb);
if (!NT_SUCCESS(Status))
{
/* Complain. There's not much we can do */
@ -1134,7 +1115,6 @@ CcRosDeleteFileCache (
}
VOID
NTAPI
CcRosReferenceCache (
PFILE_OBJECT FileObject)
{
@ -1150,7 +1130,6 @@ CcRosReferenceCache (
}
NTSTATUS
NTAPI
CcRosReleaseFileCache (
PFILE_OBJECT FileObject)
/*
@ -1207,7 +1186,6 @@ CcRosReleaseFileCache (
}
NTSTATUS
NTAPI
CcRosInitializeFileCache (
PFILE_OBJECT FileObject,
PCC_FILE_SIZES FileSizes,

View file

@ -3,7 +3,7 @@
//
// Define this if you want debugging support
//
#define _CC_DEBUG_ 0x0
#define _CC_DEBUG_ 0x00
//
// These define the Debug Masks Supported
@ -309,11 +309,9 @@ CcMdlWriteComplete2(
);
NTSTATUS
NTAPI
CcRosFlushVacb(PROS_VACB Vacb, PIO_STATUS_BLOCK Iosb);
NTSTATUS
NTAPI
CcRosGetVacb(
PROS_SHARED_CACHE_MAP SharedCacheMap,
LONGLONG FileOffset,
@ -321,7 +319,6 @@ CcRosGetVacb(
);
BOOLEAN
NTAPI
CcRosEnsureVacbResident(
_In_ PROS_VACB Vacb,
_In_ BOOLEAN Wait,
@ -339,11 +336,9 @@ NTAPI
CcShutdownLazyWriter(VOID);
BOOLEAN
NTAPI
CcInitializeCacheManager(VOID);
PROS_VACB
NTAPI
CcRosLookupVacb(
PROS_SHARED_CACHE_MAP SharedCacheMap,
LONGLONG FileOffset
@ -354,18 +349,15 @@ NTAPI
CcInitCacheZeroPage(VOID);
VOID
NTAPI
CcRosMarkDirtyVacb(
PROS_VACB Vacb);
VOID
NTAPI
CcRosUnmarkDirtyVacb(
PROS_VACB Vacb,
BOOLEAN LockViews);
NTSTATUS
NTAPI
CcRosFlushDirtyPages(
ULONG Target,
PULONG Count,
@ -374,15 +366,12 @@ CcRosFlushDirtyPages(
);
VOID
NTAPI
CcRosDereferenceCache(PFILE_OBJECT FileObject);
VOID
NTAPI
CcRosReferenceCache(PFILE_OBJECT FileObject);
NTSTATUS
NTAPI
CcRosReleaseVacb(
PROS_SHARED_CACHE_MAP SharedCacheMap,
PROS_VACB Vacb,
@ -391,7 +380,6 @@ CcRosReleaseVacb(
);
NTSTATUS
NTAPI
CcRosRequestVacb(
PROS_SHARED_CACHE_MAP SharedCacheMap,
LONGLONG FileOffset,
@ -399,7 +387,6 @@ CcRosRequestVacb(
);
NTSTATUS
NTAPI
CcRosInitializeFileCache(
PFILE_OBJECT FileObject,
PCC_FILE_SIZES FileSizes,
@ -409,7 +396,6 @@ CcRosInitializeFileCache(
);
NTSTATUS
NTAPI
CcRosReleaseFileCache(
PFILE_OBJECT FileObject
);

View file

@ -224,7 +224,7 @@ typedef struct _MEMORY_AREA
struct
{
LARGE_INTEGER ViewOffset;
LONGLONG ViewOffset;
PMM_SECTION_SEGMENT Segment;
LIST_ENTRY RegionListHead;
} SectionData;
@ -770,15 +770,6 @@ MmAccessFault(
IN PVOID TrapInformation
);
/* kmap.c ********************************************************************/
NTSTATUS
NTAPI
MiCopyFromUserPage(
PFN_NUMBER DestPage,
const VOID *SrcAddress
);
/* process.c *****************************************************************/
PVOID
@ -1359,7 +1350,8 @@ MmMapViewInSystemSpaceEx (
_In_ PVOID Section,
_Outptr_result_bytebuffer_ (*ViewSize) PVOID *MappedBase,
_Inout_ PSIZE_T ViewSize,
_Inout_ PLARGE_INTEGER SectionOffset
_Inout_ PLARGE_INTEGER SectionOffset,
_In_ ULONG_PTR Flags
);
BOOLEAN

View file

@ -412,19 +412,19 @@ MiInsertInSystemSpace(IN PMMSESSION Session,
return Base;
}
static
NTSTATUS
NTAPI
MiAddMappedPtes(IN PMMPTE FirstPte,
IN PFN_NUMBER PteCount,
IN PCONTROL_AREA ControlArea,
IN PLARGE_INTEGER SectionOffset)
IN LONGLONG SectionOffset)
{
MMPTE TempPte;
PMMPTE PointerPte, ProtoPte, LastProtoPte, LastPte;
PSUBSECTION Subsection;
/* Mapping at offset not supported yet */
ASSERT(SectionOffset->QuadPart == 0);
ASSERT(SectionOffset == 0);
/* ARM3 doesn't support this yet */
ASSERT(ControlArea->u.Flags.GlobalOnlyPerSession == 0);
@ -1054,12 +1054,12 @@ _WARN("MiSessionCommitPageTables halfplemented for amd64")
}
NTSTATUS
NTAPI
MiMapViewInSystemSpace(IN PVOID Section,
IN PMMSESSION Session,
OUT PVOID *MappedBase,
IN OUT PSIZE_T ViewSize,
IN PLARGE_INTEGER SectionOffset)
MiMapViewInSystemSpace(
_In_ PVOID Section,
_In_ PMMSESSION Session,
_Outptr_result_bytebuffer_ (*ViewSize) PVOID *MappedBase,
_Inout_ PSIZE_T ViewSize,
_Inout_ PLARGE_INTEGER SectionOffset)
{
PVOID Base;
PCONTROL_AREA ControlArea;
@ -1156,7 +1156,7 @@ MiMapViewInSystemSpace(IN PVOID Section,
Status = MiAddMappedPtes(MiAddressToPte(Base),
BYTES_TO_PAGES(*ViewSize),
ControlArea,
SectionOffset);
SectionOffset->QuadPart);
ASSERT(NT_SUCCESS(Status));
/* Return the base adress of the mapping and success */

View file

@ -128,7 +128,7 @@ GetEntry:
LARGE_INTEGER Offset;
BOOLEAN Released;
Offset.QuadPart = MemoryArea->SectionData.ViewOffset.QuadPart +
Offset.QuadPart = MemoryArea->SectionData.ViewOffset +
((ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea));
Segment = MemoryArea->SectionData.Segment;

View file

@ -125,7 +125,6 @@ PMM_IMAGE_SECTION_OBJECT ImageSectionObjectFromSegment(PMM_SECTION_SEGMENT Segme
}
NTSTATUS
NTAPI
MiMapViewInSystemSpace(IN PVOID Section,
IN PVOID Session,
OUT PVOID *MappedBase,
@ -1160,8 +1159,8 @@ MmUnsharePageEntrySectionSegment(PMEMORY_AREA MemoryArea,
return TRUE;
}
static
NTSTATUS
NTAPI
MiCopyFromUserPage(PFN_NUMBER DestPage, const VOID *SrcAddress)
{
PEPROCESS Process;
@ -1172,13 +1171,13 @@ MiCopyFromUserPage(PFN_NUMBER DestPage, const VOID *SrcAddress)
DestAddress = MiMapPageInHyperSpace(Process, DestPage, &Irql);
if (DestAddress == NULL)
{
return(STATUS_NO_MEMORY);
return STATUS_NO_MEMORY;
}
ASSERT((ULONG_PTR)DestAddress % PAGE_SIZE == 0);
ASSERT((ULONG_PTR)SrcAddress % PAGE_SIZE == 0);
RtlCopyMemory(DestAddress, SrcAddress, PAGE_SIZE);
MiUnmapPageInHyperSpace(Process, DestAddress, Irql);
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
static
@ -1465,7 +1464,7 @@ MmAlterViewAttributes(PMMSUPPORT AddressSpace,
PFN_NUMBER Page;
Offset.QuadPart = (ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)
+ MemoryArea->SectionData.ViewOffset.QuadPart;
+ MemoryArea->SectionData.ViewOffset;
Entry = MmGetPageEntrySectionSegment(Segment, &Offset);
/*
* 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))
{
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
if (MmIsDisabledPage(Process, Address))
{
return(STATUS_ACCESS_VIOLATION);
return STATUS_ACCESS_VIOLATION;
}
/*
@ -1531,12 +1530,12 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
*/
if (MemoryArea->DeleteInProgress)
{
return(STATUS_UNSUCCESSFUL);
return STATUS_UNSUCCESSFUL;
}
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
Offset.QuadPart = (ULONG_PTR)PAddress - MA_GetStartingAddress(MemoryArea)
+ MemoryArea->SectionData.ViewOffset.QuadPart;
+ MemoryArea->SectionData.ViewOffset;
Segment = MemoryArea->SectionData.Segment;
Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea),
@ -1596,7 +1595,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
MiWaitForPageEvent(NULL, NULL);
MmLockAddressSpace(AddressSpace);
DPRINT("Address 0x%p\n", Address);
return(STATUS_MM_RESTART_OPERATION);
return STATUS_MM_RESTART_OPERATION;
}
HasSwapEntry = MmIsPageSwapEntry(Process, Address);
@ -1660,7 +1659,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
{
DPRINT("MmCreateVirtualMapping failed, not out of memory\n");
KeBugCheck(MEMORY_MANAGEMENT);
return(Status);
return Status;
}
/*
@ -1678,7 +1677,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
*/
MiSetPageEvent(Process, 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");
KeBugCheck(MEMORY_MANAGEMENT);
return(Status);
return Status;
}
/*
@ -1708,7 +1707,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
*/
MiSetPageEvent(Process, Address);
DPRINT("Address 0x%p\n", Address);
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
/*
@ -1743,7 +1742,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
MiSetPageEvent(Process, Address);
DPRINT("Address 0x%p\n", Address);
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
MmUnlockSectionSegment(Segment);
@ -1853,7 +1852,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
MiSetPageEvent(Process, Address);
DPRINT("Address 0x%p\n", Address);
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
else
{
@ -1880,7 +1879,7 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
MiSetPageEvent(Process, 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)
{
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);
Offset.QuadPart = (ULONG_PTR)PAddress - MA_GetStartingAddress(MemoryArea)
+ MemoryArea->SectionData.ViewOffset.QuadPart;
+ MemoryArea->SectionData.ViewOffset;
Segment = MemoryArea->SectionData.Segment;
Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea),
@ -1940,7 +1939,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
Region->Protect == PAGE_EXECUTE_READWRITE)))
{
DPRINT("Address 0x%p\n", Address);
return(STATUS_ACCESS_VIOLATION);
return STATUS_ACCESS_VIOLATION;
}
/* Get the page mapping this section offset. */
@ -1958,7 +1957,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
MmUnlockSectionSegment(Segment);
/* This is a private page. We must only change the page protection. */
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");
KeBugCheck(MEMORY_MANAGEMENT);
return(Status);
return Status;
}
if (Process)
@ -2008,7 +2007,7 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
MiSetPageEvent(Process, Address);
DPRINT("Address 0x%p\n", Address);
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
NTSTATUS
@ -2045,7 +2044,7 @@ MmProtectSectionView(PMMSUPPORT AddressSpace,
BaseAddress, Length, Region->Type, Protect,
MmAlterViewAttributes);
return(Status);
return Status;
}
NTSTATUS NTAPI
@ -2084,7 +2083,7 @@ MmQuerySectionView(PMEMORY_AREA MemoryArea,
Info->Protect = Region->Protect;
*ResultLength = sizeof(MEMORY_BASIC_INFORMATION);
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
VOID NTAPI
@ -2180,7 +2179,7 @@ MmCreatePhysicalMemorySection(VOID)
if (!NT_SUCCESS(Status))
{
DPRINT1("MmCreatePhysicalMemorySection: failed to create object (0x%lx)\n", Status);
return(Status);
return Status;
}
/*
@ -2198,7 +2197,7 @@ MmCreatePhysicalMemorySection(VOID)
if (Segment == NULL)
{
ObDereferenceObject(PhysSection);
return(STATUS_NO_MEMORY);
return STATUS_NO_MEMORY;
}
RtlZeroMemory(Segment, sizeof(MM_SECTION_SEGMENT));
PhysSection->Segment = (PSEGMENT)Segment;
@ -2231,7 +2230,7 @@ MmCreatePhysicalMemorySection(VOID)
}
ObCloseHandle(Handle, KernelMode);
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
CODE_SEG("INIT")
@ -2264,7 +2263,7 @@ MmInitSectionImplementation(VOID)
MmCreatePhysicalMemorySection();
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
static
@ -2302,7 +2301,7 @@ MmCreateDataFileSection(PSECTION *SectionObject,
(PVOID*)&Section);
if (!NT_SUCCESS(Status))
{
return(Status);
return Status;
}
/*
* Initialize it
@ -2363,7 +2362,7 @@ MmCreateDataFileSection(PSECTION *SectionObject,
if (!NT_SUCCESS(Status))
{
ObDereferenceObject(Section);
return(STATUS_SECTION_NOT_EXTENDED);
return STATUS_SECTION_NOT_EXTENDED;
}
}
}
@ -2381,7 +2380,7 @@ MmCreateDataFileSection(PSECTION *SectionObject,
if (Status != STATUS_SUCCESS)
{
ObDereferenceObject(Section);
return(Status);
return Status;
}
/* 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)))
{
LARGE_INTEGER ShortTime = {{-10 * 100 * 1000, -1}};
MiReleasePfnLock(OldIrql);
KeDelayExecutionThread(KernelMode, FALSE, &ShortTime);
KeDelayExecutionThread(KernelMode, FALSE, &TinyTime);
OldIrql = MiAcquirePfnLock();
Segment = FileObject->SectionObjectPointer->DataSectionObject;
}
@ -2411,7 +2408,7 @@ MmCreateDataFileSection(PSECTION *SectionObject,
//KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE);
MiReleasePfnLock(OldIrql);
ObDereferenceObject(Section);
return(STATUS_NO_MEMORY);
return STATUS_NO_MEMORY;
}
/* We are creating it */
@ -2481,7 +2478,7 @@ MmCreateDataFileSection(PSECTION *SectionObject,
//KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE);
*SectionObject = Section;
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
/*
@ -3145,7 +3142,7 @@ MmCreateImageSection(PSECTION *SectionObject,
(PVOID*)(PVOID)&Section);
if (!NT_SUCCESS(Status))
{
return(Status);
return Status;
}
/*
@ -3168,12 +3165,9 @@ MmCreateImageSection(PSECTION *SectionObject,
ImageSectionObject = FileObject->SectionObjectPointer->ImageSectionObject;
while(ImageSectionObject && (ImageSectionObject->SegFlags & (MM_SEGMENT_INDELETE | MM_SEGMENT_INCREATE)))
{
LARGE_INTEGER ShortTime;
MiReleasePfnLock(OldIrql);
ShortTime.QuadPart = - 10 * 100 * 1000;
KeDelayExecutionThread(KernelMode, FALSE, &ShortTime);
KeDelayExecutionThread(KernelMode, FALSE, &TinyTime);
OldIrql = MiAcquirePfnLock();
ImageSectionObject = FileObject->SectionObjectPointer->ImageSectionObject;
@ -3188,7 +3182,7 @@ MmCreateImageSection(PSECTION *SectionObject,
{
MiReleasePfnLock(OldIrql);
ObDereferenceObject(Section);
return(STATUS_NO_MEMORY);
return STATUS_NO_MEMORY;
}
ImageSectionObject->SegFlags = MM_SEGMENT_INCREATE;
@ -3223,7 +3217,7 @@ MmCreateImageSection(PSECTION *SectionObject,
ExFreePoolWithTag(ImageSectionObject, TAG_MM_SECTION_SEGMENT);
ObDereferenceObject(Section);
return(Status);
return Status;
}
Section->Segment = (PSEGMENT)ImageSectionObject;
@ -3244,7 +3238,7 @@ MmCreateImageSection(PSECTION *SectionObject,
ExFreePool(ImageSectionObject->Segments);
ExFreePool(ImageSectionObject);
ObDereferenceObject(Section);
return(Status);
return Status;
}
OldIrql = MiAcquirePfnLock();
@ -3272,7 +3266,7 @@ MmCreateImageSection(PSECTION *SectionObject,
*SectionObject = Section;
ASSERT(ImageSectionObject->RefCount > 0);
return(Status);
return Status;
}
@ -3337,13 +3331,13 @@ MmMapViewOfSegment(
{
DPRINT1("Mapping between 0x%p and 0x%p failed (%X).\n",
(*BaseAddress), (char*)(*BaseAddress) + ViewSize, Status);
return(Status);
return Status;
}
InterlockedIncrement64(Segment->ReferenceCount);
MArea->SectionData.Segment = Segment;
MArea->SectionData.ViewOffset.QuadPart = ViewOffset;
MArea->SectionData.ViewOffset = ViewOffset;
if (AsImage)
{
MArea->VadNode.u.VadFlags.VadType = VadImageMap;
@ -3352,7 +3346,7 @@ MmMapViewOfSegment(
MmInitializeRegion(&MArea->SectionData.RegionListHead,
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);
Offset.QuadPart = ((ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)) +
MemoryArea->SectionData.ViewOffset.QuadPart;
MemoryArea->SectionData.ViewOffset;
Segment = MemoryArea->SectionData.Segment;
@ -3455,7 +3449,7 @@ MmUnmapViewOfSegment(PMMSUPPORT AddressSpace,
BaseAddress);
if (MemoryArea == NULL)
{
return(STATUS_UNSUCCESSFUL);
return STATUS_UNSUCCESSFUL;
}
Segment = MemoryArea->SectionData.Segment;
@ -3499,7 +3493,7 @@ MmUnmapViewOfSegment(PMMSUPPORT AddressSpace,
}
MmUnlockSectionSegment(Segment);
MmDereferenceSegment(Segment);
return(Status);
return Status;
}
/* This functions must be called with a locked address space */
@ -3596,7 +3590,7 @@ MiRosUnmapViewOfSection(IN PEPROCESS Process,
/* Notify debugger */
if (ImageBaseAddress && !SkipDebuggerNotify) DbgkUnMapViewOfSection(ImageBaseAddress);
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
@ -3801,7 +3795,7 @@ NtQuerySection(
ObDereferenceObject(Section);
return(Status);
return Status;
}
/**********************************************************************
@ -3959,14 +3953,14 @@ MmMapViewOfSection(IN PVOID SectionObject,
if ((*BaseAddress) != NULL)
{
MmUnlockAddressSpace(AddressSpace);
return(STATUS_CONFLICTING_ADDRESSES);
return STATUS_CONFLICTING_ADDRESSES;
}
/* Otherwise find a gap to map the image. */
ImageBase = (ULONG_PTR)MmFindGap(AddressSpace, PAGE_ROUND_UP(ImageSize), MM_VIRTMEM_GRANULARITY, FALSE);
if (ImageBase == 0)
{
MmUnlockAddressSpace(AddressSpace);
return(STATUS_CONFLICTING_ADDRESSES);
return STATUS_CONFLICTING_ADDRESSES;
}
/* Remember that we loaded image at a different base address */
NotAtBase = TRUE;
@ -3998,7 +3992,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
}
MmUnlockAddressSpace(AddressSpace);
return(Status);
return Status;
}
}
@ -4046,7 +4040,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
if ((ViewOffset % PAGE_SIZE) != 0)
{
MmUnlockAddressSpace(AddressSpace);
return(STATUS_MAPPED_ALIGNMENT);
return STATUS_MAPPED_ALIGNMENT;
}
if ((*ViewSize) == 0)
@ -4076,7 +4070,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
if (!NT_SUCCESS(Status))
{
MmUnlockAddressSpace(AddressSpace);
return(Status);
return Status;
}
}
@ -4115,7 +4109,8 @@ MmCanFileBeTruncated (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
}
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 */
Ret = TRUE;
@ -4171,7 +4166,8 @@ MmFlushImageSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
/*
* @implemented
*/
NTSTATUS NTAPI
NTSTATUS
NTAPI
MmMapViewInSystemSpace (IN PVOID SectionObject,
OUT PVOID * MappedBase,
IN OUT PSIZE_T ViewSize)
@ -4180,7 +4176,7 @@ MmMapViewInSystemSpace (IN PVOID SectionObject,
SectionOffset.QuadPart = 0;
return MmMapViewInSystemSpaceEx(SectionObject, MappedBase, ViewSize, &SectionOffset);
return MmMapViewInSystemSpaceEx(SectionObject, MappedBase, ViewSize, &SectionOffset, 0);
}
NTSTATUS
@ -4189,7 +4185,8 @@ MmMapViewInSystemSpaceEx (
_In_ PVOID SectionObject,
_Outptr_result_bytebuffer_ (*ViewSize) PVOID *MappedBase,
_Inout_ PSIZE_T ViewSize,
_Inout_ PLARGE_INTEGER SectionOffset
_Inout_ PLARGE_INTEGER SectionOffset,
_In_ ULONG_PTR Flags
)
{
PSECTION Section = SectionObject;
@ -4197,6 +4194,8 @@ MmMapViewInSystemSpaceEx (
PMMSUPPORT AddressSpace;
NTSTATUS Status;
UNREFERENCED_PARAMETER(Flags);
PAGED_CODE();
if (MiIsRosSectionObject(SectionObject) == FALSE)
@ -4523,9 +4522,9 @@ MmArePagesResident(
MmLockSectionSegment(Segment);
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)
+ MemoryArea->SectionData.ViewOffset.QuadPart;
+ MemoryArea->SectionData.ViewOffset;
while (SegmentOffset.QuadPart < RangeEnd.QuadPart)
{
@ -4576,9 +4575,9 @@ MmRosFlushVirtualMemory(
Segment = MemoryArea->SectionData.Segment;
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)
+ MemoryArea->SectionData.ViewOffset.QuadPart;
+ MemoryArea->SectionData.ViewOffset;
CurrentAddress = *Address;
@ -4990,9 +4989,9 @@ MmMakePagesDirty(
MmLockSectionSegment(Segment);
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)
+ MemoryArea->SectionData.ViewOffset.QuadPart;
+ MemoryArea->SectionData.ViewOffset;
DPRINT("MmMakePagesResident: Segment %p, 0x%I64x -> 0x%I64x\n", Segment, SegmentOffset.QuadPart, RangeEnd.QuadPart);