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
;
22 extern PVOID MmPagedPoolBase
;
23 extern ULONG MmPagedPoolSize
;
25 extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor
;
26 extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg
;
30 struct _MM_RMAP_ENTRY
;
32 typedef ULONG SWAPENTRY
;
33 typedef ULONG PFN_TYPE
, *PPFN_TYPE
;
36 //MmDbgCopyMemory Flags
38 #define MMDBG_COPY_WRITE 0x00000001
39 #define MMDBG_COPY_PHYSICAL 0x00000002
40 #define MMDBG_COPY_UNSAFE 0x00000004
41 #define MMDBG_COPY_CACHED 0x00000008
42 #define MMDBG_COPY_UNCACHED 0x00000010
43 #define MMDBG_COPY_WRITE_COMBINED 0x00000020
46 // Maximum chunk size per copy
48 #define MMDBG_COPY_MAX_SIZE 0x8
51 #define MI_STATIC_MEMORY_AREAS (12)
53 #define MEMORY_AREA_INVALID (0)
54 #define MEMORY_AREA_SECTION_VIEW (1)
55 #define MEMORY_AREA_CONTINUOUS_MEMORY (2)
56 #define MEMORY_AREA_NO_CACHE (3)
57 #define MEMORY_AREA_IO_MAPPING (4)
58 #define MEMORY_AREA_SYSTEM (5)
59 #define MEMORY_AREA_MDL_MAPPING (7)
60 #define MEMORY_AREA_VIRTUAL_MEMORY (8)
61 #define MEMORY_AREA_CACHE_SEGMENT (9)
62 #define MEMORY_AREA_SHARED_DATA (10)
63 #define MEMORY_AREA_KERNEL_STACK (11)
64 #define MEMORY_AREA_PAGED_POOL (12)
65 #define MEMORY_AREA_NO_ACCESS (13)
66 #define MEMORY_AREA_PEB_OR_TEB (14)
67 #define MEMORY_AREA_OWNED_BY_ARM3 (15)
68 #define MEMORY_AREA_STATIC (0x80000000)
70 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
72 #define MM_CORE_DUMP_TYPE_NONE (0x0)
73 #define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
74 #define MM_CORE_DUMP_TYPE_FULL (0x2)
76 #define MM_PAGEOP_PAGEIN (1)
77 #define MM_PAGEOP_PAGEOUT (2)
78 #define MM_PAGEOP_PAGESYNCH (3)
79 #define MM_PAGEOP_ACCESSFAULT (4)
81 /* Number of list heads to use */
82 #define MI_FREE_POOL_LISTS 4
84 #define MI_HYPERSPACE_PTES (256 - 1)
85 #define MI_ZERO_PTES (32)
86 #define MI_MAPPING_RANGE_START (ULONG)HYPER_SPACE
87 #define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \
88 MI_HYPERSPACE_PTES * PAGE_SIZE)
89 #define MI_ZERO_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \
92 /* Signature of free pool blocks */
93 #define MM_FREE_POOL_TAG 'lprF'
95 #define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
98 #define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \
99 ((((x)) % (4*1024*1024)) / (4*1024))
101 #define NR_SECTION_PAGE_TABLES 1024
102 #define NR_SECTION_PAGE_ENTRIES 1024
104 #define TEB_BASE 0x7FFDE000
106 /* Although Microsoft says this isn't hardcoded anymore,
107 they won't be able to change it. Stuff depends on it */
108 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
110 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
113 * Additional flags for protection attributes
115 #define PAGE_WRITETHROUGH (1024)
116 #define PAGE_SYSTEM (2048)
118 #define SEC_PHYSICALMEMORY (0x80000000)
120 #define MM_PAGEFILE_SEGMENT (0x1)
121 #define MM_DATAFILE_SEGMENT (0x2)
126 #define MC_NPPOOL (3)
127 #define MC_SYSTEM (4)
128 #define MC_MAXIMUM (5)
130 #define PAGED_POOL_MASK 1
131 #define MUST_SUCCEED_POOL_MASK 2
132 #define CACHE_ALIGNED_POOL_MASK 4
133 #define QUOTA_POOL_MASK 8
134 #define SESSION_POOL_MASK 32
135 #define VERIFIER_POOL_MASK 64
137 #define MM_PAGED_POOL_SIZE (100*1024*1024)
138 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
141 * Paged and non-paged pools are 8-byte aligned
143 #define MM_POOL_ALIGNMENT 8
146 * Maximum size of the kmalloc area (this is totally arbitary)
148 #define MM_KERNEL_MAP_SIZE (16*1024*1024)
149 #define MM_KERNEL_MAP_BASE (0xf0c00000)
152 * FIXME - different architectures have different cache line sizes...
154 #define MM_CACHE_LINE_SIZE 32
156 #define MM_ROUND_UP(x,s) \
157 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
159 #define MM_ROUND_DOWN(x,s) \
160 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
162 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
167 PAGE_EXECUTE_READ | \
168 PAGE_EXECUTE_READWRITE | \
169 PAGE_EXECUTE_WRITECOPY | \
174 #define PAGE_FLAGS_VALID_FOR_SECTION \
179 PAGE_EXECUTE_READ | \
180 PAGE_EXECUTE_READWRITE | \
181 PAGE_EXECUTE_WRITECOPY | \
184 #define PAGE_IS_READABLE \
188 PAGE_EXECUTE_READ | \
189 PAGE_EXECUTE_READWRITE | \
190 PAGE_EXECUTE_WRITECOPY)
192 #define PAGE_IS_WRITABLE \
195 PAGE_EXECUTE_READWRITE | \
196 PAGE_EXECUTE_WRITECOPY)
198 #define PAGE_IS_EXECUTABLE \
200 PAGE_EXECUTE_READ | \
201 PAGE_EXECUTE_READWRITE | \
202 PAGE_EXECUTE_WRITECOPY)
204 #define PAGE_IS_WRITECOPY \
206 PAGE_EXECUTE_WRITECOPY)
209 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
210 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
212 #define InterlockedExchangePte(PointerPte, Value) \
213 InterlockedExchange((PLONG)(PointerPte), Value)
217 ULONG Entry
[NR_SECTION_PAGE_ENTRIES
];
218 } SECTION_PAGE_TABLE
, *PSECTION_PAGE_TABLE
;
222 PSECTION_PAGE_TABLE PageTables
[NR_SECTION_PAGE_TABLES
];
223 } SECTION_PAGE_DIRECTORY
, *PSECTION_PAGE_DIRECTORY
;
225 typedef struct _MM_SECTION_SEGMENT
227 LONG FileOffset
; /* start offset into the file for image sections */
228 ULONG_PTR VirtualAddress
; /* dtart offset into the address range for image sections */
229 ULONG RawLength
; /* length of the segment which is part of the mapped file */
230 ULONG Length
; /* absolute length of the segment */
232 FAST_MUTEX Lock
; /* lock which protects the page directory */
233 ULONG ReferenceCount
;
234 SECTION_PAGE_DIRECTORY PageDirectory
;
236 ULONG Characteristics
;
238 } MM_SECTION_SEGMENT
, *PMM_SECTION_SEGMENT
;
240 typedef struct _MM_IMAGE_SECTION_OBJECT
243 ULONG_PTR StackReserve
;
244 ULONG_PTR StackCommit
;
245 ULONG_PTR EntryPoint
;
247 USHORT ImageCharacteristics
;
248 USHORT MinorSubsystemVersion
;
249 USHORT MajorSubsystemVersion
;
254 PMM_SECTION_SEGMENT Segments
;
255 } MM_IMAGE_SECTION_OBJECT
, *PMM_IMAGE_SECTION_OBJECT
;
257 typedef struct _ROS_SECTION_OBJECT
261 LARGE_INTEGER MaximumSize
;
262 ULONG SectionPageProtection
;
263 ULONG AllocationAttributes
;
264 PFILE_OBJECT FileObject
;
267 PMM_IMAGE_SECTION_OBJECT ImageSection
;
268 PMM_SECTION_SEGMENT Segment
;
270 } ROS_SECTION_OBJECT
, *PROS_SECTION_OBJECT
;
272 typedef struct _MEMORY_AREA
274 PVOID StartingAddress
;
276 struct _MEMORY_AREA
*Parent
;
277 struct _MEMORY_AREA
*LeftChild
;
278 struct _MEMORY_AREA
*RightChild
;
282 BOOLEAN DeleteInProgress
;
288 ROS_SECTION_OBJECT
* Section
;
290 PMM_SECTION_SEGMENT Segment
;
291 BOOLEAN WriteCopyView
;
292 LIST_ENTRY RegionListHead
;
296 LIST_ENTRY RegionListHead
;
299 } MEMORY_AREA
, *PMEMORY_AREA
;
302 // These two mappings are actually used by Windows itself, based on the ASSERTS
304 #define StartOfAllocation ReadInProgress
305 #define EndOfAllocation WriteInProgress
307 typedef struct _MMPFNENTRY
310 USHORT ReadInProgress
:1; // StartOfAllocation
311 USHORT WriteInProgress
:1; // EndOfAllocation
312 USHORT PrototypePte
:1; // Zero
313 USHORT PageColor
:4; // LockCount
314 USHORT PageLocation
:3; // Consumer
315 USHORT RemovalRequested
:1;
316 USHORT CacheAttribute
:2; // Type
318 USHORT ParityError
:1;
321 typedef struct _MMPFN
325 PFN_NUMBER Flink
; // ListEntry.Flink
329 SINGLE_LIST_ENTRY NextStackPfn
;
331 PMMPTE PteAddress
; // ListEntry.Blink
335 ULONG_PTR ShareCount
; // MapCount
341 USHORT ReferenceCount
; // ReferenceCount
346 USHORT ReferenceCount
;
353 LONG AweReferenceCount
; // RmapListHead
357 ULONG_PTR EntireFrame
; // SavedSwapEntry
360 ULONG_PTR PteFrame
:25;
361 ULONG_PTR InPageError
:1;
362 ULONG_PTR VerifierAllocation
:1;
363 ULONG_PTR AweAllocation
:1;
364 ULONG_PTR Priority
:3;
365 ULONG_PTR MustBeCached
:1;
370 extern PMMPFN MmPfnDatabase
;
372 typedef struct _MM_PAGEOP
374 /* Type of operation. */
376 /* Number of threads interested in this operation. */
377 ULONG ReferenceCount
;
378 /* Event that will be set when the operation is completed. */
379 KEVENT CompletionEvent
;
380 /* Status of the operation once it is completed. */
382 /* TRUE if the operation was abandoned. */
384 /* The memory area to be affected by the operation. */
387 struct _MM_PAGEOP
* Next
;
388 struct _ETHREAD
* Thread
;
390 * These fields are used to identify the operation if it is against a
391 * virtual memory area.
396 * These fields are used to identify the operation if it is against a
399 PMM_SECTION_SEGMENT Segment
;
401 } MM_PAGEOP
, *PMM_PAGEOP
;
403 typedef struct _MM_MEMORY_CONSUMER
407 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
);
408 } MM_MEMORY_CONSUMER
, *PMM_MEMORY_CONSUMER
;
410 typedef struct _MM_REGION
415 LIST_ENTRY RegionListEntry
;
416 } MM_REGION
, *PMM_REGION
;
418 /* Entry describing free pool memory */
419 typedef struct _MMFREE_POOL_ENTRY
424 struct _MMFREE_POOL_ENTRY
*Owner
;
425 } MMFREE_POOL_ENTRY
, *PMMFREE_POOL_ENTRY
;
427 /* Paged pool information */
428 typedef struct _MM_PAGED_POOL_INFO
430 PRTL_BITMAP PagedPoolAllocationMap
;
431 PRTL_BITMAP EndOfPagedPoolBitmap
;
432 PMMPTE FirstPteForPagedPool
;
433 PMMPTE LastPteForPagedPool
;
434 PMMPTE NextPdeForPagedPoolExpansion
;
436 SIZE_T PagedPoolCommit
;
437 SIZE_T AllocatedPagedPool
;
438 } MM_PAGED_POOL_INFO
, *PMM_PAGED_POOL_INFO
;
440 extern MM_MEMORY_CONSUMER MiMemoryConsumers
[MC_MAXIMUM
];
443 (*PMM_ALTER_REGION_FUNC
)(
444 PMMSUPPORT AddressSpace
,
454 (*PMM_FREE_PAGE_FUNC
)(
456 PMEMORY_AREA MemoryArea
,
464 // Mm copy support for Kd
475 /* marea.c *******************************************************************/
480 PMMSUPPORT AddressSpace
,
485 PMEMORY_AREA
*Result
,
486 BOOLEAN FixedAddress
,
487 ULONG AllocationFlags
,
488 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
493 MmLocateMemoryAreaByAddress(
494 PMMSUPPORT AddressSpace
,
501 PMMSUPPORT AddressSpace
,
508 PMMSUPPORT AddressSpace
,
509 PMEMORY_AREA MemoryArea
,
510 PMM_FREE_PAGE_FUNC FreePage
,
511 PVOID FreePageContext
516 MmFreeMemoryAreaByPtr(
517 PMMSUPPORT AddressSpace
,
519 PMM_FREE_PAGE_FUNC FreePage
,
520 PVOID FreePageContext
525 MmDumpMemoryAreas(PMMSUPPORT AddressSpace
);
529 MmLocateMemoryAreaByRegion(
530 PMMSUPPORT AddressSpace
,
538 PMMSUPPORT AddressSpace
,
540 ULONG_PTR Granularity
,
546 MmReleaseMemoryAreaIfDecommitted(
547 struct _EPROCESS
*Process
,
548 PMMSUPPORT AddressSpace
,
554 MmMapMemoryArea(PVOID BaseAddress
,
559 /* npool.c *******************************************************************/
563 MiDebugDumpNonPagedPool(BOOLEAN NewOnly
);
567 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly
);
571 MiInitializeNonPagedPool(VOID
);
576 IN POOL_TYPE PoolType
,
577 IN SIZE_T SizeInBytes
583 IN PVOID VirtualAddress
589 IN PVOID StartingAddress
599 /* pool.c *******************************************************************/
603 ExAllocateNonPagedPoolWithTag(
612 ExAllocatePagedPoolWithTag(
620 ExFreeNonPagedPool(PVOID block
);
624 ExFreePagedPool(IN PVOID Block
);
628 ExpIsPoolTagDebuggable(ULONG Tag
);
632 ExpAllocateDebugPool(
642 ExpFreeDebugPool(PVOID Block
, BOOLEAN PagedPool
);
646 MmInitializePagedPool(VOID
);
650 MiAllocateSpecialPool(
651 IN POOL_TYPE PoolType
,
652 IN SIZE_T NumberOfBytes
,
660 IN POOL_TYPE PoolType
,
661 IN ULONG CurrentMaxQuota
,
662 OUT PULONG NewMaxQuota
665 /* mdl.c *********************************************************************/
674 /* mminit.c ******************************************************************/
678 MiShutdownMemoryManager(VOID
);
688 MmInitSystem(IN ULONG Phase
,
689 IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
693 MiFreeInitMemory(VOID
);
697 MmInitializeMdlImplementation(VOID
);
699 /* pagefile.c ****************************************************************/
703 MmAllocSwapPage(VOID
);
707 MmDereserveSwapPages(ULONG Nr
);
711 MmFreeSwapPage(SWAPENTRY Entry
);
715 MmInitPagingFile(VOID
);
726 MmReserveSwapPages(ULONG Nr
);
739 ULONG BugCodeParameter1
,
740 ULONG BugCodeParameter2
,
741 ULONG BugCodeParameter3
,
742 ULONG BugCodeParameter4
,
743 struct _KTRAP_FRAME
* TrapFrame
748 MmIsAvailableSwapPage(VOID
);
752 MmShowOutOfSpaceMessagePagingFile(VOID
);
754 /* process.c ****************************************************************/
758 MmInitializeProcessAddressSpace(
759 IN PEPROCESS Process
,
760 IN PEPROCESS Clone OPTIONAL
,
761 IN PVOID Section OPTIONAL
,
763 IN POBJECT_NAME_INFORMATION
*AuditName OPTIONAL
769 IN PEPROCESS Process
,
770 IN PINITIAL_PEB InitialPeb
,
777 IN PEPROCESS Process
,
778 IN PCLIENT_ID ClientId
,
779 IN PINITIAL_TEB InitialTeb
,
786 struct _EPROCESS
*Process
,
792 MmCleanProcessAddressSpace(IN PEPROCESS Process
);
796 MmDeleteProcessAddressSpace(IN PEPROCESS Process
);
800 MmGetSessionLocaleId(VOID
);
804 MmSetMemoryPriorityProcess(
805 IN PEPROCESS Process
,
806 IN UCHAR MemoryPriority
809 /* i386/pfault.c *************************************************************/
821 /* mm.c **********************************************************************/
826 IN BOOLEAN StoreInstruction
,
828 IN KPROCESSOR_MODE Mode
,
829 IN PVOID TrapInformation
832 /* anonmem.c *****************************************************************/
836 MmNotPresentFaultVirtualMemory(
837 PMMSUPPORT AddressSpace
,
838 MEMORY_AREA
* MemoryArea
,
845 MmPageOutVirtualMemory(
846 PMMSUPPORT AddressSpace
,
847 PMEMORY_AREA MemoryArea
,
849 struct _MM_PAGEOP
* PageOp
855 PMEMORY_AREA MemoryArea
,
857 PMEMORY_BASIC_INFORMATION Info
,
864 struct _EPROCESS
* Process
,
865 PMEMORY_AREA MemoryArea
871 PMMSUPPORT AddressSpace
,
872 PMEMORY_AREA MemoryArea
,
881 MmWritePageVirtualMemory(
882 PMMSUPPORT AddressSpace
,
888 /* kmap.c ********************************************************************/
892 ExAllocatePage(VOID
);
896 ExUnmapPage(PVOID Addr
);
900 ExAllocatePageWithPhysPage(PFN_TYPE Page
);
911 MiZeroPage(PFN_TYPE Page
);
913 /* memsafe.s *****************************************************************/
917 MmSafeReadPtr(PVOID Source
);
919 /* pageop.c ******************************************************************/
923 MmReleasePageOp(PMM_PAGEOP PageOp
);
931 PMM_SECTION_SEGMENT Segment
,
943 PMM_SECTION_SEGMENT Segment
,
949 MmInitializePageOp(VOID
);
951 /* process.c *****************************************************************/
955 MmCreateKernelStack(BOOLEAN GuiStack
, UCHAR Node
);
959 MmDeleteKernelStack(PVOID Stack
,
962 /* balace.c ******************************************************************/
966 MmInitializeMemoryConsumer(
968 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
)
973 MmInitializeBalancer(
974 ULONG NrAvailablePages
,
980 MmReleasePageMemoryConsumer(
987 MmRequestPageMemoryConsumer(
990 PPFN_TYPE AllocatedPage
995 MiInitBalancerThread(VOID
);
999 MmRebalanceMemoryConsumers(VOID
);
1001 /* rmap.c **************************************************************/
1005 MmSetRmapListHeadPage(
1007 struct _MM_RMAP_ENTRY
* ListHead
1010 struct _MM_RMAP_ENTRY
*
1012 MmGetRmapListHeadPage(PFN_TYPE Page
);
1018 struct _EPROCESS
*Process
,
1027 VOID (*DeleteMapping
)(PVOID Context
, struct _EPROCESS
*Process
, PVOID Address
)
1034 struct _EPROCESS
*Process
,
1040 MmInitializeRmapList(VOID
);
1044 MmSetCleanAllRmaps(PFN_TYPE Page
);
1048 MmSetDirtyAllRmaps(PFN_TYPE Page
);
1052 MmIsDirtyPageRmap(PFN_TYPE Page
);
1056 MmWritePagePhysicalAddress(PFN_TYPE Page
);
1060 MmPageOutPhysicalAddress(PFN_TYPE Page
);
1062 /* freelist.c **********************************************************/
1064 #define ASSERT_PFN(x) ASSERT((x)->u3.e1.CacheAttribute != 0)
1068 MiGetPfnEntry(IN PFN_TYPE Pfn
)
1071 extern RTL_BITMAP MiPfnBitMap
;
1073 /* Make sure the PFN number is valid */
1074 if (Pfn
> MmHighestPhysicalPage
) return NULL
;
1076 /* Make sure this page actually has a PFN entry */
1077 if ((MiPfnBitMap
.Buffer
) && !(RtlTestBit(&MiPfnBitMap
, Pfn
))) return NULL
;
1080 Page
= &MmPfnDatabase
[Pfn
];
1082 /* Make sure it's valid */
1091 MiGetPfnEntryIndex(IN PMMPFN Pfn1
)
1094 // This will return the Page Frame Number (PFN) from the MMPFN
1096 return Pfn1
- MmPfnDatabase
;
1101 MmGetLRUNextUserPage(PFN_TYPE PreviousPage
);
1105 MmGetLRUFirstUserPage(VOID
);
1109 MmInsertLRULastUserPage(PFN_TYPE Page
);
1113 MmRemoveLRUUserPage(PFN_TYPE Page
);
1117 MmLockPage(PFN_TYPE Page
);
1121 MmUnlockPage(PFN_TYPE Page
);
1125 MmGetLockCountPage(PFN_TYPE Page
);
1129 MmInitializePageList(
1141 MmGetContinuousPages(
1142 ULONG NumberOfBytes
,
1143 PHYSICAL_ADDRESS LowestAcceptableAddress
,
1144 PHYSICAL_ADDRESS HighestAcceptableAddress
,
1145 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1151 MmZeroPageThreadMain(
1155 /* hypermap.c *****************************************************************/
1157 extern PEPROCESS HyperProcess
;
1158 extern KIRQL HyperIrql
;
1162 MiMapPageInHyperSpace(IN PEPROCESS Process
,
1168 MiUnmapPageInHyperSpace(IN PEPROCESS Process
,
1174 MiMapPagesToZeroInHyperSpace(IN PMMPFN
*Pages
,
1175 IN PFN_NUMBER NumberOfPages
);
1179 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress
,
1180 IN PFN_NUMBER NumberOfPages
);
1183 // ReactOS Compatibility Layer
1187 MmCreateHyperspaceMapping(IN PFN_NUMBER Page
)
1189 HyperProcess
= (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;
1190 return MiMapPageInHyperSpace(HyperProcess
, Page
, &HyperIrql
);
1195 MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page
)
1197 PMMPFN Pfn1
= MiGetPfnEntry(Page
);
1198 return MiMapPagesToZeroInHyperSpace(&Pfn1
, 1);
1201 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1203 /* i386/page.c *********************************************************/
1207 MmCreateVirtualMappingForKernel(
1216 MmCommitPagedPoolAddress(
1223 MmCreateVirtualMapping(
1224 struct _EPROCESS
* Process
,
1233 MmCreateVirtualMappingUnsafe(
1234 struct _EPROCESS
* Process
,
1244 struct _EPROCESS
* Process
,
1250 struct _EPROCESS
* Process
,
1258 struct _EPROCESS
* Process
,
1264 MmInitGlobalKernelPageDirectory(VOID
);
1268 MmDisableVirtualMapping(
1269 struct _EPROCESS
*Process
,
1277 MmEnableVirtualMapping(
1278 struct _EPROCESS
*Process
,
1284 MmRawDeleteVirtualMapping(PVOID Address
);
1288 MmDeletePageFileMapping(
1289 struct _EPROCESS
*Process
,
1291 SWAPENTRY
* SwapEntry
1296 MmCreatePageFileMapping(
1297 struct _EPROCESS
*Process
,
1305 struct _EPROCESS
*Process
,
1311 MmTransferOwnershipPage(
1319 struct _EPROCESS
*Process
,
1327 SWAPENTRY SavedSwapEntry
1332 MmAllocPagesSpecifyRange(
1334 PHYSICAL_ADDRESS LowestAddress
,
1335 PHYSICAL_ADDRESS HighestAddress
,
1336 ULONG NumberOfPages
,
1342 MmDereferencePage(PFN_TYPE Page
);
1346 MmReferencePage(PFN_TYPE Page
);
1350 MmGetReferenceCountPage(PFN_TYPE Page
);
1354 MmIsPageInUse(PFN_TYPE Page
);
1358 MmSetSavedSwapEntryPage(
1360 SWAPENTRY SavedSwapEntry
);
1364 MmGetSavedSwapEntryPage(PFN_TYPE Page
);
1369 struct _EPROCESS
*Process
,
1375 MmCreatePageTable(PVOID PAddress
);
1380 struct _EPROCESS
*Process
,
1387 struct _EPROCESS
*Process
,
1393 MmCreateProcessAddressSpace(
1396 IN PULONG DirectoryTableBase
1401 MmInitializeHandBuiltProcess(
1402 IN PEPROCESS Process
,
1403 IN PULONG DirectoryTableBase
1409 MmInitializeHandBuiltProcess2(
1410 IN PEPROCESS Process
1415 MmReleaseMmInfo(struct _EPROCESS
*Process
);
1419 Mmi386ReleaseMmInfo(struct _EPROCESS
*Process
);
1423 MmDeleteVirtualMapping(
1424 struct _EPROCESS
*Process
,
1434 struct _EPROCESS
*Process
,
1440 MmMarkPageMapped(PFN_TYPE Page
);
1444 MmMarkPageUnmapped(PFN_TYPE Page
);
1449 struct _EPROCESS
*Process
,
1456 MiInitPageDirectoryMap(VOID
);
1460 MiGetUserPageDirectoryCount(VOID
);
1462 /* wset.c ********************************************************************/
1471 /* region.c ************************************************************/
1476 PMMSUPPORT AddressSpace
,
1478 PLIST_ENTRY RegionListHead
,
1483 PMM_ALTER_REGION_FUNC AlterFunc
1489 PLIST_ENTRY RegionListHead
,
1499 PLIST_ENTRY RegionListHead
,
1501 PVOID
* RegionBaseAddress
1504 /* section.c *****************************************************************/
1508 MmGetFileObjectForSection(
1509 IN PROS_SECTION_OBJECT Section
1513 MmGetFileNameForAddress(
1515 OUT PUNICODE_STRING ModuleName
1520 MmGetFileNameForSection(
1521 IN PROS_SECTION_OBJECT Section
,
1522 OUT POBJECT_NAME_INFORMATION
*ModuleName
1535 PMEMORY_AREA MemoryArea
,
1537 PMEMORY_BASIC_INFORMATION Info
,
1543 MmProtectSectionView(
1544 PMMSUPPORT AddressSpace
,
1545 PMEMORY_AREA MemoryArea
,
1554 MmWritePageSectionView(
1555 PMMSUPPORT AddressSpace
,
1563 MmInitSectionImplementation(VOID
);
1567 MmNotPresentFaultSectionView(
1568 PMMSUPPORT AddressSpace
,
1569 MEMORY_AREA
* MemoryArea
,
1576 MmPageOutSectionView(
1577 PMMSUPPORT AddressSpace
,
1578 PMEMORY_AREA MemoryArea
,
1580 struct _MM_PAGEOP
*PageOp
1585 MmCreatePhysicalMemorySection(VOID
);
1589 MmAccessFaultSectionView(
1590 PMMSUPPORT AddressSpace
,
1591 MEMORY_AREA
* MemoryArea
,
1598 MmFreeSectionSegments(PFILE_OBJECT FileObject
);
1600 /* mpw.c *********************************************************************/
1604 MmInitMpwThread(VOID
);
1608 MmInitBsmThread(VOID
);
1610 /* pager.c *******************************************************************/
1614 MiIsPagerThread(VOID
);
1618 MiStartPagerThread(VOID
);
1622 MiStopPagerThread(VOID
);
1626 MiQueryVirtualMemory(
1627 IN HANDLE ProcessHandle
,
1629 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass
,
1630 OUT PVOID VirtualMemoryInformation
,
1632 OUT PULONG ResultLength
1635 /* sysldr.c ******************************************************************/
1639 MiReloadBootLoadedDrivers(
1640 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1645 MiInitializeLoadedModuleList(
1646 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1652 IN PUNICODE_STRING FileName
,
1653 IN PUNICODE_STRING NamePrefix OPTIONAL
,
1654 IN PUNICODE_STRING LoadedName OPTIONAL
,
1656 OUT PVOID
*ModuleObject
,
1657 OUT PVOID
*ImageBaseAddress
1662 MmUnloadSystemImage(
1663 IN PVOID ImageHandle
1669 IN HANDLE ImageHandle
,
1670 IN BOOLEAN PurgeSection
1675 MmCallDllInitialize(
1676 IN PLDR_DATA_TABLE_ENTRY LdrEntry
,
1677 IN PLIST_ENTRY ListHead
1680 /* ReactOS Mm Hacks */
1683 MiSyncForProcessAttach(
1684 IN PKTHREAD NextThread
,
1685 IN PEPROCESS Process
1690 MiSyncForContextSwitch(
1694 extern PMMSUPPORT MmKernelAddressSpace
;
1698 MmLockAddressSpace(PMMSUPPORT AddressSpace
)
1700 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1705 MmUnlockAddressSpace(PMMSUPPORT AddressSpace
)
1707 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1712 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace
)
1714 if (AddressSpace
== MmKernelAddressSpace
) return NULL
;
1715 return CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
);
1720 MmGetCurrentAddressSpace(VOID
)
1722 return &((PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
)->Vm
;
1727 MmGetKernelAddressSpace(VOID
)
1729 return MmKernelAddressSpace
;