1 #ifndef __INCLUDE_INTERNAL_MM_H
2 #define __INCLUDE_INTERNAL_MM_H
4 #include <internal/arch/mm.h>
6 /* TYPES *********************************************************************/
10 extern ULONG MiFreeSwapPages
;
11 extern ULONG MiUsedSwapPages
;
12 extern ULONG MmPagedPoolSize
;
13 extern ULONG MmTotalPagedPoolQuota
;
14 extern ULONG MmTotalNonPagedPoolQuota
;
15 extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress
;
16 extern ULONG MmNumberOfPhysicalPages
;
17 extern UCHAR MmDisablePagingExecutive
;
18 extern ULONG MmLowestPhysicalPage
;
19 extern ULONG MmHighestPhysicalPage
;
20 extern ULONG MmAvailablePages
;
21 extern ULONG MmResidentAvailablePages
;
23 extern PVOID MmPagedPoolBase
;
24 extern ULONG MmPagedPoolSize
;
26 extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor
;
27 extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg
;
29 extern LIST_ENTRY MmLoadedUserImageList
;
31 extern ULONG MmNumberOfPagingFiles
;
33 extern PVOID MmUnloadedDrivers
;
34 extern PVOID MmLastUnloadedDrivers
;
35 extern PVOID MmTriageActionTaken
;
36 extern PVOID KernelVerifier
;
37 extern MM_DRIVER_VERIFIER_DATA MmVerifierData
;
39 extern SIZE_T MmTotalCommitLimit
;
40 extern SIZE_T MmTotalCommittedPages
;
41 extern SIZE_T MmSharedCommit
;
42 extern SIZE_T MmDriverCommit
;
43 extern SIZE_T MmProcessCommit
;
44 extern SIZE_T MmPagedPoolCommit
;
45 extern SIZE_T MmPeakCommitment
;
46 extern SIZE_T MmtotalCommitLimitMaximum
;
48 extern BOOLEAN MiDbgReadyForPhysical
;
52 struct _MM_RMAP_ENTRY
;
54 typedef ULONG SWAPENTRY
;
55 typedef ULONG PFN_TYPE
, *PPFN_TYPE
;
58 // MmDbgCopyMemory Flags
60 #define MMDBG_COPY_WRITE 0x00000001
61 #define MMDBG_COPY_PHYSICAL 0x00000002
62 #define MMDBG_COPY_UNSAFE 0x00000004
63 #define MMDBG_COPY_CACHED 0x00000008
64 #define MMDBG_COPY_UNCACHED 0x00000010
65 #define MMDBG_COPY_WRITE_COMBINED 0x00000020
68 // Maximum chunk size per copy
70 #define MMDBG_COPY_MAX_SIZE 0x8
73 #define MI_STATIC_MEMORY_AREAS (14)
75 #define MI_STATIC_MEMORY_AREAS (13)
78 #define MEMORY_AREA_INVALID (0)
79 #define MEMORY_AREA_SECTION_VIEW (1)
80 #define MEMORY_AREA_CONTINUOUS_MEMORY (2)
81 #define MEMORY_AREA_NO_CACHE (3)
82 #define MEMORY_AREA_IO_MAPPING (4)
83 #define MEMORY_AREA_SYSTEM (5)
84 #define MEMORY_AREA_MDL_MAPPING (7)
85 #define MEMORY_AREA_VIRTUAL_MEMORY (8)
86 #define MEMORY_AREA_CACHE_SEGMENT (9)
87 #define MEMORY_AREA_SHARED_DATA (10)
88 #define MEMORY_AREA_KERNEL_STACK (11)
89 #define MEMORY_AREA_PAGED_POOL (12)
90 #define MEMORY_AREA_NO_ACCESS (13)
91 #define MEMORY_AREA_PEB_OR_TEB (14)
92 #define MEMORY_AREA_OWNED_BY_ARM3 (15)
93 #define MEMORY_AREA_STATIC (0x80000000)
95 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
97 #define MM_CORE_DUMP_TYPE_NONE (0x0)
98 #define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
99 #define MM_CORE_DUMP_TYPE_FULL (0x2)
101 #define MM_PAGEOP_PAGEIN (1)
102 #define MM_PAGEOP_PAGEOUT (2)
103 #define MM_PAGEOP_PAGESYNCH (3)
104 #define MM_PAGEOP_ACCESSFAULT (4)
106 /* Number of list heads to use */
107 #define MI_FREE_POOL_LISTS 4
109 #define MI_HYPERSPACE_PTES (256 - 1)
110 #define MI_ZERO_PTES (32)
111 #define MI_MAPPING_RANGE_START (ULONG)HYPER_SPACE
112 #define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \
113 MI_HYPERSPACE_PTES * PAGE_SIZE)
114 #define MI_ZERO_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \
117 /* Signature of free pool blocks */
118 #define MM_FREE_POOL_TAG 'lprF'
120 #define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
121 ((x) / (4*1024*1024))
123 #define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \
124 ((((x)) % (4*1024*1024)) / (4*1024))
126 #define NR_SECTION_PAGE_TABLES 1024
127 #define NR_SECTION_PAGE_ENTRIES 1024
129 #define TEB_BASE 0x7FFDE000
131 /* Although Microsoft says this isn't hardcoded anymore,
132 they won't be able to change it. Stuff depends on it */
133 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
135 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
138 * Additional flags for protection attributes
140 #define PAGE_WRITETHROUGH (1024)
141 #define PAGE_SYSTEM (2048)
143 #define SEC_PHYSICALMEMORY (0x80000000)
145 #define MM_PAGEFILE_SEGMENT (0x1)
146 #define MM_DATAFILE_SEGMENT (0x2)
151 #define MC_NPPOOL (3)
152 #define MC_SYSTEM (4)
153 #define MC_MAXIMUM (5)
155 #define PAGED_POOL_MASK 1
156 #define MUST_SUCCEED_POOL_MASK 2
157 #define CACHE_ALIGNED_POOL_MASK 4
158 #define QUOTA_POOL_MASK 8
159 #define SESSION_POOL_MASK 32
160 #define VERIFIER_POOL_MASK 64
162 #define MM_PAGED_POOL_SIZE (100*1024*1024)
163 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
166 * Paged and non-paged pools are 8-byte aligned
168 #define MM_POOL_ALIGNMENT 8
171 * Maximum size of the kmalloc area (this is totally arbitary)
173 #define MM_KERNEL_MAP_SIZE (16*1024*1024)
174 #define MM_KERNEL_MAP_BASE (0xf0c00000)
177 * FIXME - different architectures have different cache line sizes...
179 #define MM_CACHE_LINE_SIZE 32
181 #define MM_ROUND_UP(x,s) \
182 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
184 #define MM_ROUND_DOWN(x,s) \
185 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
187 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
192 PAGE_EXECUTE_READ | \
193 PAGE_EXECUTE_READWRITE | \
194 PAGE_EXECUTE_WRITECOPY | \
199 #define PAGE_FLAGS_VALID_FOR_SECTION \
204 PAGE_EXECUTE_READ | \
205 PAGE_EXECUTE_READWRITE | \
206 PAGE_EXECUTE_WRITECOPY | \
209 #define PAGE_IS_READABLE \
213 PAGE_EXECUTE_READ | \
214 PAGE_EXECUTE_READWRITE | \
215 PAGE_EXECUTE_WRITECOPY)
217 #define PAGE_IS_WRITABLE \
220 PAGE_EXECUTE_READWRITE | \
221 PAGE_EXECUTE_WRITECOPY)
223 #define PAGE_IS_EXECUTABLE \
225 PAGE_EXECUTE_READ | \
226 PAGE_EXECUTE_READWRITE | \
227 PAGE_EXECUTE_WRITECOPY)
229 #define PAGE_IS_WRITECOPY \
231 PAGE_EXECUTE_WRITECOPY)
234 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
235 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
237 #define InterlockedExchangePte(PointerPte, Value) \
238 InterlockedExchange((PLONG)(PointerPte), Value)
242 ULONG Entry
[NR_SECTION_PAGE_ENTRIES
];
243 } SECTION_PAGE_TABLE
, *PSECTION_PAGE_TABLE
;
247 PSECTION_PAGE_TABLE PageTables
[NR_SECTION_PAGE_TABLES
];
248 } SECTION_PAGE_DIRECTORY
, *PSECTION_PAGE_DIRECTORY
;
250 typedef struct _MM_SECTION_SEGMENT
252 LONG FileOffset
; /* start offset into the file for image sections */
253 ULONG_PTR VirtualAddress
; /* dtart offset into the address range for image sections */
254 ULONG RawLength
; /* length of the segment which is part of the mapped file */
255 ULONG Length
; /* absolute length of the segment */
257 FAST_MUTEX Lock
; /* lock which protects the page directory */
258 ULONG ReferenceCount
;
259 SECTION_PAGE_DIRECTORY PageDirectory
;
261 ULONG Characteristics
;
263 } MM_SECTION_SEGMENT
, *PMM_SECTION_SEGMENT
;
265 typedef struct _MM_IMAGE_SECTION_OBJECT
268 ULONG_PTR StackReserve
;
269 ULONG_PTR StackCommit
;
270 ULONG_PTR EntryPoint
;
272 USHORT ImageCharacteristics
;
273 USHORT MinorSubsystemVersion
;
274 USHORT MajorSubsystemVersion
;
279 PMM_SECTION_SEGMENT Segments
;
280 } MM_IMAGE_SECTION_OBJECT
, *PMM_IMAGE_SECTION_OBJECT
;
282 typedef struct _ROS_SECTION_OBJECT
286 LARGE_INTEGER MaximumSize
;
287 ULONG SectionPageProtection
;
288 ULONG AllocationAttributes
;
289 PFILE_OBJECT FileObject
;
292 PMM_IMAGE_SECTION_OBJECT ImageSection
;
293 PMM_SECTION_SEGMENT Segment
;
295 } ROS_SECTION_OBJECT
, *PROS_SECTION_OBJECT
;
297 typedef struct _MEMORY_AREA
299 PVOID StartingAddress
;
301 struct _MEMORY_AREA
*Parent
;
302 struct _MEMORY_AREA
*LeftChild
;
303 struct _MEMORY_AREA
*RightChild
;
307 BOOLEAN DeleteInProgress
;
313 ROS_SECTION_OBJECT
* Section
;
315 PMM_SECTION_SEGMENT Segment
;
316 BOOLEAN WriteCopyView
;
317 LIST_ENTRY RegionListHead
;
321 LIST_ENTRY RegionListHead
;
324 } MEMORY_AREA
, *PMEMORY_AREA
;
327 // These two mappings are actually used by Windows itself, based on the ASSERTS
329 #define StartOfAllocation ReadInProgress
330 #define EndOfAllocation WriteInProgress
332 typedef struct _MMPFNENTRY
335 USHORT ReadInProgress
:1; // StartOfAllocation
336 USHORT WriteInProgress
:1; // EndOfAllocation
337 USHORT PrototypePte
:1; // Zero
338 USHORT PageColor
:4; // LockCount
339 USHORT PageLocation
:3; // Consumer
340 USHORT RemovalRequested
:1;
341 USHORT CacheAttribute
:2; // Type
343 USHORT ParityError
:1;
346 typedef struct _MMPFN
350 PFN_NUMBER Flink
; // ListEntry.Flink
354 SINGLE_LIST_ENTRY NextStackPfn
;
356 PMMPTE PteAddress
; // ListEntry.Blink
360 ULONG_PTR ShareCount
; // MapCount
366 USHORT ReferenceCount
; // ReferenceCount
371 USHORT ReferenceCount
;
378 LONG AweReferenceCount
; // RmapListHead
382 ULONG_PTR EntireFrame
; // SavedSwapEntry
385 ULONG_PTR PteFrame
:25;
386 ULONG_PTR InPageError
:1;
387 ULONG_PTR VerifierAllocation
:1;
388 ULONG_PTR AweAllocation
:1;
389 ULONG_PTR Priority
:3;
390 ULONG_PTR MustBeCached
:1;
395 extern PMMPFN MmPfnDatabase
;
397 typedef struct _MMPFNLIST
403 } MMPFNLIST
, *PMMPFNLIST
;
405 extern MMPFNLIST MmZeroedPageListHead
;
406 extern MMPFNLIST MmFreePageListHead
;
407 extern MMPFNLIST MmStandbyPageListHead
;
408 extern MMPFNLIST MmModifiedPageListHead
;
409 extern MMPFNLIST MmModifiedNoWritePageListHead
;
411 typedef struct _MM_PAGEOP
413 /* Type of operation. */
415 /* Number of threads interested in this operation. */
416 ULONG ReferenceCount
;
417 /* Event that will be set when the operation is completed. */
418 KEVENT CompletionEvent
;
419 /* Status of the operation once it is completed. */
421 /* TRUE if the operation was abandoned. */
423 /* The memory area to be affected by the operation. */
426 struct _MM_PAGEOP
* Next
;
427 struct _ETHREAD
* Thread
;
429 * These fields are used to identify the operation if it is against a
430 * virtual memory area.
435 * These fields are used to identify the operation if it is against a
438 PMM_SECTION_SEGMENT Segment
;
440 } MM_PAGEOP
, *PMM_PAGEOP
;
442 typedef struct _MM_MEMORY_CONSUMER
446 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
);
447 } MM_MEMORY_CONSUMER
, *PMM_MEMORY_CONSUMER
;
449 typedef struct _MM_REGION
454 LIST_ENTRY RegionListEntry
;
455 } MM_REGION
, *PMM_REGION
;
457 /* Entry describing free pool memory */
458 typedef struct _MMFREE_POOL_ENTRY
463 struct _MMFREE_POOL_ENTRY
*Owner
;
464 } MMFREE_POOL_ENTRY
, *PMMFREE_POOL_ENTRY
;
466 /* Paged pool information */
467 typedef struct _MM_PAGED_POOL_INFO
469 PRTL_BITMAP PagedPoolAllocationMap
;
470 PRTL_BITMAP EndOfPagedPoolBitmap
;
471 PMMPTE FirstPteForPagedPool
;
472 PMMPTE LastPteForPagedPool
;
473 PMMPTE NextPdeForPagedPoolExpansion
;
475 SIZE_T PagedPoolCommit
;
476 SIZE_T AllocatedPagedPool
;
477 } MM_PAGED_POOL_INFO
, *PMM_PAGED_POOL_INFO
;
479 extern MM_MEMORY_CONSUMER MiMemoryConsumers
[MC_MAXIMUM
];
482 (*PMM_ALTER_REGION_FUNC
)(
483 PMMSUPPORT AddressSpace
,
493 (*PMM_FREE_PAGE_FUNC
)(
495 PMEMORY_AREA MemoryArea
,
503 // Mm copy support for Kd
514 /* marea.c *******************************************************************/
519 PMMSUPPORT AddressSpace
,
524 PMEMORY_AREA
*Result
,
525 BOOLEAN FixedAddress
,
526 ULONG AllocationFlags
,
527 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
532 MmLocateMemoryAreaByAddress(
533 PMMSUPPORT AddressSpace
,
540 PMMSUPPORT AddressSpace
,
547 PMMSUPPORT AddressSpace
,
548 PMEMORY_AREA MemoryArea
,
549 PMM_FREE_PAGE_FUNC FreePage
,
550 PVOID FreePageContext
555 MmFreeMemoryAreaByPtr(
556 PMMSUPPORT AddressSpace
,
558 PMM_FREE_PAGE_FUNC FreePage
,
559 PVOID FreePageContext
564 MmDumpMemoryAreas(PMMSUPPORT AddressSpace
);
568 MmLocateMemoryAreaByRegion(
569 PMMSUPPORT AddressSpace
,
577 PMMSUPPORT AddressSpace
,
579 ULONG_PTR Granularity
,
585 MmReleaseMemoryAreaIfDecommitted(
586 struct _EPROCESS
*Process
,
587 PMMSUPPORT AddressSpace
,
593 MmMapMemoryArea(PVOID BaseAddress
,
598 /* npool.c *******************************************************************/
602 MiDebugDumpNonPagedPool(BOOLEAN NewOnly
);
606 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly
);
610 MiInitializeNonPagedPool(VOID
);
615 IN POOL_TYPE PoolType
,
616 IN SIZE_T SizeInBytes
622 IN PVOID VirtualAddress
628 IN PVOID StartingAddress
638 /* pool.c *******************************************************************/
642 ExAllocateNonPagedPoolWithTag(
651 ExAllocatePagedPoolWithTag(
659 ExFreeNonPagedPool(PVOID block
);
663 ExFreePagedPool(IN PVOID Block
);
667 ExpIsPoolTagDebuggable(ULONG Tag
);
671 ExpAllocateDebugPool(
681 ExpFreeDebugPool(PVOID Block
, BOOLEAN PagedPool
);
685 MmInitializePagedPool(VOID
);
689 MiAllocateSpecialPool(
690 IN POOL_TYPE PoolType
,
691 IN SIZE_T NumberOfBytes
,
699 IN POOL_TYPE PoolType
,
700 IN ULONG CurrentMaxQuota
,
701 OUT PULONG NewMaxQuota
704 /* mdl.c *********************************************************************/
713 /* mminit.c ******************************************************************/
717 MiShutdownMemoryManager(VOID
);
727 MmInitSystem(IN ULONG Phase
,
728 IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
732 MiFreeInitMemory(VOID
);
736 MmInitializeMdlImplementation(VOID
);
738 /* pagefile.c ****************************************************************/
742 MmAllocSwapPage(VOID
);
746 MmDereserveSwapPages(ULONG Nr
);
750 MmFreeSwapPage(SWAPENTRY Entry
);
754 MmInitPagingFile(VOID
);
765 MmReserveSwapPages(ULONG Nr
);
778 ULONG BugCodeParameter1
,
779 ULONG BugCodeParameter2
,
780 ULONG BugCodeParameter3
,
781 ULONG BugCodeParameter4
,
782 struct _KTRAP_FRAME
* TrapFrame
787 MmIsAvailableSwapPage(VOID
);
791 MmShowOutOfSpaceMessagePagingFile(VOID
);
793 /* process.c ****************************************************************/
797 MmInitializeProcessAddressSpace(
798 IN PEPROCESS Process
,
799 IN PEPROCESS Clone OPTIONAL
,
800 IN PVOID Section OPTIONAL
,
802 IN POBJECT_NAME_INFORMATION
*AuditName OPTIONAL
808 IN PEPROCESS Process
,
809 IN PINITIAL_PEB InitialPeb
,
816 IN PEPROCESS Process
,
817 IN PCLIENT_ID ClientId
,
818 IN PINITIAL_TEB InitialTeb
,
825 struct _EPROCESS
*Process
,
831 MmCleanProcessAddressSpace(IN PEPROCESS Process
);
835 MmDeleteProcessAddressSpace(IN PEPROCESS Process
);
839 MmGetSessionLocaleId(VOID
);
843 MmSetMemoryPriorityProcess(
844 IN PEPROCESS Process
,
845 IN UCHAR MemoryPriority
848 /* i386/pfault.c *************************************************************/
860 /* mm.c **********************************************************************/
865 IN BOOLEAN StoreInstruction
,
867 IN KPROCESSOR_MODE Mode
,
868 IN PVOID TrapInformation
871 /* anonmem.c *****************************************************************/
875 MmNotPresentFaultVirtualMemory(
876 PMMSUPPORT AddressSpace
,
877 MEMORY_AREA
* MemoryArea
,
884 MmPageOutVirtualMemory(
885 PMMSUPPORT AddressSpace
,
886 PMEMORY_AREA MemoryArea
,
888 struct _MM_PAGEOP
* PageOp
894 PMEMORY_AREA MemoryArea
,
896 PMEMORY_BASIC_INFORMATION Info
,
903 struct _EPROCESS
* Process
,
904 PMEMORY_AREA MemoryArea
910 PMMSUPPORT AddressSpace
,
911 PMEMORY_AREA MemoryArea
,
920 MmWritePageVirtualMemory(
921 PMMSUPPORT AddressSpace
,
927 /* kmap.c ********************************************************************/
931 ExAllocatePage(VOID
);
935 ExUnmapPage(PVOID Addr
);
939 ExAllocatePageWithPhysPage(PFN_TYPE Page
);
950 MiZeroPage(PFN_TYPE Page
);
952 /* memsafe.s *****************************************************************/
956 MmSafeReadPtr(PVOID Source
);
958 /* pageop.c ******************************************************************/
962 MmReleasePageOp(PMM_PAGEOP PageOp
);
970 PMM_SECTION_SEGMENT Segment
,
982 PMM_SECTION_SEGMENT Segment
,
988 MmInitializePageOp(VOID
);
990 /* process.c *****************************************************************/
994 MmCreateKernelStack(BOOLEAN GuiStack
, UCHAR Node
);
998 MmDeleteKernelStack(PVOID Stack
,
1001 /* balace.c ******************************************************************/
1005 MmInitializeMemoryConsumer(
1007 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
)
1012 MmInitializeBalancer(
1013 ULONG NrAvailablePages
,
1019 MmReleasePageMemoryConsumer(
1026 MmRequestPageMemoryConsumer(
1029 PPFN_TYPE AllocatedPage
1034 MiInitBalancerThread(VOID
);
1038 MmRebalanceMemoryConsumers(VOID
);
1040 /* rmap.c **************************************************************/
1044 MmSetRmapListHeadPage(
1046 struct _MM_RMAP_ENTRY
* ListHead
1049 struct _MM_RMAP_ENTRY
*
1051 MmGetRmapListHeadPage(PFN_TYPE Page
);
1057 struct _EPROCESS
*Process
,
1066 VOID (*DeleteMapping
)(PVOID Context
, struct _EPROCESS
*Process
, PVOID Address
)
1073 struct _EPROCESS
*Process
,
1079 MmInitializeRmapList(VOID
);
1083 MmSetCleanAllRmaps(PFN_TYPE Page
);
1087 MmSetDirtyAllRmaps(PFN_TYPE Page
);
1091 MmIsDirtyPageRmap(PFN_TYPE Page
);
1095 MmWritePagePhysicalAddress(PFN_TYPE Page
);
1099 MmPageOutPhysicalAddress(PFN_TYPE Page
);
1101 /* freelist.c **********************************************************/
1103 #define ASSERT_PFN(x) ASSERT((x)->u3.e1.CacheAttribute != 0)
1107 MiGetPfnEntry(IN PFN_TYPE Pfn
)
1110 extern RTL_BITMAP MiPfnBitMap
;
1112 /* Make sure the PFN number is valid */
1113 if (Pfn
> MmHighestPhysicalPage
) return NULL
;
1115 /* Make sure this page actually has a PFN entry */
1116 if ((MiPfnBitMap
.Buffer
) && !(RtlTestBit(&MiPfnBitMap
, Pfn
))) return NULL
;
1119 Page
= &MmPfnDatabase
[Pfn
];
1121 /* Make sure it's valid */
1130 MiGetPfnEntryIndex(IN PMMPFN Pfn1
)
1133 // This will return the Page Frame Number (PFN) from the MMPFN
1135 return Pfn1
- MmPfnDatabase
;
1140 MmGetLRUNextUserPage(PFN_TYPE PreviousPage
);
1144 MmGetLRUFirstUserPage(VOID
);
1148 MmInsertLRULastUserPage(PFN_TYPE Page
);
1152 MmRemoveLRUUserPage(PFN_TYPE Page
);
1156 MmLockPage(PFN_TYPE Page
);
1160 MmUnlockPage(PFN_TYPE Page
);
1164 MmGetLockCountPage(PFN_TYPE Page
);
1168 MmInitializePageList(
1180 MmGetContinuousPages(
1181 ULONG NumberOfBytes
,
1182 PHYSICAL_ADDRESS LowestAcceptableAddress
,
1183 PHYSICAL_ADDRESS HighestAcceptableAddress
,
1184 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1190 MmZeroPageThreadMain(
1194 /* hypermap.c *****************************************************************/
1196 extern PEPROCESS HyperProcess
;
1197 extern KIRQL HyperIrql
;
1201 MiMapPageInHyperSpace(IN PEPROCESS Process
,
1207 MiUnmapPageInHyperSpace(IN PEPROCESS Process
,
1213 MiMapPagesToZeroInHyperSpace(IN PMMPFN
*Pages
,
1214 IN PFN_NUMBER NumberOfPages
);
1218 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress
,
1219 IN PFN_NUMBER NumberOfPages
);
1222 // ReactOS Compatibility Layer
1226 MmCreateHyperspaceMapping(IN PFN_NUMBER Page
)
1228 HyperProcess
= (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;
1229 return MiMapPageInHyperSpace(HyperProcess
, Page
, &HyperIrql
);
1234 MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page
)
1236 PMMPFN Pfn1
= MiGetPfnEntry(Page
);
1237 return MiMapPagesToZeroInHyperSpace(&Pfn1
, 1);
1240 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1242 /* i386/page.c *********************************************************/
1246 MmCreateVirtualMappingForKernel(
1255 MmCommitPagedPoolAddress(
1262 MmCreateVirtualMapping(
1263 struct _EPROCESS
* Process
,
1272 MmCreateVirtualMappingUnsafe(
1273 struct _EPROCESS
* Process
,
1283 struct _EPROCESS
* Process
,
1289 struct _EPROCESS
* Process
,
1297 struct _EPROCESS
* Process
,
1303 MmInitGlobalKernelPageDirectory(VOID
);
1307 MmDisableVirtualMapping(
1308 struct _EPROCESS
*Process
,
1316 MmEnableVirtualMapping(
1317 struct _EPROCESS
*Process
,
1323 MmRawDeleteVirtualMapping(PVOID Address
);
1327 MmDeletePageFileMapping(
1328 struct _EPROCESS
*Process
,
1330 SWAPENTRY
* SwapEntry
1335 MmCreatePageFileMapping(
1336 struct _EPROCESS
*Process
,
1344 struct _EPROCESS
*Process
,
1350 MmTransferOwnershipPage(
1358 struct _EPROCESS
*Process
,
1366 SWAPENTRY SavedSwapEntry
1371 MmAllocPagesSpecifyRange(
1373 PHYSICAL_ADDRESS LowestAddress
,
1374 PHYSICAL_ADDRESS HighestAddress
,
1375 ULONG NumberOfPages
,
1381 MmDereferencePage(PFN_TYPE Page
);
1385 MmReferencePage(PFN_TYPE Page
);
1389 MmGetReferenceCountPage(PFN_TYPE Page
);
1393 MmIsPageInUse(PFN_TYPE Page
);
1397 MmSetSavedSwapEntryPage(
1399 SWAPENTRY SavedSwapEntry
);
1403 MmGetSavedSwapEntryPage(PFN_TYPE Page
);
1408 struct _EPROCESS
*Process
,
1414 MmCreatePageTable(PVOID PAddress
);
1419 struct _EPROCESS
*Process
,
1426 struct _EPROCESS
*Process
,
1432 MmCreateProcessAddressSpace(
1435 IN PULONG DirectoryTableBase
1440 MmInitializeHandBuiltProcess(
1441 IN PEPROCESS Process
,
1442 IN PULONG DirectoryTableBase
1448 MmInitializeHandBuiltProcess2(
1449 IN PEPROCESS Process
1454 MmReleaseMmInfo(struct _EPROCESS
*Process
);
1458 Mmi386ReleaseMmInfo(struct _EPROCESS
*Process
);
1462 MmDeleteVirtualMapping(
1463 struct _EPROCESS
*Process
,
1473 struct _EPROCESS
*Process
,
1479 MmMarkPageMapped(PFN_TYPE Page
);
1483 MmMarkPageUnmapped(PFN_TYPE Page
);
1488 struct _EPROCESS
*Process
,
1495 MiInitPageDirectoryMap(VOID
);
1499 MiGetUserPageDirectoryCount(VOID
);
1501 /* wset.c ********************************************************************/
1510 /* region.c ************************************************************/
1515 PMMSUPPORT AddressSpace
,
1517 PLIST_ENTRY RegionListHead
,
1522 PMM_ALTER_REGION_FUNC AlterFunc
1528 PLIST_ENTRY RegionListHead
,
1538 PLIST_ENTRY RegionListHead
,
1540 PVOID
* RegionBaseAddress
1543 /* section.c *****************************************************************/
1547 MmGetFileObjectForSection(
1548 IN PROS_SECTION_OBJECT Section
1552 MmGetFileNameForAddress(
1554 OUT PUNICODE_STRING ModuleName
1559 MmGetFileNameForSection(
1560 IN PROS_SECTION_OBJECT Section
,
1561 OUT POBJECT_NAME_INFORMATION
*ModuleName
1574 PMEMORY_AREA MemoryArea
,
1576 PMEMORY_BASIC_INFORMATION Info
,
1582 MmProtectSectionView(
1583 PMMSUPPORT AddressSpace
,
1584 PMEMORY_AREA MemoryArea
,
1593 MmWritePageSectionView(
1594 PMMSUPPORT AddressSpace
,
1602 MmInitSectionImplementation(VOID
);
1606 MmNotPresentFaultSectionView(
1607 PMMSUPPORT AddressSpace
,
1608 MEMORY_AREA
* MemoryArea
,
1615 MmPageOutSectionView(
1616 PMMSUPPORT AddressSpace
,
1617 PMEMORY_AREA MemoryArea
,
1619 struct _MM_PAGEOP
*PageOp
1624 MmCreatePhysicalMemorySection(VOID
);
1628 MmAccessFaultSectionView(
1629 PMMSUPPORT AddressSpace
,
1630 MEMORY_AREA
* MemoryArea
,
1637 MmFreeSectionSegments(PFILE_OBJECT FileObject
);
1639 /* mpw.c *********************************************************************/
1643 MmInitMpwThread(VOID
);
1647 MmInitBsmThread(VOID
);
1649 /* pager.c *******************************************************************/
1653 MiIsPagerThread(VOID
);
1657 MiStartPagerThread(VOID
);
1661 MiStopPagerThread(VOID
);
1665 MiQueryVirtualMemory(
1666 IN HANDLE ProcessHandle
,
1668 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass
,
1669 OUT PVOID VirtualMemoryInformation
,
1671 OUT PULONG ResultLength
1674 /* sysldr.c ******************************************************************/
1678 MiReloadBootLoadedDrivers(
1679 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1684 MiInitializeLoadedModuleList(
1685 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1691 IN PUNICODE_STRING FileName
,
1692 IN PUNICODE_STRING NamePrefix OPTIONAL
,
1693 IN PUNICODE_STRING LoadedName OPTIONAL
,
1695 OUT PVOID
*ModuleObject
,
1696 OUT PVOID
*ImageBaseAddress
1701 MmUnloadSystemImage(
1702 IN PVOID ImageHandle
1708 IN HANDLE ImageHandle
,
1709 IN BOOLEAN PurgeSection
1714 MmCallDllInitialize(
1715 IN PLDR_DATA_TABLE_ENTRY LdrEntry
,
1716 IN PLIST_ENTRY ListHead
1719 /* ReactOS Mm Hacks */
1722 MiSyncForProcessAttach(
1723 IN PKTHREAD NextThread
,
1724 IN PEPROCESS Process
1729 MiSyncForContextSwitch(
1733 extern PMMSUPPORT MmKernelAddressSpace
;
1737 MmLockAddressSpace(PMMSUPPORT AddressSpace
)
1739 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1744 MmUnlockAddressSpace(PMMSUPPORT AddressSpace
)
1746 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1751 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace
)
1753 if (AddressSpace
== MmKernelAddressSpace
) return NULL
;
1754 return CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
);
1759 MmGetCurrentAddressSpace(VOID
)
1761 return &((PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
)->Vm
;
1766 MmGetKernelAddressSpace(VOID
)
1768 return MmKernelAddressSpace
;