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 ULONG MmLowestPhysicalPage
;
18 extern ULONG MmHighestPhysicalPage
;
20 extern PVOID MmPagedPoolBase
;
21 extern ULONG MmPagedPoolSize
;
23 extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor
;
24 extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg
;
28 struct _MM_RMAP_ENTRY
;
30 typedef ULONG SWAPENTRY
;
31 typedef ULONG PFN_TYPE
, *PPFN_TYPE
;
34 //MmDbgCopyMemory Flags
36 #define MMDBG_COPY_WRITE 0x00000001
37 #define MMDBG_COPY_PHYSICAL 0x00000002
38 #define MMDBG_COPY_UNSAFE 0x00000004
39 #define MMDBG_COPY_CACHED 0x00000008
40 #define MMDBG_COPY_UNCACHED 0x00000010
41 #define MMDBG_COPY_WRITE_COMBINED 0x00000020
44 // Maximum chunk size per copy
46 #define MMDBG_COPY_MAX_SIZE 0x8
49 #define MI_STATIC_MEMORY_AREAS (12)
51 #define MEMORY_AREA_INVALID (0)
52 #define MEMORY_AREA_SECTION_VIEW (1)
53 #define MEMORY_AREA_CONTINUOUS_MEMORY (2)
54 #define MEMORY_AREA_NO_CACHE (3)
55 #define MEMORY_AREA_IO_MAPPING (4)
56 #define MEMORY_AREA_SYSTEM (5)
57 #define MEMORY_AREA_MDL_MAPPING (7)
58 #define MEMORY_AREA_VIRTUAL_MEMORY (8)
59 #define MEMORY_AREA_CACHE_SEGMENT (9)
60 #define MEMORY_AREA_SHARED_DATA (10)
61 #define MEMORY_AREA_KERNEL_STACK (11)
62 #define MEMORY_AREA_PAGED_POOL (12)
63 #define MEMORY_AREA_NO_ACCESS (13)
64 #define MEMORY_AREA_PEB_OR_TEB (14)
65 #define MEMORY_AREA_OWNED_BY_ARM3 (15)
66 #define MEMORY_AREA_STATIC (0x80000000)
68 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
70 #define MM_CORE_DUMP_TYPE_NONE (0x0)
71 #define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
72 #define MM_CORE_DUMP_TYPE_FULL (0x2)
74 #define MM_PAGEOP_PAGEIN (1)
75 #define MM_PAGEOP_PAGEOUT (2)
76 #define MM_PAGEOP_PAGESYNCH (3)
77 #define MM_PAGEOP_ACCESSFAULT (4)
79 /* Number of list heads to use */
80 #define MI_FREE_POOL_LISTS 4
82 #define MI_HYPERSPACE_PTES (256 - 1)
83 #define MI_ZERO_PTES (32)
84 #define MI_MAPPING_RANGE_START (ULONG)HYPER_SPACE
85 #define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \
86 MI_HYPERSPACE_PTES * PAGE_SIZE)
87 #define MI_ZERO_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \
90 /* Signature of free pool blocks */
91 #define MM_FREE_POOL_TAG 'lprF'
93 #define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
96 #define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \
97 ((((x)) % (4*1024*1024)) / (4*1024))
99 #define NR_SECTION_PAGE_TABLES 1024
100 #define NR_SECTION_PAGE_ENTRIES 1024
102 #define TEB_BASE 0x7FFDE000
104 /* Although Microsoft says this isn't hardcoded anymore,
105 they won't be able to change it. Stuff depends on it */
106 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
108 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
111 * Additional flags for protection attributes
113 #define PAGE_WRITETHROUGH (1024)
114 #define PAGE_SYSTEM (2048)
116 #define SEC_PHYSICALMEMORY (0x80000000)
118 #define MM_PAGEFILE_SEGMENT (0x1)
119 #define MM_DATAFILE_SEGMENT (0x2)
124 #define MC_NPPOOL (3)
125 #define MC_SYSTEM (4)
126 #define MC_MAXIMUM (5)
128 #define PAGED_POOL_MASK 1
129 #define MUST_SUCCEED_POOL_MASK 2
130 #define CACHE_ALIGNED_POOL_MASK 4
131 #define QUOTA_POOL_MASK 8
132 #define SESSION_POOL_MASK 32
133 #define VERIFIER_POOL_MASK 64
135 #define MM_PAGED_POOL_SIZE (100*1024*1024)
136 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
139 * Paged and non-paged pools are 8-byte aligned
141 #define MM_POOL_ALIGNMENT 8
144 * Maximum size of the kmalloc area (this is totally arbitary)
146 #define MM_KERNEL_MAP_SIZE (16*1024*1024)
147 #define MM_KERNEL_MAP_BASE (0xf0c00000)
150 * FIXME - different architectures have different cache line sizes...
152 #define MM_CACHE_LINE_SIZE 32
154 #define MM_ROUND_UP(x,s) \
155 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
157 #define MM_ROUND_DOWN(x,s) \
158 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
160 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
165 PAGE_EXECUTE_READ | \
166 PAGE_EXECUTE_READWRITE | \
167 PAGE_EXECUTE_WRITECOPY | \
172 #define PAGE_FLAGS_VALID_FOR_SECTION \
177 PAGE_EXECUTE_READ | \
178 PAGE_EXECUTE_READWRITE | \
179 PAGE_EXECUTE_WRITECOPY | \
182 #define PAGE_IS_READABLE \
186 PAGE_EXECUTE_READ | \
187 PAGE_EXECUTE_READWRITE | \
188 PAGE_EXECUTE_WRITECOPY)
190 #define PAGE_IS_WRITABLE \
193 PAGE_EXECUTE_READWRITE | \
194 PAGE_EXECUTE_WRITECOPY)
196 #define PAGE_IS_EXECUTABLE \
198 PAGE_EXECUTE_READ | \
199 PAGE_EXECUTE_READWRITE | \
200 PAGE_EXECUTE_WRITECOPY)
202 #define PAGE_IS_WRITECOPY \
204 PAGE_EXECUTE_WRITECOPY)
207 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
208 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
210 #define InterlockedExchangePte(PointerPte, Value) \
211 InterlockedExchange((PLONG)(PointerPte), Value)
215 ULONG Entry
[NR_SECTION_PAGE_ENTRIES
];
216 } SECTION_PAGE_TABLE
, *PSECTION_PAGE_TABLE
;
220 PSECTION_PAGE_TABLE PageTables
[NR_SECTION_PAGE_TABLES
];
221 } SECTION_PAGE_DIRECTORY
, *PSECTION_PAGE_DIRECTORY
;
223 typedef struct _MM_SECTION_SEGMENT
225 LONG FileOffset
; /* start offset into the file for image sections */
226 ULONG_PTR VirtualAddress
; /* dtart offset into the address range for image sections */
227 ULONG RawLength
; /* length of the segment which is part of the mapped file */
228 ULONG Length
; /* absolute length of the segment */
230 FAST_MUTEX Lock
; /* lock which protects the page directory */
231 ULONG ReferenceCount
;
232 SECTION_PAGE_DIRECTORY PageDirectory
;
234 ULONG Characteristics
;
236 } MM_SECTION_SEGMENT
, *PMM_SECTION_SEGMENT
;
238 typedef struct _MM_IMAGE_SECTION_OBJECT
241 ULONG_PTR StackReserve
;
242 ULONG_PTR StackCommit
;
243 ULONG_PTR EntryPoint
;
245 USHORT ImageCharacteristics
;
246 USHORT MinorSubsystemVersion
;
247 USHORT MajorSubsystemVersion
;
252 PMM_SECTION_SEGMENT Segments
;
253 } MM_IMAGE_SECTION_OBJECT
, *PMM_IMAGE_SECTION_OBJECT
;
255 typedef struct _ROS_SECTION_OBJECT
259 LARGE_INTEGER MaximumSize
;
260 ULONG SectionPageProtection
;
261 ULONG AllocationAttributes
;
262 PFILE_OBJECT FileObject
;
265 PMM_IMAGE_SECTION_OBJECT ImageSection
;
266 PMM_SECTION_SEGMENT Segment
;
268 } ROS_SECTION_OBJECT
, *PROS_SECTION_OBJECT
;
270 typedef struct _MEMORY_AREA
272 PVOID StartingAddress
;
274 struct _MEMORY_AREA
*Parent
;
275 struct _MEMORY_AREA
*LeftChild
;
276 struct _MEMORY_AREA
*RightChild
;
280 BOOLEAN DeleteInProgress
;
286 ROS_SECTION_OBJECT
* Section
;
288 PMM_SECTION_SEGMENT Segment
;
289 BOOLEAN WriteCopyView
;
290 LIST_ENTRY RegionListHead
;
294 LIST_ENTRY RegionListHead
;
297 } MEMORY_AREA
, *PMEMORY_AREA
;
307 ULONG PagingRequestsInLastMinute
;
308 ULONG PagingRequestsInLastFiveMinutes
;
309 ULONG PagingRequestsInLastFifteenMinutes
;
313 // These two mappings are actually used by Windows itself, based on the ASSERTS
315 #define StartOfAllocation ReadInProgress
316 #define EndOfAllocation WriteInProgress
318 typedef struct _MMPFNENTRY
321 USHORT ReadInProgress
:1; // StartOfAllocation
322 USHORT WriteInProgress
:1; // EndOfAllocation
323 USHORT PrototypePte
:1; // Zero
324 USHORT PageColor
:4; // LockCount
325 USHORT PageLocation
:3; // Consumer
326 USHORT RemovalRequested
:1;
327 USHORT CacheAttribute
:2; // Type
329 USHORT ParityError
:1;
332 typedef struct _MMPFN
336 PFN_NUMBER Flink
; // ListEntry.Flink
340 SINGLE_LIST_ENTRY NextStackPfn
;
342 PMMPTE PteAddress
; // ListEntry.Blink
346 ULONG_PTR ShareCount
; // MapCount
352 USHORT ReferenceCount
; // ReferenceCount
357 USHORT ReferenceCount
;
364 LONG AweReferenceCount
; // RmapListHead
368 ULONG_PTR EntireFrame
; // SavedSwapEntry
371 ULONG_PTR PteFrame
:25;
372 ULONG_PTR InPageError
:1;
373 ULONG_PTR VerifierAllocation
:1;
374 ULONG_PTR AweAllocation
:1;
375 ULONG_PTR Priority
:3;
376 ULONG_PTR MustBeCached
:1;
381 extern PMMPFN MmPfnDatabase
;
382 extern MM_STATS MmStats
;
384 typedef struct _MM_PAGEOP
386 /* Type of operation. */
388 /* Number of threads interested in this operation. */
389 ULONG ReferenceCount
;
390 /* Event that will be set when the operation is completed. */
391 KEVENT CompletionEvent
;
392 /* Status of the operation once it is completed. */
394 /* TRUE if the operation was abandoned. */
396 /* The memory area to be affected by the operation. */
399 struct _MM_PAGEOP
* Next
;
400 struct _ETHREAD
* Thread
;
402 * These fields are used to identify the operation if it is against a
403 * virtual memory area.
408 * These fields are used to identify the operation if it is against a
411 PMM_SECTION_SEGMENT Segment
;
413 } MM_PAGEOP
, *PMM_PAGEOP
;
415 typedef struct _MM_MEMORY_CONSUMER
419 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
);
420 } MM_MEMORY_CONSUMER
, *PMM_MEMORY_CONSUMER
;
422 typedef struct _MM_REGION
427 LIST_ENTRY RegionListEntry
;
428 } MM_REGION
, *PMM_REGION
;
430 /* Entry describing free pool memory */
431 typedef struct _MMFREE_POOL_ENTRY
436 struct _MMFREE_POOL_ENTRY
*Owner
;
437 } MMFREE_POOL_ENTRY
, *PMMFREE_POOL_ENTRY
;
439 /* Paged pool information */
440 typedef struct _MM_PAGED_POOL_INFO
442 PRTL_BITMAP PagedPoolAllocationMap
;
443 PRTL_BITMAP EndOfPagedPoolBitmap
;
444 PMMPTE FirstPteForPagedPool
;
445 PMMPTE LastPteForPagedPool
;
446 PMMPTE NextPdeForPagedPoolExpansion
;
448 SIZE_T PagedPoolCommit
;
449 SIZE_T AllocatedPagedPool
;
450 } MM_PAGED_POOL_INFO
, *PMM_PAGED_POOL_INFO
;
452 extern MM_MEMORY_CONSUMER MiMemoryConsumers
[MC_MAXIMUM
];
455 (*PMM_ALTER_REGION_FUNC
)(
456 PMMSUPPORT AddressSpace
,
466 (*PMM_FREE_PAGE_FUNC
)(
468 PMEMORY_AREA MemoryArea
,
476 // Mm copy support for Kd
487 /* marea.c *******************************************************************/
492 PMMSUPPORT AddressSpace
,
497 PMEMORY_AREA
*Result
,
498 BOOLEAN FixedAddress
,
499 ULONG AllocationFlags
,
500 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
505 MmLocateMemoryAreaByAddress(
506 PMMSUPPORT AddressSpace
,
513 PMMSUPPORT AddressSpace
,
520 PMMSUPPORT AddressSpace
,
521 PMEMORY_AREA MemoryArea
,
522 PMM_FREE_PAGE_FUNC FreePage
,
523 PVOID FreePageContext
528 MmFreeMemoryAreaByPtr(
529 PMMSUPPORT AddressSpace
,
531 PMM_FREE_PAGE_FUNC FreePage
,
532 PVOID FreePageContext
537 MmDumpMemoryAreas(PMMSUPPORT AddressSpace
);
541 MmLocateMemoryAreaByRegion(
542 PMMSUPPORT AddressSpace
,
550 PMMSUPPORT AddressSpace
,
552 ULONG_PTR Granularity
,
558 MmReleaseMemoryAreaIfDecommitted(
559 struct _EPROCESS
*Process
,
560 PMMSUPPORT AddressSpace
,
566 MmMapMemoryArea(PVOID BaseAddress
,
571 /* npool.c *******************************************************************/
575 MiDebugDumpNonPagedPool(BOOLEAN NewOnly
);
579 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly
);
583 MiInitializeNonPagedPool(VOID
);
588 IN POOL_TYPE PoolType
,
589 IN SIZE_T SizeInBytes
595 IN PVOID VirtualAddress
601 IN PVOID StartingAddress
611 /* pool.c *******************************************************************/
615 ExAllocateNonPagedPoolWithTag(
624 ExAllocatePagedPoolWithTag(
632 ExFreeNonPagedPool(PVOID block
);
636 ExFreePagedPool(IN PVOID Block
);
640 ExpIsPoolTagDebuggable(ULONG Tag
);
644 ExpAllocateDebugPool(
654 ExpFreeDebugPool(PVOID Block
, BOOLEAN PagedPool
);
658 MmInitializePagedPool(VOID
);
662 MiAllocateSpecialPool(
663 IN POOL_TYPE PoolType
,
664 IN SIZE_T NumberOfBytes
,
672 IN POOL_TYPE PoolType
,
673 IN ULONG CurrentMaxQuota
,
674 OUT PULONG NewMaxQuota
677 /* mdl.c *********************************************************************/
686 /* mminit.c ******************************************************************/
690 MiShutdownMemoryManager(VOID
);
700 MmInitSystem(IN ULONG Phase
,
701 IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
705 MiFreeInitMemory(VOID
);
709 MmInitializeMdlImplementation(VOID
);
711 /* pagefile.c ****************************************************************/
715 MmAllocSwapPage(VOID
);
719 MmDereserveSwapPages(ULONG Nr
);
723 MmFreeSwapPage(SWAPENTRY Entry
);
727 MmInitPagingFile(VOID
);
738 MmReserveSwapPages(ULONG Nr
);
751 ULONG BugCodeParameter1
,
752 ULONG BugCodeParameter2
,
753 ULONG BugCodeParameter3
,
754 ULONG BugCodeParameter4
,
755 struct _KTRAP_FRAME
* TrapFrame
760 MmIsAvailableSwapPage(VOID
);
764 MmShowOutOfSpaceMessagePagingFile(VOID
);
766 /* process.c ****************************************************************/
770 MmInitializeProcessAddressSpace(
771 IN PEPROCESS Process
,
772 IN PEPROCESS Clone OPTIONAL
,
773 IN PVOID Section OPTIONAL
,
775 IN POBJECT_NAME_INFORMATION
*AuditName OPTIONAL
781 IN PEPROCESS Process
,
782 IN PINITIAL_PEB InitialPeb
,
789 IN PEPROCESS Process
,
790 IN PCLIENT_ID ClientId
,
791 IN PINITIAL_TEB InitialTeb
,
798 struct _EPROCESS
*Process
,
804 MmCleanProcessAddressSpace(IN PEPROCESS Process
);
808 MmDeleteProcessAddressSpace(IN PEPROCESS Process
);
812 MmGetSessionLocaleId(VOID
);
816 MmSetMemoryPriorityProcess(
817 IN PEPROCESS Process
,
818 IN UCHAR MemoryPriority
821 /* i386/pfault.c *************************************************************/
833 /* mm.c **********************************************************************/
838 IN BOOLEAN StoreInstruction
,
840 IN KPROCESSOR_MODE Mode
,
841 IN PVOID TrapInformation
844 /* anonmem.c *****************************************************************/
848 MmNotPresentFaultVirtualMemory(
849 PMMSUPPORT AddressSpace
,
850 MEMORY_AREA
* MemoryArea
,
857 MmPageOutVirtualMemory(
858 PMMSUPPORT AddressSpace
,
859 PMEMORY_AREA MemoryArea
,
861 struct _MM_PAGEOP
* PageOp
867 PMEMORY_AREA MemoryArea
,
869 PMEMORY_BASIC_INFORMATION Info
,
876 struct _EPROCESS
* Process
,
877 PMEMORY_AREA MemoryArea
883 PMMSUPPORT AddressSpace
,
884 PMEMORY_AREA MemoryArea
,
893 MmWritePageVirtualMemory(
894 PMMSUPPORT AddressSpace
,
900 /* kmap.c ********************************************************************/
904 ExAllocatePage(VOID
);
908 ExUnmapPage(PVOID Addr
);
912 ExAllocatePageWithPhysPage(PFN_TYPE Page
);
923 MiZeroPage(PFN_TYPE Page
);
925 /* memsafe.s *****************************************************************/
929 MmSafeReadPtr(PVOID Source
);
931 /* pageop.c ******************************************************************/
935 MmReleasePageOp(PMM_PAGEOP PageOp
);
943 PMM_SECTION_SEGMENT Segment
,
955 PMM_SECTION_SEGMENT Segment
,
961 MmInitializePageOp(VOID
);
963 /* process.c *****************************************************************/
967 MmCreateKernelStack(BOOLEAN GuiStack
, UCHAR Node
);
971 MmDeleteKernelStack(PVOID Stack
,
974 /* balace.c ******************************************************************/
978 MmInitializeMemoryConsumer(
980 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
)
985 MmInitializeBalancer(
986 ULONG NrAvailablePages
,
992 MmReleasePageMemoryConsumer(
999 MmRequestPageMemoryConsumer(
1002 PPFN_TYPE AllocatedPage
1007 MiInitBalancerThread(VOID
);
1011 MmRebalanceMemoryConsumers(VOID
);
1013 /* rmap.c **************************************************************/
1017 MmSetRmapListHeadPage(
1019 struct _MM_RMAP_ENTRY
* ListHead
1022 struct _MM_RMAP_ENTRY
*
1024 MmGetRmapListHeadPage(PFN_TYPE Page
);
1030 struct _EPROCESS
*Process
,
1039 VOID (*DeleteMapping
)(PVOID Context
, struct _EPROCESS
*Process
, PVOID Address
)
1046 struct _EPROCESS
*Process
,
1052 MmInitializeRmapList(VOID
);
1056 MmSetCleanAllRmaps(PFN_TYPE Page
);
1060 MmSetDirtyAllRmaps(PFN_TYPE Page
);
1064 MmIsDirtyPageRmap(PFN_TYPE Page
);
1068 MmWritePagePhysicalAddress(PFN_TYPE Page
);
1072 MmPageOutPhysicalAddress(PFN_TYPE Page
);
1074 /* freelist.c **********************************************************/
1076 #define ASSERT_PFN(x) ASSERT((x)->u3.e1.CacheAttribute != 0)
1080 MiGetPfnEntry(IN PFN_TYPE Pfn
)
1083 extern RTL_BITMAP MiPfnBitMap
;
1085 /* Make sure the PFN number is valid */
1086 if (Pfn
> MmHighestPhysicalPage
) return NULL
;
1088 /* Make sure this page actually has a PFN entry */
1089 if ((MiPfnBitMap
.Buffer
) && !(RtlTestBit(&MiPfnBitMap
, Pfn
))) return NULL
;
1092 Page
= &MmPfnDatabase
[Pfn
];
1094 /* Make sure it's valid */
1103 MiGetPfnEntryIndex(IN PMMPFN Pfn1
)
1106 // This will return the Page Frame Number (PFN) from the MMPFN
1108 return Pfn1
- MmPfnDatabase
;
1113 MmGetLRUNextUserPage(PFN_TYPE PreviousPage
);
1117 MmGetLRUFirstUserPage(VOID
);
1121 MmInsertLRULastUserPage(PFN_TYPE Page
);
1125 MmRemoveLRUUserPage(PFN_TYPE Page
);
1129 MmLockPage(PFN_TYPE Page
);
1133 MmUnlockPage(PFN_TYPE Page
);
1137 MmGetLockCountPage(PFN_TYPE Page
);
1141 MmInitializePageList(
1153 MmGetContinuousPages(
1154 ULONG NumberOfBytes
,
1155 PHYSICAL_ADDRESS LowestAcceptableAddress
,
1156 PHYSICAL_ADDRESS HighestAcceptableAddress
,
1157 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1163 MmZeroPageThreadMain(
1167 /* hypermap.c *****************************************************************/
1169 extern PEPROCESS HyperProcess
;
1170 extern KIRQL HyperIrql
;
1174 MiMapPageInHyperSpace(IN PEPROCESS Process
,
1180 MiUnmapPageInHyperSpace(IN PEPROCESS Process
,
1186 MiMapPagesToZeroInHyperSpace(IN PMMPFN
*Pages
,
1187 IN PFN_NUMBER NumberOfPages
);
1191 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress
,
1192 IN PFN_NUMBER NumberOfPages
);
1195 // ReactOS Compatibility Layer
1199 MmCreateHyperspaceMapping(IN PFN_NUMBER Page
)
1201 HyperProcess
= (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;
1202 return MiMapPageInHyperSpace(HyperProcess
, Page
, &HyperIrql
);
1207 MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page
)
1209 PMMPFN Pfn1
= MiGetPfnEntry(Page
);
1210 return MiMapPagesToZeroInHyperSpace(&Pfn1
, 1);
1213 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1215 /* i386/page.c *********************************************************/
1219 MmCreateVirtualMappingForKernel(
1228 MmCommitPagedPoolAddress(
1235 MmCreateVirtualMapping(
1236 struct _EPROCESS
* Process
,
1245 MmCreateVirtualMappingUnsafe(
1246 struct _EPROCESS
* Process
,
1256 struct _EPROCESS
* Process
,
1262 struct _EPROCESS
* Process
,
1270 struct _EPROCESS
* Process
,
1276 MmInitGlobalKernelPageDirectory(VOID
);
1280 MmDisableVirtualMapping(
1281 struct _EPROCESS
*Process
,
1289 MmEnableVirtualMapping(
1290 struct _EPROCESS
*Process
,
1296 MmRawDeleteVirtualMapping(PVOID Address
);
1300 MmDeletePageFileMapping(
1301 struct _EPROCESS
*Process
,
1303 SWAPENTRY
* SwapEntry
1308 MmCreatePageFileMapping(
1309 struct _EPROCESS
*Process
,
1317 struct _EPROCESS
*Process
,
1323 MmTransferOwnershipPage(
1331 struct _EPROCESS
*Process
,
1339 SWAPENTRY SavedSwapEntry
1344 MmAllocPagesSpecifyRange(
1346 PHYSICAL_ADDRESS LowestAddress
,
1347 PHYSICAL_ADDRESS HighestAddress
,
1348 ULONG NumberOfPages
,
1354 MmDereferencePage(PFN_TYPE Page
);
1358 MmReferencePage(PFN_TYPE Page
);
1362 MmGetReferenceCountPage(PFN_TYPE Page
);
1366 MmIsPageInUse(PFN_TYPE Page
);
1370 MmSetSavedSwapEntryPage(
1372 SWAPENTRY SavedSwapEntry
);
1376 MmGetSavedSwapEntryPage(PFN_TYPE Page
);
1381 struct _EPROCESS
*Process
,
1387 MmCreatePageTable(PVOID PAddress
);
1392 struct _EPROCESS
*Process
,
1399 struct _EPROCESS
*Process
,
1405 MmCreateProcessAddressSpace(
1408 IN PULONG DirectoryTableBase
1413 MmInitializeHandBuiltProcess(
1414 IN PEPROCESS Process
,
1415 IN PULONG DirectoryTableBase
1421 MmInitializeHandBuiltProcess2(
1422 IN PEPROCESS Process
1427 MmReleaseMmInfo(struct _EPROCESS
*Process
);
1431 Mmi386ReleaseMmInfo(struct _EPROCESS
*Process
);
1435 MmDeleteVirtualMapping(
1436 struct _EPROCESS
*Process
,
1446 struct _EPROCESS
*Process
,
1452 MmMarkPageMapped(PFN_TYPE Page
);
1456 MmMarkPageUnmapped(PFN_TYPE Page
);
1461 struct _EPROCESS
*Process
,
1468 MiInitPageDirectoryMap(VOID
);
1472 MiGetUserPageDirectoryCount(VOID
);
1474 /* wset.c ********************************************************************/
1483 /* region.c ************************************************************/
1488 PMMSUPPORT AddressSpace
,
1490 PLIST_ENTRY RegionListHead
,
1495 PMM_ALTER_REGION_FUNC AlterFunc
1501 PLIST_ENTRY RegionListHead
,
1511 PLIST_ENTRY RegionListHead
,
1513 PVOID
* RegionBaseAddress
1516 /* section.c *****************************************************************/
1520 MmGetFileObjectForSection(
1521 IN PROS_SECTION_OBJECT Section
1525 MmGetFileNameForAddress(
1527 OUT PUNICODE_STRING ModuleName
1532 MmGetFileNameForSection(
1533 IN PROS_SECTION_OBJECT Section
,
1534 OUT POBJECT_NAME_INFORMATION
*ModuleName
1547 PMEMORY_AREA MemoryArea
,
1549 PMEMORY_BASIC_INFORMATION Info
,
1555 MmProtectSectionView(
1556 PMMSUPPORT AddressSpace
,
1557 PMEMORY_AREA MemoryArea
,
1566 MmWritePageSectionView(
1567 PMMSUPPORT AddressSpace
,
1575 MmInitSectionImplementation(VOID
);
1579 MmNotPresentFaultSectionView(
1580 PMMSUPPORT AddressSpace
,
1581 MEMORY_AREA
* MemoryArea
,
1588 MmPageOutSectionView(
1589 PMMSUPPORT AddressSpace
,
1590 PMEMORY_AREA MemoryArea
,
1592 struct _MM_PAGEOP
*PageOp
1597 MmCreatePhysicalMemorySection(VOID
);
1601 MmAccessFaultSectionView(
1602 PMMSUPPORT AddressSpace
,
1603 MEMORY_AREA
* MemoryArea
,
1610 MmFreeSectionSegments(PFILE_OBJECT FileObject
);
1612 /* mpw.c *********************************************************************/
1616 MmInitMpwThread(VOID
);
1620 MmInitBsmThread(VOID
);
1622 /* pager.c *******************************************************************/
1626 MiIsPagerThread(VOID
);
1630 MiStartPagerThread(VOID
);
1634 MiStopPagerThread(VOID
);
1638 MiQueryVirtualMemory(
1639 IN HANDLE ProcessHandle
,
1641 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass
,
1642 OUT PVOID VirtualMemoryInformation
,
1644 OUT PULONG ResultLength
1647 /* sysldr.c ******************************************************************/
1651 MiReloadBootLoadedDrivers(
1652 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1657 MiInitializeLoadedModuleList(
1658 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1664 IN PUNICODE_STRING FileName
,
1665 IN PUNICODE_STRING NamePrefix OPTIONAL
,
1666 IN PUNICODE_STRING LoadedName OPTIONAL
,
1668 OUT PVOID
*ModuleObject
,
1669 OUT PVOID
*ImageBaseAddress
1674 MmUnloadSystemImage(
1675 IN PVOID ImageHandle
1681 IN HANDLE ImageHandle
,
1682 IN BOOLEAN PurgeSection
1687 MmCallDllInitialize(
1688 IN PLDR_DATA_TABLE_ENTRY LdrEntry
,
1689 IN PLIST_ENTRY ListHead
1692 /* ReactOS Mm Hacks */
1695 MiSyncForProcessAttach(
1696 IN PKTHREAD NextThread
,
1697 IN PEPROCESS Process
1702 MiSyncForContextSwitch(
1706 extern PMMSUPPORT MmKernelAddressSpace
;
1710 MmLockAddressSpace(PMMSUPPORT AddressSpace
)
1712 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1717 MmUnlockAddressSpace(PMMSUPPORT AddressSpace
)
1719 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1724 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace
)
1726 if (AddressSpace
== MmKernelAddressSpace
) return NULL
;
1727 return CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
);
1732 MmGetCurrentAddressSpace(VOID
)
1734 return &((PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
)->Vm
;
1739 MmGetKernelAddressSpace(VOID
)
1741 return MmKernelAddressSpace
;