https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3e43aa1305fa2865c3e61647e5c51857c9a1c9fd
commit 3e43aa1305fa2865c3e61647e5c51857c9a1c9fd Author: Jérôme Gardou <jerome.gar...@reactos.org> AuthorDate: Wed Jan 27 16:20:08 2021 +0100 Commit: Jérôme Gardou <jerome.gar...@reactos.org> CommitDate: Wed Feb 3 09:41:23 2021 +0100 [NTOS:MM] Use 64-bit integer to count references on segments --- ntoskrnl/include/internal/mm.h | 8 +++++--- ntoskrnl/mm/rmap.c | 2 +- ntoskrnl/mm/section.c | 25 +++---------------------- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index dad1a08bf33..86ed4dfb23a 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -168,7 +168,7 @@ typedef struct _MM_SECTION_SEGMENT FAST_MUTEX Lock; /* lock which protects the page directory */ LARGE_INTEGER RawLength; /* length of the segment which is part of the mapped file */ LARGE_INTEGER Length; /* absolute length of the segment */ - PULONG ReferenceCount; + PLONG64 ReferenceCount; ULONG SectionCount; ULONG Protection; PULONG Flags; @@ -182,9 +182,11 @@ typedef struct _MM_SECTION_SEGMENT ULONG Characteristics; } Image; - ULONG RefCount; + LONG64 RefCount; ULONG SegFlags; + ULONGLONG LastPage; + RTL_GENERIC_TABLE PageTable; } MM_SECTION_SEGMENT, *PMM_SECTION_SEGMENT; @@ -192,7 +194,7 @@ typedef struct _MM_IMAGE_SECTION_OBJECT { PFILE_OBJECT FileObject; - ULONG RefCount; + LONG64 RefCount; ULONG SegFlags; SECTION_IMAGE_INFORMATION ImageInformation; diff --git a/ntoskrnl/mm/rmap.c b/ntoskrnl/mm/rmap.c index f50e680e401..5b7ffe3a3da 100644 --- a/ntoskrnl/mm/rmap.c +++ b/ntoskrnl/mm/rmap.c @@ -525,7 +525,7 @@ MmGetSegmentRmap(PFN_NUMBER Page, PULONG RawOffset) return NULL; } - InterlockedIncrementUL(Result->Segment->ReferenceCount); + InterlockedIncrement64(Result->Segment->ReferenceCount); MiReleasePfnLock(OldIrql); return Result; } diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index a223ba0e302..524b282f606 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -107,7 +107,7 @@ MiGrabDataSection(PSECTION_OBJECT_POINTERS SectionObjectPointer) } ASSERT(Segment->SegFlags & MM_DATAFILE_SEGMENT); - InterlockedIncrementUL(&Segment->RefCount); + InterlockedIncrement64(&Segment->RefCount); break; } @@ -996,7 +996,7 @@ MmDereferenceSegment(PMM_SECTION_SEGMENT Segment) /* Lock the PFN lock because we mess around with SectionObjectPointers */ OldIrql = MiAcquirePfnLock(); - if (InterlockedDecrementUL(Segment->ReferenceCount) > 0) + if (InterlockedDecrement64(Segment->ReferenceCount) > 0) { /* Nothing to do yet */ MiReleasePfnLock(OldIrql); @@ -2049,25 +2049,6 @@ MmpDeleteSection(PVOID ObjectBody) ASSERT(ImageSectionObject->RefCount > 0); MmDereferenceSegment(ImageSectionObject->Segments); } -#ifdef NEWCC - else if (Section->Segment && Section->Segment->Flags & MM_DATAFILE_SEGMENT) - { - ULONG RefCount = 0; - PMM_SECTION_SEGMENT Segment = Section->Segment; - - if (Segment && - (RefCount = InterlockedDecrementUL(&Segment->ReferenceCount)) == 0) - { - DPRINT("Freeing section segment\n"); - Section->Segment = NULL; - MmFinalizeSegment(Segment); - } - else - { - DPRINT("RefCount %d\n", RefCount); - } - } -#endif else { PMM_SECTION_SEGMENT Segment = (PMM_SECTION_SEGMENT)Section->Segment; @@ -3339,7 +3320,7 @@ MmMapViewOfSegment( return(Status); } - InterlockedIncrementUL(Segment->ReferenceCount); + InterlockedIncrement64(Segment->ReferenceCount); MArea->SectionData.Segment = Segment; MArea->SectionData.ViewOffset.QuadPart = ViewOffset;