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
;
18 extern PVOID MmPagedPoolBase
;
19 extern ULONG MmPagedPoolSize
;
21 extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor
;
22 extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg
;
23 extern ULONG MmHighestPhysicalPage
;
27 struct _MM_RMAP_ENTRY
;
29 typedef ULONG SWAPENTRY
;
30 typedef ULONG PFN_TYPE
, *PPFN_TYPE
;
32 #define MI_STATIC_MEMORY_AREAS (8)
34 #define MEMORY_AREA_INVALID (0)
35 #define MEMORY_AREA_SECTION_VIEW (1)
36 #define MEMORY_AREA_CONTINUOUS_MEMORY (2)
37 #define MEMORY_AREA_NO_CACHE (3)
38 #define MEMORY_AREA_IO_MAPPING (4)
39 #define MEMORY_AREA_SYSTEM (5)
40 #define MEMORY_AREA_MDL_MAPPING (7)
41 #define MEMORY_AREA_VIRTUAL_MEMORY (8)
42 #define MEMORY_AREA_CACHE_SEGMENT (9)
43 #define MEMORY_AREA_SHARED_DATA (10)
44 #define MEMORY_AREA_KERNEL_STACK (11)
45 #define MEMORY_AREA_PAGED_POOL (12)
46 #define MEMORY_AREA_NO_ACCESS (13)
47 #define MEMORY_AREA_PEB_OR_TEB (14)
48 #define MEMORY_AREA_STATIC (0x80000000)
50 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
52 #define MM_CORE_DUMP_TYPE_NONE (0x0)
53 #define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
54 #define MM_CORE_DUMP_TYPE_FULL (0x2)
56 #define MM_PAGEOP_PAGEIN (1)
57 #define MM_PAGEOP_PAGEOUT (2)
58 #define MM_PAGEOP_PAGESYNCH (3)
59 #define MM_PAGEOP_ACCESSFAULT (4)
61 /* Number of list heads to use */
62 #define MI_FREE_POOL_LISTS 4
64 #define MI_HYPERSPACE_PTES (256 - 1)
65 #define MI_ZERO_PTES (32)
66 #define MI_MAPPING_RANGE_START (ULONG)HYPER_SPACE
67 #define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \
68 MI_HYPERSPACE_PTES * PAGE_SIZE)
69 #define MI_ZERO_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \
72 /* Signature of free pool blocks */
73 #define MM_FREE_POOL_TAG TAG('F', 'r', 'p', 'l')
75 #define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
78 #define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \
79 ((((x)) % (4*1024*1024)) / (4*1024))
81 #define NR_SECTION_PAGE_TABLES 1024
82 #define NR_SECTION_PAGE_ENTRIES 1024
84 #define TEB_BASE 0x7FFDE000
86 /* Although Microsoft says this isn't hardcoded anymore,
87 they won't be able to change it. Stuff depends on it */
88 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
90 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
93 * Additional flags for protection attributes
95 #define PAGE_WRITETHROUGH (1024)
96 #define PAGE_SYSTEM (2048)
98 #define SEC_PHYSICALMEMORY (0x80000000)
100 #define MM_PAGEFILE_SEGMENT (0x1)
101 #define MM_DATAFILE_SEGMENT (0x2)
106 #define MC_NPPOOL (3)
107 #define MC_SYSTEM (4)
108 #define MC_MAXIMUM (5)
110 #define PAGED_POOL_MASK 1
111 #define MUST_SUCCEED_POOL_MASK 2
112 #define CACHE_ALIGNED_POOL_MASK 4
113 #define QUOTA_POOL_MASK 8
114 #define SESSION_POOL_MASK 32
115 #define VERIFIER_POOL_MASK 64
117 #define MM_PAGED_POOL_SIZE (100*1024*1024)
118 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
121 * Paged and non-paged pools are 8-byte aligned
123 #define MM_POOL_ALIGNMENT 8
126 * Maximum size of the kmalloc area (this is totally arbitary)
128 #define MM_KERNEL_MAP_SIZE (16*1024*1024)
129 #define MM_KERNEL_MAP_BASE (0xf0c00000)
132 * FIXME - different architectures have different cache line sizes...
134 #define MM_CACHE_LINE_SIZE 32
136 #define MM_ROUND_UP(x,s) \
137 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
139 #define MM_ROUND_DOWN(x,s) \
140 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
142 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
147 PAGE_EXECUTE_READ | \
148 PAGE_EXECUTE_READWRITE | \
149 PAGE_EXECUTE_WRITECOPY | \
154 #define PAGE_FLAGS_VALID_FOR_SECTION \
159 PAGE_EXECUTE_READ | \
160 PAGE_EXECUTE_READWRITE | \
161 PAGE_EXECUTE_WRITECOPY | \
164 #define PAGE_IS_READABLE \
168 PAGE_EXECUTE_READ | \
169 PAGE_EXECUTE_READWRITE | \
170 PAGE_EXECUTE_WRITECOPY)
172 #define PAGE_IS_WRITABLE \
175 PAGE_EXECUTE_READWRITE | \
176 PAGE_EXECUTE_WRITECOPY)
178 #define PAGE_IS_EXECUTABLE \
180 PAGE_EXECUTE_READ | \
181 PAGE_EXECUTE_READWRITE | \
182 PAGE_EXECUTE_WRITECOPY)
184 #define PAGE_IS_WRITECOPY \
186 PAGE_EXECUTE_WRITECOPY)
189 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
190 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
192 #define InterlockedExchangePte(PointerPte, Value) \
193 InterlockedExchange((PLONG)(PointerPte), Value)
197 ULONG Entry
[NR_SECTION_PAGE_ENTRIES
];
198 } SECTION_PAGE_TABLE
, *PSECTION_PAGE_TABLE
;
202 PSECTION_PAGE_TABLE PageTables
[NR_SECTION_PAGE_TABLES
];
203 } SECTION_PAGE_DIRECTORY
, *PSECTION_PAGE_DIRECTORY
;
205 typedef struct _MM_SECTION_SEGMENT
207 LONG FileOffset
; /* start offset into the file for image sections */
208 ULONG_PTR VirtualAddress
; /* dtart offset into the address range for image sections */
209 ULONG RawLength
; /* length of the segment which is part of the mapped file */
210 ULONG Length
; /* absolute length of the segment */
212 FAST_MUTEX Lock
; /* lock which protects the page directory */
213 ULONG ReferenceCount
;
214 SECTION_PAGE_DIRECTORY PageDirectory
;
216 ULONG Characteristics
;
218 } MM_SECTION_SEGMENT
, *PMM_SECTION_SEGMENT
;
220 typedef struct _MM_IMAGE_SECTION_OBJECT
223 ULONG_PTR StackReserve
;
224 ULONG_PTR StackCommit
;
225 ULONG_PTR EntryPoint
;
227 USHORT ImageCharacteristics
;
228 USHORT MinorSubsystemVersion
;
229 USHORT MajorSubsystemVersion
;
234 PMM_SECTION_SEGMENT Segments
;
235 } MM_IMAGE_SECTION_OBJECT
, *PMM_IMAGE_SECTION_OBJECT
;
237 typedef struct _ROS_SECTION_OBJECT
241 LARGE_INTEGER MaximumSize
;
242 ULONG SectionPageProtection
;
243 ULONG AllocationAttributes
;
244 PFILE_OBJECT FileObject
;
247 PMM_IMAGE_SECTION_OBJECT ImageSection
;
248 PMM_SECTION_SEGMENT Segment
;
250 } ROS_SECTION_OBJECT
, *PROS_SECTION_OBJECT
;
252 typedef struct _MEMORY_AREA
254 PVOID StartingAddress
;
256 struct _MEMORY_AREA
*Parent
;
257 struct _MEMORY_AREA
*LeftChild
;
258 struct _MEMORY_AREA
*RightChild
;
262 BOOLEAN DeleteInProgress
;
268 ROS_SECTION_OBJECT
* Section
;
270 PMM_SECTION_SEGMENT Segment
;
271 BOOLEAN WriteCopyView
;
272 LIST_ENTRY RegionListHead
;
276 LIST_ENTRY RegionListHead
;
279 } MEMORY_AREA
, *PMEMORY_AREA
;
289 ULONG PagingRequestsInLastMinute
;
290 ULONG PagingRequestsInLastFiveMinutes
;
291 ULONG PagingRequestsInLastFifteenMinutes
;
295 // These two mappings are actually used by Windows itself, based on the ASSERTS
297 #define StartOfAllocation ReadInProgress
298 #define EndOfAllocation WriteInProgress
300 typedef struct _MMPFNENTRY
303 USHORT ReadInProgress
:1; // StartOfAllocation
304 USHORT WriteInProgress
:1; // EndOfAllocation
305 USHORT PrototypePte
:1; // Zero
306 USHORT PageColor
:4; // LockCount
307 USHORT PageLocation
:3; // Consumer
308 USHORT RemovalRequested
:1;
309 USHORT CacheAttribute
:2; // Type
311 USHORT ParityError
:1;
314 typedef struct _MMPFN
318 PFN_NUMBER Flink
; // ListEntry.Flink
322 SINGLE_LIST_ENTRY NextStackPfn
;
324 PMMPTE PteAddress
; // ListEntry.Blink
328 ULONG_PTR ShareCount
; // MapCount
334 USHORT ReferenceCount
; // ReferenceCount
339 USHORT ReferenceCount
;
346 LONG AweReferenceCount
; // RmapListHead
350 ULONG_PTR EntireFrame
; // SavedSwapEntry
353 ULONG_PTR PteFrame
:25;
354 ULONG_PTR InPageError
:1;
355 ULONG_PTR VerifierAllocation
:1;
356 ULONG_PTR AweAllocation
:1;
357 ULONG_PTR Priority
:3;
358 ULONG_PTR MustBeCached
:1;
363 extern PMMPFN MmPfnDatabase
;
364 extern MM_STATS MmStats
;
366 typedef struct _MM_PAGEOP
368 /* Type of operation. */
370 /* Number of threads interested in this operation. */
371 ULONG ReferenceCount
;
372 /* Event that will be set when the operation is completed. */
373 KEVENT CompletionEvent
;
374 /* Status of the operation once it is completed. */
376 /* TRUE if the operation was abandoned. */
378 /* The memory area to be affected by the operation. */
381 struct _MM_PAGEOP
* Next
;
382 struct _ETHREAD
* Thread
;
384 * These fields are used to identify the operation if it is against a
385 * virtual memory area.
390 * These fields are used to identify the operation if it is against a
393 PMM_SECTION_SEGMENT Segment
;
395 } MM_PAGEOP
, *PMM_PAGEOP
;
397 typedef struct _MM_MEMORY_CONSUMER
401 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
);
402 } MM_MEMORY_CONSUMER
, *PMM_MEMORY_CONSUMER
;
404 typedef struct _MM_REGION
409 LIST_ENTRY RegionListEntry
;
410 } MM_REGION
, *PMM_REGION
;
412 /* Entry describing free pool memory */
413 typedef struct _MMFREE_POOL_ENTRY
418 struct _MMFREE_POOL_ENTRY
*Owner
;
419 } MMFREE_POOL_ENTRY
, *PMMFREE_POOL_ENTRY
;
421 /* Paged pool information */
422 typedef struct _MM_PAGED_POOL_INFO
424 PRTL_BITMAP PagedPoolAllocationMap
;
425 PRTL_BITMAP EndOfPagedPoolBitmap
;
426 PMMPTE FirstPteForPagedPool
;
427 PMMPTE LastPteForPagedPool
;
428 PMMPTE NextPdeForPagedPoolExpansion
;
430 SIZE_T PagedPoolCommit
;
431 SIZE_T AllocatedPagedPool
;
432 } MM_PAGED_POOL_INFO
, *PMM_PAGED_POOL_INFO
;
434 extern MM_MEMORY_CONSUMER MiMemoryConsumers
[MC_MAXIMUM
];
437 (*PMM_ALTER_REGION_FUNC
)(
438 PMMSUPPORT AddressSpace
,
448 (*PMM_FREE_PAGE_FUNC
)(
450 PMEMORY_AREA MemoryArea
,
457 /* marea.c *******************************************************************/
462 PMMSUPPORT AddressSpace
,
467 PMEMORY_AREA
*Result
,
468 BOOLEAN FixedAddress
,
469 ULONG AllocationFlags
,
470 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
475 MmLocateMemoryAreaByAddress(
476 PMMSUPPORT AddressSpace
,
483 PMMSUPPORT AddressSpace
,
490 PMMSUPPORT AddressSpace
,
491 PMEMORY_AREA MemoryArea
,
492 PMM_FREE_PAGE_FUNC FreePage
,
493 PVOID FreePageContext
498 MmFreeMemoryAreaByPtr(
499 PMMSUPPORT AddressSpace
,
501 PMM_FREE_PAGE_FUNC FreePage
,
502 PVOID FreePageContext
507 MmDumpMemoryAreas(PMMSUPPORT AddressSpace
);
511 MmLocateMemoryAreaByRegion(
512 PMMSUPPORT AddressSpace
,
520 PMMSUPPORT AddressSpace
,
522 ULONG_PTR Granularity
,
528 MmReleaseMemoryAreaIfDecommitted(
529 struct _EPROCESS
*Process
,
530 PMMSUPPORT AddressSpace
,
536 MmMapMemoryArea(PVOID BaseAddress
,
541 /* npool.c *******************************************************************/
545 MiDebugDumpNonPagedPool(BOOLEAN NewOnly
);
549 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly
);
553 MiInitializeNonPagedPool(VOID
);
558 IN POOL_TYPE PoolType
,
559 IN SIZE_T SizeInBytes
565 IN PVOID VirtualAddress
571 IN PVOID StartingAddress
581 /* pool.c *******************************************************************/
585 ExAllocateNonPagedPoolWithTag(
594 ExAllocatePagedPoolWithTag(
602 ExFreeNonPagedPool(PVOID block
);
606 ExFreePagedPool(IN PVOID Block
);
610 ExpIsPoolTagDebuggable(ULONG Tag
);
614 ExpAllocateDebugPool(
624 ExpFreeDebugPool(PVOID Block
, BOOLEAN PagedPool
);
628 MmInitializePagedPool(VOID
);
632 MiAllocateSpecialPool(
633 IN POOL_TYPE PoolType
,
634 IN SIZE_T NumberOfBytes
,
642 IN POOL_TYPE PoolType
,
643 IN ULONG CurrentMaxQuota
,
644 OUT PULONG NewMaxQuota
647 /* mdl.c *********************************************************************/
656 /* mminit.c ******************************************************************/
660 MiShutdownMemoryManager(VOID
);
670 MmInitSystem(IN ULONG Phase
,
671 IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
675 MiFreeInitMemory(VOID
);
679 MmInitializeMdlImplementation(VOID
);
681 /* pagefile.c ****************************************************************/
685 MmAllocSwapPage(VOID
);
689 MmDereserveSwapPages(ULONG Nr
);
693 MmFreeSwapPage(SWAPENTRY Entry
);
697 MmInitPagingFile(VOID
);
708 MmReserveSwapPages(ULONG Nr
);
721 ULONG BugCodeParameter1
,
722 ULONG BugCodeParameter2
,
723 ULONG BugCodeParameter3
,
724 ULONG BugCodeParameter4
,
725 struct _KTRAP_FRAME
* TrapFrame
730 MmIsAvailableSwapPage(VOID
);
734 MmShowOutOfSpaceMessagePagingFile(VOID
);
736 /* process.c ****************************************************************/
740 MmInitializeProcessAddressSpace(
741 IN PEPROCESS Process
,
742 IN PEPROCESS Clone OPTIONAL
,
743 IN PVOID Section OPTIONAL
,
745 IN POBJECT_NAME_INFORMATION
*AuditName OPTIONAL
750 MmCreatePeb(struct _EPROCESS
*Process
);
755 struct _EPROCESS
*Process
,
757 PINITIAL_TEB InitialTeb
763 struct _EPROCESS
*Process
,
769 MmCleanProcessAddressSpace(IN PEPROCESS Process
);
773 MmDeleteProcessAddressSpace(IN PEPROCESS Process
);
777 MmGetSessionLocaleId(VOID
);
781 MmSetMemoryPriorityProcess(
782 IN PEPROCESS Process
,
783 IN UCHAR MemoryPriority
786 /* i386/pfault.c *************************************************************/
798 /* mm.c **********************************************************************/
803 IN BOOLEAN StoreInstruction
,
805 IN KPROCESSOR_MODE Mode
,
806 IN PVOID TrapInformation
809 /* anonmem.c *****************************************************************/
813 MmNotPresentFaultVirtualMemory(
814 PMMSUPPORT AddressSpace
,
815 MEMORY_AREA
* MemoryArea
,
822 MmPageOutVirtualMemory(
823 PMMSUPPORT AddressSpace
,
824 PMEMORY_AREA MemoryArea
,
826 struct _MM_PAGEOP
* PageOp
832 PMEMORY_AREA MemoryArea
,
834 PMEMORY_BASIC_INFORMATION Info
,
841 struct _EPROCESS
* Process
,
842 PMEMORY_AREA MemoryArea
848 PMMSUPPORT AddressSpace
,
849 PMEMORY_AREA MemoryArea
,
858 MmWritePageVirtualMemory(
859 PMMSUPPORT AddressSpace
,
865 /* kmap.c ********************************************************************/
869 ExAllocatePage(VOID
);
873 ExUnmapPage(PVOID Addr
);
877 ExAllocatePageWithPhysPage(PFN_TYPE Page
);
888 MiZeroPage(PFN_TYPE Page
);
890 /* memsafe.s *****************************************************************/
894 MmSafeReadPtr(PVOID Source
);
896 /* pageop.c ******************************************************************/
900 MmReleasePageOp(PMM_PAGEOP PageOp
);
908 PMM_SECTION_SEGMENT Segment
,
920 PMM_SECTION_SEGMENT Segment
,
926 MmInitializePageOp(VOID
);
928 /* process.c *****************************************************************/
932 MmCreateKernelStack(BOOLEAN GuiStack
, UCHAR Node
);
936 MmDeleteKernelStack(PVOID Stack
,
939 /* balace.c ******************************************************************/
943 MmInitializeMemoryConsumer(
945 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
)
950 MmInitializeBalancer(
951 ULONG NrAvailablePages
,
957 MmReleasePageMemoryConsumer(
964 MmRequestPageMemoryConsumer(
967 PPFN_TYPE AllocatedPage
972 MiInitBalancerThread(VOID
);
976 MmRebalanceMemoryConsumers(VOID
);
978 /* rmap.c **************************************************************/
982 MmSetRmapListHeadPage(
984 struct _MM_RMAP_ENTRY
* ListHead
987 struct _MM_RMAP_ENTRY
*
989 MmGetRmapListHeadPage(PFN_TYPE Page
);
995 struct _EPROCESS
*Process
,
1004 VOID (*DeleteMapping
)(PVOID Context
, struct _EPROCESS
*Process
, PVOID Address
)
1011 struct _EPROCESS
*Process
,
1017 MmInitializeRmapList(VOID
);
1021 MmSetCleanAllRmaps(PFN_TYPE Page
);
1025 MmSetDirtyAllRmaps(PFN_TYPE Page
);
1029 MmIsDirtyPageRmap(PFN_TYPE Page
);
1033 MmWritePagePhysicalAddress(PFN_TYPE Page
);
1037 MmPageOutPhysicalAddress(PFN_TYPE Page
);
1039 /* freelist.c **********************************************************/
1041 #define ASSERT_PFN(x) ASSERT((x)->u3.e1.CacheAttribute != 0)
1045 MiGetPfnEntry(IN PFN_TYPE Pfn
)
1048 extern RTL_BITMAP MiPfnBitMap
;
1050 /* Make sure the PFN number is valid */
1051 if (Pfn
> MmHighestPhysicalPage
) return NULL
;
1053 /* Make sure this page actually has a PFN entry */
1054 if ((MiPfnBitMap
.Buffer
) && !(RtlTestBit(&MiPfnBitMap
, Pfn
))) return NULL
;
1057 Page
= &MmPfnDatabase
[Pfn
];
1059 /* Make sure it's valid */
1068 MiGetPfnEntryIndex(IN PMMPFN Pfn1
)
1071 // This will return the Page Frame Number (PFN) from the MMPFN
1073 return Pfn1
- MmPfnDatabase
;
1078 MmGetLRUNextUserPage(PFN_TYPE PreviousPage
);
1082 MmGetLRUFirstUserPage(VOID
);
1086 MmInsertLRULastUserPage(PFN_TYPE Page
);
1090 MmRemoveLRUUserPage(PFN_TYPE Page
);
1094 MmLockPage(PFN_TYPE Page
);
1098 MmLockPageUnsafe(PFN_TYPE Page
);
1102 MmUnlockPage(PFN_TYPE Page
);
1106 MmGetLockCountPage(PFN_TYPE Page
);
1112 MmAcquirePageListLock()
1114 return KeAcquireQueuedSpinLock(LockQueuePfnLock
);
1120 MmReleasePageListLock(KIRQL oldIrql
)
1122 KeReleaseQueuedSpinLock(LockQueuePfnLock
, oldIrql
);
1127 MmInitializePageList(
1139 MmGetContinuousPages(
1140 ULONG NumberOfBytes
,
1141 PHYSICAL_ADDRESS LowestAcceptableAddress
,
1142 PHYSICAL_ADDRESS HighestAcceptableAddress
,
1143 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1149 MmZeroPageThreadMain(
1153 /* hypermap.c *****************************************************************/
1155 extern PEPROCESS HyperProcess
;
1156 extern KIRQL HyperIrql
;
1160 MiMapPageInHyperSpace(IN PEPROCESS Process
,
1166 MiUnmapPageInHyperSpace(IN PEPROCESS Process
,
1172 MiMapPagesToZeroInHyperSpace(IN PMMPFN
*Pages
,
1173 IN PFN_NUMBER NumberOfPages
);
1177 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress
,
1178 IN PFN_NUMBER NumberOfPages
);
1181 // ReactOS Compatibility Layer
1185 MmCreateHyperspaceMapping(IN PFN_NUMBER Page
)
1187 HyperProcess
= (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;
1188 return MiMapPageInHyperSpace(HyperProcess
, Page
, &HyperIrql
);
1193 MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page
)
1195 PMMPFN Pfn1
= MiGetPfnEntry(Page
);
1196 return MiMapPagesToZeroInHyperSpace(&Pfn1
, 1);
1199 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1201 /* i386/page.c *********************************************************/
1205 MmCreateVirtualMappingForKernel(
1214 MmCommitPagedPoolAddress(
1221 MmCreateVirtualMapping(
1222 struct _EPROCESS
* Process
,
1231 MmCreateVirtualMappingUnsafe(
1232 struct _EPROCESS
* Process
,
1242 struct _EPROCESS
* Process
,
1248 struct _EPROCESS
* Process
,
1256 struct _EPROCESS
* Process
,
1262 MmInitGlobalKernelPageDirectory(VOID
);
1266 MmDisableVirtualMapping(
1267 struct _EPROCESS
*Process
,
1275 MmEnableVirtualMapping(
1276 struct _EPROCESS
*Process
,
1282 MmRawDeleteVirtualMapping(PVOID Address
);
1286 MmDeletePageFileMapping(
1287 struct _EPROCESS
*Process
,
1289 SWAPENTRY
* SwapEntry
1294 MmCreatePageFileMapping(
1295 struct _EPROCESS
*Process
,
1303 struct _EPROCESS
*Process
,
1309 MmTransferOwnershipPage(
1317 struct _EPROCESS
*Process
,
1325 SWAPENTRY SavedSwapEntry
1330 MmAllocPagesSpecifyRange(
1332 PHYSICAL_ADDRESS LowestAddress
,
1333 PHYSICAL_ADDRESS HighestAddress
,
1334 ULONG NumberOfPages
,
1340 MmDereferencePage(PFN_TYPE Page
);
1344 MmReferencePage(PFN_TYPE Page
);
1348 MmReferencePageUnsafe(PFN_TYPE Page
);
1352 MmGetReferenceCountPage(PFN_TYPE Page
);
1356 MmIsPageInUse(PFN_TYPE Page
);
1360 MmSetSavedSwapEntryPage(
1362 SWAPENTRY SavedSwapEntry
);
1366 MmGetSavedSwapEntryPage(PFN_TYPE Page
);
1371 struct _EPROCESS
*Process
,
1377 MmCreatePageTable(PVOID PAddress
);
1382 struct _EPROCESS
*Process
,
1389 struct _EPROCESS
*Process
,
1395 MmCreateProcessAddressSpace(
1398 IN PULONG_PTR DirectoryTableBase
1403 MmInitializeHandBuiltProcess(
1404 IN PEPROCESS Process
,
1405 IN PULONG_PTR DirectoryTableBase
1411 MmInitializeHandBuiltProcess2(
1412 IN PEPROCESS Process
1417 MmReleaseMmInfo(struct _EPROCESS
*Process
);
1421 Mmi386ReleaseMmInfo(struct _EPROCESS
*Process
);
1425 MmDeleteVirtualMapping(
1426 struct _EPROCESS
*Process
,
1436 struct _EPROCESS
*Process
,
1442 MmMarkPageMapped(PFN_TYPE Page
);
1446 MmMarkPageUnmapped(PFN_TYPE Page
);
1451 struct _EPROCESS
*Process
,
1458 MiInitPageDirectoryMap(VOID
);
1462 MiGetUserPageDirectoryCount(VOID
);
1464 /* wset.c ********************************************************************/
1473 /* region.c ************************************************************/
1478 PMMSUPPORT AddressSpace
,
1480 PLIST_ENTRY RegionListHead
,
1485 PMM_ALTER_REGION_FUNC AlterFunc
1491 PLIST_ENTRY RegionListHead
,
1501 PLIST_ENTRY RegionListHead
,
1503 PVOID
* RegionBaseAddress
1506 /* section.c *****************************************************************/
1510 MmGetFileObjectForSection(
1511 IN PROS_SECTION_OBJECT Section
1515 MmGetFileNameForAddress(
1517 OUT PUNICODE_STRING ModuleName
1522 MmGetFileNameForSection(
1523 IN PROS_SECTION_OBJECT Section
,
1524 OUT POBJECT_NAME_INFORMATION
*ModuleName
1537 PMEMORY_AREA MemoryArea
,
1539 PMEMORY_BASIC_INFORMATION Info
,
1540 PSIZE_T ResultLength
1545 MmProtectSectionView(
1546 PMMSUPPORT AddressSpace
,
1547 PMEMORY_AREA MemoryArea
,
1556 MmWritePageSectionView(
1557 PMMSUPPORT AddressSpace
,
1565 MmInitSectionImplementation(VOID
);
1569 MmNotPresentFaultSectionView(
1570 PMMSUPPORT AddressSpace
,
1571 MEMORY_AREA
* MemoryArea
,
1578 MmPageOutSectionView(
1579 PMMSUPPORT AddressSpace
,
1580 PMEMORY_AREA MemoryArea
,
1582 struct _MM_PAGEOP
*PageOp
1587 MmCreatePhysicalMemorySection(VOID
);
1591 MmAccessFaultSectionView(
1592 PMMSUPPORT AddressSpace
,
1593 MEMORY_AREA
* MemoryArea
,
1600 MmFreeSectionSegments(PFILE_OBJECT FileObject
);
1602 /* mpw.c *********************************************************************/
1606 MmInitMpwThread(VOID
);
1610 MmInitBsmThread(VOID
);
1612 /* pager.c *******************************************************************/
1616 MiIsPagerThread(VOID
);
1620 MiStartPagerThread(VOID
);
1624 MiStopPagerThread(VOID
);
1628 MiQueryVirtualMemory(
1629 IN HANDLE ProcessHandle
,
1631 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass
,
1632 OUT PVOID VirtualMemoryInformation
,
1634 OUT PSIZE_T ResultLength
1637 /* sysldr.c ******************************************************************/
1641 MiReloadBootLoadedDrivers(
1642 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1647 MiInitializeLoadedModuleList(
1648 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1654 IN PUNICODE_STRING FileName
,
1655 IN PUNICODE_STRING NamePrefix OPTIONAL
,
1656 IN PUNICODE_STRING LoadedName OPTIONAL
,
1658 OUT PVOID
*ModuleObject
,
1659 OUT PVOID
*ImageBaseAddress
1664 MmUnloadSystemImage(
1665 IN PVOID ImageHandle
1671 IN HANDLE ImageHandle
,
1672 IN BOOLEAN PurgeSection
1677 MmCallDllInitialize(
1678 IN PLDR_DATA_TABLE_ENTRY LdrEntry
,
1679 IN PLIST_ENTRY ListHead
1682 /* ReactOS Mm Hacks */
1685 MiSyncForProcessAttach(
1686 IN PKTHREAD NextThread
,
1687 IN PEPROCESS Process
1692 MiSyncForContextSwitch(
1696 extern PMMSUPPORT MmKernelAddressSpace
;
1700 MmLockAddressSpace(PMMSUPPORT AddressSpace
)
1702 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1707 MmUnlockAddressSpace(PMMSUPPORT AddressSpace
)
1709 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1714 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace
)
1716 if (AddressSpace
== MmKernelAddressSpace
) return NULL
;
1717 return CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
);
1722 MmGetCurrentAddressSpace(VOID
)
1724 return &((PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
)->Vm
;
1729 MmGetKernelAddressSpace(VOID
)
1731 return MmKernelAddressSpace
;