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