[WKSSVC] Implement parts of NetrJoinDomain2 to join a work group
[reactos.git] / sdk / include / xdk / mmfuncs.h
1 /******************************************************************************
2 * Memory manager Functions *
3 ******************************************************************************/
4 $if (_WDMDDK_)
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 }
180 $endif (_WDMDDK_)
181 $if (_NTIFS_)
182
183 FORCEINLINE
184 ULONG
185 HEAP_MAKE_TAG_FLAGS(
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_)
196 _Must_inspect_result_
197 _IRQL_requires_max_(DISPATCH_LEVEL)
198 _When_ (return != NULL, _Post_writable_byte_size_ (NumberOfBytes))
199 NTKERNELAPI
200 PVOID
201 NTAPI
202 MmAllocateContiguousMemory(
203 _In_ SIZE_T NumberOfBytes,
204 _In_ PHYSICAL_ADDRESS HighestAcceptableAddress);
205
206 _Must_inspect_result_
207 _IRQL_requires_max_(DISPATCH_LEVEL)
208 _When_ (return != NULL, _Post_writable_byte_size_ (NumberOfBytes))
209 NTKERNELAPI
210 PVOID
211 NTAPI
212 MmAllocateContiguousMemorySpecifyCache(
213 _In_ SIZE_T NumberOfBytes,
214 _In_ PHYSICAL_ADDRESS LowestAcceptableAddress,
215 _In_ PHYSICAL_ADDRESS HighestAcceptableAddress,
216 _In_opt_ PHYSICAL_ADDRESS BoundaryAddressMultiple,
217 _In_ MEMORY_CACHING_TYPE CacheType);
218
219 _Must_inspect_result_
220 _IRQL_requires_max_(DISPATCH_LEVEL)
221 NTKERNELAPI
222 PMDL
223 NTAPI
224 MmAllocatePagesForMdl(
225 _In_ PHYSICAL_ADDRESS LowAddress,
226 _In_ PHYSICAL_ADDRESS HighAddress,
227 _In_ PHYSICAL_ADDRESS SkipBytes,
228 _In_ SIZE_T TotalBytes);
229
230 _IRQL_requires_max_(DISPATCH_LEVEL)
231 NTKERNELAPI
232 VOID
233 NTAPI
234 MmBuildMdlForNonPagedPool(
235 _Inout_ PMDL MemoryDescriptorList);
236
237 //DECLSPEC_DEPRECATED_DDK
238 NTKERNELAPI
239 PMDL
240 NTAPI
241 MmCreateMdl(
242 _Out_writes_bytes_opt_ (sizeof (MDL) + (sizeof (PFN_NUMBER) * ADDRESS_AND_SIZE_TO_SPAN_PAGES (Base, Length)))
243 PMDL MemoryDescriptorList,
244 _In_reads_bytes_opt_ (Length) PVOID Base,
245 _In_ SIZE_T Length);
246
247 _IRQL_requires_max_(DISPATCH_LEVEL)
248 NTKERNELAPI
249 VOID
250 NTAPI
251 MmFreeContiguousMemory(
252 _In_ PVOID BaseAddress);
253
254 _IRQL_requires_max_ (DISPATCH_LEVEL)
255 NTKERNELAPI
256 VOID
257 NTAPI
258 MmFreeContiguousMemorySpecifyCache(
259 _In_reads_bytes_ (NumberOfBytes) PVOID BaseAddress,
260 _In_ SIZE_T NumberOfBytes,
261 _In_ MEMORY_CACHING_TYPE CacheType);
262
263 _IRQL_requires_max_(DISPATCH_LEVEL)
264 NTKERNELAPI
265 VOID
266 NTAPI
267 MmFreePagesFromMdl(
268 _Inout_ PMDL MemoryDescriptorList);
269
270 _IRQL_requires_max_(PASSIVE_LEVEL)
271 NTKERNELAPI
272 PVOID
273 NTAPI
274 MmGetSystemRoutineAddress(
275 _In_ PUNICODE_STRING SystemRoutineName);
276
277 NTKERNELAPI
278 LOGICAL
279 NTAPI
280 MmIsDriverVerifying(
281 _In_ struct _DRIVER_OBJECT *DriverObject);
282
283 _Must_inspect_result_
284 _IRQL_requires_max_(APC_LEVEL)
285 NTKERNELAPI
286 PVOID
287 NTAPI
288 MmLockPagableDataSection(
289 _In_ PVOID AddressWithinSection);
290
291 _Must_inspect_result_
292 _IRQL_requires_max_(DISPATCH_LEVEL)
293 _Out_writes_bytes_opt_ (NumberOfBytes)
294 NTKERNELAPI
295 PVOID
296 NTAPI
297 MmMapIoSpace(
298 _In_ PHYSICAL_ADDRESS PhysicalAddress,
299 _In_ SIZE_T NumberOfBytes,
300 _In_ MEMORY_CACHING_TYPE CacheType);
301
302 _Must_inspect_result_
303 _When_(AccessMode==KernelMode, _IRQL_requires_max_(DISPATCH_LEVEL))
304 _When_(AccessMode==UserMode, _Maybe_raises_SEH_exception_ _IRQL_requires_max_(APC_LEVEL))
305 NTKERNELAPI
306 PVOID
307 NTAPI
308 MmMapLockedPages(
309 _Inout_ PMDL MemoryDescriptorList,
310 _In_ __drv_strictType(KPROCESSOR_MODE/enum _MODE,__drv_typeConst)
311 KPROCESSOR_MODE AccessMode);
312
313 _Post_writable_byte_size_(MemoryDescriptorList->ByteCount)
314 _When_(AccessMode==KernelMode, _IRQL_requires_max_(DISPATCH_LEVEL))
315 _When_(AccessMode==UserMode, _Maybe_raises_SEH_exception_ _IRQL_requires_max_(APC_LEVEL) _Post_notnull_)
316 _At_(MemoryDescriptorList->MappedSystemVa, _Post_writable_byte_size_(MemoryDescriptorList->ByteCount))
317 _Must_inspect_result_
318 _Success_(return != NULL)
319 NTKERNELAPI
320 PVOID
321 NTAPI
322 MmMapLockedPagesSpecifyCache(
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,
329 _In_ MM_PAGE_PRIORITY Priority);
330
331 _IRQL_requires_max_(APC_LEVEL)
332 NTKERNELAPI
333 PVOID
334 NTAPI
335 MmPageEntireDriver(
336 _In_ PVOID AddressWithinSection);
337
338 _IRQL_requires_max_(DISPATCH_LEVEL)
339 _At_(MemoryDescriptorList->StartVa + MemoryDescriptorList->ByteOffset,
340 _Field_size_bytes_opt_(MemoryDescriptorList->ByteCount))
341 NTKERNELAPI
342 VOID
343 NTAPI
344 MmProbeAndLockPages(
345 _Inout_ PMDL MemoryDescriptorList,
346 _In_ KPROCESSOR_MODE AccessMode,
347 _In_ LOCK_OPERATION Operation);
348
349 NTKERNELAPI
350 MM_SYSTEMSIZE
351 NTAPI
352 MmQuerySystemSize(VOID);
353
354 _IRQL_requires_max_(APC_LEVEL)
355 NTKERNELAPI
356 VOID
357 NTAPI
358 MmResetDriverPaging(
359 _In_ PVOID AddressWithinSection);
360
361 NTKERNELAPI
362 SIZE_T
363 NTAPI
364 MmSizeOfMdl(
365 _In_reads_bytes_opt_ (Length) PVOID Base,
366 _In_ SIZE_T Length);
367
368 _IRQL_requires_max_(DISPATCH_LEVEL)
369 NTKERNELAPI
370 VOID
371 NTAPI
372 MmUnlockPagableImageSection(
373 _In_ PVOID ImageSectionHandle);
374
375 _IRQL_requires_max_(DISPATCH_LEVEL)
376 NTKERNELAPI
377 VOID
378 NTAPI
379 MmUnlockPages(
380 _Inout_ PMDL MemoryDescriptorList);
381
382 _IRQL_requires_max_(DISPATCH_LEVEL)
383 NTKERNELAPI
384 VOID
385 NTAPI
386 MmUnmapIoSpace(
387 _In_reads_bytes_ (NumberOfBytes) PVOID BaseAddress,
388 _In_ SIZE_T NumberOfBytes);
389
390 _IRQL_requires_max_ (APC_LEVEL)
391 NTKERNELAPI
392 VOID
393 NTAPI
394 MmProbeAndLockProcessPages(
395 _Inout_ PMDL MemoryDescriptorList,
396 _In_ PEPROCESS Process,
397 _In_ KPROCESSOR_MODE AccessMode,
398 _In_ LOCK_OPERATION Operation);
399
400 _IRQL_requires_max_(DISPATCH_LEVEL)
401 NTKERNELAPI
402 VOID
403 NTAPI
404 MmUnmapLockedPages(
405 _In_ PVOID BaseAddress,
406 _Inout_ PMDL MemoryDescriptorList);
407
408 _Must_inspect_result_
409 _IRQL_requires_max_(DISPATCH_LEVEL)
410 _When_ (return != NULL, _Post_writable_byte_size_ (NumberOfBytes))
411 NTKERNELAPI
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);
421 $endif (_WDMDDK_)
422 $if (_NTDDK_)
423
424 _IRQL_requires_max_ (PASSIVE_LEVEL)
425 NTKERNELAPI
426 PPHYSICAL_MEMORY_RANGE
427 NTAPI
428 MmGetPhysicalMemoryRanges(VOID);
429
430 NTKERNELAPI
431 PHYSICAL_ADDRESS
432 NTAPI
433 MmGetPhysicalAddress(
434 _In_ PVOID BaseAddress);
435
436 NTKERNELAPI
437 BOOLEAN
438 NTAPI
439 MmIsNonPagedSystemAddressValid(
440 _In_ PVOID VirtualAddress);
441
442 _Must_inspect_result_
443 _IRQL_requires_max_(APC_LEVEL)
444 _Out_writes_bytes_opt_(NumberOfBytes)
445 NTKERNELAPI
446 PVOID
447 NTAPI
448 MmAllocateNonCachedMemory(
449 _In_ SIZE_T NumberOfBytes);
450
451 _IRQL_requires_max_(APC_LEVEL)
452 NTKERNELAPI
453 VOID
454 NTAPI
455 MmFreeNonCachedMemory(
456 _In_reads_bytes_(NumberOfBytes) PVOID BaseAddress,
457 _In_ SIZE_T NumberOfBytes);
458
459 NTKERNELAPI
460 PVOID
461 NTAPI
462 MmGetVirtualForPhysical(
463 _In_ PHYSICAL_ADDRESS PhysicalAddress);
464
465 _Must_inspect_result_
466 _IRQL_requires_max_(APC_LEVEL)
467 NTKERNELAPI
468 NTSTATUS
469 NTAPI
470 MmMapUserAddressesToPage(
471 _In_reads_bytes_(NumberOfBytes) PVOID BaseAddress,
472 _In_ SIZE_T NumberOfBytes,
473 _In_ PVOID PageAddress);
474
475 _Must_inspect_result_
476 _IRQL_requires_max_(APC_LEVEL)
477 _Out_writes_bytes_opt_(NumberOfBytes)
478 NTKERNELAPI
479 PVOID
480 NTAPI
481 MmMapVideoDisplay(
482 _In_ PHYSICAL_ADDRESS PhysicalAddress,
483 _In_ SIZE_T NumberOfBytes,
484 _In_ MEMORY_CACHING_TYPE CacheType);
485
486 _Must_inspect_result_
487 _IRQL_requires_max_(APC_LEVEL)
488 NTKERNELAPI
489 NTSTATUS
490 NTAPI
491 MmMapViewInSessionSpace(
492 _In_ PVOID Section,
493 _Outptr_result_bytebuffer_(*ViewSize) PVOID *MappedBase,
494 _Inout_ PSIZE_T ViewSize);
495
496 _Must_inspect_result_
497 _IRQL_requires_max_(APC_LEVEL)
498 NTKERNELAPI
499 NTSTATUS
500 NTAPI
501 MmMapViewInSystemSpace(
502 _In_ PVOID Section,
503 _Outptr_result_bytebuffer_(*ViewSize) PVOID *MappedBase,
504 _Inout_ PSIZE_T ViewSize);
505
506 _IRQL_requires_max_(DISPATCH_LEVEL)
507 NTKERNELAPI
508 BOOLEAN
509 NTAPI
510 MmIsAddressValid(
511 _In_ PVOID VirtualAddress);
512
513 NTKERNELAPI
514 BOOLEAN
515 NTAPI
516 MmIsThisAnNtAsSystem(VOID);
517
518 _IRQL_requires_max_(APC_LEVEL)
519 NTKERNELAPI
520 VOID
521 NTAPI
522 MmLockPagableSectionByHandle(
523 _In_ PVOID ImageSectionHandle);
524
525 _IRQL_requires_max_(APC_LEVEL)
526 NTKERNELAPI
527 NTSTATUS
528 NTAPI
529 MmUnmapViewInSessionSpace(
530 _In_ PVOID MappedBase);
531
532 _IRQL_requires_max_(APC_LEVEL)
533 NTKERNELAPI
534 NTSTATUS
535 NTAPI
536 MmUnmapViewInSystemSpace(
537 _In_ PVOID MappedBase);
538
539 _IRQL_requires_max_(APC_LEVEL)
540 NTKERNELAPI
541 VOID
542 NTAPI
543 MmUnsecureVirtualMemory(
544 _In_ HANDLE SecureHandle);
545
546 _IRQL_requires_max_ (PASSIVE_LEVEL)
547 NTKERNELAPI
548 NTSTATUS
549 NTAPI
550 MmRemovePhysicalMemory(
551 _In_ PPHYSICAL_ADDRESS StartAddress,
552 _Inout_ PLARGE_INTEGER NumberOfBytes);
553
554 _Must_inspect_result_
555 _IRQL_requires_max_(APC_LEVEL)
556 NTKERNELAPI
557 HANDLE
558 NTAPI
559 MmSecureVirtualMemory(
560 __in_data_source(USER_MODE) _In_reads_bytes_ (Size) PVOID Address,
561 _In_ __in_data_source(USER_MODE) SIZE_T Size,
562 _In_ ULONG ProbeMode);
563
564 _IRQL_requires_max_(APC_LEVEL)
565 NTKERNELAPI
566 VOID
567 NTAPI
568 MmUnmapVideoDisplay(
569 _In_reads_bytes_(NumberOfBytes) PVOID BaseAddress,
570 _In_ SIZE_T NumberOfBytes);
571
572 _IRQL_requires_max_ (PASSIVE_LEVEL)
573 NTKERNELAPI
574 NTSTATUS
575 NTAPI
576 MmAddPhysicalMemory(
577 _In_ PPHYSICAL_ADDRESS StartAddress,
578 _Inout_ PLARGE_INTEGER NumberOfBytes);
579 $endif (_NTDDK_)
580 $if (_NTIFS_)
581
582 NTKERNELAPI
583 BOOLEAN
584 NTAPI
585 MmIsRecursiveIoFault(VOID);
586
587 _IRQL_requires_max_ (APC_LEVEL)
588 NTKERNELAPI
589 BOOLEAN
590 NTAPI
591 MmForceSectionClosed(
592 _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer,
593 _In_ BOOLEAN DelayClose);
594
595 _IRQL_requires_max_ (APC_LEVEL)
596 NTKERNELAPI
597 BOOLEAN
598 NTAPI
599 MmFlushImageSection(
600 _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer,
601 _In_ MMFLUSH_TYPE FlushType);
602
603 _IRQL_requires_max_ (APC_LEVEL)
604 NTKERNELAPI
605 BOOLEAN
606 NTAPI
607 MmCanFileBeTruncated(
608 _In_ PSECTION_OBJECT_POINTERS SectionObjectPointer,
609 _In_opt_ PLARGE_INTEGER NewFileSize);
610
611 _IRQL_requires_max_ (APC_LEVEL)
612 NTKERNELAPI
613 BOOLEAN
614 NTAPI
615 MmSetAddressRangeModified(
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)
624 $endif (_WDMDDK_ || _NTIFS_)
625
626 $if (_WDMDDK_)
627 _IRQL_requires_max_(DISPATCH_LEVEL)
628 NTKERNELAPI
629 NTSTATUS
630 NTAPI
631 MmAdvanceMdl(
632 _Inout_ PMDL Mdl,
633 _In_ ULONG NumberOfBytes);
634
635 _Must_inspect_result_
636 _IRQL_requires_max_(APC_LEVEL)
637 _When_ (return != NULL, _Out_writes_bytes_opt_ (NumberOfBytes))
638 NTKERNELAPI
639 PVOID
640 NTAPI
641 MmAllocateMappingAddress(
642 _In_ SIZE_T NumberOfBytes,
643 _In_ ULONG PoolTag);
644
645 _IRQL_requires_max_(APC_LEVEL)
646 NTKERNELAPI
647 VOID
648 NTAPI
649 MmFreeMappingAddress(
650 _In_ PVOID BaseAddress,
651 _In_ ULONG PoolTag);
652
653 _IRQL_requires_max_ (APC_LEVEL)
654 NTKERNELAPI
655 NTSTATUS
656 NTAPI
657 MmIsVerifierEnabled(
658 _Out_ PULONG VerifierFlags);
659
660 _Post_writable_byte_size_(MemoryDescriptorList->ByteCount)
661 _IRQL_requires_max_(DISPATCH_LEVEL)
662 _At_(MemoryDescriptorList->MappedSystemVa + MemoryDescriptorList->ByteOffset,
663 _Post_writable_byte_size_(MemoryDescriptorList->ByteCount))
664 _Must_inspect_result_
665 _Success_(return != NULL)
666 NTKERNELAPI
667 PVOID
668 NTAPI
669 MmMapLockedPagesWithReservedMapping(
670 _In_ PVOID MappingAddress,
671 _In_ ULONG PoolTag,
672 _Inout_ PMDL MemoryDescriptorList,
673 _In_ __drv_strictTypeMatch(__drv_typeCond)
674 MEMORY_CACHING_TYPE CacheType);
675
676 _Must_inspect_result_
677 _IRQL_requires_max_(DISPATCH_LEVEL)
678 NTKERNELAPI
679 NTSTATUS
680 NTAPI
681 MmProtectMdlSystemAddress(
682 _In_ PMDL MemoryDescriptorList,
683 _In_ ULONG NewProtect);
684
685 _IRQL_requires_max_(DISPATCH_LEVEL)
686 NTKERNELAPI
687 VOID
688 NTAPI
689 MmUnmapReservedMapping(
690 _In_ PVOID BaseAddress,
691 _In_ ULONG PoolTag,
692 _Inout_ PMDL MemoryDescriptorList);
693
694 _IRQL_requires_max_ (APC_LEVEL)
695 NTKERNELAPI
696 NTSTATUS
697 NTAPI
698 MmAddVerifierThunks(
699 _In_reads_bytes_ (ThunkBufferSize) PVOID ThunkBuffer,
700 _In_ ULONG ThunkBufferSize);
701 $endif (_WDMDDK_)
702 $if (_NTIFS_)
703
704 _IRQL_requires_max_ (PASSIVE_LEVEL)
705 NTKERNELAPI
706 NTSTATUS
707 NTAPI
708 MmPrefetchPages(
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) */
715 $endif (_WDMDDK_ || _NTIFS_)
716 $if (_WDMDDK_ || _NTDDK_)
717 #if (NTDDI_VERSION >= NTDDI_WS03)
718 $endif (_WDMDDK_ || _NTDDK_)
719 $if (_WDMDDK_)
720 _IRQL_requires_max_ (DISPATCH_LEVEL)
721 NTKERNELAPI
722 LOGICAL
723 NTAPI
724 MmIsIoSpaceActive(
725 _In_ PHYSICAL_ADDRESS StartAddress,
726 _In_ SIZE_T NumberOfBytes);
727 $endif (_WDMDDK_)
728
729 $if (_NTDDK_)
730 _Must_inspect_result_
731 _IRQL_requires_max_(PASSIVE_LEVEL)
732 NTKERNELAPI
733 NTSTATUS
734 NTAPI
735 MmCreateMirror(VOID);
736 $endif (_NTDDK_)
737 $if (_WDMDDK_ || _NTDDK_)
738 #endif /* (NTDDI_VERSION >= NTDDI_WS03) */
739 $endif (_WDMDDK_ || _NTDDK_)
740 $if (_WDMDDK_)
741 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
742 _Must_inspect_result_
743 _IRQL_requires_max_ (DISPATCH_LEVEL)
744 NTKERNELAPI
745 PMDL
746 NTAPI
747 MmAllocatePagesForMdlEx(
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
755 $endif (_WDMDDK_)
756
757 #if (NTDDI_VERSION >= NTDDI_VISTA)
758 $if (_WDMDDK_)
759 _IRQL_requires_max_ (APC_LEVEL)
760 NTKERNELAPI
761 LOGICAL
762 NTAPI
763 MmIsDriverVerifyingByAddress(
764 _In_ PVOID AddressWithinSection);
765 $endif (_WDMDDK_)
766 $if (_NTDDK_)
767 _Must_inspect_result_
768 _IRQL_requires_max_(APC_LEVEL)
769 NTSTATUS
770 NTAPI
771 MmRotatePhysicalView(
772 _In_ PVOID VirtualAddress,
773 _Inout_ PSIZE_T NumberOfBytes,
774 _In_opt_ PMDLX NewMdl,
775 _In_ MM_ROTATE_DIRECTION Direction,
776 _In_ PMM_ROTATE_COPY_CALLBACK_FUNCTION CopyFunction,
777 _In_opt_ PVOID Context);
778 $endif (_NTDDK_)
779 $if (_NTIFS_)
780
781 _IRQL_requires_max_ (APC_LEVEL)
782 NTKERNELAPI
783 ULONG
784 NTAPI
785 MmDoesFileHaveUserWritableReferences(
786 _In_ PSECTION_OBJECT_POINTERS SectionPointer);
787
788 _Must_inspect_result_
789 _At_(*BaseAddress, __drv_allocatesMem(Mem))
790 __kernel_entry
791 NTSYSCALLAPI
792 NTSTATUS
793 NTAPI
794 NtAllocateVirtualMemory(
795 _In_ HANDLE ProcessHandle,
796 _Inout_ _Outptr_result_buffer_(*RegionSize) PVOID *BaseAddress,
797 _In_ ULONG_PTR ZeroBits,
798 _Inout_ PSIZE_T RegionSize,
799 _In_ ULONG AllocationType,
800 _In_ ULONG Protect);
801
802 __kernel_entry
803 _IRQL_requires_max_(PASSIVE_LEVEL)
804 NTSYSCALLAPI
805 NTSTATUS
806 NTAPI
807 NtFreeVirtualMemory(
808 _In_ HANDLE ProcessHandle,
809 _Inout_ __drv_freesMem(Mem) PVOID *BaseAddress,
810 _Inout_ PSIZE_T RegionSize,
811 _In_ ULONG FreeType);
812
813 $endif (_NTIFS_)
814 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
815