40019a925e9a78ae3483600197298b889ab30338
[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; // SavedSwapEntry
343 PKEVENT Event;
344 NTSTATUS ReadStatus;
345 SINGLE_LIST_ENTRY NextStackPfn;
346 } u1;
347 PMMPTE PteAddress;
348 union
349 {
350 PFN_NUMBER Blink;
351 ULONG_PTR ShareCount;
352 } u2;
353 union
354 {
355 struct
356 {
357 USHORT ReferenceCount; // ReferenceCount
358 MMPFNENTRY e1;
359 };
360 struct
361 {
362 USHORT ReferenceCount;
363 USHORT ShortFlags;
364 } e2;
365 } u3;
366 union
367 {
368 MMPTE OriginalPte;
369 LONG AweReferenceCount; // RmapListHead
370 };
371 union
372 {
373 ULONG_PTR EntireFrame;
374 struct
375 {
376 ULONG_PTR PteFrame:25;
377 ULONG_PTR InPageError:1;
378 ULONG_PTR VerifierAllocation:1;
379 ULONG_PTR AweAllocation:1;
380 ULONG_PTR Priority:3;
381 ULONG_PTR MustBeCached:1;
382 };
383 } u4;
384 #if MI_TRACE_PFNS
385 MI_PFN_USAGES PfnUsage;
386 CHAR ProcessName[16];
387 #endif
388 } MMPFN, *PMMPFN;
389
390 extern PMMPFN MmPfnDatabase;
391
392 typedef struct _MMPFNLIST
393 {
394 PFN_NUMBER Total;
395 MMLISTS ListName;
396 PFN_NUMBER Flink;
397 PFN_NUMBER Blink;
398 } MMPFNLIST, *PMMPFNLIST;
399
400 extern MMPFNLIST MmZeroedPageListHead;
401 extern MMPFNLIST MmFreePageListHead;
402 extern MMPFNLIST MmStandbyPageListHead;
403 extern MMPFNLIST MmModifiedPageListHead;
404 extern MMPFNLIST MmModifiedNoWritePageListHead;
405
406 typedef struct _MM_MEMORY_CONSUMER
407 {
408 ULONG PagesUsed;
409 ULONG PagesTarget;
410 NTSTATUS (*Trim)(ULONG Target, ULONG Priority, PULONG NrFreed);
411 } MM_MEMORY_CONSUMER, *PMM_MEMORY_CONSUMER;
412
413 typedef struct _MM_REGION
414 {
415 ULONG Type;
416 ULONG Protect;
417 SIZE_T Length;
418 LIST_ENTRY RegionListEntry;
419 } MM_REGION, *PMM_REGION;
420
421 /* Entry describing free pool memory */
422 typedef struct _MMFREE_POOL_ENTRY
423 {
424 LIST_ENTRY List;
425 PFN_COUNT Size;
426 ULONG Signature;
427 struct _MMFREE_POOL_ENTRY *Owner;
428 } MMFREE_POOL_ENTRY, *PMMFREE_POOL_ENTRY;
429
430 /* Signature of a freed block */
431 #define MM_FREE_POOL_SIGNATURE 'ARM3'
432
433 /* Paged pool information */
434 typedef struct _MM_PAGED_POOL_INFO
435 {
436 PRTL_BITMAP PagedPoolAllocationMap;
437 PRTL_BITMAP EndOfPagedPoolBitmap;
438 PMMPTE FirstPteForPagedPool;
439 PMMPTE LastPteForPagedPool;
440 PMMPDE NextPdeForPagedPoolExpansion;
441 ULONG PagedPoolHint;
442 SIZE_T PagedPoolCommit;
443 SIZE_T AllocatedPagedPool;
444 } MM_PAGED_POOL_INFO, *PMM_PAGED_POOL_INFO;
445
446 extern MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM];
447
448 typedef VOID
449 (*PMM_ALTER_REGION_FUNC)(
450 PMMSUPPORT AddressSpace,
451 PVOID BaseAddress,
452 SIZE_T Length,
453 ULONG OldType,
454 ULONG OldProtect,
455 ULONG NewType,
456 ULONG NewProtect
457 );
458
459 typedef VOID
460 (*PMM_FREE_PAGE_FUNC)(
461 PVOID Context,
462 PMEMORY_AREA MemoryArea,
463 PVOID Address,
464 PFN_NUMBER Page,
465 SWAPENTRY SwapEntry,
466 BOOLEAN Dirty
467 );
468
469 //
470 // Mm copy support for Kd
471 //
472 NTSTATUS
473 NTAPI
474 MmDbgCopyMemory(
475 IN ULONG64 Address,
476 IN PVOID Buffer,
477 IN ULONG Size,
478 IN ULONG Flags
479 );
480
481 //
482 // Determines if a given address is a session address
483 //
484 BOOLEAN
485 NTAPI
486 MmIsSessionAddress(
487 IN PVOID Address
488 );
489
490 ULONG
491 NTAPI
492 MmGetSessionId(
493 IN PEPROCESS Process
494 );
495
496 ULONG
497 NTAPI
498 MmGetSessionIdEx(
499 IN PEPROCESS Process
500 );
501
502 /* marea.c *******************************************************************/
503
504 NTSTATUS
505 NTAPI
506 MmCreateMemoryArea(
507 PMMSUPPORT AddressSpace,
508 ULONG Type,
509 PVOID *BaseAddress,
510 SIZE_T Length,
511 ULONG Protection,
512 PMEMORY_AREA *Result,
513 BOOLEAN FixedAddress,
514 ULONG AllocationFlags,
515 ULONG AllocationGranularity
516 );
517
518 PMEMORY_AREA
519 NTAPI
520 MmLocateMemoryAreaByAddress(
521 PMMSUPPORT AddressSpace,
522 PVOID Address
523 );
524
525 ULONG_PTR
526 NTAPI
527 MmFindGapAtAddress(
528 PMMSUPPORT AddressSpace,
529 PVOID Address
530 );
531
532 NTSTATUS
533 NTAPI
534 MmFreeMemoryArea(
535 PMMSUPPORT AddressSpace,
536 PMEMORY_AREA MemoryArea,
537 PMM_FREE_PAGE_FUNC FreePage,
538 PVOID FreePageContext
539 );
540
541 NTSTATUS
542 NTAPI
543 MmFreeMemoryAreaByPtr(
544 PMMSUPPORT AddressSpace,
545 PVOID BaseAddress,
546 PMM_FREE_PAGE_FUNC FreePage,
547 PVOID FreePageContext
548 );
549
550 VOID
551 NTAPI
552 MmDumpMemoryAreas(PMMSUPPORT AddressSpace);
553
554 PMEMORY_AREA
555 NTAPI
556 MmLocateMemoryAreaByRegion(
557 PMMSUPPORT AddressSpace,
558 PVOID Address,
559 SIZE_T Length
560 );
561
562 PVOID
563 NTAPI
564 MmFindGap(
565 PMMSUPPORT AddressSpace,
566 SIZE_T Length,
567 ULONG_PTR Granularity,
568 BOOLEAN TopDown
569 );
570
571 VOID
572 NTAPI
573 MmReleaseMemoryAreaIfDecommitted(
574 struct _EPROCESS *Process,
575 PMMSUPPORT AddressSpace,
576 PVOID BaseAddress
577 );
578
579 VOID
580 NTAPI
581 MmMapMemoryArea(PVOID BaseAddress,
582 SIZE_T Length,
583 ULONG Consumer,
584 ULONG Protection);
585
586 VOID
587 NTAPI
588 MiRosCheckMemoryAreas(
589 PMMSUPPORT AddressSpace);
590
591 VOID
592 NTAPI
593 MiCheckAllProcessMemoryAreas(VOID);
594
595 /* npool.c *******************************************************************/
596
597 VOID
598 NTAPI
599 MiDebugDumpNonPagedPool(BOOLEAN NewOnly);
600
601 VOID
602 NTAPI
603 MiDebugDumpNonPagedPoolStats(BOOLEAN NewOnly);
604
605 VOID
606 NTAPI
607 MiInitializeNonPagedPool(VOID);
608
609 PVOID
610 NTAPI
611 MiAllocatePoolPages(
612 IN POOL_TYPE PoolType,
613 IN SIZE_T SizeInBytes
614 );
615
616 POOL_TYPE
617 NTAPI
618 MmDeterminePoolType(
619 IN PVOID VirtualAddress
620 );
621
622 ULONG
623 NTAPI
624 MiFreePoolPages(
625 IN PVOID StartingAddress
626 );
627
628 PVOID
629 NTAPI
630 MmGetMdlPageAddress(
631 PMDL Mdl,
632 PVOID Offset
633 );
634
635 /* pool.c *******************************************************************/
636
637 PVOID
638 NTAPI
639 ExAllocateNonPagedPoolWithTag(
640 POOL_TYPE type,
641 ULONG size,
642 ULONG Tag,
643 PVOID Caller
644 );
645
646 PVOID
647 NTAPI
648 ExAllocatePagedPoolWithTag(
649 POOL_TYPE Type,
650 ULONG size,
651 ULONG Tag
652 );
653
654 VOID
655 NTAPI
656 ExFreeNonPagedPool(PVOID block);
657
658 VOID
659 NTAPI
660 ExFreePagedPool(IN PVOID Block);
661
662 BOOLEAN
663 NTAPI
664 ExpIsPoolTagDebuggable(ULONG Tag);
665
666 PVOID
667 NTAPI
668 ExpAllocateDebugPool(
669 POOL_TYPE Type,
670 ULONG Size,
671 ULONG Tag,
672 PVOID Caller,
673 BOOLEAN EndOfPage
674 );
675
676 VOID
677 NTAPI
678 ExpFreeDebugPool(PVOID Block, BOOLEAN PagedPool);
679
680 VOID
681 NTAPI
682 MmInitializePagedPool(VOID);
683
684 PVOID
685 NTAPI
686 MiAllocateSpecialPool(
687 IN POOL_TYPE PoolType,
688 IN SIZE_T NumberOfBytes,
689 IN ULONG Tag,
690 IN ULONG Underrun
691 );
692
693 BOOLEAN
694 NTAPI
695 MiRaisePoolQuota(
696 IN POOL_TYPE PoolType,
697 IN ULONG CurrentMaxQuota,
698 OUT PULONG NewMaxQuota
699 );
700
701 /* mdl.c *********************************************************************/
702
703 VOID
704 NTAPI
705 MmBuildMdlFromPages(
706 PMDL Mdl,
707 PPFN_NUMBER Pages
708 );
709
710 /* mminit.c ******************************************************************/
711
712 VOID
713 NTAPI
714 MiShutdownMemoryManager(VOID);
715
716 VOID
717 NTAPI
718 MmInit1(
719 VOID
720 );
721
722 BOOLEAN
723 NTAPI
724 MmInitSystem(IN ULONG Phase,
725 IN PLOADER_PARAMETER_BLOCK LoaderBlock);
726
727 VOID
728 NTAPI
729 MiFreeInitMemory(VOID);
730
731 VOID
732 NTAPI
733 MmInitializeMdlImplementation(VOID);
734
735 /* pagefile.c ****************************************************************/
736
737 SWAPENTRY
738 NTAPI
739 MmAllocSwapPage(VOID);
740
741 VOID
742 NTAPI
743 MmDereserveSwapPages(ULONG Nr);
744
745 VOID
746 NTAPI
747 MmFreeSwapPage(SWAPENTRY Entry);
748
749 VOID
750 NTAPI
751 MmInitPagingFile(VOID);
752
753 BOOLEAN
754 NTAPI
755 MmIsFileObjectAPagingFile(PFILE_OBJECT FileObject);
756
757 NTSTATUS
758 NTAPI
759 MmReadFromSwapPage(
760 SWAPENTRY SwapEntry,
761 PFN_NUMBER Page
762 );
763
764 BOOLEAN
765 NTAPI
766 MmReserveSwapPages(ULONG Nr);
767
768 NTSTATUS
769 NTAPI
770 MmWriteToSwapPage(
771 SWAPENTRY SwapEntry,
772 PFN_NUMBER Page
773 );
774
775 NTSTATUS
776 NTAPI
777 MmDumpToPagingFile(
778 ULONG BugCode,
779 ULONG BugCodeParameter1,
780 ULONG BugCodeParameter2,
781 ULONG BugCodeParameter3,
782 ULONG BugCodeParameter4,
783 struct _KTRAP_FRAME* TrapFrame
784 );
785
786 BOOLEAN
787 NTAPI
788 MmIsAvailableSwapPage(VOID);
789
790 VOID
791 NTAPI
792 MmShowOutOfSpaceMessagePagingFile(VOID);
793
794 /* process.c ****************************************************************/
795
796 NTSTATUS
797 NTAPI
798 MmInitializeProcessAddressSpace(
799 IN PEPROCESS Process,
800 IN PEPROCESS Clone OPTIONAL,
801 IN PVOID Section OPTIONAL,
802 IN OUT PULONG Flags,
803 IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL
804 );
805
806 NTSTATUS
807 NTAPI
808 MmCreatePeb(
809 IN PEPROCESS Process,
810 IN PINITIAL_PEB InitialPeb,
811 OUT PPEB *BasePeb
812 );
813
814 NTSTATUS
815 NTAPI
816 MmCreateTeb(
817 IN PEPROCESS Process,
818 IN PCLIENT_ID ClientId,
819 IN PINITIAL_TEB InitialTeb,
820 OUT PTEB* BaseTeb
821 );
822
823 VOID
824 NTAPI
825 MmDeleteTeb(
826 struct _EPROCESS *Process,
827 PTEB Teb
828 );
829
830 VOID
831 NTAPI
832 MmCleanProcessAddressSpace(IN PEPROCESS Process);
833
834 NTSTATUS
835 NTAPI
836 MmDeleteProcessAddressSpace(IN PEPROCESS Process);
837
838 ULONG
839 NTAPI
840 MmGetSessionLocaleId(VOID);
841
842 NTSTATUS
843 NTAPI
844 MmSetMemoryPriorityProcess(
845 IN PEPROCESS Process,
846 IN UCHAR MemoryPriority
847 );
848
849 /* i386/pfault.c *************************************************************/
850
851 NTSTATUS
852 NTAPI
853 MmPageFault(
854 ULONG Cs,
855 PULONG Eip,
856 PULONG Eax,
857 ULONG Cr2,
858 ULONG ErrorCode
859 );
860
861 /* special.c *****************************************************************/
862
863 VOID
864 NTAPI
865 MiInitializeSpecialPool();
866
867 BOOLEAN
868 NTAPI
869 MmUseSpecialPool(
870 IN SIZE_T NumberOfBytes,
871 IN ULONG Tag);
872
873 BOOLEAN
874 NTAPI
875 MmIsSpecialPoolAddress(
876 IN PVOID P);
877
878 PVOID
879 NTAPI
880 MmAllocateSpecialPool(
881 IN SIZE_T NumberOfBytes,
882 IN ULONG Tag,
883 IN POOL_TYPE PoolType,
884 IN ULONG SpecialType);
885
886 VOID
887 NTAPI
888 MmFreeSpecialPool(
889 IN PVOID P);
890
891 /* mm.c **********************************************************************/
892
893 NTSTATUS
894 NTAPI
895 MmAccessFault(
896 IN BOOLEAN StoreInstruction,
897 IN PVOID Address,
898 IN KPROCESSOR_MODE Mode,
899 IN PVOID TrapInformation
900 );
901
902 /* anonmem.c *****************************************************************/
903
904 NTSTATUS
905 NTAPI
906 MmNotPresentFaultVirtualMemory(
907 PMMSUPPORT AddressSpace,
908 MEMORY_AREA* MemoryArea,
909 PVOID Address
910 );
911
912 NTSTATUS
913 NTAPI
914 MmPageOutVirtualMemory(
915 PMMSUPPORT AddressSpace,
916 PMEMORY_AREA MemoryArea,
917 PVOID Address,
918 PFN_NUMBER Page
919 );
920
921 NTSTATUS
922 NTAPI
923 MmQueryAnonMem(
924 PMEMORY_AREA MemoryArea,
925 PVOID Address,
926 PMEMORY_BASIC_INFORMATION Info,
927 PSIZE_T ResultLength
928 );
929
930 VOID
931 NTAPI
932 MmFreeVirtualMemory(
933 struct _EPROCESS* Process,
934 PMEMORY_AREA MemoryArea
935 );
936
937 NTSTATUS
938 NTAPI
939 MmProtectAnonMem(
940 PMMSUPPORT AddressSpace,
941 PMEMORY_AREA MemoryArea,
942 PVOID BaseAddress,
943 SIZE_T Length,
944 ULONG Protect,
945 PULONG OldProtect
946 );
947
948 NTSTATUS
949 NTAPI
950 MmWritePageVirtualMemory(
951 PMMSUPPORT AddressSpace,
952 PMEMORY_AREA MArea,
953 PVOID Address,
954 PFN_NUMBER Page
955 );
956
957 /* kmap.c ********************************************************************/
958
959 PVOID
960 NTAPI
961 ExAllocatePage(VOID);
962
963 VOID
964 NTAPI
965 ExUnmapPage(PVOID Addr);
966
967 PVOID
968 NTAPI
969 ExAllocatePageWithPhysPage(PFN_NUMBER Page);
970
971 NTSTATUS
972 NTAPI
973 MiCopyFromUserPage(
974 PFN_NUMBER NewPage,
975 PFN_NUMBER OldPage
976 );
977
978 NTSTATUS
979 NTAPI
980 MiZeroPage(PFN_NUMBER Page);
981
982 /* memsafe.s *****************************************************************/
983
984 PVOID
985 FASTCALL
986 MmSafeReadPtr(PVOID Source);
987
988 /* process.c *****************************************************************/
989
990 PVOID
991 NTAPI
992 MmCreateKernelStack(BOOLEAN GuiStack, UCHAR Node);
993
994 VOID
995 NTAPI
996 MmDeleteKernelStack(PVOID Stack,
997 BOOLEAN GuiStack);
998
999 /* balace.c ******************************************************************/
1000
1001 VOID
1002 NTAPI
1003 MmInitializeMemoryConsumer(
1004 ULONG Consumer,
1005 NTSTATUS (*Trim)(ULONG Target, ULONG Priority, PULONG NrFreed)
1006 );
1007
1008 VOID
1009 NTAPI
1010 MmInitializeBalancer(
1011 ULONG NrAvailablePages,
1012 ULONG NrSystemPages
1013 );
1014
1015 NTSTATUS
1016 NTAPI
1017 MmReleasePageMemoryConsumer(
1018 ULONG Consumer,
1019 PFN_NUMBER Page
1020 );
1021
1022 NTSTATUS
1023 NTAPI
1024 MmRequestPageMemoryConsumer(
1025 ULONG Consumer,
1026 BOOLEAN MyWait,
1027 PPFN_NUMBER AllocatedPage
1028 );
1029
1030 VOID
1031 NTAPI
1032 MiInitBalancerThread(VOID);
1033
1034 VOID
1035 NTAPI
1036 MmRebalanceMemoryConsumers(VOID);
1037
1038 /* rmap.c **************************************************************/
1039
1040 VOID
1041 NTAPI
1042 MmSetRmapListHeadPage(
1043 PFN_NUMBER Page,
1044 struct _MM_RMAP_ENTRY* ListHead
1045 );
1046
1047 struct _MM_RMAP_ENTRY*
1048 NTAPI
1049 MmGetRmapListHeadPage(PFN_NUMBER Page);
1050
1051 VOID
1052 NTAPI
1053 MmInsertRmap(
1054 PFN_NUMBER Page,
1055 struct _EPROCESS *Process,
1056 PVOID Address
1057 );
1058
1059 VOID
1060 NTAPI
1061 MmDeleteAllRmaps(
1062 PFN_NUMBER Page,
1063 PVOID Context,
1064 VOID (*DeleteMapping)(PVOID Context, struct _EPROCESS *Process, PVOID Address)
1065 );
1066
1067 VOID
1068 NTAPI
1069 MmDeleteRmap(
1070 PFN_NUMBER Page,
1071 struct _EPROCESS *Process,
1072 PVOID Address
1073 );
1074
1075 VOID
1076 NTAPI
1077 MmInitializeRmapList(VOID);
1078
1079 VOID
1080 NTAPI
1081 MmSetCleanAllRmaps(PFN_NUMBER Page);
1082
1083 VOID
1084 NTAPI
1085 MmSetDirtyAllRmaps(PFN_NUMBER Page);
1086
1087 BOOLEAN
1088 NTAPI
1089 MmIsDirtyPageRmap(PFN_NUMBER Page);
1090
1091 NTSTATUS
1092 NTAPI
1093 MmPageOutPhysicalAddress(PFN_NUMBER Page);
1094
1095 /* freelist.c **********************************************************/
1096
1097 FORCEINLINE
1098 PMMPFN
1099 MiGetPfnEntry(IN PFN_NUMBER Pfn)
1100 {
1101 PMMPFN Page;
1102 extern RTL_BITMAP MiPfnBitMap;
1103
1104 /* Make sure the PFN number is valid */
1105 if (Pfn > MmHighestPhysicalPage) return NULL;
1106
1107 /* Make sure this page actually has a PFN entry */
1108 if ((MiPfnBitMap.Buffer) && !(RtlTestBit(&MiPfnBitMap, (ULONG)Pfn))) return NULL;
1109
1110 /* Get the entry */
1111 Page = &MmPfnDatabase[Pfn];
1112
1113 /* Return it */
1114 return Page;
1115 };
1116
1117 FORCEINLINE
1118 PFN_NUMBER
1119 MiGetPfnEntryIndex(IN PMMPFN Pfn1)
1120 {
1121 //
1122 // This will return the Page Frame Number (PFN) from the MMPFN
1123 //
1124 return Pfn1 - MmPfnDatabase;
1125 }
1126
1127 PFN_NUMBER
1128 NTAPI
1129 MmGetLRUNextUserPage(PFN_NUMBER PreviousPage);
1130
1131 PFN_NUMBER
1132 NTAPI
1133 MmGetLRUFirstUserPage(VOID);
1134
1135 VOID
1136 NTAPI
1137 MmInsertLRULastUserPage(PFN_NUMBER Page);
1138
1139 VOID
1140 NTAPI
1141 MmRemoveLRUUserPage(PFN_NUMBER Page);
1142
1143 VOID
1144 NTAPI
1145 MmLockPage(PFN_NUMBER Page);
1146
1147 VOID
1148 NTAPI
1149 MmUnlockPage(PFN_NUMBER Page);
1150
1151 ULONG
1152 NTAPI
1153 MmGetLockCountPage(PFN_NUMBER Page);
1154
1155 VOID
1156 NTAPI
1157 MmInitializePageList(
1158 VOID
1159 );
1160
1161 VOID
1162 NTAPI
1163 MmDumpArmPfnDatabase(
1164 IN BOOLEAN StatusOnly
1165 );
1166
1167 PFN_NUMBER
1168 NTAPI
1169 MmGetContinuousPages(
1170 ULONG NumberOfBytes,
1171 PHYSICAL_ADDRESS LowestAcceptableAddress,
1172 PHYSICAL_ADDRESS HighestAcceptableAddress,
1173 PHYSICAL_ADDRESS BoundaryAddressMultiple,
1174 BOOLEAN ZeroPages
1175 );
1176
1177 VOID
1178 NTAPI
1179 MmZeroPageThread(
1180 VOID
1181 );
1182
1183 /* hypermap.c *****************************************************************/
1184
1185 extern PEPROCESS HyperProcess;
1186 extern KIRQL HyperIrql;
1187
1188 PVOID
1189 NTAPI
1190 MiMapPageInHyperSpace(IN PEPROCESS Process,
1191 IN PFN_NUMBER Page,
1192 IN PKIRQL OldIrql);
1193
1194 VOID
1195 NTAPI
1196 MiUnmapPageInHyperSpace(IN PEPROCESS Process,
1197 IN PVOID Address,
1198 IN KIRQL OldIrql);
1199
1200 PVOID
1201 NTAPI
1202 MiMapPagesInZeroSpace(IN PMMPFN Pfn1,
1203 IN PFN_NUMBER NumberOfPages);
1204
1205 VOID
1206 NTAPI
1207 MiUnmapPagesInZeroSpace(IN PVOID VirtualAddress,
1208 IN PFN_NUMBER NumberOfPages);
1209
1210 //
1211 // ReactOS Compatibility Layer
1212 //
1213 FORCEINLINE
1214 PVOID
1215 MmCreateHyperspaceMapping(IN PFN_NUMBER Page)
1216 {
1217 HyperProcess = (PEPROCESS)KeGetCurrentThread()->ApcState.Process;
1218 return MiMapPageInHyperSpace(HyperProcess, Page, &HyperIrql);
1219 }
1220
1221 #define MmDeleteHyperspaceMapping(x) MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
1222
1223 /* i386/page.c *********************************************************/
1224
1225 NTSTATUS
1226 NTAPI
1227 MmCreateVirtualMappingForKernel(
1228 PVOID Address,
1229 ULONG flProtect,
1230 PPFN_NUMBER Pages,
1231 ULONG PageCount
1232 );
1233
1234 NTSTATUS
1235 NTAPI
1236 MmCommitPagedPoolAddress(
1237 PVOID Address,
1238 BOOLEAN Locked
1239 );
1240
1241 NTSTATUS
1242 NTAPI
1243 MmCreateVirtualMapping(
1244 struct _EPROCESS* Process,
1245 PVOID Address,
1246 ULONG flProtect,
1247 PPFN_NUMBER Pages,
1248 ULONG PageCount
1249 );
1250
1251 NTSTATUS
1252 NTAPI
1253 MmCreateVirtualMappingUnsafe(
1254 struct _EPROCESS* Process,
1255 PVOID Address,
1256 ULONG flProtect,
1257 PPFN_NUMBER Pages,
1258 ULONG PageCount
1259 );
1260
1261 ULONG
1262 NTAPI
1263 MmGetPageProtect(
1264 struct _EPROCESS* Process,
1265 PVOID Address);
1266
1267 VOID
1268 NTAPI
1269 MmSetPageProtect(
1270 struct _EPROCESS* Process,
1271 PVOID Address,
1272 ULONG flProtect
1273 );
1274
1275 BOOLEAN
1276 NTAPI
1277 MmIsPagePresent(
1278 struct _EPROCESS* Process,
1279 PVOID Address
1280 );
1281
1282 BOOLEAN
1283 NTAPI
1284 MmIsDisabledPage(
1285 struct _EPROCESS* Process,
1286 PVOID Address
1287 );
1288
1289 VOID
1290 NTAPI
1291 MmInitGlobalKernelPageDirectory(VOID);
1292
1293 VOID
1294 NTAPI
1295 MmEnableVirtualMapping(
1296 struct _EPROCESS *Process,
1297 PVOID Address
1298 );
1299
1300 VOID
1301 NTAPI
1302 MmGetPageFileMapping(
1303 struct _EPROCESS *Process,
1304 PVOID Address,
1305 SWAPENTRY* SwapEntry);
1306
1307 VOID
1308 NTAPI
1309 MmDeletePageFileMapping(
1310 struct _EPROCESS *Process,
1311 PVOID Address,
1312 SWAPENTRY* SwapEntry
1313 );
1314
1315 NTSTATUS
1316 NTAPI
1317 MmCreatePageFileMapping(
1318 struct _EPROCESS *Process,
1319 PVOID Address,
1320 SWAPENTRY SwapEntry
1321 );
1322
1323 BOOLEAN
1324 NTAPI
1325 MmIsPageSwapEntry(
1326 struct _EPROCESS *Process,
1327 PVOID Address
1328 );
1329
1330 VOID
1331 NTAPI
1332 MmTransferOwnershipPage(
1333 PFN_NUMBER Page,
1334 ULONG NewConsumer
1335 );
1336
1337 VOID
1338 NTAPI
1339 MmSetDirtyPage(
1340 struct _EPROCESS *Process,
1341 PVOID Address
1342 );
1343
1344 PFN_NUMBER
1345 NTAPI
1346 MmAllocPage(
1347 ULONG Consumer
1348 );
1349
1350 LONG
1351 NTAPI
1352 MmAllocPagesSpecifyRange(
1353 ULONG Consumer,
1354 PHYSICAL_ADDRESS LowestAddress,
1355 PHYSICAL_ADDRESS HighestAddress,
1356 ULONG NumberOfPages,
1357 PPFN_NUMBER Pages
1358 );
1359
1360 VOID
1361 NTAPI
1362 MmDereferencePage(PFN_NUMBER Page);
1363
1364 VOID
1365 NTAPI
1366 MmReferencePage(PFN_NUMBER Page);
1367
1368 ULONG
1369 NTAPI
1370 MmGetReferenceCountPage(PFN_NUMBER Page);
1371
1372 BOOLEAN
1373 NTAPI
1374 MmIsPageInUse(PFN_NUMBER Page);
1375
1376 VOID
1377 NTAPI
1378 MmSetSavedSwapEntryPage(
1379 PFN_NUMBER Page,
1380 SWAPENTRY SavedSwapEntry);
1381
1382 SWAPENTRY
1383 NTAPI
1384 MmGetSavedSwapEntryPage(PFN_NUMBER Page);
1385
1386 VOID
1387 NTAPI
1388 MmSetCleanPage(
1389 struct _EPROCESS *Process,
1390 PVOID Address
1391 );
1392
1393 NTSTATUS
1394 NTAPI
1395 MmCreatePageTable(PVOID PAddress);
1396
1397 VOID
1398 NTAPI
1399 MmDeletePageTable(
1400 struct _EPROCESS *Process,
1401 PVOID Address
1402 );
1403
1404 PFN_NUMBER
1405 NTAPI
1406 MmGetPfnForProcess(
1407 struct _EPROCESS *Process,
1408 PVOID Address
1409 );
1410
1411 BOOLEAN
1412 NTAPI
1413 MmCreateProcessAddressSpace(
1414 IN ULONG MinWs,
1415 IN PEPROCESS Dest,
1416 IN PULONG_PTR DirectoryTableBase
1417 );
1418
1419 NTSTATUS
1420 NTAPI
1421 MmInitializeHandBuiltProcess(
1422 IN PEPROCESS Process,
1423 IN PULONG_PTR DirectoryTableBase
1424 );
1425
1426
1427 NTSTATUS
1428 NTAPI
1429 MmInitializeHandBuiltProcess2(
1430 IN PEPROCESS Process
1431 );
1432
1433 NTSTATUS
1434 NTAPI
1435 MmReleaseMmInfo(struct _EPROCESS *Process);
1436
1437 NTSTATUS
1438 NTAPI
1439 MmSetExecuteOptions(IN ULONG ExecuteOptions);
1440
1441 NTSTATUS
1442 NTAPI
1443 MmGetExecuteOptions(IN PULONG ExecuteOptions);
1444
1445 VOID
1446 NTAPI
1447 MmDeleteProcessPageDirectory(struct _EPROCESS *Process);
1448
1449 VOID
1450 NTAPI
1451 MmDeleteVirtualMapping(
1452 struct _EPROCESS *Process,
1453 PVOID Address,
1454 BOOLEAN FreePage,
1455 BOOLEAN* WasDirty,
1456 PPFN_NUMBER Page
1457 );
1458
1459 BOOLEAN
1460 NTAPI
1461 MmIsDirtyPage(
1462 struct _EPROCESS *Process,
1463 PVOID Address
1464 );
1465
1466 VOID
1467 NTAPI
1468 MmMarkPageMapped(PFN_NUMBER Page);
1469
1470 VOID
1471 NTAPI
1472 MmMarkPageUnmapped(PFN_NUMBER Page);
1473
1474 VOID
1475 NTAPI
1476 MmUpdatePageDir(
1477 struct _EPROCESS *Process,
1478 PVOID Address,
1479 ULONG Size
1480 );
1481
1482 VOID
1483 NTAPI
1484 MiInitPageDirectoryMap(VOID);
1485
1486 ULONG
1487 NTAPI
1488 MiGetUserPageDirectoryCount(VOID);
1489
1490 /* wset.c ********************************************************************/
1491
1492 NTSTATUS
1493 MmTrimUserMemory(
1494 ULONG Target,
1495 ULONG Priority,
1496 PULONG NrFreedPages
1497 );
1498
1499 /* region.c ************************************************************/
1500
1501 NTSTATUS
1502 NTAPI
1503 MmAlterRegion(
1504 PMMSUPPORT AddressSpace,
1505 PVOID BaseAddress,
1506 PLIST_ENTRY RegionListHead,
1507 PVOID StartAddress,
1508 SIZE_T Length,
1509 ULONG NewType,
1510 ULONG NewProtect,
1511 PMM_ALTER_REGION_FUNC AlterFunc
1512 );
1513
1514 VOID
1515 NTAPI
1516 MmInitializeRegion(
1517 PLIST_ENTRY RegionListHead,
1518 SIZE_T Length,
1519 ULONG Type,
1520 ULONG Protect
1521 );
1522
1523 PMM_REGION
1524 NTAPI
1525 MmFindRegion(
1526 PVOID BaseAddress,
1527 PLIST_ENTRY RegionListHead,
1528 PVOID Address,
1529 PVOID* RegionBaseAddress
1530 );
1531
1532 /* section.c *****************************************************************/
1533
1534 VOID
1535 NTAPI
1536 MmGetImageInformation(
1537 OUT PSECTION_IMAGE_INFORMATION ImageInformation
1538 );
1539
1540 PFILE_OBJECT
1541 NTAPI
1542 MmGetFileObjectForSection(
1543 IN PVOID Section
1544 );
1545 NTSTATUS
1546 NTAPI
1547 MmGetFileNameForAddress(
1548 IN PVOID Address,
1549 OUT PUNICODE_STRING ModuleName
1550 );
1551
1552 NTSTATUS
1553 NTAPI
1554 MmGetFileNameForSection(
1555 IN PVOID Section,
1556 OUT POBJECT_NAME_INFORMATION *ModuleName
1557 );
1558
1559 PVOID
1560 NTAPI
1561 MmAllocateSection(
1562 IN SIZE_T Length,
1563 PVOID BaseAddress
1564 );
1565
1566 NTSTATUS
1567 NTAPI
1568 MmQuerySectionView(
1569 PMEMORY_AREA MemoryArea,
1570 PVOID Address,
1571 PMEMORY_BASIC_INFORMATION Info,
1572 PSIZE_T ResultLength
1573 );
1574
1575 NTSTATUS
1576 NTAPI
1577 MmProtectSectionView(
1578 PMMSUPPORT AddressSpace,
1579 PMEMORY_AREA MemoryArea,
1580 PVOID BaseAddress,
1581 SIZE_T Length,
1582 ULONG Protect,
1583 PULONG OldProtect
1584 );
1585
1586 NTSTATUS
1587 NTAPI
1588 MmInitSectionImplementation(VOID);
1589
1590 NTSTATUS
1591 NTAPI
1592 MmNotPresentFaultSectionView(
1593 PMMSUPPORT AddressSpace,
1594 MEMORY_AREA* MemoryArea,
1595 PVOID Address,
1596 BOOLEAN Locked
1597 );
1598
1599 NTSTATUS
1600 NTAPI
1601 MmPageOutSectionView(
1602 PMMSUPPORT AddressSpace,
1603 PMEMORY_AREA MemoryArea,
1604 PVOID Address,
1605 ULONG_PTR Entry
1606 );
1607
1608 NTSTATUS
1609 NTAPI
1610 MmCreatePhysicalMemorySection(VOID);
1611
1612 NTSTATUS
1613 NTAPI
1614 MmAccessFaultSectionView(
1615 PMMSUPPORT AddressSpace,
1616 MEMORY_AREA* MemoryArea,
1617 PVOID Address
1618 );
1619
1620 VOID
1621 NTAPI
1622 MmFreeSectionSegments(PFILE_OBJECT FileObject);
1623
1624 /* mpw.c *********************************************************************/
1625
1626 NTSTATUS
1627 NTAPI
1628 MmInitMpwThread(VOID);
1629
1630 NTSTATUS
1631 NTAPI
1632 MmInitBsmThread(VOID);
1633
1634 /* pager.c *******************************************************************/
1635
1636 BOOLEAN
1637 NTAPI
1638 MiIsPagerThread(VOID);
1639
1640 VOID
1641 NTAPI
1642 MiStartPagerThread(VOID);
1643
1644 VOID
1645 NTAPI
1646 MiStopPagerThread(VOID);
1647
1648 NTSTATUS
1649 FASTCALL
1650 MiQueryVirtualMemory(
1651 IN HANDLE ProcessHandle,
1652 IN PVOID Address,
1653 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass,
1654 OUT PVOID VirtualMemoryInformation,
1655 IN SIZE_T Length,
1656 OUT PSIZE_T ResultLength
1657 );
1658
1659 /* sysldr.c ******************************************************************/
1660
1661 VOID
1662 NTAPI
1663 MiReloadBootLoadedDrivers(
1664 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1665 );
1666
1667 BOOLEAN
1668 NTAPI
1669 MiInitializeLoadedModuleList(
1670 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1671 );
1672
1673 NTSTATUS
1674 NTAPI
1675 MmLoadSystemImage(
1676 IN PUNICODE_STRING FileName,
1677 IN PUNICODE_STRING NamePrefix OPTIONAL,
1678 IN PUNICODE_STRING LoadedName OPTIONAL,
1679 IN ULONG Flags,
1680 OUT PVOID *ModuleObject,
1681 OUT PVOID *ImageBaseAddress
1682 );
1683
1684 NTSTATUS
1685 NTAPI
1686 MmUnloadSystemImage(
1687 IN PVOID ImageHandle
1688 );
1689
1690 NTSTATUS
1691 NTAPI
1692 MmCheckSystemImage(
1693 IN HANDLE ImageHandle,
1694 IN BOOLEAN PurgeSection
1695 );
1696
1697 NTSTATUS
1698 NTAPI
1699 MmCallDllInitialize(
1700 IN PLDR_DATA_TABLE_ENTRY LdrEntry,
1701 IN PLIST_ENTRY ListHead
1702 );
1703
1704
1705 /* procsup.c *****************************************************************/
1706
1707 NTSTATUS
1708 NTAPI
1709 MmGrowKernelStack(
1710 IN PVOID StackPointer
1711 );
1712
1713
1714 FORCEINLINE
1715 VOID
1716 MmLockAddressSpace(PMMSUPPORT AddressSpace)
1717 {
1718 KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, Vm)->AddressCreationLock);
1719 }
1720
1721 FORCEINLINE
1722 VOID
1723 MmUnlockAddressSpace(PMMSUPPORT AddressSpace)
1724 {
1725 KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, Vm)->AddressCreationLock);
1726 }
1727
1728 FORCEINLINE
1729 PEPROCESS
1730 MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace)
1731 {
1732 if (AddressSpace == MmKernelAddressSpace) return NULL;
1733 return CONTAINING_RECORD(AddressSpace, EPROCESS, Vm);
1734 }
1735
1736 FORCEINLINE
1737 PMMSUPPORT
1738 MmGetCurrentAddressSpace(VOID)
1739 {
1740 return &((PEPROCESS)KeGetCurrentThread()->ApcState.Process)->Vm;
1741 }
1742
1743 FORCEINLINE
1744 PMMSUPPORT
1745 MmGetKernelAddressSpace(VOID)
1746 {
1747 return MmKernelAddressSpace;
1748 }
1749
1750
1751 /* expool.c ******************************************************************/
1752
1753 VOID
1754 NTAPI
1755 ExpCheckPoolAllocation(
1756 PVOID P,
1757 POOL_TYPE PoolType,
1758 ULONG Tag);
1759
1760
1761 /* session.c *****************************************************************/
1762
1763 _IRQL_requires_max_(APC_LEVEL)
1764 NTSTATUS
1765 NTAPI
1766 MmAttachSession(
1767 _Inout_ PVOID SessionEntry,
1768 _Out_ PKAPC_STATE ApcState);
1769
1770 _IRQL_requires_max_(APC_LEVEL)
1771 VOID
1772 NTAPI
1773 MmDetachSession(
1774 _Inout_ PVOID SessionEntry,
1775 _Out_ PKAPC_STATE ApcState);
1776
1777 VOID
1778 NTAPI
1779 MmQuitNextSession(
1780 _Inout_ PVOID SessionEntry);
1781
1782 PVOID
1783 NTAPI
1784 MmGetSessionById(
1785 _In_ ULONG SessionId);
1786
1787 _IRQL_requires_max_(APC_LEVEL)
1788 VOID
1789 NTAPI
1790 MmSetSessionLocaleId(
1791 _In_ LCID LocaleId);