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
;
19 extern ULONG MmAvailablePages
;
21 extern PVOID MmPagedPoolBase
;
22 extern ULONG MmPagedPoolSize
;
24 extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor
;
25 extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg
;
29 struct _MM_RMAP_ENTRY
;
31 typedef ULONG SWAPENTRY
;
32 typedef ULONG PFN_TYPE
, *PPFN_TYPE
;
35 //MmDbgCopyMemory Flags
37 #define MMDBG_COPY_WRITE 0x00000001
38 #define MMDBG_COPY_PHYSICAL 0x00000002
39 #define MMDBG_COPY_UNSAFE 0x00000004
40 #define MMDBG_COPY_CACHED 0x00000008
41 #define MMDBG_COPY_UNCACHED 0x00000010
42 #define MMDBG_COPY_WRITE_COMBINED 0x00000020
45 // Maximum chunk size per copy
47 #define MMDBG_COPY_MAX_SIZE 0x8
50 #define MI_STATIC_MEMORY_AREAS (12)
52 #define MEMORY_AREA_INVALID (0)
53 #define MEMORY_AREA_SECTION_VIEW (1)
54 #define MEMORY_AREA_CONTINUOUS_MEMORY (2)
55 #define MEMORY_AREA_NO_CACHE (3)
56 #define MEMORY_AREA_IO_MAPPING (4)
57 #define MEMORY_AREA_SYSTEM (5)
58 #define MEMORY_AREA_MDL_MAPPING (7)
59 #define MEMORY_AREA_VIRTUAL_MEMORY (8)
60 #define MEMORY_AREA_CACHE_SEGMENT (9)
61 #define MEMORY_AREA_SHARED_DATA (10)
62 #define MEMORY_AREA_KERNEL_STACK (11)
63 #define MEMORY_AREA_PAGED_POOL (12)
64 #define MEMORY_AREA_NO_ACCESS (13)
65 #define MEMORY_AREA_PEB_OR_TEB (14)
66 #define MEMORY_AREA_OWNED_BY_ARM3 (15)
67 #define MEMORY_AREA_STATIC (0x80000000)
69 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
71 #define MM_CORE_DUMP_TYPE_NONE (0x0)
72 #define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
73 #define MM_CORE_DUMP_TYPE_FULL (0x2)
75 #define MM_PAGEOP_PAGEIN (1)
76 #define MM_PAGEOP_PAGEOUT (2)
77 #define MM_PAGEOP_PAGESYNCH (3)
78 #define MM_PAGEOP_ACCESSFAULT (4)
80 /* Number of list heads to use */
81 #define MI_FREE_POOL_LISTS 4
83 #define MI_HYPERSPACE_PTES (256 - 1)
84 #define MI_ZERO_PTES (32)
85 #define MI_MAPPING_RANGE_START (ULONG)HYPER_SPACE
86 #define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \
87 MI_HYPERSPACE_PTES * PAGE_SIZE)
88 #define MI_ZERO_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \
91 /* Signature of free pool blocks */
92 #define MM_FREE_POOL_TAG 'lprF'
94 #define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
97 #define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \
98 ((((x)) % (4*1024*1024)) / (4*1024))
100 #define NR_SECTION_PAGE_TABLES 1024
101 #define NR_SECTION_PAGE_ENTRIES 1024
103 #define TEB_BASE 0x7FFDE000
105 /* Although Microsoft says this isn't hardcoded anymore,
106 they won't be able to change it. Stuff depends on it */
107 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
109 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
112 * Additional flags for protection attributes
114 #define PAGE_WRITETHROUGH (1024)
115 #define PAGE_SYSTEM (2048)
117 #define SEC_PHYSICALMEMORY (0x80000000)
119 #define MM_PAGEFILE_SEGMENT (0x1)
120 #define MM_DATAFILE_SEGMENT (0x2)
125 #define MC_NPPOOL (3)
126 #define MC_SYSTEM (4)
127 #define MC_MAXIMUM (5)
129 #define PAGED_POOL_MASK 1
130 #define MUST_SUCCEED_POOL_MASK 2
131 #define CACHE_ALIGNED_POOL_MASK 4
132 #define QUOTA_POOL_MASK 8
133 #define SESSION_POOL_MASK 32
134 #define VERIFIER_POOL_MASK 64
136 #define MM_PAGED_POOL_SIZE (100*1024*1024)
137 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
140 * Paged and non-paged pools are 8-byte aligned
142 #define MM_POOL_ALIGNMENT 8
145 * Maximum size of the kmalloc area (this is totally arbitary)
147 #define MM_KERNEL_MAP_SIZE (16*1024*1024)
148 #define MM_KERNEL_MAP_BASE (0xf0c00000)
151 * FIXME - different architectures have different cache line sizes...
153 #define MM_CACHE_LINE_SIZE 32
155 #define MM_ROUND_UP(x,s) \
156 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
158 #define MM_ROUND_DOWN(x,s) \
159 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
161 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
166 PAGE_EXECUTE_READ | \
167 PAGE_EXECUTE_READWRITE | \
168 PAGE_EXECUTE_WRITECOPY | \
173 #define PAGE_FLAGS_VALID_FOR_SECTION \
178 PAGE_EXECUTE_READ | \
179 PAGE_EXECUTE_READWRITE | \
180 PAGE_EXECUTE_WRITECOPY | \
183 #define PAGE_IS_READABLE \
187 PAGE_EXECUTE_READ | \
188 PAGE_EXECUTE_READWRITE | \
189 PAGE_EXECUTE_WRITECOPY)
191 #define PAGE_IS_WRITABLE \
194 PAGE_EXECUTE_READWRITE | \
195 PAGE_EXECUTE_WRITECOPY)
197 #define PAGE_IS_EXECUTABLE \
199 PAGE_EXECUTE_READ | \
200 PAGE_EXECUTE_READWRITE | \
201 PAGE_EXECUTE_WRITECOPY)
203 #define PAGE_IS_WRITECOPY \
205 PAGE_EXECUTE_WRITECOPY)
208 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
209 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
211 #define InterlockedExchangePte(PointerPte, Value) \
212 InterlockedExchange((PLONG)(PointerPte), Value)
216 ULONG Entry
[NR_SECTION_PAGE_ENTRIES
];
217 } SECTION_PAGE_TABLE
, *PSECTION_PAGE_TABLE
;
221 PSECTION_PAGE_TABLE PageTables
[NR_SECTION_PAGE_TABLES
];
222 } SECTION_PAGE_DIRECTORY
, *PSECTION_PAGE_DIRECTORY
;
224 typedef struct _MM_SECTION_SEGMENT
226 LONG FileOffset
; /* start offset into the file for image sections */
227 ULONG_PTR VirtualAddress
; /* dtart offset into the address range for image sections */
228 ULONG RawLength
; /* length of the segment which is part of the mapped file */
229 ULONG Length
; /* absolute length of the segment */
231 FAST_MUTEX Lock
; /* lock which protects the page directory */
232 ULONG ReferenceCount
;
233 SECTION_PAGE_DIRECTORY PageDirectory
;
235 ULONG Characteristics
;
237 } MM_SECTION_SEGMENT
, *PMM_SECTION_SEGMENT
;
239 typedef struct _MM_IMAGE_SECTION_OBJECT
242 ULONG_PTR StackReserve
;
243 ULONG_PTR StackCommit
;
244 ULONG_PTR EntryPoint
;
246 USHORT ImageCharacteristics
;
247 USHORT MinorSubsystemVersion
;
248 USHORT MajorSubsystemVersion
;
253 PMM_SECTION_SEGMENT Segments
;
254 } MM_IMAGE_SECTION_OBJECT
, *PMM_IMAGE_SECTION_OBJECT
;
256 typedef struct _ROS_SECTION_OBJECT
260 LARGE_INTEGER MaximumSize
;
261 ULONG SectionPageProtection
;
262 ULONG AllocationAttributes
;
263 PFILE_OBJECT FileObject
;
266 PMM_IMAGE_SECTION_OBJECT ImageSection
;
267 PMM_SECTION_SEGMENT Segment
;
269 } ROS_SECTION_OBJECT
, *PROS_SECTION_OBJECT
;
271 typedef struct _MEMORY_AREA
273 PVOID StartingAddress
;
275 struct _MEMORY_AREA
*Parent
;
276 struct _MEMORY_AREA
*LeftChild
;
277 struct _MEMORY_AREA
*RightChild
;
281 BOOLEAN DeleteInProgress
;
287 ROS_SECTION_OBJECT
* Section
;
289 PMM_SECTION_SEGMENT Segment
;
290 BOOLEAN WriteCopyView
;
291 LIST_ENTRY RegionListHead
;
295 LIST_ENTRY RegionListHead
;
298 } MEMORY_AREA
, *PMEMORY_AREA
;
301 // These two mappings are actually used by Windows itself, based on the ASSERTS
303 #define StartOfAllocation ReadInProgress
304 #define EndOfAllocation WriteInProgress
306 typedef struct _MMPFNENTRY
309 USHORT ReadInProgress
:1; // StartOfAllocation
310 USHORT WriteInProgress
:1; // EndOfAllocation
311 USHORT PrototypePte
:1; // Zero
312 USHORT PageColor
:4; // LockCount
313 USHORT PageLocation
:3; // Consumer
314 USHORT RemovalRequested
:1;
315 USHORT CacheAttribute
:2; // Type
317 USHORT ParityError
:1;
320 typedef struct _MMPFN
324 PFN_NUMBER Flink
; // ListEntry.Flink
328 SINGLE_LIST_ENTRY NextStackPfn
;
330 PMMPTE PteAddress
; // ListEntry.Blink
334 ULONG_PTR ShareCount
; // MapCount
340 USHORT ReferenceCount
; // ReferenceCount
345 USHORT ReferenceCount
;
352 LONG AweReferenceCount
; // RmapListHead
356 ULONG_PTR EntireFrame
; // SavedSwapEntry
359 ULONG_PTR PteFrame
:25;
360 ULONG_PTR InPageError
:1;
361 ULONG_PTR VerifierAllocation
:1;
362 ULONG_PTR AweAllocation
:1;
363 ULONG_PTR Priority
:3;
364 ULONG_PTR MustBeCached
:1;
369 extern PMMPFN MmPfnDatabase
;
371 typedef struct _MM_PAGEOP
373 /* Type of operation. */
375 /* Number of threads interested in this operation. */
376 ULONG ReferenceCount
;
377 /* Event that will be set when the operation is completed. */
378 KEVENT CompletionEvent
;
379 /* Status of the operation once it is completed. */
381 /* TRUE if the operation was abandoned. */
383 /* The memory area to be affected by the operation. */
386 struct _MM_PAGEOP
* Next
;
387 struct _ETHREAD
* Thread
;
389 * These fields are used to identify the operation if it is against a
390 * virtual memory area.
395 * These fields are used to identify the operation if it is against a
398 PMM_SECTION_SEGMENT Segment
;
400 } MM_PAGEOP
, *PMM_PAGEOP
;
402 typedef struct _MM_MEMORY_CONSUMER
406 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
);
407 } MM_MEMORY_CONSUMER
, *PMM_MEMORY_CONSUMER
;
409 typedef struct _MM_REGION
414 LIST_ENTRY RegionListEntry
;
415 } MM_REGION
, *PMM_REGION
;
417 /* Entry describing free pool memory */
418 typedef struct _MMFREE_POOL_ENTRY
423 struct _MMFREE_POOL_ENTRY
*Owner
;
424 } MMFREE_POOL_ENTRY
, *PMMFREE_POOL_ENTRY
;
426 /* Paged pool information */
427 typedef struct _MM_PAGED_POOL_INFO
429 PRTL_BITMAP PagedPoolAllocationMap
;
430 PRTL_BITMAP EndOfPagedPoolBitmap
;
431 PMMPTE FirstPteForPagedPool
;
432 PMMPTE LastPteForPagedPool
;
433 PMMPTE NextPdeForPagedPoolExpansion
;
435 SIZE_T PagedPoolCommit
;
436 SIZE_T AllocatedPagedPool
;
437 } MM_PAGED_POOL_INFO
, *PMM_PAGED_POOL_INFO
;
439 extern MM_MEMORY_CONSUMER MiMemoryConsumers
[MC_MAXIMUM
];
442 (*PMM_ALTER_REGION_FUNC
)(
443 PMMSUPPORT AddressSpace
,
453 (*PMM_FREE_PAGE_FUNC
)(
455 PMEMORY_AREA MemoryArea
,
463 // Mm copy support for Kd
474 /* marea.c *******************************************************************/
479 PMMSUPPORT AddressSpace
,
484 PMEMORY_AREA
*Result
,
485 BOOLEAN FixedAddress
,
486 ULONG AllocationFlags
,
487 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
492 MmLocateMemoryAreaByAddress(
493 PMMSUPPORT AddressSpace
,
500 PMMSUPPORT AddressSpace
,
507 PMMSUPPORT AddressSpace
,
508 PMEMORY_AREA MemoryArea
,
509 PMM_FREE_PAGE_FUNC FreePage
,
510 PVOID FreePageContext
515 MmFreeMemoryAreaByPtr(
516 PMMSUPPORT AddressSpace
,
518 PMM_FREE_PAGE_FUNC FreePage
,
519 PVOID FreePageContext
524 MmDumpMemoryAreas(PMMSUPPORT AddressSpace
);
528 MmLocateMemoryAreaByRegion(
529 PMMSUPPORT AddressSpace
,
537 PMMSUPPORT AddressSpace
,
539 ULONG_PTR Granularity
,
545 MmReleaseMemoryAreaIfDecommitted(
546 struct _EPROCESS
*Process
,
547 PMMSUPPORT AddressSpace
,
553 MmMapMemoryArea(PVOID BaseAddress
,
558 /* npool.c *******************************************************************/
562 MiDebugDumpNonPagedPool(BOOLEAN NewOnly
);
566 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly
);
570 MiInitializeNonPagedPool(VOID
);
575 IN POOL_TYPE PoolType
,
576 IN SIZE_T SizeInBytes
582 IN PVOID VirtualAddress
588 IN PVOID StartingAddress
598 /* pool.c *******************************************************************/
602 ExAllocateNonPagedPoolWithTag(
611 ExAllocatePagedPoolWithTag(
619 ExFreeNonPagedPool(PVOID block
);
623 ExFreePagedPool(IN PVOID Block
);
627 ExpIsPoolTagDebuggable(ULONG Tag
);
631 ExpAllocateDebugPool(
641 ExpFreeDebugPool(PVOID Block
, BOOLEAN PagedPool
);
645 MmInitializePagedPool(VOID
);
649 MiAllocateSpecialPool(
650 IN POOL_TYPE PoolType
,
651 IN SIZE_T NumberOfBytes
,
659 IN POOL_TYPE PoolType
,
660 IN ULONG CurrentMaxQuota
,
661 OUT PULONG NewMaxQuota
664 /* mdl.c *********************************************************************/
673 /* mminit.c ******************************************************************/
677 MiShutdownMemoryManager(VOID
);
687 MmInitSystem(IN ULONG Phase
,
688 IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
692 MiFreeInitMemory(VOID
);
696 MmInitializeMdlImplementation(VOID
);
698 /* pagefile.c ****************************************************************/
702 MmAllocSwapPage(VOID
);
706 MmDereserveSwapPages(ULONG Nr
);
710 MmFreeSwapPage(SWAPENTRY Entry
);
714 MmInitPagingFile(VOID
);
725 MmReserveSwapPages(ULONG Nr
);
738 ULONG BugCodeParameter1
,
739 ULONG BugCodeParameter2
,
740 ULONG BugCodeParameter3
,
741 ULONG BugCodeParameter4
,
742 struct _KTRAP_FRAME
* TrapFrame
747 MmIsAvailableSwapPage(VOID
);
751 MmShowOutOfSpaceMessagePagingFile(VOID
);
753 /* process.c ****************************************************************/
757 MmInitializeProcessAddressSpace(
758 IN PEPROCESS Process
,
759 IN PEPROCESS Clone OPTIONAL
,
760 IN PVOID Section OPTIONAL
,
762 IN POBJECT_NAME_INFORMATION
*AuditName OPTIONAL
768 IN PEPROCESS Process
,
769 IN PINITIAL_PEB InitialPeb
,
776 IN PEPROCESS Process
,
777 IN PCLIENT_ID ClientId
,
778 IN PINITIAL_TEB InitialTeb
,
785 struct _EPROCESS
*Process
,
791 MmCleanProcessAddressSpace(IN PEPROCESS Process
);
795 MmDeleteProcessAddressSpace(IN PEPROCESS Process
);
799 MmGetSessionLocaleId(VOID
);
803 MmSetMemoryPriorityProcess(
804 IN PEPROCESS Process
,
805 IN UCHAR MemoryPriority
808 /* i386/pfault.c *************************************************************/
820 /* mm.c **********************************************************************/
825 IN BOOLEAN StoreInstruction
,
827 IN KPROCESSOR_MODE Mode
,
828 IN PVOID TrapInformation
831 /* anonmem.c *****************************************************************/
835 MmNotPresentFaultVirtualMemory(
836 PMMSUPPORT AddressSpace
,
837 MEMORY_AREA
* MemoryArea
,
844 MmPageOutVirtualMemory(
845 PMMSUPPORT AddressSpace
,
846 PMEMORY_AREA MemoryArea
,
848 struct _MM_PAGEOP
* PageOp
854 PMEMORY_AREA MemoryArea
,
856 PMEMORY_BASIC_INFORMATION Info
,
863 struct _EPROCESS
* Process
,
864 PMEMORY_AREA MemoryArea
870 PMMSUPPORT AddressSpace
,
871 PMEMORY_AREA MemoryArea
,
880 MmWritePageVirtualMemory(
881 PMMSUPPORT AddressSpace
,
887 /* kmap.c ********************************************************************/
891 ExAllocatePage(VOID
);
895 ExUnmapPage(PVOID Addr
);
899 ExAllocatePageWithPhysPage(PFN_TYPE Page
);
910 MiZeroPage(PFN_TYPE Page
);
912 /* memsafe.s *****************************************************************/
916 MmSafeReadPtr(PVOID Source
);
918 /* pageop.c ******************************************************************/
922 MmReleasePageOp(PMM_PAGEOP PageOp
);
930 PMM_SECTION_SEGMENT Segment
,
942 PMM_SECTION_SEGMENT Segment
,
948 MmInitializePageOp(VOID
);
950 /* process.c *****************************************************************/
954 MmCreateKernelStack(BOOLEAN GuiStack
, UCHAR Node
);
958 MmDeleteKernelStack(PVOID Stack
,
961 /* balace.c ******************************************************************/
965 MmInitializeMemoryConsumer(
967 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
)
972 MmInitializeBalancer(
973 ULONG NrAvailablePages
,
979 MmReleasePageMemoryConsumer(
986 MmRequestPageMemoryConsumer(
989 PPFN_TYPE AllocatedPage
994 MiInitBalancerThread(VOID
);
998 MmRebalanceMemoryConsumers(VOID
);
1000 /* rmap.c **************************************************************/
1004 MmSetRmapListHeadPage(
1006 struct _MM_RMAP_ENTRY
* ListHead
1009 struct _MM_RMAP_ENTRY
*
1011 MmGetRmapListHeadPage(PFN_TYPE Page
);
1017 struct _EPROCESS
*Process
,
1026 VOID (*DeleteMapping
)(PVOID Context
, struct _EPROCESS
*Process
, PVOID Address
)
1033 struct _EPROCESS
*Process
,
1039 MmInitializeRmapList(VOID
);
1043 MmSetCleanAllRmaps(PFN_TYPE Page
);
1047 MmSetDirtyAllRmaps(PFN_TYPE Page
);
1051 MmIsDirtyPageRmap(PFN_TYPE Page
);
1055 MmWritePagePhysicalAddress(PFN_TYPE Page
);
1059 MmPageOutPhysicalAddress(PFN_TYPE Page
);
1061 /* freelist.c **********************************************************/
1063 #define ASSERT_PFN(x) ASSERT((x)->u3.e1.CacheAttribute != 0)
1067 MiGetPfnEntry(IN PFN_TYPE Pfn
)
1070 extern RTL_BITMAP MiPfnBitMap
;
1072 /* Make sure the PFN number is valid */
1073 if (Pfn
> MmHighestPhysicalPage
) return NULL
;
1075 /* Make sure this page actually has a PFN entry */
1076 if ((MiPfnBitMap
.Buffer
) && !(RtlTestBit(&MiPfnBitMap
, Pfn
))) return NULL
;
1079 Page
= &MmPfnDatabase
[Pfn
];
1081 /* Make sure it's valid */
1090 MiGetPfnEntryIndex(IN PMMPFN Pfn1
)
1093 // This will return the Page Frame Number (PFN) from the MMPFN
1095 return Pfn1
- MmPfnDatabase
;
1100 MmGetLRUNextUserPage(PFN_TYPE PreviousPage
);
1104 MmGetLRUFirstUserPage(VOID
);
1108 MmInsertLRULastUserPage(PFN_TYPE Page
);
1112 MmRemoveLRUUserPage(PFN_TYPE Page
);
1116 MmLockPage(PFN_TYPE Page
);
1120 MmUnlockPage(PFN_TYPE Page
);
1124 MmGetLockCountPage(PFN_TYPE Page
);
1128 MmInitializePageList(
1140 MmGetContinuousPages(
1141 ULONG NumberOfBytes
,
1142 PHYSICAL_ADDRESS LowestAcceptableAddress
,
1143 PHYSICAL_ADDRESS HighestAcceptableAddress
,
1144 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1150 MmZeroPageThreadMain(
1154 /* hypermap.c *****************************************************************/
1156 extern PEPROCESS HyperProcess
;
1157 extern KIRQL HyperIrql
;
1161 MiMapPageInHyperSpace(IN PEPROCESS Process
,
1167 MiUnmapPageInHyperSpace(IN PEPROCESS Process
,
1173 MiMapPagesToZeroInHyperSpace(IN PMMPFN
*Pages
,
1174 IN PFN_NUMBER NumberOfPages
);
1178 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress
,
1179 IN PFN_NUMBER NumberOfPages
);
1182 // ReactOS Compatibility Layer
1186 MmCreateHyperspaceMapping(IN PFN_NUMBER Page
)
1188 HyperProcess
= (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;
1189 return MiMapPageInHyperSpace(HyperProcess
, Page
, &HyperIrql
);
1194 MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page
)
1196 PMMPFN Pfn1
= MiGetPfnEntry(Page
);
1197 return MiMapPagesToZeroInHyperSpace(&Pfn1
, 1);
1200 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1202 /* i386/page.c *********************************************************/
1206 MmCreateVirtualMappingForKernel(
1215 MmCommitPagedPoolAddress(
1222 MmCreateVirtualMapping(
1223 struct _EPROCESS
* Process
,
1232 MmCreateVirtualMappingUnsafe(
1233 struct _EPROCESS
* Process
,
1243 struct _EPROCESS
* Process
,
1249 struct _EPROCESS
* Process
,
1257 struct _EPROCESS
* Process
,
1263 MmInitGlobalKernelPageDirectory(VOID
);
1267 MmDisableVirtualMapping(
1268 struct _EPROCESS
*Process
,
1276 MmEnableVirtualMapping(
1277 struct _EPROCESS
*Process
,
1283 MmRawDeleteVirtualMapping(PVOID Address
);
1287 MmDeletePageFileMapping(
1288 struct _EPROCESS
*Process
,
1290 SWAPENTRY
* SwapEntry
1295 MmCreatePageFileMapping(
1296 struct _EPROCESS
*Process
,
1304 struct _EPROCESS
*Process
,
1310 MmTransferOwnershipPage(
1318 struct _EPROCESS
*Process
,
1326 SWAPENTRY SavedSwapEntry
1331 MmAllocPagesSpecifyRange(
1333 PHYSICAL_ADDRESS LowestAddress
,
1334 PHYSICAL_ADDRESS HighestAddress
,
1335 ULONG NumberOfPages
,
1341 MmDereferencePage(PFN_TYPE Page
);
1345 MmReferencePage(PFN_TYPE Page
);
1349 MmGetReferenceCountPage(PFN_TYPE Page
);
1353 MmIsPageInUse(PFN_TYPE Page
);
1357 MmSetSavedSwapEntryPage(
1359 SWAPENTRY SavedSwapEntry
);
1363 MmGetSavedSwapEntryPage(PFN_TYPE Page
);
1368 struct _EPROCESS
*Process
,
1374 MmCreatePageTable(PVOID PAddress
);
1379 struct _EPROCESS
*Process
,
1386 struct _EPROCESS
*Process
,
1392 MmCreateProcessAddressSpace(
1395 IN PULONG DirectoryTableBase
1400 MmInitializeHandBuiltProcess(
1401 IN PEPROCESS Process
,
1402 IN PULONG DirectoryTableBase
1408 MmInitializeHandBuiltProcess2(
1409 IN PEPROCESS Process
1414 MmReleaseMmInfo(struct _EPROCESS
*Process
);
1418 Mmi386ReleaseMmInfo(struct _EPROCESS
*Process
);
1422 MmDeleteVirtualMapping(
1423 struct _EPROCESS
*Process
,
1433 struct _EPROCESS
*Process
,
1439 MmMarkPageMapped(PFN_TYPE Page
);
1443 MmMarkPageUnmapped(PFN_TYPE Page
);
1448 struct _EPROCESS
*Process
,
1455 MiInitPageDirectoryMap(VOID
);
1459 MiGetUserPageDirectoryCount(VOID
);
1461 /* wset.c ********************************************************************/
1470 /* region.c ************************************************************/
1475 PMMSUPPORT AddressSpace
,
1477 PLIST_ENTRY RegionListHead
,
1482 PMM_ALTER_REGION_FUNC AlterFunc
1488 PLIST_ENTRY RegionListHead
,
1498 PLIST_ENTRY RegionListHead
,
1500 PVOID
* RegionBaseAddress
1503 /* section.c *****************************************************************/
1507 MmGetFileObjectForSection(
1508 IN PROS_SECTION_OBJECT Section
1512 MmGetFileNameForAddress(
1514 OUT PUNICODE_STRING ModuleName
1519 MmGetFileNameForSection(
1520 IN PROS_SECTION_OBJECT Section
,
1521 OUT POBJECT_NAME_INFORMATION
*ModuleName
1534 PMEMORY_AREA MemoryArea
,
1536 PMEMORY_BASIC_INFORMATION Info
,
1542 MmProtectSectionView(
1543 PMMSUPPORT AddressSpace
,
1544 PMEMORY_AREA MemoryArea
,
1553 MmWritePageSectionView(
1554 PMMSUPPORT AddressSpace
,
1562 MmInitSectionImplementation(VOID
);
1566 MmNotPresentFaultSectionView(
1567 PMMSUPPORT AddressSpace
,
1568 MEMORY_AREA
* MemoryArea
,
1575 MmPageOutSectionView(
1576 PMMSUPPORT AddressSpace
,
1577 PMEMORY_AREA MemoryArea
,
1579 struct _MM_PAGEOP
*PageOp
1584 MmCreatePhysicalMemorySection(VOID
);
1588 MmAccessFaultSectionView(
1589 PMMSUPPORT AddressSpace
,
1590 MEMORY_AREA
* MemoryArea
,
1597 MmFreeSectionSegments(PFILE_OBJECT FileObject
);
1599 /* mpw.c *********************************************************************/
1603 MmInitMpwThread(VOID
);
1607 MmInitBsmThread(VOID
);
1609 /* pager.c *******************************************************************/
1613 MiIsPagerThread(VOID
);
1617 MiStartPagerThread(VOID
);
1621 MiStopPagerThread(VOID
);
1625 MiQueryVirtualMemory(
1626 IN HANDLE ProcessHandle
,
1628 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass
,
1629 OUT PVOID VirtualMemoryInformation
,
1631 OUT PULONG ResultLength
1634 /* sysldr.c ******************************************************************/
1638 MiReloadBootLoadedDrivers(
1639 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1644 MiInitializeLoadedModuleList(
1645 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1651 IN PUNICODE_STRING FileName
,
1652 IN PUNICODE_STRING NamePrefix OPTIONAL
,
1653 IN PUNICODE_STRING LoadedName OPTIONAL
,
1655 OUT PVOID
*ModuleObject
,
1656 OUT PVOID
*ImageBaseAddress
1661 MmUnloadSystemImage(
1662 IN PVOID ImageHandle
1668 IN HANDLE ImageHandle
,
1669 IN BOOLEAN PurgeSection
1674 MmCallDllInitialize(
1675 IN PLDR_DATA_TABLE_ENTRY LdrEntry
,
1676 IN PLIST_ENTRY ListHead
1679 /* ReactOS Mm Hacks */
1682 MiSyncForProcessAttach(
1683 IN PKTHREAD NextThread
,
1684 IN PEPROCESS Process
1689 MiSyncForContextSwitch(
1693 extern PMMSUPPORT MmKernelAddressSpace
;
1697 MmLockAddressSpace(PMMSUPPORT AddressSpace
)
1699 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1704 MmUnlockAddressSpace(PMMSUPPORT AddressSpace
)
1706 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1711 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace
)
1713 if (AddressSpace
== MmKernelAddressSpace
) return NULL
;
1714 return CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
);
1719 MmGetCurrentAddressSpace(VOID
)
1721 return &((PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
)->Vm
;
1726 MmGetKernelAddressSpace(VOID
)
1728 return MmKernelAddressSpace
;