ReactOS  r74405
mmfuncs.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Memory manager Functions *
3  ******************************************************************************/
5 /* Alignment Macros */
6 #define ALIGN_DOWN_BY(size, align) \
7  ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1))
8 
9 #define ALIGN_UP_BY(size, align) \
10  (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align))
11 
12 #define ALIGN_DOWN_POINTER_BY(ptr, align) \
13  ((PVOID)ALIGN_DOWN_BY(ptr, align))
14 
15 #define ALIGN_UP_POINTER_BY(ptr, align) \
16  ((PVOID)ALIGN_UP_BY(ptr, align))
17 
18 #define ALIGN_DOWN(size, type) \
19  ALIGN_DOWN_BY(size, sizeof(type))
20 
21 #define ALIGN_UP(size, type) \
22  ALIGN_UP_BY(size, sizeof(type))
23 
24 #define ALIGN_DOWN_POINTER(ptr, type) \
25  ALIGN_DOWN_POINTER_BY(ptr, sizeof(type))
26 
27 #define ALIGN_UP_POINTER(ptr, type) \
28  ALIGN_UP_POINTER_BY(ptr, sizeof(type))
29 
30 #ifndef FIELD_OFFSET
31 #define FIELD_OFFSET(type, field) ((ULONG)&(((type *)0)->field))
32 #endif
33 
34 #ifndef FIELD_SIZE
35 #define FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
36 #endif
37 
38 #define POOL_TAGGING 1
39 
40 #if DBG
41 #define IF_DEBUG if (TRUE)
42 #else
43 #define IF_DEBUG if (FALSE)
44 #endif /* DBG */
45 
46 /* ULONG
47  * BYTE_OFFSET(
48  * _In_ PVOID Va)
49  */
50 #define BYTE_OFFSET(Va) \
51  ((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1)))
52 
53 /* ULONG
54  * BYTES_TO_PAGES(
55  * _In_ ULONG Size)
56  *
57  * Note: This needs to be like this to avoid overflows!
58  */
59 #define BYTES_TO_PAGES(Size) \
60  (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0))
61 
62 /* PVOID
63  * PAGE_ALIGN(
64  * _In_ PVOID Va)
65  */
66 #define PAGE_ALIGN(Va) \
67  ((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
68 
69 /* ULONG_PTR
70  * ROUND_TO_PAGES(
71  * _In_ ULONG_PTR Size)
72  */
73 #define ROUND_TO_PAGES(Size) \
74  (((ULONG_PTR) (Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
75 
76 /* ULONG
77  * ADDRESS_AND_SIZE_TO_SPAN_PAGES(
78  * _In_ PVOID Va,
79  * _In_ ULONG Size)
80  */
81 #define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size) \
82  ((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \
83  + (_Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT))
84 
85 #define COMPUTE_PAGES_SPANNED(Va, Size) \
86  ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size)
87 
88 /*
89  * ULONG
90  * MmGetMdlByteCount(
91  * _In_ PMDL Mdl)
92  */
93 #define MmGetMdlByteCount(_Mdl) \
94  ((_Mdl)->ByteCount)
95 
96 /*
97  * ULONG
98  * MmGetMdlByteOffset(
99  * IN PMDL Mdl)
100  */
101 #define MmGetMdlByteOffset(_Mdl) \
102  ((_Mdl)->ByteOffset)
103 
104 #define MmGetMdlBaseVa(Mdl) ((Mdl)->StartVa)
105 
106 /*
107  * PPFN_NUMBER
108  * MmGetMdlPfnArray(
109  * _In_ PMDL Mdl)
110  */
111 #define MmGetMdlPfnArray(_Mdl) \
112  ((PPFN_NUMBER) ((_Mdl) + 1))
113 
114 /*
115  * PVOID
116  * MmGetMdlVirtualAddress(
117  * _In_ PMDL Mdl)
118  */
119 #define MmGetMdlVirtualAddress(_Mdl) \
120  ((PVOID) ((PCHAR) ((_Mdl)->StartVa) + (_Mdl)->ByteOffset))
121 
122 #define MmGetProcedureAddress(Address) (Address)
123 #define MmLockPagableCodeSection(Address) MmLockPagableDataSection(Address)
124 
125 /* PVOID MmGetSystemAddressForMdl(
126  * _In_ PMDL Mdl);
127  */
128 #define MmGetSystemAddressForMdl(Mdl) \
129  (((Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | \
130  MDL_SOURCE_IS_NONPAGED_POOL)) ? \
131  ((Mdl)->MappedSystemVa) : \
132  (MmMapLockedPages((Mdl), KernelMode)))
133 
134 /* PVOID
135  * MmGetSystemAddressForMdlSafe(
136  * _In_ PMDL Mdl,
137  * _In_ MM_PAGE_PRIORITY Priority)
138  */
139 #define MmGetSystemAddressForMdlSafe(_Mdl, _Priority) \
140  (((_Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA \
141  | MDL_SOURCE_IS_NONPAGED_POOL)) ? \
142  (_Mdl)->MappedSystemVa : \
143  (PVOID) MmMapLockedPagesSpecifyCache((_Mdl), \
144  KernelMode, MmCached, NULL, FALSE, (_Priority)))
145 
146 /*
147  * VOID
148  * MmInitializeMdl(
149  * _In_ PMDL MemoryDescriptorList,
150  * _In_ PVOID BaseVa,
151  * _In_ SIZE_T Length)
152  */
153 #define MmInitializeMdl(_MemoryDescriptorList, \
154  _BaseVa, \
155  _Length) \
156 { \
157  (_MemoryDescriptorList)->Next = (PMDL) NULL; \
158  (_MemoryDescriptorList)->Size = (CSHORT) (sizeof(MDL) + \
159  (sizeof(PFN_NUMBER) * ADDRESS_AND_SIZE_TO_SPAN_PAGES(_BaseVa, _Length))); \
160  (_MemoryDescriptorList)->MdlFlags = 0; \
161  (_MemoryDescriptorList)->StartVa = (PVOID) PAGE_ALIGN(_BaseVa); \
162  (_MemoryDescriptorList)->ByteOffset = BYTE_OFFSET(_BaseVa); \
163  (_MemoryDescriptorList)->ByteCount = (ULONG) _Length; \
164 }
165 
166 /*
167  * VOID
168  * MmPrepareMdlForReuse(
169  * _In_ PMDL Mdl)
170  */
171 #define MmPrepareMdlForReuse(_Mdl) \
172 { \
173  if (((_Mdl)->MdlFlags & MDL_PARTIAL_HAS_BEEN_MAPPED) != 0) { \
174  ASSERT(((_Mdl)->MdlFlags & MDL_PARTIAL) != 0); \
175  MmUnmapLockedPages((_Mdl)->MappedSystemVa, (_Mdl)); \
176  } else if (((_Mdl)->MdlFlags & MDL_PARTIAL) == 0) { \
177  ASSERT(((_Mdl)->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA) == 0); \
178  } \
179 }
181 $if (_NTIFS_)
182 
184 ULONG
186  _In_ ULONG TagBase,
187  _In_ ULONG Tag)
188 {
189  //__assume_bound(TagBase); // FIXME
190  return ((ULONG)((TagBase) + ((Tag) << HEAP_TAG_SHIFT)));
191 }
192 $endif (_NTIFS_)
193 
194 #if (NTDDI_VERSION >= NTDDI_WIN2K)
195 $if (_WDMDDK_)
200 PVOID
201 NTAPI
205 
208 _When_ (return != NULL, _Post_writable_byte_size_ (NumberOfBytes))
210 PVOID
211 NTAPI
213  _In_ SIZE_T NumberOfBytes,
215  _In_ PHYSICAL_ADDRESS HighestAcceptableAddress,
218 
222 PMDL
223 NTAPI
225  _In_ PHYSICAL_ADDRESS LowAddress,
229 
232 VOID
233 NTAPI
236 
237 //DECLSPEC_DEPRECATED_DDK
239 PMDL
240 NTAPI
243  PMDL MemoryDescriptorList,
245  _In_ SIZE_T Length);
246 
249 VOID
250 NTAPI
253 
256 VOID
257 NTAPI
259  _In_reads_bytes_ (NumberOfBytes) PVOID BaseAddress,
260  _In_ SIZE_T NumberOfBytes,
261  _In_ MEMORY_CACHING_TYPE CacheType);
262 
265 VOID
266 NTAPI
268  _Inout_ PMDL MemoryDescriptorList);
269 
272 PVOID
273 NTAPI
275  _In_ PUNICODE_STRING SystemRoutineName);
276 
278 LOGICAL
279 NTAPI
282 
286 PVOID
287 NTAPI
288 MmLockPagableDataSection(
289  _In_ PVOID AddressWithinSection);
290 
293 _Out_writes_bytes_opt_ (NumberOfBytes)
295 PVOID
296 NTAPI
299  _In_ SIZE_T NumberOfBytes,
300  _In_ MEMORY_CACHING_TYPE CacheType);
301 
306 PVOID
307 NTAPI
309  _Inout_ PMDL MemoryDescriptorList,
312 
313 _Post_writable_byte_size_(MemoryDescriptorList->ByteCount)
314 _When_(AccessMode==KernelMode, _IRQL_requires_max_(DISPATCH_LEVEL))
316 _At_(MemoryDescriptorList->MappedSystemVa, _Post_writable_byte_size_(MemoryDescriptorList->ByteCount))
318 _Success_(return != NULL)
320 PVOID
321 NTAPI
323  _Inout_ PMDL MemoryDescriptorList,
324  _In_ __drv_strictType(KPROCESSOR_MODE/enum _MODE,__drv_typeConst)
325  KPROCESSOR_MODE AccessMode,
326  _In_ __drv_strictTypeMatch(__drv_typeCond) MEMORY_CACHING_TYPE CacheType,
327  _In_opt_ PVOID BaseAddress,
328  _In_ ULONG BugCheckOnFailure,
330 
333 PVOID
334 NTAPI
336  _In_ PVOID AddressWithinSection);
337 
339 _At_(MemoryDescriptorList->StartVa + MemoryDescriptorList->ByteOffset,
340  _Field_size_bytes_opt_(MemoryDescriptorList->ByteCount))
342 VOID
343 NTAPI
345  _Inout_ PMDL MemoryDescriptorList,
346  _In_ KPROCESSOR_MODE AccessMode,
348 
351 NTAPI
353 
356 VOID
357 NTAPI
359  _In_ PVOID AddressWithinSection);
360 
362 SIZE_T
363 NTAPI
365  _In_reads_bytes_opt_ (Length) PVOID Base,
366  _In_ SIZE_T Length);
367 
370 VOID
371 NTAPI
372 MmUnlockPagableImageSection(
373  _In_ PVOID ImageSectionHandle);
374 
377 VOID
378 NTAPI
380  _Inout_ PMDL MemoryDescriptorList);
381 
384 VOID
385 NTAPI
387  _In_reads_bytes_ (NumberOfBytes) PVOID BaseAddress,
388  _In_ SIZE_T NumberOfBytes);
389 
392 VOID
393 NTAPI
395  _Inout_ PMDL MemoryDescriptorList,
397  _In_ KPROCESSOR_MODE AccessMode,
398  _In_ LOCK_OPERATION Operation);
399 
402 VOID
403 NTAPI
405  _In_ PVOID BaseAddress,
406  _Inout_ PMDL MemoryDescriptorList);
407 
410 _When_ (return != NULL, _Post_writable_byte_size_ (NumberOfBytes))
412 PVOID
413 NTAPI
414 MmAllocateContiguousMemorySpecifyCacheNode(
415  _In_ SIZE_T NumberOfBytes,
416  _In_ PHYSICAL_ADDRESS LowestAcceptableAddress,
417  _In_ PHYSICAL_ADDRESS HighestAcceptableAddress,
418  _In_opt_ PHYSICAL_ADDRESS BoundaryAddressMultiple,
419  _In_ MEMORY_CACHING_TYPE CacheType,
420  _In_ NODE_REQUIREMENT PreferredNode);
422 $if (_NTDDK_)
423 
427 NTAPI
429 
432 NTAPI
434  _In_ PVOID BaseAddress);
435 
437 BOOLEAN
438 NTAPI
441 
444 _Out_writes_bytes_opt_(NumberOfBytes)
446 PVOID
447 NTAPI
449  _In_ SIZE_T NumberOfBytes);
450 
453 VOID
454 NTAPI
456  _In_reads_bytes_(NumberOfBytes) PVOID BaseAddress,
457  _In_ SIZE_T NumberOfBytes);
458 
460 PVOID
461 NTAPI
463  _In_ PHYSICAL_ADDRESS PhysicalAddress);
464 
468 NTSTATUS
469 NTAPI
471  _In_reads_bytes_(NumberOfBytes) PVOID BaseAddress,
472  _In_ SIZE_T NumberOfBytes,
474 
477 _Out_writes_bytes_opt_(NumberOfBytes)
479 PVOID
480 NTAPI
482  _In_ PHYSICAL_ADDRESS PhysicalAddress,
483  _In_ SIZE_T NumberOfBytes,
484  _In_ MEMORY_CACHING_TYPE CacheType);
485 
489 NTSTATUS
490 NTAPI
492  _In_ PVOID Section,
495 
499 NTSTATUS
500 NTAPI
502  _In_ PVOID Section,
503  _Outptr_result_bytebuffer_(*ViewSize) PVOID *MappedBase,
504  _Inout_ PSIZE_T ViewSize);
505 
508 BOOLEAN
509 NTAPI
511  _In_ PVOID VirtualAddress);
512 
514 BOOLEAN
515 NTAPI
517 
520 VOID
521 NTAPI
522 MmLockPagableSectionByHandle(
523  _In_ PVOID ImageSectionHandle);
524 
527 NTSTATUS
528 NTAPI
530  _In_ PVOID MappedBase);
531 
534 NTSTATUS
535 NTAPI
537  _In_ PVOID MappedBase);
538 
541 VOID
542 NTAPI
544  _In_ HANDLE SecureHandle);
545 
548 NTSTATUS
549 NTAPI
551  _In_ PPHYSICAL_ADDRESS StartAddress,
552  _Inout_ PLARGE_INTEGER NumberOfBytes);
553 
557 HANDLE
558 NTAPI
561  _In_ __in_data_source(USER_MODE) SIZE_T Size,
563 
566 VOID
567 NTAPI
569  _In_reads_bytes_(NumberOfBytes) PVOID BaseAddress,
570  _In_ SIZE_T NumberOfBytes);
571 
574 NTSTATUS
575 NTAPI
577  _In_ PPHYSICAL_ADDRESS StartAddress,
578  _Inout_ PLARGE_INTEGER NumberOfBytes);
579 $endif (_NTDDK_)
580 $if (_NTIFS_)
581 
583 BOOLEAN
584 NTAPI
586 
589 BOOLEAN
590 NTAPI
594 
597 BOOLEAN
598 NTAPI
600  _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer,
602 
605 BOOLEAN
606 NTAPI
608  _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer,
610 
613 BOOLEAN
614 NTAPI
616  _In_reads_bytes_ (Length) PVOID Address,
617  _In_ SIZE_T Length);
618 $endif (_NTIFS_)
619 
620 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
621 
622 $if (_WDMDDK_ || _NTIFS_)
623 #if (NTDDI_VERSION >= NTDDI_WINXP)
625 
626 $if (_WDMDDK_)
629 NTSTATUS
630 NTAPI
632  _Inout_ PMDL Mdl,
633  _In_ ULONG NumberOfBytes);
634 
637 _When_ (return != NULL, _Out_writes_bytes_opt_ (NumberOfBytes))
639 PVOID
640 NTAPI
642  _In_ SIZE_T NumberOfBytes,
644 
647 VOID
648 NTAPI
650  _In_ PVOID BaseAddress,
651  _In_ ULONG PoolTag);
652 
655 NTSTATUS
656 NTAPI
658  _Out_ PULONG VerifierFlags);
659 
660 _Post_writable_byte_size_(MemoryDescriptorList->ByteCount)
662 _At_(MemoryDescriptorList->MappedSystemVa + MemoryDescriptorList->ByteOffset,
663  _Post_writable_byte_size_(MemoryDescriptorList->ByteCount))
665 _Success_(return != NULL)
667 PVOID
668 NTAPI
670  _In_ PVOID MappingAddress,
671  _In_ ULONG PoolTag,
672  _Inout_ PMDL MemoryDescriptorList,
673  _In_ __drv_strictTypeMatch(__drv_typeCond)
674  MEMORY_CACHING_TYPE CacheType);
675 
679 NTSTATUS
680 NTAPI
682  _In_ PMDL MemoryDescriptorList,
684 
687 VOID
688 NTAPI
690  _In_ PVOID BaseAddress,
691  _In_ ULONG PoolTag,
692  _Inout_ PMDL MemoryDescriptorList);
693 
696 NTSTATUS
697 NTAPI
699  _In_reads_bytes_ (ThunkBufferSize) PVOID ThunkBuffer,
702 $if (_NTIFS_)
703 
706 NTSTATUS
707 NTAPI
709  _In_ ULONG NumberOfLists,
710  _In_reads_ (NumberOfLists) PREAD_LIST *ReadLists);
711 $endif (_NTIFS_)
712 
713 $if (_WDMDDK_ || _NTIFS_)
714 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
716 $if (_WDMDDK_ || _NTDDK_)
717 #if (NTDDI_VERSION >= NTDDI_WS03)
719 $if (_WDMDDK_)
722 LOGICAL
723 NTAPI
725  _In_ PHYSICAL_ADDRESS StartAddress,
726  _In_ SIZE_T NumberOfBytes);
728 
729 $if (_NTDDK_)
733 NTSTATUS
734 NTAPI
735 MmCreateMirror(VOID);
736 $endif (_NTDDK_)
737 $if (_WDMDDK_ || _NTDDK_)
738 #endif /* (NTDDI_VERSION >= NTDDI_WS03) */
740 $if (_WDMDDK_)
741 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
745 PMDL
746 NTAPI
748  _In_ PHYSICAL_ADDRESS LowAddress,
749  _In_ PHYSICAL_ADDRESS HighAddress,
750  _In_ PHYSICAL_ADDRESS SkipBytes,
751  _In_ SIZE_T TotalBytes,
752  _In_ MEMORY_CACHING_TYPE CacheType,
753  _In_ ULONG Flags);
754 #endif
756 
757 #if (NTDDI_VERSION >= NTDDI_VISTA)
758 $if (_WDMDDK_)
761 LOGICAL
762 NTAPI
763 MmIsDriverVerifyingByAddress(
764  _In_ PVOID AddressWithinSection);
766 $if (_NTDDK_)
769 NTSTATUS
770 NTAPI
771 MmRotatePhysicalView(
772  _In_ PVOID VirtualAddress,
773  _Inout_ PSIZE_T NumberOfBytes,
778 $endif (_NTDDK_)
779 $if (_NTIFS_)
780 
783 ULONG
784 NTAPI
786  _In_ PSECTION_OBJECT_POINTERS SectionPointer);
787 
789 _At_(*BaseAddress, __drv_allocatesMem(Mem))
792 NTSTATUS
793 NTAPI
800  _In_ ULONG Protect);
801 
805 NTSTATUS
806 NTAPI
808  _In_ HANDLE ProcessHandle,
809  _Inout_ __drv_freesMem(Mem) PVOID *BaseAddress,
810  _Inout_ PSIZE_T RegionSize,
812 
813 $endif (_NTIFS_)
814 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
815 
DWORD *typedef PVOID
Definition: winlogon.h:52
_Must_inspect_result_ _When_(AccessMode==KernelMode, _IRQL_requires_max_(DISPATCH_LEVEL)) _When_(AccessMode
MMFLUSH_TYPE
Definition: mmtypes.h:183
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS _In_opt_ PHYSICAL_ADDRESS BoundaryAddressMultiple
Definition: mmfuncs.h:214
_Must_inspect_result_ _Out_writes_bytes_opt_(NumberOfBytes)) NTKERNELAPI PVOID NTAPI MmAllocateMappingAddress(_In_ SIZE_T NumberOfBytes
BOOLEAN NTAPI MmCanFileBeTruncated(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN PLARGE_INTEGER NewFileSize)
Definition: section.c:4730
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR ZeroBits
Definition: mmfuncs.h:404
#define _Must_inspect_result_
Definition: no_sal2.h:314
BOOLEAN NTAPI MmSetAddressRangeModified(IN PVOID Address, IN SIZE_T Length)
Definition: mmsup.c:162
enum _MM_PAGE_PRIORITY MM_PAGE_PRIORITY
PVOID ULONG Address
Definition: oprghdlr.h:14
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
NTKERNELAPI PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress(_In_ PVOID BaseAddress)
MDL * PMDLX
Definition: mmtypes.h:121
#define HEAP_MAKE_TAG_FLAGS(b, o)
Definition: nt_native.h:1725
NTSTATUS NTAPI MmAddVerifierThunks(IN PVOID ThunkBuffer, IN ULONG ThunkBufferSize)
Definition: drvmgmt.c:82
#define _In_reads_bytes_opt_(size)
Definition: no_sal2.h:230
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
Definition: mdlsup.c:77
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2327
_In_ KPRIORITY Priority
Definition: kefuncs.h:516
#define _NTIFS_
Definition: ifssupp.h:20
NTKERNELAPI BOOLEAN NTAPI MmIsNonPagedSystemAddressValid(_In_ PVOID VirtualAddress)
_In_ MMFLUSH_TYPE FlushType
Definition: mmfuncs.h:601
_Must_inspect_result_ _In_ _In_ ULONG ProbeMode
Definition: mmfuncs.h:562
#define _WDMDDK_
Definition: wdm.template.h:26
#define _Post_notnull_
Definition: no_sal2.h:460
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1089
#define NTSYSCALLAPI
Definition: ntbasedef.h:196
_Post_writable_byte_size_(NumberOfBytes)) NTKERNELAPI PVOID NTAPI MmAllocateContiguousMemory(_In_ SIZE_T NumberOfBytes
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
PVOID PMDL
Definition: usb.h:39
NTKERNELAPI LOGICAL NTAPI MmIsDriverVerifying(_In_ struct _DRIVER_OBJECT *DriverObject)
PVOID NTAPI MmMapLockedPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode)
Definition: mdlsup.c:472
VOID NTAPI MmFreeContiguousMemory(IN PVOID BaseAddress)
Definition: contmem.c:648
#define _In_opt_
Definition: no_sal2.h:213
_Must_inspect_result_ _In_ PDEVICE_OBJECT _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer
Definition: fsrtlfuncs.h:1368
PMDL NTAPI MmAllocatePagesForMdlEx(IN PHYSICAL_ADDRESS LowAddress, IN PHYSICAL_ADDRESS HighAddress, IN PHYSICAL_ADDRESS SkipBytes, IN SIZE_T TotalBytes, IN MEMORY_CACHING_TYPE CacheType, IN ULONG Flags)
Definition: mdlsup.c:163
_Must_inspect_result_ _In_ SIZE_T _In_ PVOID PageAddress
Definition: mmfuncs.h:472
NTKERNELAPI SIZE_T NTAPI MmSizeOfMdl(_In_reads_bytes_opt_(Length) PVOID Base, _In_ SIZE_T Length)
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER ByteOffset
Definition: fltkernel.h:1251
uint32_t ULONG_PTR
Definition: typedefs.h:64
enum _MM_SYSTEM_SIZE MM_SYSTEMSIZE
NTSTATUS NTAPI MmAddPhysicalMemory(IN PPHYSICAL_ADDRESS StartAddress, IN OUT PLARGE_INTEGER NumberOfBytes)
Definition: dynamic.c:25
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
ULONG PFN_NUMBER
Definition: ke.h:8
ULONG_PTR * PSIZE_T
Definition: typedefs.h:79
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
__kernel_entry _IRQL_requires_max_(PASSIVE_LEVEL) NTSYSCALLAPI NTSTATUS NTAPI NtFreeVirtualMemory(_In_ HANDLE ProcessHandle
Definition: event.c:401
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG _In_ ULONG Protect
Definition: zwfuncs.h:214
PVOID NTAPI MmGetSystemRoutineAddress(IN PUNICODE_STRING SystemRoutineName)
Definition: sysldr.c:3452
_Inout_ PMDL MemoryDescriptorList
Definition: mmfuncs.h:406
NTSTATUS NTAPI MmUnmapViewInSystemSpace(IN PVOID MappedBase)
Definition: section.c:3058
NTSTATUS(NTAPI * PMM_ROTATE_COPY_CALLBACK_FUNCTION)(_In_ PMDL DestinationMdl, _In_ PMDL SourceMdl, _In_ PVOID Context)
Definition: mmtypes.h:165
VOID NTAPI MmUnmapLockedPages(IN PVOID BaseAddress, IN PMDL Mdl)
Definition: mdlsup.c:491
_In_ ULONG ThunkBufferSize
Definition: mmfuncs.h:700
VOID NTAPI MmFreePagesFromMdl(IN PMDL Mdl)
Definition: mdlsup.c:217
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
Definition: mmfuncs.h:396
NTSTATUS NTAPI MmUnmapViewInSessionSpace(IN PVOID MappedBase)
Definition: section.c:3019
NTSTATUS NTAPI MmRemovePhysicalMemory(IN PPHYSICAL_ADDRESS StartAddress, IN OUT PLARGE_INTEGER NumberOfBytes)
Definition: dynamic.c:61
$endif(_NTIFS_) $if(_WDMDDK_) _Must_inspect_result_ _IRQL_requires_max_(DISPATCH_LEVEL) _When_(return!
Definition: iofuncs.h:2594
_In_ BOOLEAN DelayClose
Definition: mmfuncs.h:593
PVOID NTAPI MmMapVideoDisplay(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:243
smooth NULL
Definition: ftsmooth.c:464
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS _In_opt_ PHYSICAL_ADDRESS _In_ MEMORY_CACHING_TYPE CacheType
Definition: mmfuncs.h:214
#define FORCEINLINE
Definition: ntbasedef.h:213
#define _Out_
Definition: no_sal2.h:323
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define _At_(target, annos)
Definition: no_sal2.h:11
#define NTKERNELAPI
return(0)
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _In_ LARGE_INTEGER ByteCount
Definition: iotypes.h:1060
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS SkipBytes
Definition: mmfuncs.h:226
$if(_WDMDDK_)$endif(_WDMDDK_) $if(_NTIFS_) FORCEINLINE ULONG HEAP_MAKE_TAG_FLAGS(_In_ ULONG TagBase
Definition: ke.h:1
__kernel_entry _Inout_ __drv_freesMem(Mem) PVOID *BaseAddress
_Must_inspect_result_ _In_ __in_data_source(USER_MODE) SIZE_T Size
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size)
BOOLEAN NTAPI MmIsRecursiveIoFault(VOID)
Definition: mmsup.c:231
UINTN Size
Definition: acefiex.h:550
* PPHYSICAL_MEMORY_RANGE
Definition: mmtypes.h:162
unsigned char BOOLEAN
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
_Inout_ PSIZE_T _In_opt_ PMDLX NewMdl
Definition: mmfuncs.h:773
#define __drv_allocatesMem(kind)
Definition: driverspecs.h:239
#define __kernel_entry
Definition: specstrings.h:50
BOOLEAN NTAPI MmFlushImageSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN MMFLUSH_TYPE FlushType)
Definition: section.c:4804
_In_reads_(NumberOfLists) PREAD_LIST *ReadLists)
#define _Outptr_result_buffer_(size)
Definition: no_sal2.h:414
#define _Success_(expr)
Definition: no_sal2.h:635
_Inout_ PSIZE_T _In_opt_ PMDLX _In_ MM_ROTATE_DIRECTION Direction
Definition: mmfuncs.h:773
PVOID NTAPI MmPageEntireDriver(IN PVOID AddressWithinSection)
Definition: sysldr.c:3405
PVOID NTAPI MmSecureVirtualMemory(IN PVOID Address, IN SIZE_T Length, IN ULONG Mode)
Definition: virtual.c:2669
_Must_inspect_result_ _In_ ULONG PoolTag
Definition: mmfuncs.h:643
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS _In_opt_ PHYSICAL_ADDRESS _In_ MEMORY_CACHING_TYPE _In_ NODE_REQUIREMENT PreferredNode
Definition: mmfuncs.h:416
NTKERNELAPI MM_SYSTEMSIZE NTAPI MmQuerySystemSize(VOID)
Definition: mmsup.c:257
ULONG NTAPI MmDoesFileHaveUserWritableReferences(IN PSECTION_OBJECT_POINTERS SectionPointer)
Definition: section.c:3278
#define _Inout_
Definition: no_sal2.h:244
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
VOID NTAPI MmResetDriverPaging(IN PVOID AddressWithinSection)
Definition: sysldr.c:3442
BOOLEAN NTAPI MmIsAddressValid(IN PVOID VirtualAddress)
Definition: mmsup.c:174
_In_opt_ PLARGE_INTEGER NewFileSize
Definition: mmfuncs.h:609
LOGICAL NTAPI MmIsIoSpaceActive(IN PHYSICAL_ADDRESS StartAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:271
NTSTATUS NTAPI MmMapViewInSystemSpace(IN PVOID SectionObject, OUT PVOID *MappedBase, IN OUT PSIZE_T ViewSize)
Definition: section.c:4853
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1060
MDL
Definition: mmtypes.h:117
NTKERNELAPI BOOLEAN NTAPI MmIsThisAnNtAsSystem(VOID)
Definition: mmsup.c:246
NTSTATUS NTAPI MmCreateMirror(VOID)
Definition: mmsup.c:265
VOID UINTN Length
Definition: acefiex.h:718
IN SIZE_T NumberOfBytes
Definition: ndis.h:3914
_In_ PHYSICAL_ADDRESS HighestAcceptableAddress
Definition: mmfuncs.h:204
BOOLEAN NTAPI MmForceSectionClosed(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN BOOLEAN DelayClose)
Definition: section.c:2975
_MODE
Definition: ketypes.h:10
_In_ ULONG _In_ BOOLEAN _Must_inspect_result_ PVOID * VirtualAddress
Definition: ndis.h:3772
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define _In_reads_bytes_(size)
Definition: no_sal2.h:229
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG AllocationType
Definition: mmfuncs.h:404
#define _Maybe_raises_SEH_exception_
Definition: no_sal2.h:313
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS LowestAcceptableAddress
Definition: mmfuncs.h:214
NTSTATUS NTAPI MmIsVerifierEnabled(OUT PULONG VerifierFlags)
Definition: drvmgmt.c:233
PPHYSICAL_MEMORY_RANGE NTAPI MmGetPhysicalMemoryRanges(VOID)
Definition: dynamic.c:73
_Must_inspect_result_ _Maybe_raises_SEH_exception_ _In_ __drv_strictType(KPROCESSOR_MODE/enum _MODE, __drv_typeConst) KPROCESSOR_MODE AccessMode)
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define _In_
Definition: no_sal2.h:204
ULONG_PTR SIZE_T
Definition: typedefs.h:79
DWORD *typedef HANDLE
Definition: winlogon.h:52
NTSTATUS NTAPI MmProtectMdlSystemAddress(IN PMDL MemoryDescriptorList, IN ULONG NewProtect)
Definition: mdlsup.c:1321
NTSTATUS NTAPI NtAllocateVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UBaseAddress, IN ULONG_PTR ZeroBits, IN OUT PSIZE_T URegionSize, IN ULONG AllocationType, IN ULONG Protect)
Definition: virtual.c:4367
LONG NTSTATUS
Definition: DriverTester.h:11
#define HEAP_TAG_SHIFT
Definition: nt_native.h:1724
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:585
enum _LOCK_OPERATION LOCK_OPERATION
__kernel_entry _Inout_ _Inout_ PSIZE_T _In_ ULONG FreeType
Definition: mmfuncs.h:172
PVOID NTAPI MmMapLockedPagesSpecifyCache(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN MEMORY_CACHING_TYPE CacheType, IN PVOID BaseAddress, IN ULONG BugCheckOnFailure, IN MM_PAGE_PRIORITY Priority)
Definition: mdlsup.c:313
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS HighAddress
Definition: mmfuncs.h:226
__kernel_entry _Inout_ _Inout_ PSIZE_T RegionSize
Definition: mmfuncs.h:172
enum _MM_ROTATE_DIRECTION MM_ROTATE_DIRECTION
NTKERNELAPI PMDL NTAPI MmCreateMdl(_Out_writes_bytes_opt_(sizeof(MDL)+(sizeof(PFN_NUMBER)*ADDRESS_AND_SIZE_TO_SPAN_PAGES(Base, Length))) PMDL MemoryDescriptorList, _In_reads_bytes_opt_(Length) PVOID Base, _In_ SIZE_T Length)
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:193
PVOID NTAPI MmMapLockedPagesWithReservedMapping(IN PVOID MappingAddress, IN ULONG PoolTag, IN PMDL MemoryDescriptorList, IN MEMORY_CACHING_TYPE CacheType)
Definition: mdlsup.c:1283
_Must_inspect_result_ _In_ ULONG NewProtect
Definition: mmfuncs.h:683
_In_ PEPROCESS Process
Definition: mmfuncs.h:396
NTSTATUS NTAPI MmAdvanceMdl(IN PMDL Mdl, IN ULONG NumberOfBytes)
Definition: mdlsup.c:1271
unsigned int * PULONG
Definition: retypes.h:1
PVOID NTAPI MmAllocateContiguousMemory(IN SIZE_T NumberOfBytes, IN PHYSICAL_ADDRESS HighestAcceptableAddress)
Definition: contmem.c:621
#define __drv_strictTypeMatch(mode)
Definition: driverspecs.h:312
VOID NTAPI MmFreeNonCachedMemory(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: ncache.c:172
_In_ PEPROCESS _In_ KPROCESSOR_MODE _In_ LOCK_OPERATION Operation
Definition: mmfuncs.h:396
NTSTATUS NTAPI MmMapUserAddressesToPage(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes, IN PVOID PageAddress)
Definition: mmsup.c:31
_Must_inspect_result_ _Outptr_result_bytebuffer_ ViewSize PVOID * MappedBase
Definition: mmfuncs.h:493
IN ULONG IN ULONG Tag
Definition: evtlib.h:153
VOID NTAPI MmUnmapVideoDisplay(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:260
#define _Field_size_bytes_opt_(size)
Definition: no_sal2.h:193
VOID NTAPI MmFreeContiguousMemorySpecifyCache(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: contmem.c:661
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:404
#define _Outptr_result_bytebuffer_(size)
Definition: no_sal2.h:420
unsigned int ULONG
Definition: retypes.h:1
NTKERNELAPI PVOID NTAPI MmGetVirtualForPhysical(_In_ PHYSICAL_ADDRESS PhysicalAddress)
VOID NTAPI MmUnmapReservedMapping(IN PVOID BaseAddress, IN ULONG PoolTag, IN PMDL MemoryDescriptorList)
Definition: mdlsup.c:1297
NTSTATUS NTAPI MmMapViewInSessionSpace(IN PVOID Section, OUT PVOID *MappedBase, IN OUT PSIZE_T ViewSize)
Definition: section.c:2987
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
enum _MEMORY_CACHING_TYPE MEMORY_CACHING_TYPE
PVOID NTAPI MmAllocateNonCachedMemory(IN SIZE_T NumberOfBytes)
Definition: ncache.c:25
#define APC_LEVEL
Definition: env_spec_w32.h:695
PMDL NTAPI MmAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress, IN PHYSICAL_ADDRESS HighAddress, IN PHYSICAL_ADDRESS SkipBytes, IN SIZE_T TotalBytes)
Definition: mdlsup.c:142
PVOID NTAPI MmAllocateMappingAddress(IN SIZE_T NumberOfBytes, IN ULONG PoolTag)
Definition: pool.c:1387
_Inout_ PSIZE_T _In_opt_ PMDLX _In_ MM_ROTATE_DIRECTION _In_ PMM_ROTATE_COPY_CALLBACK_FUNCTION CopyFunction
Definition: mmfuncs.h:773
#define _NTDDK_
NTSTATUS NTAPI MmPrefetchPages(IN ULONG NumberOfLists, IN PREAD_LIST *ReadLists)
Definition: mdlsup.c:1309
VOID NTAPI MmProbeAndLockProcessPages(IN OUT PMDL MemoryDescriptorList, IN PEPROCESS Process, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:1333
VOID NTAPI MmUnsecureVirtualMemory(IN PVOID SecureMem)
Definition: virtual.c:2682
_Must_inspect_result_ _In_ PHYSICAL_ADDRESS _In_ PHYSICAL_ADDRESS _In_ SIZE_T TotalBytes
Definition: mmfuncs.h:226
VOID NTAPI MmFreeMappingAddress(IN PVOID BaseAddress, IN ULONG PoolTag)
Definition: pool.c:1399
PVOID NTAPI MmAllocateContiguousMemorySpecifyCache(IN SIZE_T NumberOfBytes, IN PHYSICAL_ADDRESS LowestAcceptableAddress OPTIONAL, IN PHYSICAL_ADDRESS HighestAcceptableAddress, IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, IN MEMORY_CACHING_TYPE CacheType OPTIONAL)
Definition: contmem.c:569
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
Definition: virtual.c:5089