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 (8)
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_STATIC (0x80000000)
67 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
69 #define MM_CORE_DUMP_TYPE_NONE (0x0)
70 #define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
71 #define MM_CORE_DUMP_TYPE_FULL (0x2)
73 #define MM_PAGEOP_PAGEIN (1)
74 #define MM_PAGEOP_PAGEOUT (2)
75 #define MM_PAGEOP_PAGESYNCH (3)
76 #define MM_PAGEOP_ACCESSFAULT (4)
78 /* Number of list heads to use */
79 #define MI_FREE_POOL_LISTS 4
81 #define MI_HYPERSPACE_PTES (256 - 1)
82 #define MI_ZERO_PTES (32)
83 #define MI_MAPPING_RANGE_START (ULONG)HYPER_SPACE
84 #define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \
85 MI_HYPERSPACE_PTES * PAGE_SIZE)
86 #define MI_ZERO_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \
89 /* Signature of free pool blocks */
90 #define MM_FREE_POOL_TAG 'lprF'
92 #define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
95 #define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \
96 ((((x)) % (4*1024*1024)) / (4*1024))
98 #define NR_SECTION_PAGE_TABLES 1024
99 #define NR_SECTION_PAGE_ENTRIES 1024
101 #define TEB_BASE 0x7FFDE000
103 /* Although Microsoft says this isn't hardcoded anymore,
104 they won't be able to change it. Stuff depends on it */
105 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
107 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
110 * Additional flags for protection attributes
112 #define PAGE_WRITETHROUGH (1024)
113 #define PAGE_SYSTEM (2048)
115 #define SEC_PHYSICALMEMORY (0x80000000)
117 #define MM_PAGEFILE_SEGMENT (0x1)
118 #define MM_DATAFILE_SEGMENT (0x2)
123 #define MC_NPPOOL (3)
124 #define MC_SYSTEM (4)
125 #define MC_MAXIMUM (5)
127 #define PAGED_POOL_MASK 1
128 #define MUST_SUCCEED_POOL_MASK 2
129 #define CACHE_ALIGNED_POOL_MASK 4
130 #define QUOTA_POOL_MASK 8
131 #define SESSION_POOL_MASK 32
132 #define VERIFIER_POOL_MASK 64
134 #define MM_PAGED_POOL_SIZE (100*1024*1024)
135 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
138 * Paged and non-paged pools are 8-byte aligned
140 #define MM_POOL_ALIGNMENT 8
143 * Maximum size of the kmalloc area (this is totally arbitary)
145 #define MM_KERNEL_MAP_SIZE (16*1024*1024)
146 #define MM_KERNEL_MAP_BASE (0xf0c00000)
149 * FIXME - different architectures have different cache line sizes...
151 #define MM_CACHE_LINE_SIZE 32
153 #define MM_ROUND_UP(x,s) \
154 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
156 #define MM_ROUND_DOWN(x,s) \
157 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
159 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
164 PAGE_EXECUTE_READ | \
165 PAGE_EXECUTE_READWRITE | \
166 PAGE_EXECUTE_WRITECOPY | \
171 #define PAGE_FLAGS_VALID_FOR_SECTION \
176 PAGE_EXECUTE_READ | \
177 PAGE_EXECUTE_READWRITE | \
178 PAGE_EXECUTE_WRITECOPY | \
181 #define PAGE_IS_READABLE \
185 PAGE_EXECUTE_READ | \
186 PAGE_EXECUTE_READWRITE | \
187 PAGE_EXECUTE_WRITECOPY)
189 #define PAGE_IS_WRITABLE \
192 PAGE_EXECUTE_READWRITE | \
193 PAGE_EXECUTE_WRITECOPY)
195 #define PAGE_IS_EXECUTABLE \
197 PAGE_EXECUTE_READ | \
198 PAGE_EXECUTE_READWRITE | \
199 PAGE_EXECUTE_WRITECOPY)
201 #define PAGE_IS_WRITECOPY \
203 PAGE_EXECUTE_WRITECOPY)
206 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
207 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
209 #define InterlockedExchangePte(PointerPte, Value) \
210 InterlockedExchange((PLONG)(PointerPte), Value)
214 ULONG Entry
[NR_SECTION_PAGE_ENTRIES
];
215 } SECTION_PAGE_TABLE
, *PSECTION_PAGE_TABLE
;
219 PSECTION_PAGE_TABLE PageTables
[NR_SECTION_PAGE_TABLES
];
220 } SECTION_PAGE_DIRECTORY
, *PSECTION_PAGE_DIRECTORY
;
222 typedef struct _MM_SECTION_SEGMENT
224 LONG FileOffset
; /* start offset into the file for image sections */
225 ULONG_PTR VirtualAddress
; /* dtart offset into the address range for image sections */
226 ULONG RawLength
; /* length of the segment which is part of the mapped file */
227 ULONG Length
; /* absolute length of the segment */
229 FAST_MUTEX Lock
; /* lock which protects the page directory */
230 ULONG ReferenceCount
;
231 SECTION_PAGE_DIRECTORY PageDirectory
;
233 ULONG Characteristics
;
235 } MM_SECTION_SEGMENT
, *PMM_SECTION_SEGMENT
;
237 typedef struct _MM_IMAGE_SECTION_OBJECT
240 ULONG_PTR StackReserve
;
241 ULONG_PTR StackCommit
;
242 ULONG_PTR EntryPoint
;
244 USHORT ImageCharacteristics
;
245 USHORT MinorSubsystemVersion
;
246 USHORT MajorSubsystemVersion
;
251 PMM_SECTION_SEGMENT Segments
;
252 } MM_IMAGE_SECTION_OBJECT
, *PMM_IMAGE_SECTION_OBJECT
;
254 typedef struct _ROS_SECTION_OBJECT
258 LARGE_INTEGER MaximumSize
;
259 ULONG SectionPageProtection
;
260 ULONG AllocationAttributes
;
261 PFILE_OBJECT FileObject
;
264 PMM_IMAGE_SECTION_OBJECT ImageSection
;
265 PMM_SECTION_SEGMENT Segment
;
267 } ROS_SECTION_OBJECT
, *PROS_SECTION_OBJECT
;
269 typedef struct _MEMORY_AREA
271 PVOID StartingAddress
;
273 struct _MEMORY_AREA
*Parent
;
274 struct _MEMORY_AREA
*LeftChild
;
275 struct _MEMORY_AREA
*RightChild
;
279 BOOLEAN DeleteInProgress
;
285 ROS_SECTION_OBJECT
* Section
;
287 PMM_SECTION_SEGMENT Segment
;
288 BOOLEAN WriteCopyView
;
289 LIST_ENTRY RegionListHead
;
293 LIST_ENTRY RegionListHead
;
296 } MEMORY_AREA
, *PMEMORY_AREA
;
306 ULONG PagingRequestsInLastMinute
;
307 ULONG PagingRequestsInLastFiveMinutes
;
308 ULONG PagingRequestsInLastFifteenMinutes
;
312 // These two mappings are actually used by Windows itself, based on the ASSERTS
314 #define StartOfAllocation ReadInProgress
315 #define EndOfAllocation WriteInProgress
317 typedef struct _MMPFNENTRY
320 USHORT ReadInProgress
:1; // StartOfAllocation
321 USHORT WriteInProgress
:1; // EndOfAllocation
322 USHORT PrototypePte
:1; // Zero
323 USHORT PageColor
:4; // LockCount
324 USHORT PageLocation
:3; // Consumer
325 USHORT RemovalRequested
:1;
326 USHORT CacheAttribute
:2; // Type
328 USHORT ParityError
:1;
331 typedef struct _MMPFN
335 PFN_NUMBER Flink
; // ListEntry.Flink
339 SINGLE_LIST_ENTRY NextStackPfn
;
341 PMMPTE PteAddress
; // ListEntry.Blink
345 ULONG_PTR ShareCount
; // MapCount
351 USHORT ReferenceCount
; // ReferenceCount
356 USHORT ReferenceCount
;
363 LONG AweReferenceCount
; // RmapListHead
367 ULONG_PTR EntireFrame
; // SavedSwapEntry
370 ULONG_PTR PteFrame
:25;
371 ULONG_PTR InPageError
:1;
372 ULONG_PTR VerifierAllocation
:1;
373 ULONG_PTR AweAllocation
:1;
374 ULONG_PTR Priority
:3;
375 ULONG_PTR MustBeCached
:1;
380 extern PMMPFN MmPfnDatabase
;
381 extern MM_STATS MmStats
;
383 typedef struct _MM_PAGEOP
385 /* Type of operation. */
387 /* Number of threads interested in this operation. */
388 ULONG ReferenceCount
;
389 /* Event that will be set when the operation is completed. */
390 KEVENT CompletionEvent
;
391 /* Status of the operation once it is completed. */
393 /* TRUE if the operation was abandoned. */
395 /* The memory area to be affected by the operation. */
398 struct _MM_PAGEOP
* Next
;
399 struct _ETHREAD
* Thread
;
401 * These fields are used to identify the operation if it is against a
402 * virtual memory area.
407 * These fields are used to identify the operation if it is against a
410 PMM_SECTION_SEGMENT Segment
;
412 } MM_PAGEOP
, *PMM_PAGEOP
;
414 typedef struct _MM_MEMORY_CONSUMER
418 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
);
419 } MM_MEMORY_CONSUMER
, *PMM_MEMORY_CONSUMER
;
421 typedef struct _MM_REGION
426 LIST_ENTRY RegionListEntry
;
427 } MM_REGION
, *PMM_REGION
;
429 /* Entry describing free pool memory */
430 typedef struct _MMFREE_POOL_ENTRY
435 struct _MMFREE_POOL_ENTRY
*Owner
;
436 } MMFREE_POOL_ENTRY
, *PMMFREE_POOL_ENTRY
;
438 /* Paged pool information */
439 typedef struct _MM_PAGED_POOL_INFO
441 PRTL_BITMAP PagedPoolAllocationMap
;
442 PRTL_BITMAP EndOfPagedPoolBitmap
;
443 PMMPTE FirstPteForPagedPool
;
444 PMMPTE LastPteForPagedPool
;
445 PMMPTE NextPdeForPagedPoolExpansion
;
447 SIZE_T PagedPoolCommit
;
448 SIZE_T AllocatedPagedPool
;
449 } MM_PAGED_POOL_INFO
, *PMM_PAGED_POOL_INFO
;
451 extern MM_MEMORY_CONSUMER MiMemoryConsumers
[MC_MAXIMUM
];
454 (*PMM_ALTER_REGION_FUNC
)(
455 PMMSUPPORT AddressSpace
,
465 (*PMM_FREE_PAGE_FUNC
)(
467 PMEMORY_AREA MemoryArea
,
475 // Mm copy support for Kd
486 /* marea.c *******************************************************************/
491 PMMSUPPORT AddressSpace
,
496 PMEMORY_AREA
*Result
,
497 BOOLEAN FixedAddress
,
498 ULONG AllocationFlags
,
499 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
504 MmLocateMemoryAreaByAddress(
505 PMMSUPPORT AddressSpace
,
512 PMMSUPPORT AddressSpace
,
519 PMMSUPPORT AddressSpace
,
520 PMEMORY_AREA MemoryArea
,
521 PMM_FREE_PAGE_FUNC FreePage
,
522 PVOID FreePageContext
527 MmFreeMemoryAreaByPtr(
528 PMMSUPPORT AddressSpace
,
530 PMM_FREE_PAGE_FUNC FreePage
,
531 PVOID FreePageContext
536 MmDumpMemoryAreas(PMMSUPPORT AddressSpace
);
540 MmLocateMemoryAreaByRegion(
541 PMMSUPPORT AddressSpace
,
549 PMMSUPPORT AddressSpace
,
551 ULONG_PTR Granularity
,
557 MmReleaseMemoryAreaIfDecommitted(
558 struct _EPROCESS
*Process
,
559 PMMSUPPORT AddressSpace
,
565 MmMapMemoryArea(PVOID BaseAddress
,
570 /* npool.c *******************************************************************/
574 MiDebugDumpNonPagedPool(BOOLEAN NewOnly
);
578 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly
);
582 MiInitializeNonPagedPool(VOID
);
587 IN POOL_TYPE PoolType
,
588 IN SIZE_T SizeInBytes
594 IN PVOID VirtualAddress
600 IN PVOID StartingAddress
610 /* pool.c *******************************************************************/
614 ExAllocateNonPagedPoolWithTag(
623 ExAllocatePagedPoolWithTag(
631 ExFreeNonPagedPool(PVOID block
);
635 ExFreePagedPool(IN PVOID Block
);
639 ExpIsPoolTagDebuggable(ULONG Tag
);
643 ExpAllocateDebugPool(
653 ExpFreeDebugPool(PVOID Block
, BOOLEAN PagedPool
);
657 MmInitializePagedPool(VOID
);
661 MiAllocateSpecialPool(
662 IN POOL_TYPE PoolType
,
663 IN SIZE_T NumberOfBytes
,
671 IN POOL_TYPE PoolType
,
672 IN ULONG CurrentMaxQuota
,
673 OUT PULONG NewMaxQuota
676 /* mdl.c *********************************************************************/
685 /* mminit.c ******************************************************************/
689 MiShutdownMemoryManager(VOID
);
699 MmInitSystem(IN ULONG Phase
,
700 IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
704 MiFreeInitMemory(VOID
);
708 MmInitializeMdlImplementation(VOID
);
710 /* pagefile.c ****************************************************************/
714 MmAllocSwapPage(VOID
);
718 MmDereserveSwapPages(ULONG Nr
);
722 MmFreeSwapPage(SWAPENTRY Entry
);
726 MmInitPagingFile(VOID
);
737 MmReserveSwapPages(ULONG Nr
);
750 ULONG BugCodeParameter1
,
751 ULONG BugCodeParameter2
,
752 ULONG BugCodeParameter3
,
753 ULONG BugCodeParameter4
,
754 struct _KTRAP_FRAME
* TrapFrame
759 MmIsAvailableSwapPage(VOID
);
763 MmShowOutOfSpaceMessagePagingFile(VOID
);
765 /* process.c ****************************************************************/
769 MmInitializeProcessAddressSpace(
770 IN PEPROCESS Process
,
771 IN PEPROCESS Clone OPTIONAL
,
772 IN PVOID Section OPTIONAL
,
774 IN POBJECT_NAME_INFORMATION
*AuditName OPTIONAL
780 IN PEPROCESS Process
,
781 IN PINITIAL_PEB InitialPeb
,
788 IN PEPROCESS Process
,
789 IN PCLIENT_ID ClientId
,
790 IN PINITIAL_TEB InitialTeb
,
797 struct _EPROCESS
*Process
,
803 MmCleanProcessAddressSpace(IN PEPROCESS Process
);
807 MmDeleteProcessAddressSpace(IN PEPROCESS Process
);
811 MmGetSessionLocaleId(VOID
);
815 MmSetMemoryPriorityProcess(
816 IN PEPROCESS Process
,
817 IN UCHAR MemoryPriority
820 /* i386/pfault.c *************************************************************/
832 /* mm.c **********************************************************************/
837 IN BOOLEAN StoreInstruction
,
839 IN KPROCESSOR_MODE Mode
,
840 IN PVOID TrapInformation
843 /* anonmem.c *****************************************************************/
847 MmNotPresentFaultVirtualMemory(
848 PMMSUPPORT AddressSpace
,
849 MEMORY_AREA
* MemoryArea
,
856 MmPageOutVirtualMemory(
857 PMMSUPPORT AddressSpace
,
858 PMEMORY_AREA MemoryArea
,
860 struct _MM_PAGEOP
* PageOp
866 PMEMORY_AREA MemoryArea
,
868 PMEMORY_BASIC_INFORMATION Info
,
875 struct _EPROCESS
* Process
,
876 PMEMORY_AREA MemoryArea
882 PMMSUPPORT AddressSpace
,
883 PMEMORY_AREA MemoryArea
,
892 MmWritePageVirtualMemory(
893 PMMSUPPORT AddressSpace
,
899 /* kmap.c ********************************************************************/
903 ExAllocatePage(VOID
);
907 ExUnmapPage(PVOID Addr
);
911 ExAllocatePageWithPhysPage(PFN_TYPE Page
);
922 MiZeroPage(PFN_TYPE Page
);
924 /* memsafe.s *****************************************************************/
928 MmSafeReadPtr(PVOID Source
);
930 /* pageop.c ******************************************************************/
934 MmReleasePageOp(PMM_PAGEOP PageOp
);
942 PMM_SECTION_SEGMENT Segment
,
954 PMM_SECTION_SEGMENT Segment
,
960 MmInitializePageOp(VOID
);
962 /* process.c *****************************************************************/
966 MmCreateKernelStack(BOOLEAN GuiStack
, UCHAR Node
);
970 MmDeleteKernelStack(PVOID Stack
,
973 /* balace.c ******************************************************************/
977 MmInitializeMemoryConsumer(
979 NTSTATUS (*Trim
)(ULONG Target
, ULONG Priority
, PULONG NrFreed
)
984 MmInitializeBalancer(
985 ULONG NrAvailablePages
,
991 MmReleasePageMemoryConsumer(
998 MmRequestPageMemoryConsumer(
1001 PPFN_TYPE AllocatedPage
1006 MiInitBalancerThread(VOID
);
1010 MmRebalanceMemoryConsumers(VOID
);
1012 /* rmap.c **************************************************************/
1016 MmSetRmapListHeadPage(
1018 struct _MM_RMAP_ENTRY
* ListHead
1021 struct _MM_RMAP_ENTRY
*
1023 MmGetRmapListHeadPage(PFN_TYPE Page
);
1029 struct _EPROCESS
*Process
,
1038 VOID (*DeleteMapping
)(PVOID Context
, struct _EPROCESS
*Process
, PVOID Address
)
1045 struct _EPROCESS
*Process
,
1051 MmInitializeRmapList(VOID
);
1055 MmSetCleanAllRmaps(PFN_TYPE Page
);
1059 MmSetDirtyAllRmaps(PFN_TYPE Page
);
1063 MmIsDirtyPageRmap(PFN_TYPE Page
);
1067 MmWritePagePhysicalAddress(PFN_TYPE Page
);
1071 MmPageOutPhysicalAddress(PFN_TYPE Page
);
1073 /* freelist.c **********************************************************/
1075 #define ASSERT_PFN(x) ASSERT((x)->u3.e1.CacheAttribute != 0)
1079 MiGetPfnEntry(IN PFN_TYPE Pfn
)
1082 extern RTL_BITMAP MiPfnBitMap
;
1084 /* Make sure the PFN number is valid */
1085 if (Pfn
> MmHighestPhysicalPage
) return NULL
;
1087 /* Make sure this page actually has a PFN entry */
1088 if ((MiPfnBitMap
.Buffer
) && !(RtlTestBit(&MiPfnBitMap
, Pfn
))) return NULL
;
1091 Page
= &MmPfnDatabase
[Pfn
];
1093 /* Make sure it's valid */
1102 MiGetPfnEntryIndex(IN PMMPFN Pfn1
)
1105 // This will return the Page Frame Number (PFN) from the MMPFN
1107 return Pfn1
- MmPfnDatabase
;
1112 MmGetLRUNextUserPage(PFN_TYPE PreviousPage
);
1116 MmGetLRUFirstUserPage(VOID
);
1120 MmInsertLRULastUserPage(PFN_TYPE Page
);
1124 MmRemoveLRUUserPage(PFN_TYPE Page
);
1128 MmLockPage(PFN_TYPE Page
);
1132 MmUnlockPage(PFN_TYPE Page
);
1136 MmGetLockCountPage(PFN_TYPE Page
);
1140 MmInitializePageList(
1152 MmGetContinuousPages(
1153 ULONG NumberOfBytes
,
1154 PHYSICAL_ADDRESS LowestAcceptableAddress
,
1155 PHYSICAL_ADDRESS HighestAcceptableAddress
,
1156 PHYSICAL_ADDRESS BoundaryAddressMultiple
,
1162 MmZeroPageThreadMain(
1166 /* hypermap.c *****************************************************************/
1168 extern PEPROCESS HyperProcess
;
1169 extern KIRQL HyperIrql
;
1173 MiMapPageInHyperSpace(IN PEPROCESS Process
,
1179 MiUnmapPageInHyperSpace(IN PEPROCESS Process
,
1185 MiMapPagesToZeroInHyperSpace(IN PMMPFN
*Pages
,
1186 IN PFN_NUMBER NumberOfPages
);
1190 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress
,
1191 IN PFN_NUMBER NumberOfPages
);
1194 // ReactOS Compatibility Layer
1198 MmCreateHyperspaceMapping(IN PFN_NUMBER Page
)
1200 HyperProcess
= (PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
;
1201 return MiMapPageInHyperSpace(HyperProcess
, Page
, &HyperIrql
);
1206 MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page
)
1208 PMMPFN Pfn1
= MiGetPfnEntry(Page
);
1209 return MiMapPagesToZeroInHyperSpace(&Pfn1
, 1);
1212 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1214 /* i386/page.c *********************************************************/
1218 MmCreateVirtualMappingForKernel(
1227 MmCommitPagedPoolAddress(
1234 MmCreateVirtualMapping(
1235 struct _EPROCESS
* Process
,
1244 MmCreateVirtualMappingUnsafe(
1245 struct _EPROCESS
* Process
,
1255 struct _EPROCESS
* Process
,
1261 struct _EPROCESS
* Process
,
1269 struct _EPROCESS
* Process
,
1275 MmInitGlobalKernelPageDirectory(VOID
);
1279 MmDisableVirtualMapping(
1280 struct _EPROCESS
*Process
,
1288 MmEnableVirtualMapping(
1289 struct _EPROCESS
*Process
,
1295 MmRawDeleteVirtualMapping(PVOID Address
);
1299 MmDeletePageFileMapping(
1300 struct _EPROCESS
*Process
,
1302 SWAPENTRY
* SwapEntry
1307 MmCreatePageFileMapping(
1308 struct _EPROCESS
*Process
,
1316 struct _EPROCESS
*Process
,
1322 MmTransferOwnershipPage(
1330 struct _EPROCESS
*Process
,
1338 SWAPENTRY SavedSwapEntry
1343 MmAllocPagesSpecifyRange(
1345 PHYSICAL_ADDRESS LowestAddress
,
1346 PHYSICAL_ADDRESS HighestAddress
,
1347 ULONG NumberOfPages
,
1353 MmDereferencePage(PFN_TYPE Page
);
1357 MmReferencePage(PFN_TYPE Page
);
1361 MmGetReferenceCountPage(PFN_TYPE Page
);
1365 MmIsPageInUse(PFN_TYPE Page
);
1369 MmSetSavedSwapEntryPage(
1371 SWAPENTRY SavedSwapEntry
);
1375 MmGetSavedSwapEntryPage(PFN_TYPE Page
);
1380 struct _EPROCESS
*Process
,
1386 MmCreatePageTable(PVOID PAddress
);
1391 struct _EPROCESS
*Process
,
1398 struct _EPROCESS
*Process
,
1404 MmCreateProcessAddressSpace(
1407 IN PULONG DirectoryTableBase
1412 MmInitializeHandBuiltProcess(
1413 IN PEPROCESS Process
,
1414 IN PULONG DirectoryTableBase
1420 MmInitializeHandBuiltProcess2(
1421 IN PEPROCESS Process
1426 MmReleaseMmInfo(struct _EPROCESS
*Process
);
1430 Mmi386ReleaseMmInfo(struct _EPROCESS
*Process
);
1434 MmDeleteVirtualMapping(
1435 struct _EPROCESS
*Process
,
1445 struct _EPROCESS
*Process
,
1451 MmMarkPageMapped(PFN_TYPE Page
);
1455 MmMarkPageUnmapped(PFN_TYPE Page
);
1460 struct _EPROCESS
*Process
,
1467 MiInitPageDirectoryMap(VOID
);
1471 MiGetUserPageDirectoryCount(VOID
);
1473 /* wset.c ********************************************************************/
1482 /* region.c ************************************************************/
1487 PMMSUPPORT AddressSpace
,
1489 PLIST_ENTRY RegionListHead
,
1494 PMM_ALTER_REGION_FUNC AlterFunc
1500 PLIST_ENTRY RegionListHead
,
1510 PLIST_ENTRY RegionListHead
,
1512 PVOID
* RegionBaseAddress
1515 /* section.c *****************************************************************/
1519 MmGetFileObjectForSection(
1520 IN PROS_SECTION_OBJECT Section
1524 MmGetFileNameForAddress(
1526 OUT PUNICODE_STRING ModuleName
1531 MmGetFileNameForSection(
1532 IN PROS_SECTION_OBJECT Section
,
1533 OUT POBJECT_NAME_INFORMATION
*ModuleName
1546 PMEMORY_AREA MemoryArea
,
1548 PMEMORY_BASIC_INFORMATION Info
,
1554 MmProtectSectionView(
1555 PMMSUPPORT AddressSpace
,
1556 PMEMORY_AREA MemoryArea
,
1565 MmWritePageSectionView(
1566 PMMSUPPORT AddressSpace
,
1574 MmInitSectionImplementation(VOID
);
1578 MmNotPresentFaultSectionView(
1579 PMMSUPPORT AddressSpace
,
1580 MEMORY_AREA
* MemoryArea
,
1587 MmPageOutSectionView(
1588 PMMSUPPORT AddressSpace
,
1589 PMEMORY_AREA MemoryArea
,
1591 struct _MM_PAGEOP
*PageOp
1596 MmCreatePhysicalMemorySection(VOID
);
1600 MmAccessFaultSectionView(
1601 PMMSUPPORT AddressSpace
,
1602 MEMORY_AREA
* MemoryArea
,
1609 MmFreeSectionSegments(PFILE_OBJECT FileObject
);
1611 /* mpw.c *********************************************************************/
1615 MmInitMpwThread(VOID
);
1619 MmInitBsmThread(VOID
);
1621 /* pager.c *******************************************************************/
1625 MiIsPagerThread(VOID
);
1629 MiStartPagerThread(VOID
);
1633 MiStopPagerThread(VOID
);
1637 MiQueryVirtualMemory(
1638 IN HANDLE ProcessHandle
,
1640 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass
,
1641 OUT PVOID VirtualMemoryInformation
,
1643 OUT PULONG ResultLength
1646 /* sysldr.c ******************************************************************/
1650 MiReloadBootLoadedDrivers(
1651 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1656 MiInitializeLoadedModuleList(
1657 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1663 IN PUNICODE_STRING FileName
,
1664 IN PUNICODE_STRING NamePrefix OPTIONAL
,
1665 IN PUNICODE_STRING LoadedName OPTIONAL
,
1667 OUT PVOID
*ModuleObject
,
1668 OUT PVOID
*ImageBaseAddress
1673 MmUnloadSystemImage(
1674 IN PVOID ImageHandle
1680 IN HANDLE ImageHandle
,
1681 IN BOOLEAN PurgeSection
1686 MmCallDllInitialize(
1687 IN PLDR_DATA_TABLE_ENTRY LdrEntry
,
1688 IN PLIST_ENTRY ListHead
1691 /* ReactOS Mm Hacks */
1694 MiSyncForProcessAttach(
1695 IN PKTHREAD NextThread
,
1696 IN PEPROCESS Process
1701 MiSyncForContextSwitch(
1705 extern PMMSUPPORT MmKernelAddressSpace
;
1709 MmLockAddressSpace(PMMSUPPORT AddressSpace
)
1711 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1716 MmUnlockAddressSpace(PMMSUPPORT AddressSpace
)
1718 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
)->AddressCreationLock
);
1723 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace
)
1725 if (AddressSpace
== MmKernelAddressSpace
) return NULL
;
1726 return CONTAINING_RECORD(AddressSpace
, EPROCESS
, Vm
);
1731 MmGetCurrentAddressSpace(VOID
)
1733 return &((PEPROCESS
)KeGetCurrentThread()->ApcState
.Process
)->Vm
;
1738 MmGetKernelAddressSpace(VOID
)
1740 return MmKernelAddressSpace
;