Merge 36852, 37322, 37333, 37334, 43428, 43451, 44259, 46404 from amd64 branch.
[reactos.git] / reactos / ntoskrnl / include / internal / mm.h
1 #pragma once
2
3 #include <internal/arch/mm.h>
4
5 /* TYPES *********************************************************************/
6
7 struct _EPROCESS;
8
9 extern PFN_NUMBER MiFreeSwapPages;
10 extern PFN_NUMBER MiUsedSwapPages;
11 extern SIZE_T MmPagedPoolSize;
12 extern SIZE_T MmTotalPagedPoolQuota;
13 extern SIZE_T MmTotalNonPagedPoolQuota;
14 extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
15 extern PFN_NUMBER MmNumberOfPhysicalPages;
16 extern UCHAR MmDisablePagingExecutive;
17 extern PFN_NUMBER MmLowestPhysicalPage;
18 extern PFN_NUMBER MmHighestPhysicalPage;
19 extern PFN_NUMBER MmAvailablePages;
20 extern PFN_NUMBER MmResidentAvailablePages;
21
22 extern PVOID MmPagedPoolBase;
23 extern SIZE_T MmPagedPoolSize;
24
25 extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
26 extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg;
27
28 extern LIST_ENTRY MmLoadedUserImageList;
29
30 extern KMUTANT MmSystemLoadLock;
31
32 extern ULONG MmNumberOfPagingFiles;
33
34 extern PVOID MmUnloadedDrivers;
35 extern PVOID MmLastUnloadedDrivers;
36 extern PVOID MmTriageActionTaken;
37 extern PVOID KernelVerifier;
38 extern MM_DRIVER_VERIFIER_DATA MmVerifierData;
39
40 extern SIZE_T MmTotalCommitLimit;
41 extern SIZE_T MmTotalCommittedPages;
42 extern SIZE_T MmSharedCommit;
43 extern SIZE_T MmDriverCommit;
44 extern SIZE_T MmProcessCommit;
45 extern SIZE_T MmPagedPoolCommit;
46 extern SIZE_T MmPeakCommitment;
47 extern SIZE_T MmtotalCommitLimitMaximum;
48
49 extern BOOLEAN MiDbgReadyForPhysical;
50
51 struct _KTRAP_FRAME;
52 struct _EPROCESS;
53 struct _MM_RMAP_ENTRY;
54 struct _MM_PAGEOP;
55 typedef ULONG SWAPENTRY;
56
57 //
58 // MmDbgCopyMemory Flags
59 //
60 #define MMDBG_COPY_WRITE 0x00000001
61 #define MMDBG_COPY_PHYSICAL 0x00000002
62 #define MMDBG_COPY_UNSAFE 0x00000004
63 #define MMDBG_COPY_CACHED 0x00000008
64 #define MMDBG_COPY_UNCACHED 0x00000010
65 #define MMDBG_COPY_WRITE_COMBINED 0x00000020
66
67 //
68 // Maximum chunk size per copy
69 //
70 #define MMDBG_COPY_MAX_SIZE 0x8
71
72 #if defined(_X86_)
73 #define MI_STATIC_MEMORY_AREAS (14)
74 #else
75 #define MI_STATIC_MEMORY_AREAS (13)
76 #endif
77
78 #define MEMORY_AREA_INVALID (0)
79 #define MEMORY_AREA_SECTION_VIEW (1)
80 #define MEMORY_AREA_CONTINUOUS_MEMORY (2)
81 #define MEMORY_AREA_NO_CACHE (3)
82 #define MEMORY_AREA_IO_MAPPING (4)
83 #define MEMORY_AREA_SYSTEM (5)
84 #define MEMORY_AREA_MDL_MAPPING (7)
85 #define MEMORY_AREA_VIRTUAL_MEMORY (8)
86 #define MEMORY_AREA_CACHE_SEGMENT (9)
87 #define MEMORY_AREA_SHARED_DATA (10)
88 #define MEMORY_AREA_KERNEL_STACK (11)
89 #define MEMORY_AREA_PAGED_POOL (12)
90 #define MEMORY_AREA_NO_ACCESS (13)
91 #define MEMORY_AREA_PEB_OR_TEB (14)
92 #define MEMORY_AREA_OWNED_BY_ARM3 (15)
93 #define MEMORY_AREA_STATIC (0x80000000)
94
95 #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
96
97 #define MM_CORE_DUMP_TYPE_NONE (0x0)
98 #define MM_CORE_DUMP_TYPE_MINIMAL (0x1)
99 #define MM_CORE_DUMP_TYPE_FULL (0x2)
100
101 #define MM_PAGEOP_PAGEIN (1)
102 #define MM_PAGEOP_PAGEOUT (2)
103 #define MM_PAGEOP_PAGESYNCH (3)
104 #define MM_PAGEOP_ACCESSFAULT (4)
105
106 /* Number of list heads to use */
107 #define MI_FREE_POOL_LISTS 4
108
109
110 /* Signature of free pool blocks */
111 #define MM_FREE_POOL_TAG 'lprF'
112
113 /* Although Microsoft says this isn't hardcoded anymore,
114 they won't be able to change it. Stuff depends on it */
115 #define MM_VIRTMEM_GRANULARITY (64 * 1024)
116
117 #define STATUS_MM_RESTART_OPERATION ((NTSTATUS)0xD0000001)
118
119 /*
120 * Additional flags for protection attributes
121 */
122 #define PAGE_WRITETHROUGH (1024)
123 #define PAGE_SYSTEM (2048)
124
125 #define SEC_PHYSICALMEMORY (0x80000000)
126
127 #define MM_PAGEFILE_SEGMENT (0x1)
128 #define MM_DATAFILE_SEGMENT (0x2)
129
130 #define MC_CACHE (0)
131 #define MC_USER (1)
132 #define MC_PPOOL (2)
133 #define MC_NPPOOL (3)
134 #define MC_SYSTEM (4)
135 #define MC_MAXIMUM (5)
136
137 #define PAGED_POOL_MASK 1
138 #define MUST_SUCCEED_POOL_MASK 2
139 #define CACHE_ALIGNED_POOL_MASK 4
140 #define QUOTA_POOL_MASK 8
141 #define SESSION_POOL_MASK 32
142 #define VERIFIER_POOL_MASK 64
143
144 #define MM_PAGED_POOL_SIZE (100*1024*1024)
145 #define MM_NONPAGED_POOL_SIZE (100*1024*1024)
146
147 /*
148 * Paged and non-paged pools are 8-byte aligned
149 */
150 #define MM_POOL_ALIGNMENT 8
151
152 #define MM_ROUND_UP(x,s) \
153 ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
154
155 #define MM_ROUND_DOWN(x,s) \
156 ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
157
158 #define PAGE_FLAGS_VALID_FROM_USER_MODE \
159 (PAGE_READONLY | \
160 PAGE_READWRITE | \
161 PAGE_WRITECOPY | \
162 PAGE_EXECUTE | \
163 PAGE_EXECUTE_READ | \
164 PAGE_EXECUTE_READWRITE | \
165 PAGE_EXECUTE_WRITECOPY | \
166 PAGE_GUARD | \
167 PAGE_NOACCESS | \
168 PAGE_NOCACHE)
169
170 #define PAGE_FLAGS_VALID_FOR_SECTION \
171 (PAGE_READONLY | \
172 PAGE_READWRITE | \
173 PAGE_WRITECOPY | \
174 PAGE_EXECUTE | \
175 PAGE_EXECUTE_READ | \
176 PAGE_EXECUTE_READWRITE | \
177 PAGE_EXECUTE_WRITECOPY | \
178 PAGE_NOACCESS)
179
180 #define PAGE_IS_READABLE \
181 (PAGE_READONLY | \
182 PAGE_READWRITE | \
183 PAGE_WRITECOPY | \
184 PAGE_EXECUTE_READ | \
185 PAGE_EXECUTE_READWRITE | \
186 PAGE_EXECUTE_WRITECOPY)
187
188 #define PAGE_IS_WRITABLE \
189 (PAGE_READWRITE | \
190 PAGE_WRITECOPY | \
191 PAGE_EXECUTE_READWRITE | \
192 PAGE_EXECUTE_WRITECOPY)
193
194 #define PAGE_IS_EXECUTABLE \
195 (PAGE_EXECUTE | \
196 PAGE_EXECUTE_READ | \
197 PAGE_EXECUTE_READWRITE | \
198 PAGE_EXECUTE_WRITECOPY)
199
200 #define PAGE_IS_WRITECOPY \
201 (PAGE_WRITECOPY | \
202 PAGE_EXECUTE_WRITECOPY)
203
204
205 #define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand) \
206 InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
207
208 #define InterlockedExchangePte(PointerPte, Value) \
209 InterlockedExchange((PLONG)(PointerPte), Value)
210
211 typedef struct
212 {
213 ULONG Entry[NR_SECTION_PAGE_ENTRIES];
214 } SECTION_PAGE_TABLE, *PSECTION_PAGE_TABLE;
215
216 typedef struct
217 {
218 PSECTION_PAGE_TABLE PageTables[NR_SECTION_PAGE_TABLES];
219 } SECTION_PAGE_DIRECTORY, *PSECTION_PAGE_DIRECTORY;
220
221 typedef struct _MM_SECTION_SEGMENT
222 {
223 LONG FileOffset; /* start offset into the file for image sections */
224 ULONG_PTR VirtualAddress; /* dtart offset into the address range for image sections */
225 ULONG RawLength; /* length of the segment which is part of the mapped file */
226 ULONG Length; /* absolute length of the segment */
227 ULONG Protection;
228 FAST_MUTEX Lock; /* lock which protects the page directory */
229 ULONG ReferenceCount;
230 SECTION_PAGE_DIRECTORY PageDirectory;
231 ULONG Flags;
232 ULONG Characteristics;
233 BOOLEAN WriteCopy;
234 } MM_SECTION_SEGMENT, *PMM_SECTION_SEGMENT;
235
236 typedef struct _MM_IMAGE_SECTION_OBJECT
237 {
238 ULONG_PTR ImageBase;
239 ULONG_PTR StackReserve;
240 ULONG_PTR StackCommit;
241 ULONG_PTR EntryPoint;
242 USHORT Subsystem;
243 USHORT ImageCharacteristics;
244 USHORT MinorSubsystemVersion;
245 USHORT MajorSubsystemVersion;
246 USHORT Machine;
247 BOOLEAN Executable;
248 ULONG NrSegments;
249 ULONG ImageSize;
250 PMM_SECTION_SEGMENT Segments;
251 } MM_IMAGE_SECTION_OBJECT, *PMM_IMAGE_SECTION_OBJECT;
252
253 typedef struct _ROS_SECTION_OBJECT
254 {
255 CSHORT Type;
256 CSHORT Size;
257 LARGE_INTEGER MaximumSize;
258 ULONG SectionPageProtection;
259 ULONG AllocationAttributes;
260 PFILE_OBJECT FileObject;
261 union
262 {
263 PMM_IMAGE_SECTION_OBJECT ImageSection;
264 PMM_SECTION_SEGMENT Segment;
265 };
266 } ROS_SECTION_OBJECT, *PROS_SECTION_OBJECT;
267
268 typedef struct _MEMORY_AREA
269 {
270 PVOID StartingAddress;
271 PVOID EndingAddress;
272 struct _MEMORY_AREA *Parent;
273 struct _MEMORY_AREA *LeftChild;
274 struct _MEMORY_AREA *RightChild;
275 ULONG Type;
276 ULONG Protect;
277 ULONG Flags;
278 BOOLEAN DeleteInProgress;
279 ULONG PageOpCount;
280 union
281 {
282 struct
283 {
284 ROS_SECTION_OBJECT* Section;
285 ULONG ViewOffset;
286 PMM_SECTION_SEGMENT Segment;
287 BOOLEAN WriteCopyView;
288 LIST_ENTRY RegionListHead;
289 } SectionData;
290 struct
291 {
292 LIST_ENTRY RegionListHead;
293 } VirtualMemoryData;
294 } Data;
295 } MEMORY_AREA, *PMEMORY_AREA;
296
297 //
298 // These two mappings are actually used by Windows itself, based on the ASSERTS
299 //
300 #define StartOfAllocation ReadInProgress
301 #define EndOfAllocation WriteInProgress
302
303 typedef struct _MMPFNENTRY
304 {
305 USHORT Modified:1;
306 USHORT ReadInProgress:1; // StartOfAllocation
307 USHORT WriteInProgress:1; // EndOfAllocation
308 USHORT PrototypePte:1; // Zero
309 USHORT PageColor:4; // LockCount
310 USHORT PageLocation:3; // Consumer
311 USHORT RemovalRequested:1;
312 USHORT CacheAttribute:2; // Type
313 USHORT Rom:1;
314 USHORT ParityError:1;
315 } MMPFNENTRY;
316
317 typedef struct _MMPFN
318 {
319 union
320 {
321 PFN_NUMBER Flink; // ListEntry.Flink
322 ULONG WsIndex;
323 PKEVENT Event;
324 NTSTATUS ReadStatus;
325 SINGLE_LIST_ENTRY NextStackPfn;
326 } u1;
327 PMMPTE PteAddress; // ListEntry.Blink
328 union
329 {
330 PFN_NUMBER Blink;
331 ULONG_PTR ShareCount; // MapCount
332 } u2;
333 union
334 {
335 struct
336 {
337 USHORT ReferenceCount; // ReferenceCount
338 MMPFNENTRY e1;
339 };
340 struct
341 {
342 USHORT ReferenceCount;
343 USHORT ShortFlags;
344 } e2;
345 } u3;
346 union
347 {
348 MMPTE OriginalPte;
349 LONG AweReferenceCount; // RmapListHead
350 };
351 union
352 {
353 ULONG_PTR EntireFrame; // SavedSwapEntry
354 struct
355 {
356 ULONG_PTR PteFrame:25;
357 ULONG_PTR InPageError:1;
358 ULONG_PTR VerifierAllocation:1;
359 ULONG_PTR AweAllocation:1;
360 ULONG_PTR Priority:3;
361 ULONG_PTR MustBeCached:1;
362 };
363 } u4;
364 } MMPFN, *PMMPFN;
365
366 extern PMMPFN MmPfnDatabase;
367
368 typedef struct _MMPFNLIST
369 {
370 PFN_NUMBER Total;
371 MMLISTS ListName;
372 PFN_NUMBER Flink;
373 PFN_NUMBER Blink;
374 } MMPFNLIST, *PMMPFNLIST;
375
376 extern MMPFNLIST MmZeroedPageListHead;
377 extern MMPFNLIST MmFreePageListHead;
378 extern MMPFNLIST MmStandbyPageListHead;
379 extern MMPFNLIST MmModifiedPageListHead;
380 extern MMPFNLIST MmModifiedNoWritePageListHead;
381
382 typedef struct _MM_PAGEOP
383 {
384 /* Type of operation. */
385 ULONG OpType;
386 /* Number of threads interested in this operation. */
387 ULONG ReferenceCount;
388 /* Event that will be set when the operation is completed. */
389 KEVENT CompletionEvent;
390 /* Status of the operation once it is completed. */
391 NTSTATUS Status;
392 /* TRUE if the operation was abandoned. */
393 BOOLEAN Abandoned;
394 /* The memory area to be affected by the operation. */
395 PMEMORY_AREA MArea;
396 ULONG Hash;
397 struct _MM_PAGEOP* Next;
398 struct _ETHREAD* Thread;
399 /*
400 * These fields are used to identify the operation if it is against a
401 * virtual memory area.
402 */
403 HANDLE Pid;
404 PVOID Address;
405 /*
406 * These fields are used to identify the operation if it is against a
407 * section mapping.
408 */
409 PMM_SECTION_SEGMENT Segment;
410 ULONG Offset;
411 } MM_PAGEOP, *PMM_PAGEOP;
412
413 typedef struct _MM_MEMORY_CONSUMER
414 {
415 ULONG PagesUsed;
416 ULONG PagesTarget;
417 NTSTATUS (*Trim)(ULONG Target, ULONG Priority, PULONG NrFreed);
418 } MM_MEMORY_CONSUMER, *PMM_MEMORY_CONSUMER;
419
420 typedef struct _MM_REGION
421 {
422 ULONG Type;
423 ULONG Protect;
424 ULONG Length;
425 LIST_ENTRY RegionListEntry;
426 } MM_REGION, *PMM_REGION;
427
428 /* Entry describing free pool memory */
429 typedef struct _MMFREE_POOL_ENTRY
430 {
431 LIST_ENTRY List;
432 PFN_NUMBER Size;
433 ULONG Signature;
434 struct _MMFREE_POOL_ENTRY *Owner;
435 } MMFREE_POOL_ENTRY, *PMMFREE_POOL_ENTRY;
436
437 /* Paged pool information */
438 typedef struct _MM_PAGED_POOL_INFO
439 {
440 PRTL_BITMAP PagedPoolAllocationMap;
441 PRTL_BITMAP EndOfPagedPoolBitmap;
442 PMMPTE FirstPteForPagedPool;
443 PMMPTE LastPteForPagedPool;
444 PMMPTE NextPdeForPagedPoolExpansion;
445 ULONG PagedPoolHint;
446 SIZE_T PagedPoolCommit;
447 SIZE_T AllocatedPagedPool;
448 } MM_PAGED_POOL_INFO, *PMM_PAGED_POOL_INFO;
449
450 extern MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM];
451
452 typedef VOID
453 (*PMM_ALTER_REGION_FUNC)(
454 PMMSUPPORT AddressSpace,
455 PVOID BaseAddress,
456 ULONG Length,
457 ULONG OldType,
458 ULONG OldProtect,
459 ULONG NewType,
460 ULONG NewProtect
461 );
462
463 typedef VOID
464 (*PMM_FREE_PAGE_FUNC)(
465 PVOID Context,
466 PMEMORY_AREA MemoryArea,
467 PVOID Address,
468 PFN_NUMBER Page,
469 SWAPENTRY SwapEntry,
470 BOOLEAN Dirty
471 );
472
473 //
474 // Mm copy support for Kd
475 //
476 NTSTATUS
477 NTAPI
478 MmDbgCopyMemory(
479 IN ULONG64 Address,
480 IN PVOID Buffer,
481 IN ULONG Size,
482 IN ULONG Flags
483 );
484
485 //
486 // Determines if a given address is a session address
487 //
488 BOOLEAN
489 NTAPI
490 MmIsSessionAddress(
491 IN PVOID Address
492 );
493
494 /* marea.c *******************************************************************/
495
496 NTSTATUS
497 NTAPI
498 MmCreateMemoryArea(
499 PMMSUPPORT AddressSpace,
500 ULONG Type,
501 PVOID *BaseAddress,
502 ULONG_PTR Length,
503 ULONG Protection,
504 PMEMORY_AREA *Result,
505 BOOLEAN FixedAddress,
506 ULONG AllocationFlags,
507 PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL
508 );
509
510 PMEMORY_AREA
511 NTAPI
512 MmLocateMemoryAreaByAddress(
513 PMMSUPPORT AddressSpace,
514 PVOID Address
515 );
516
517 ULONG_PTR
518 NTAPI
519 MmFindGapAtAddress(
520 PMMSUPPORT AddressSpace,
521 PVOID Address
522 );
523
524 NTSTATUS
525 NTAPI
526 MmFreeMemoryArea(
527 PMMSUPPORT AddressSpace,
528 PMEMORY_AREA MemoryArea,
529 PMM_FREE_PAGE_FUNC FreePage,
530 PVOID FreePageContext
531 );
532
533 NTSTATUS
534 NTAPI
535 MmFreeMemoryAreaByPtr(
536 PMMSUPPORT AddressSpace,
537 PVOID BaseAddress,
538 PMM_FREE_PAGE_FUNC FreePage,
539 PVOID FreePageContext
540 );
541
542 VOID
543 NTAPI
544 MmDumpMemoryAreas(PMMSUPPORT AddressSpace);
545
546 PMEMORY_AREA
547 NTAPI
548 MmLocateMemoryAreaByRegion(
549 PMMSUPPORT AddressSpace,
550 PVOID Address,
551 ULONG_PTR Length
552 );
553
554 PVOID
555 NTAPI
556 MmFindGap(
557 PMMSUPPORT AddressSpace,
558 ULONG_PTR Length,
559 ULONG_PTR Granularity,
560 BOOLEAN TopDown
561 );
562
563 VOID
564 NTAPI
565 MmReleaseMemoryAreaIfDecommitted(
566 struct _EPROCESS *Process,
567 PMMSUPPORT AddressSpace,
568 PVOID BaseAddress
569 );
570
571 VOID
572 NTAPI
573 MmMapMemoryArea(PVOID BaseAddress,
574 ULONG Length,
575 ULONG Consumer,
576 ULONG Protection);
577
578 /* npool.c *******************************************************************/
579
580 VOID
581 NTAPI
582 MiDebugDumpNonPagedPool(BOOLEAN NewOnly);
583
584 VOID
585 NTAPI
586 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly);
587
588 VOID
589 NTAPI
590 MiInitializeNonPagedPool(VOID);
591
592 PVOID
593 NTAPI
594 MiAllocatePoolPages(
595 IN POOL_TYPE PoolType,
596 IN SIZE_T SizeInBytes
597 );
598
599 POOL_TYPE
600 NTAPI
601 MmDeterminePoolType(
602 IN PVOID VirtualAddress
603 );
604
605 ULONG
606 NTAPI
607 MiFreePoolPages(
608 IN PVOID StartingAddress
609 );
610
611 PVOID
612 NTAPI
613 MmGetMdlPageAddress(
614 PMDL Mdl,
615 PVOID Offset
616 );
617
618 /* pool.c *******************************************************************/
619
620 PVOID
621 NTAPI
622 ExAllocateNonPagedPoolWithTag(
623 POOL_TYPE type,
624 ULONG size,
625 ULONG Tag,
626 PVOID Caller
627 );
628
629 PVOID
630 NTAPI
631 ExAllocatePagedPoolWithTag(
632 POOL_TYPE Type,
633 ULONG size,
634 ULONG Tag
635 );
636
637 VOID
638 NTAPI
639 ExFreeNonPagedPool(PVOID block);
640
641 VOID
642 NTAPI
643 ExFreePagedPool(IN PVOID Block);
644
645 BOOLEAN
646 NTAPI
647 ExpIsPoolTagDebuggable(ULONG Tag);
648
649 PVOID
650 NTAPI
651 ExpAllocateDebugPool(
652 POOL_TYPE Type,
653 ULONG Size,
654 ULONG Tag,
655 PVOID Caller,
656 BOOLEAN EndOfPage
657 );
658
659 VOID
660 NTAPI
661 ExpFreeDebugPool(PVOID Block, BOOLEAN PagedPool);
662
663 VOID
664 NTAPI
665 MmInitializePagedPool(VOID);
666
667 PVOID
668 NTAPI
669 MiAllocateSpecialPool(
670 IN POOL_TYPE PoolType,
671 IN SIZE_T NumberOfBytes,
672 IN ULONG Tag,
673 IN ULONG Underrun
674 );
675
676 BOOLEAN
677 NTAPI
678 MiRaisePoolQuota(
679 IN POOL_TYPE PoolType,
680 IN ULONG CurrentMaxQuota,
681 OUT PULONG NewMaxQuota
682 );
683
684 /* mdl.c *********************************************************************/
685
686 VOID
687 NTAPI
688 MmBuildMdlFromPages(
689 PMDL Mdl,
690 PPFN_NUMBER Pages
691 );
692
693 /* mminit.c ******************************************************************/
694
695 VOID
696 NTAPI
697 MiShutdownMemoryManager(VOID);
698
699 VOID
700 NTAPI
701 MmInit1(
702 VOID
703 );
704
705 BOOLEAN
706 NTAPI
707 MmInitSystem(IN ULONG Phase,
708 IN PLOADER_PARAMETER_BLOCK LoaderBlock);
709
710 VOID
711 NTAPI
712 MiFreeInitMemory(VOID);
713
714 VOID
715 NTAPI
716 MmInitializeMdlImplementation(VOID);
717
718 /* pagefile.c ****************************************************************/
719
720 SWAPENTRY
721 NTAPI
722 MmAllocSwapPage(VOID);
723
724 VOID
725 NTAPI
726 MmDereserveSwapPages(ULONG Nr);
727
728 VOID
729 NTAPI
730 MmFreeSwapPage(SWAPENTRY Entry);
731
732 VOID
733 NTAPI
734 MmInitPagingFile(VOID);
735
736 NTSTATUS
737 NTAPI
738 MmReadFromSwapPage(
739 SWAPENTRY SwapEntry,
740 PFN_NUMBER Page
741 );
742
743 BOOLEAN
744 NTAPI
745 MmReserveSwapPages(ULONG Nr);
746
747 NTSTATUS
748 NTAPI
749 MmWriteToSwapPage(
750 SWAPENTRY SwapEntry,
751 PFN_NUMBER Page
752 );
753
754 NTSTATUS
755 NTAPI
756 MmDumpToPagingFile(
757 ULONG BugCode,
758 ULONG BugCodeParameter1,
759 ULONG BugCodeParameter2,
760 ULONG BugCodeParameter3,
761 ULONG BugCodeParameter4,
762 struct _KTRAP_FRAME* TrapFrame
763 );
764
765 BOOLEAN
766 NTAPI
767 MmIsAvailableSwapPage(VOID);
768
769 VOID
770 NTAPI
771 MmShowOutOfSpaceMessagePagingFile(VOID);
772
773 /* process.c ****************************************************************/
774
775 NTSTATUS
776 NTAPI
777 MmInitializeProcessAddressSpace(
778 IN PEPROCESS Process,
779 IN PEPROCESS Clone OPTIONAL,
780 IN PVOID Section OPTIONAL,
781 IN OUT PULONG Flags,
782 IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL
783 );
784
785 NTSTATUS
786 NTAPI
787 MmCreatePeb(
788 IN PEPROCESS Process,
789 IN PINITIAL_PEB InitialPeb,
790 OUT PPEB *BasePeb
791 );
792
793 NTSTATUS
794 NTAPI
795 MmCreateTeb(
796 IN PEPROCESS Process,
797 IN PCLIENT_ID ClientId,
798 IN PINITIAL_TEB InitialTeb,
799 OUT PTEB* BaseTeb
800 );
801
802 VOID
803 NTAPI
804 MmDeleteTeb(
805 struct _EPROCESS *Process,
806 PTEB Teb
807 );
808
809 VOID
810 NTAPI
811 MmCleanProcessAddressSpace(IN PEPROCESS Process);
812
813 NTSTATUS
814 NTAPI
815 MmDeleteProcessAddressSpace(IN PEPROCESS Process);
816
817 ULONG
818 NTAPI
819 MmGetSessionLocaleId(VOID);
820
821 NTSTATUS
822 NTAPI
823 MmSetMemoryPriorityProcess(
824 IN PEPROCESS Process,
825 IN UCHAR MemoryPriority
826 );
827
828 /* i386/pfault.c *************************************************************/
829
830 NTSTATUS
831 NTAPI
832 MmPageFault(
833 ULONG Cs,
834 PULONG Eip,
835 PULONG Eax,
836 ULONG Cr2,
837 ULONG ErrorCode
838 );
839
840 /* mm.c **********************************************************************/
841
842 NTSTATUS
843 NTAPI
844 MmAccessFault(
845 IN BOOLEAN StoreInstruction,
846 IN PVOID Address,
847 IN KPROCESSOR_MODE Mode,
848 IN PVOID TrapInformation
849 );
850
851 /* anonmem.c *****************************************************************/
852
853 NTSTATUS
854 NTAPI
855 MmNotPresentFaultVirtualMemory(
856 PMMSUPPORT AddressSpace,
857 MEMORY_AREA* MemoryArea,
858 PVOID Address,
859 BOOLEAN Locked
860 );
861
862 NTSTATUS
863 NTAPI
864 MmPageOutVirtualMemory(
865 PMMSUPPORT AddressSpace,
866 PMEMORY_AREA MemoryArea,
867 PVOID Address,
868 struct _MM_PAGEOP* PageOp
869 );
870
871 NTSTATUS
872 NTAPI
873 MmQueryAnonMem(
874 PMEMORY_AREA MemoryArea,
875 PVOID Address,
876 PMEMORY_BASIC_INFORMATION Info,
877 PSIZE_T ResultLength
878 );
879
880 VOID
881 NTAPI
882 MmFreeVirtualMemory(
883 struct _EPROCESS* Process,
884 PMEMORY_AREA MemoryArea
885 );
886
887 NTSTATUS
888 NTAPI
889 MmProtectAnonMem(
890 PMMSUPPORT AddressSpace,
891 PMEMORY_AREA MemoryArea,
892 PVOID BaseAddress,
893 ULONG Length,
894 ULONG Protect,
895 PULONG OldProtect
896 );
897
898 NTSTATUS
899 NTAPI
900 MmWritePageVirtualMemory(
901 PMMSUPPORT AddressSpace,
902 PMEMORY_AREA MArea,
903 PVOID Address,
904 PMM_PAGEOP PageOp
905 );
906
907 /* kmap.c ********************************************************************/
908
909 PVOID
910 NTAPI
911 ExAllocatePage(VOID);
912
913 VOID
914 NTAPI
915 ExUnmapPage(PVOID Addr);
916
917 PVOID
918 NTAPI
919 ExAllocatePageWithPhysPage(PFN_NUMBER Page);
920
921 NTSTATUS
922 NTAPI
923 MiCopyFromUserPage(
924 PFN_NUMBER Page,
925 PVOID SourceAddress
926 );
927
928 NTSTATUS
929 NTAPI
930 MiZeroPage(PFN_NUMBER Page);
931
932 /* memsafe.s *****************************************************************/
933
934 PVOID
935 FASTCALL
936 MmSafeReadPtr(PVOID Source);
937
938 /* pageop.c ******************************************************************/
939
940 VOID
941 NTAPI
942 MmReleasePageOp(PMM_PAGEOP PageOp);
943
944 PMM_PAGEOP
945 NTAPI
946 MmGetPageOp(
947 PMEMORY_AREA MArea,
948 HANDLE Pid,
949 PVOID Address,
950 PMM_SECTION_SEGMENT Segment,
951 ULONG Offset,
952 ULONG OpType,
953 BOOLEAN First
954 );
955
956 PMM_PAGEOP
957 NTAPI
958 MmCheckForPageOp(
959 PMEMORY_AREA MArea,
960 HANDLE Pid,
961 PVOID Address,
962 PMM_SECTION_SEGMENT Segment,
963 ULONG Offset
964 );
965
966 VOID
967 NTAPI
968 MmInitializePageOp(VOID);
969
970 /* process.c *****************************************************************/
971
972 PVOID
973 NTAPI
974 MmCreateKernelStack(BOOLEAN GuiStack, UCHAR Node);
975
976 VOID
977 NTAPI
978 MmDeleteKernelStack(PVOID Stack,
979 BOOLEAN GuiStack);
980
981 /* balace.c ******************************************************************/
982
983 VOID
984 NTAPI
985 MmInitializeMemoryConsumer(
986 ULONG Consumer,
987 NTSTATUS (*Trim)(ULONG Target, ULONG Priority, PULONG NrFreed)
988 );
989
990 VOID
991 NTAPI
992 MmInitializeBalancer(
993 ULONG NrAvailablePages,
994 ULONG NrSystemPages
995 );
996
997 NTSTATUS
998 NTAPI
999 MmReleasePageMemoryConsumer(
1000 ULONG Consumer,
1001 PFN_NUMBER Page
1002 );
1003
1004 NTSTATUS
1005 NTAPI
1006 MmRequestPageMemoryConsumer(
1007 ULONG Consumer,
1008 BOOLEAN MyWait,
1009 PPFN_NUMBER AllocatedPage
1010 );
1011
1012 VOID
1013 NTAPI
1014 MiInitBalancerThread(VOID);
1015
1016 VOID
1017 NTAPI
1018 MmRebalanceMemoryConsumers(VOID);
1019
1020 /* rmap.c **************************************************************/
1021
1022 VOID
1023 NTAPI
1024 MmSetRmapListHeadPage(
1025 PFN_NUMBER Page,
1026 struct _MM_RMAP_ENTRY* ListHead
1027 );
1028
1029 struct _MM_RMAP_ENTRY*
1030 NTAPI
1031 MmGetRmapListHeadPage(PFN_NUMBER Page);
1032
1033 VOID
1034 NTAPI
1035 MmInsertRmap(
1036 PFN_NUMBER Page,
1037 struct _EPROCESS *Process,
1038 PVOID Address
1039 );
1040
1041 VOID
1042 NTAPI
1043 MmDeleteAllRmaps(
1044 PFN_NUMBER Page,
1045 PVOID Context,
1046 VOID (*DeleteMapping)(PVOID Context, struct _EPROCESS *Process, PVOID Address)
1047 );
1048
1049 VOID
1050 NTAPI
1051 MmDeleteRmap(
1052 PFN_NUMBER Page,
1053 struct _EPROCESS *Process,
1054 PVOID Address
1055 );
1056
1057 VOID
1058 NTAPI
1059 MmInitializeRmapList(VOID);
1060
1061 VOID
1062 NTAPI
1063 MmSetCleanAllRmaps(PFN_NUMBER Page);
1064
1065 VOID
1066 NTAPI
1067 MmSetDirtyAllRmaps(PFN_NUMBER Page);
1068
1069 BOOLEAN
1070 NTAPI
1071 MmIsDirtyPageRmap(PFN_NUMBER Page);
1072
1073 NTSTATUS
1074 NTAPI
1075 MmWritePagePhysicalAddress(PFN_NUMBER Page);
1076
1077 NTSTATUS
1078 NTAPI
1079 MmPageOutPhysicalAddress(PFN_NUMBER Page);
1080
1081 /* freelist.c **********************************************************/
1082
1083 FORCEINLINE
1084 PMMPFN
1085 MiGetPfnEntry(IN PFN_NUMBER Pfn)
1086 {
1087 PMMPFN Page;
1088 extern RTL_BITMAP MiPfnBitMap;
1089
1090 /* Make sure the PFN number is valid */
1091 if (Pfn > MmHighestPhysicalPage) return NULL;
1092
1093 /* Make sure this page actually has a PFN entry */
1094 if ((MiPfnBitMap.Buffer) && !(RtlTestBit(&MiPfnBitMap, Pfn))) return NULL;
1095
1096 /* Get the entry */
1097 Page = &MmPfnDatabase[Pfn];
1098
1099 /* Return it */
1100 return Page;
1101 };
1102
1103 FORCEINLINE
1104 PFN_NUMBER
1105 MiGetPfnEntryIndex(IN PMMPFN Pfn1)
1106 {
1107 //
1108 // This will return the Page Frame Number (PFN) from the MMPFN
1109 //
1110 return Pfn1 - MmPfnDatabase;
1111 }
1112
1113 PFN_NUMBER
1114 NTAPI
1115 MmGetLRUNextUserPage(PFN_NUMBER PreviousPage);
1116
1117 PFN_NUMBER
1118 NTAPI
1119 MmGetLRUFirstUserPage(VOID);
1120
1121 VOID
1122 NTAPI
1123 MmInsertLRULastUserPage(PFN_NUMBER Page);
1124
1125 VOID
1126 NTAPI
1127 MmRemoveLRUUserPage(PFN_NUMBER Page);
1128
1129 VOID
1130 NTAPI
1131 MmLockPage(PFN_NUMBER Page);
1132
1133 VOID
1134 NTAPI
1135 MmUnlockPage(PFN_NUMBER Page);
1136
1137 ULONG
1138 NTAPI
1139 MmGetLockCountPage(PFN_NUMBER Page);
1140
1141 VOID
1142 NTAPI
1143 MmInitializePageList(
1144 VOID
1145 );
1146
1147 VOID
1148 NTAPI
1149 MmDumpPfnDatabase(
1150 VOID
1151 );
1152
1153 PFN_NUMBER
1154 NTAPI
1155 MmGetContinuousPages(
1156 ULONG NumberOfBytes,
1157 PHYSICAL_ADDRESS LowestAcceptableAddress,
1158 PHYSICAL_ADDRESS HighestAcceptableAddress,
1159 PHYSICAL_ADDRESS BoundaryAddressMultiple,
1160 BOOLEAN ZeroPages
1161 );
1162
1163 NTSTATUS
1164 NTAPI
1165 MmZeroPageThreadMain(
1166 PVOID Context
1167 );
1168
1169 /* hypermap.c *****************************************************************/
1170
1171 extern PEPROCESS HyperProcess;
1172 extern KIRQL HyperIrql;
1173
1174 PVOID
1175 NTAPI
1176 MiMapPageInHyperSpace(IN PEPROCESS Process,
1177 IN PFN_NUMBER Page,
1178 IN PKIRQL OldIrql);
1179
1180 VOID
1181 NTAPI
1182 MiUnmapPageInHyperSpace(IN PEPROCESS Process,
1183 IN PVOID Address,
1184 IN KIRQL OldIrql);
1185
1186 PVOID
1187 NTAPI
1188 MiMapPagesToZeroInHyperSpace(IN PMMPFN *Pages,
1189 IN PFN_NUMBER NumberOfPages);
1190
1191 VOID
1192 NTAPI
1193 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress,
1194 IN PFN_NUMBER NumberOfPages);
1195
1196 //
1197 // ReactOS Compatibility Layer
1198 //
1199 FORCEINLINE
1200 PVOID
1201 MmCreateHyperspaceMapping(IN PFN_NUMBER Page)
1202 {
1203 HyperProcess = (PEPROCESS)KeGetCurrentThread()->ApcState.Process;
1204 return MiMapPageInHyperSpace(HyperProcess, Page, &HyperIrql);
1205 }
1206
1207 FORCEINLINE
1208 PVOID
1209 MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page)
1210 {
1211 PMMPFN Pfn1 = MiGetPfnEntry(Page);
1212 return MiMapPagesToZeroInHyperSpace(&Pfn1, 1);
1213 }
1214
1215 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1216
1217 /* i386/page.c *********************************************************/
1218
1219 NTSTATUS
1220 NTAPI
1221 MmCreateVirtualMappingForKernel(
1222 PVOID Address,
1223 ULONG flProtect,
1224 PPFN_NUMBER Pages,
1225 ULONG PageCount
1226 );
1227
1228 NTSTATUS
1229 NTAPI
1230 MmCommitPagedPoolAddress(
1231 PVOID Address,
1232 BOOLEAN Locked
1233 );
1234
1235 NTSTATUS
1236 NTAPI
1237 MmCreateVirtualMapping(
1238 struct _EPROCESS* Process,
1239 PVOID Address,
1240 ULONG flProtect,
1241 PPFN_NUMBER Pages,
1242 ULONG PageCount
1243 );
1244
1245 NTSTATUS
1246 NTAPI
1247 MmCreateVirtualMappingUnsafe(
1248 struct _EPROCESS* Process,
1249 PVOID Address,
1250 ULONG flProtect,
1251 PPFN_NUMBER Pages,
1252 ULONG PageCount
1253 );
1254
1255 ULONG
1256 NTAPI
1257 MmGetPageProtect(
1258 struct _EPROCESS* Process,
1259 PVOID Address);
1260
1261 VOID
1262 NTAPI
1263 MmSetPageProtect(
1264 struct _EPROCESS* Process,
1265 PVOID Address,
1266 ULONG flProtect
1267 );
1268
1269 BOOLEAN
1270 NTAPI
1271 MmIsPagePresent(
1272 struct _EPROCESS* Process,
1273 PVOID Address
1274 );
1275
1276 VOID
1277 NTAPI
1278 MmInitGlobalKernelPageDirectory(VOID);
1279
1280 VOID
1281 NTAPI
1282 MmDisableVirtualMapping(
1283 struct _EPROCESS *Process,
1284 PVOID Address,
1285 BOOLEAN* WasDirty,
1286 PPFN_NUMBER Page
1287 );
1288
1289 VOID
1290 NTAPI
1291 MmEnableVirtualMapping(
1292 struct _EPROCESS *Process,
1293 PVOID Address
1294 );
1295
1296 VOID
1297 NTAPI
1298 MmRawDeleteVirtualMapping(PVOID Address);
1299
1300 VOID
1301 NTAPI
1302 MmDeletePageFileMapping(
1303 struct _EPROCESS *Process,
1304 PVOID Address,
1305 SWAPENTRY* SwapEntry
1306 );
1307
1308 NTSTATUS
1309 NTAPI
1310 MmCreatePageFileMapping(
1311 struct _EPROCESS *Process,
1312 PVOID Address,
1313 SWAPENTRY SwapEntry
1314 );
1315
1316 BOOLEAN
1317 NTAPI
1318 MmIsPageSwapEntry(
1319 struct _EPROCESS *Process,
1320 PVOID Address
1321 );
1322
1323 VOID
1324 NTAPI
1325 MmTransferOwnershipPage(
1326 PFN_NUMBER Page,
1327 ULONG NewConsumer
1328 );
1329
1330 VOID
1331 NTAPI
1332 MmSetDirtyPage(
1333 struct _EPROCESS *Process,
1334 PVOID Address
1335 );
1336
1337 PFN_NUMBER
1338 NTAPI
1339 MmAllocPage(
1340 ULONG Consumer
1341 );
1342
1343 LONG
1344 NTAPI
1345 MmAllocPagesSpecifyRange(
1346 ULONG Consumer,
1347 PHYSICAL_ADDRESS LowestAddress,
1348 PHYSICAL_ADDRESS HighestAddress,
1349 ULONG NumberOfPages,
1350 PPFN_NUMBER Pages
1351 );
1352
1353 VOID
1354 NTAPI
1355 MmDereferencePage(PFN_NUMBER Page);
1356
1357 VOID
1358 NTAPI
1359 MmReferencePage(PFN_NUMBER Page);
1360
1361 ULONG
1362 NTAPI
1363 MmGetReferenceCountPage(PFN_NUMBER Page);
1364
1365 BOOLEAN
1366 NTAPI
1367 MmIsPageInUse(PFN_NUMBER Page);
1368
1369 VOID
1370 NTAPI
1371 MmSetSavedSwapEntryPage(
1372 PFN_NUMBER Page,
1373 SWAPENTRY SavedSwapEntry);
1374
1375 SWAPENTRY
1376 NTAPI
1377 MmGetSavedSwapEntryPage(PFN_NUMBER Page);
1378
1379 VOID
1380 NTAPI
1381 MmSetCleanPage(
1382 struct _EPROCESS *Process,
1383 PVOID Address
1384 );
1385
1386 NTSTATUS
1387 NTAPI
1388 MmCreatePageTable(PVOID PAddress);
1389
1390 VOID
1391 NTAPI
1392 MmDeletePageTable(
1393 struct _EPROCESS *Process,
1394 PVOID Address
1395 );
1396
1397 PFN_NUMBER
1398 NTAPI
1399 MmGetPfnForProcess(
1400 struct _EPROCESS *Process,
1401 PVOID Address
1402 );
1403
1404 BOOLEAN
1405 NTAPI
1406 MmCreateProcessAddressSpace(
1407 IN ULONG MinWs,
1408 IN PEPROCESS Dest,
1409 IN PULONG DirectoryTableBase
1410 );
1411
1412 NTSTATUS
1413 NTAPI
1414 MmInitializeHandBuiltProcess(
1415 IN PEPROCESS Process,
1416 IN PULONG DirectoryTableBase
1417 );
1418
1419
1420 NTSTATUS
1421 NTAPI
1422 MmInitializeHandBuiltProcess2(
1423 IN PEPROCESS Process
1424 );
1425
1426 NTSTATUS
1427 NTAPI
1428 MmReleaseMmInfo(struct _EPROCESS *Process);
1429
1430 NTSTATUS
1431 NTAPI
1432 Mmi386ReleaseMmInfo(struct _EPROCESS *Process);
1433
1434 VOID
1435 NTAPI
1436 MmDeleteVirtualMapping(
1437 struct _EPROCESS *Process,
1438 PVOID Address,
1439 BOOLEAN FreePage,
1440 BOOLEAN* WasDirty,
1441 PPFN_NUMBER Page
1442 );
1443
1444 BOOLEAN
1445 NTAPI
1446 MmIsDirtyPage(
1447 struct _EPROCESS *Process,
1448 PVOID Address
1449 );
1450
1451 VOID
1452 NTAPI
1453 MmMarkPageMapped(PFN_NUMBER Page);
1454
1455 VOID
1456 NTAPI
1457 MmMarkPageUnmapped(PFN_NUMBER Page);
1458
1459 VOID
1460 NTAPI
1461 MmUpdatePageDir(
1462 struct _EPROCESS *Process,
1463 PVOID Address,
1464 ULONG Size
1465 );
1466
1467 VOID
1468 NTAPI
1469 MiInitPageDirectoryMap(VOID);
1470
1471 ULONG
1472 NTAPI
1473 MiGetUserPageDirectoryCount(VOID);
1474
1475 /* wset.c ********************************************************************/
1476
1477 NTSTATUS
1478 MmTrimUserMemory(
1479 ULONG Target,
1480 ULONG Priority,
1481 PULONG NrFreedPages
1482 );
1483
1484 /* region.c ************************************************************/
1485
1486 NTSTATUS
1487 NTAPI
1488 MmAlterRegion(
1489 PMMSUPPORT AddressSpace,
1490 PVOID BaseAddress,
1491 PLIST_ENTRY RegionListHead,
1492 PVOID StartAddress,
1493 ULONG Length,
1494 ULONG NewType,
1495 ULONG NewProtect,
1496 PMM_ALTER_REGION_FUNC AlterFunc
1497 );
1498
1499 VOID
1500 NTAPI
1501 MmInitializeRegion(
1502 PLIST_ENTRY RegionListHead,
1503 SIZE_T Length,
1504 ULONG Type,
1505 ULONG Protect
1506 );
1507
1508 PMM_REGION
1509 NTAPI
1510 MmFindRegion(
1511 PVOID BaseAddress,
1512 PLIST_ENTRY RegionListHead,
1513 PVOID Address,
1514 PVOID* RegionBaseAddress
1515 );
1516
1517 /* section.c *****************************************************************/
1518
1519 PFILE_OBJECT
1520 NTAPI
1521 MmGetFileObjectForSection(
1522 IN PROS_SECTION_OBJECT Section
1523 );
1524 NTSTATUS
1525 NTAPI
1526 MmGetFileNameForAddress(
1527 IN PVOID Address,
1528 OUT PUNICODE_STRING ModuleName
1529 );
1530
1531 NTSTATUS
1532 NTAPI
1533 MmGetFileNameForSection(
1534 IN PROS_SECTION_OBJECT Section,
1535 OUT POBJECT_NAME_INFORMATION *ModuleName
1536 );
1537
1538 PVOID
1539 NTAPI
1540 MmAllocateSection(
1541 IN ULONG Length,
1542 PVOID BaseAddress
1543 );
1544
1545 NTSTATUS
1546 NTAPI
1547 MmQuerySectionView(
1548 PMEMORY_AREA MemoryArea,
1549 PVOID Address,
1550 PMEMORY_BASIC_INFORMATION Info,
1551 PSIZE_T ResultLength
1552 );
1553
1554 NTSTATUS
1555 NTAPI
1556 MmProtectSectionView(
1557 PMMSUPPORT AddressSpace,
1558 PMEMORY_AREA MemoryArea,
1559 PVOID BaseAddress,
1560 ULONG Length,
1561 ULONG Protect,
1562 PULONG OldProtect
1563 );
1564
1565 NTSTATUS
1566 NTAPI
1567 MmWritePageSectionView(
1568 PMMSUPPORT AddressSpace,
1569 PMEMORY_AREA MArea,
1570 PVOID Address,
1571 PMM_PAGEOP PageOp
1572 );
1573
1574 NTSTATUS
1575 NTAPI
1576 MmInitSectionImplementation(VOID);
1577
1578 NTSTATUS
1579 NTAPI
1580 MmNotPresentFaultSectionView(
1581 PMMSUPPORT AddressSpace,
1582 MEMORY_AREA* MemoryArea,
1583 PVOID Address,
1584 BOOLEAN Locked
1585 );
1586
1587 NTSTATUS
1588 NTAPI
1589 MmPageOutSectionView(
1590 PMMSUPPORT AddressSpace,
1591 PMEMORY_AREA MemoryArea,
1592 PVOID Address,
1593 struct _MM_PAGEOP *PageOp
1594 );
1595
1596 NTSTATUS
1597 NTAPI
1598 MmCreatePhysicalMemorySection(VOID);
1599
1600 NTSTATUS
1601 NTAPI
1602 MmAccessFaultSectionView(
1603 PMMSUPPORT AddressSpace,
1604 MEMORY_AREA* MemoryArea,
1605 PVOID Address,
1606 BOOLEAN Locked
1607 );
1608
1609 VOID
1610 NTAPI
1611 MmFreeSectionSegments(PFILE_OBJECT FileObject);
1612
1613 /* mpw.c *********************************************************************/
1614
1615 NTSTATUS
1616 NTAPI
1617 MmInitMpwThread(VOID);
1618
1619 NTSTATUS
1620 NTAPI
1621 MmInitBsmThread(VOID);
1622
1623 /* pager.c *******************************************************************/
1624
1625 BOOLEAN
1626 NTAPI
1627 MiIsPagerThread(VOID);
1628
1629 VOID
1630 NTAPI
1631 MiStartPagerThread(VOID);
1632
1633 VOID
1634 NTAPI
1635 MiStopPagerThread(VOID);
1636
1637 NTSTATUS
1638 FASTCALL
1639 MiQueryVirtualMemory(
1640 IN HANDLE ProcessHandle,
1641 IN PVOID Address,
1642 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass,
1643 OUT PVOID VirtualMemoryInformation,
1644 IN SIZE_T Length,
1645 OUT PSIZE_T ResultLength
1646 );
1647
1648 /* sysldr.c ******************************************************************/
1649
1650 VOID
1651 NTAPI
1652 MiReloadBootLoadedDrivers(
1653 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1654 );
1655
1656 BOOLEAN
1657 NTAPI
1658 MiInitializeLoadedModuleList(
1659 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1660 );
1661
1662 NTSTATUS
1663 NTAPI
1664 MmLoadSystemImage(
1665 IN PUNICODE_STRING FileName,
1666 IN PUNICODE_STRING NamePrefix OPTIONAL,
1667 IN PUNICODE_STRING LoadedName OPTIONAL,
1668 IN ULONG Flags,
1669 OUT PVOID *ModuleObject,
1670 OUT PVOID *ImageBaseAddress
1671 );
1672
1673 NTSTATUS
1674 NTAPI
1675 MmUnloadSystemImage(
1676 IN PVOID ImageHandle
1677 );
1678
1679 NTSTATUS
1680 NTAPI
1681 MmCheckSystemImage(
1682 IN HANDLE ImageHandle,
1683 IN BOOLEAN PurgeSection
1684 );
1685
1686 NTSTATUS
1687 NTAPI
1688 MmCallDllInitialize(
1689 IN PLDR_DATA_TABLE_ENTRY LdrEntry,
1690 IN PLIST_ENTRY ListHead
1691 );
1692
1693 /* ReactOS Mm Hacks */
1694 VOID
1695 FASTCALL
1696 MiSyncForProcessAttach(
1697 IN PKTHREAD NextThread,
1698 IN PEPROCESS Process
1699 );
1700
1701 VOID
1702 FASTCALL
1703 MiSyncForContextSwitch(
1704 IN PKTHREAD Thread
1705 );
1706
1707 extern PMMSUPPORT MmKernelAddressSpace;
1708
1709 FORCEINLINE
1710 VOID
1711 MmLockAddressSpace(PMMSUPPORT AddressSpace)
1712 {
1713 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, Vm)->AddressCreationLock);
1714 }
1715
1716 FORCEINLINE
1717 VOID
1718 MmUnlockAddressSpace(PMMSUPPORT AddressSpace)
1719 {
1720 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, Vm)->AddressCreationLock);
1721 }
1722
1723 FORCEINLINE
1724 PEPROCESS
1725 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace)
1726 {
1727 if (AddressSpace == MmKernelAddressSpace) return NULL;
1728 return CONTAINING_RECORD(AddressSpace, EPROCESS, Vm);
1729 }
1730
1731 FORCEINLINE
1732 PMMSUPPORT
1733 MmGetCurrentAddressSpace(VOID)
1734 {
1735 return &((PEPROCESS)KeGetCurrentThread()->ApcState.Process)->Vm;
1736 }
1737
1738 FORCEINLINE
1739 PMMSUPPORT
1740 MmGetKernelAddressSpace(VOID)
1741 {
1742 return MmKernelAddressSpace;
1743 }