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