https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3814a822f1de78266e1d0…
commit 3814a822f1de78266e1d0b82429c146a6a448cc7
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Mon Aug 13 07:52:05 2018 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Mon Aug 13 08:30:17 2018 +0200
[NTOSKRNL] Close page files (and delete them!) on shutdown
---
ntoskrnl/include/internal/mm.h | 18 ++++++++++++++++++
ntoskrnl/mm/pagefile.c | 20 +-------------------
ntoskrnl/mm/shutdown.c | 9 +++++++++
3 files changed, 28 insertions(+), 19 deletions(-)
diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h
index f7b08a2d0f..6f0972da40 100644
--- a/ntoskrnl/include/internal/mm.h
+++ b/ntoskrnl/include/internal/mm.h
@@ -102,6 +102,8 @@ typedef ULONG_PTR SWAPENTRY;
#define SESSION_POOL_MASK 32
#define VERIFIER_POOL_MASK 64
+#define MAX_PAGING_FILES (16)
+
// FIXME: use ALIGN_UP_BY
#define MM_ROUND_UP(x,s) \
((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
@@ -421,6 +423,22 @@ typedef struct _MM_PAGED_POOL_INFO
extern MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM];
+/* Page file information */
+typedef struct _MMPAGING_FILE
+{
+ PFILE_OBJECT FileObject;
+ HANDLE FileHandle;
+ LARGE_INTEGER MaximumSize;
+ LARGE_INTEGER CurrentSize;
+ PFN_NUMBER FreePages;
+ PFN_NUMBER UsedPages;
+ PRTL_BITMAP AllocMap;
+ KSPIN_LOCK AllocMapLock;
+}
+MMPAGING_FILE, *PMMPAGING_FILE;
+
+extern PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES];
+
typedef VOID
(*PMM_ALTER_REGION_FUNC)(
PMMSUPPORT AddressSpace,
diff --git a/ntoskrnl/mm/pagefile.c b/ntoskrnl/mm/pagefile.c
index 347ffec4a5..2859a35fd1 100644
--- a/ntoskrnl/mm/pagefile.c
+++ b/ntoskrnl/mm/pagefile.c
@@ -36,30 +36,12 @@
#pragma alloc_text(INIT, MmInitPagingFile)
#endif
-
-/* TYPES *********************************************************************/
-
-typedef struct _MMPAGING_FILE
-{
- PFILE_OBJECT FileObject;
- HANDLE FileHandle;
- LARGE_INTEGER MaximumSize;
- LARGE_INTEGER CurrentSize;
- PFN_NUMBER FreePages;
- PFN_NUMBER UsedPages;
- PRTL_BITMAP AllocMap;
- KSPIN_LOCK AllocMapLock;
-}
-MMPAGING_FILE, *PMMPAGING_FILE;
-
/* GLOBALS *******************************************************************/
#define PAIRS_PER_RUN (1024)
-#define MAX_PAGING_FILES (16)
-
/* List of paging files, both used and free */
-static PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES];
+PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES];
/* Lock for examining the list of paging files */
static KSPIN_LOCK PagingFileListLock;
diff --git a/ntoskrnl/mm/shutdown.c b/ntoskrnl/mm/shutdown.c
index 68549983bf..50522dd4e8 100644
--- a/ntoskrnl/mm/shutdown.c
+++ b/ntoskrnl/mm/shutdown.c
@@ -20,6 +20,15 @@
VOID
MiShutdownSystem(VOID)
{
+ ULONG i;
+
+ /* Loop through all the paging files */
+ for (i = 0; i < MmNumberOfPagingFiles; i++)
+ {
+ /* And close them */
+ ZwClose(MmPagingFile[i]->FileHandle);
+ }
+
UNIMPLEMENTED;
}