Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2454 lines
46 KiB

  1. /*-- BUILD Version: 0005 // Increment this if a change has global effects
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. mm.h
  5. Abstract:
  6. This module contains the public data structures and procedure
  7. prototypes for the memory management system.
  8. Author:
  9. Lou Perazzoli (loup) 20-Mar-1989
  10. Revision History:
  11. --*/
  12. #ifndef _MM_
  13. #define _MM_
  14. //
  15. // Virtual bias applied when the kernel image was loaded.
  16. //
  17. #if !defined(_WIN64)
  18. extern ULONG_PTR MmVirtualBias;
  19. #else
  20. #define MmVirtualBias 0
  21. #endif
  22. typedef struct _PHYSICAL_MEMORY_RUN {
  23. PFN_NUMBER BasePage;
  24. PFN_NUMBER PageCount;
  25. } PHYSICAL_MEMORY_RUN, *PPHYSICAL_MEMORY_RUN;
  26. typedef struct _PHYSICAL_MEMORY_DESCRIPTOR {
  27. ULONG NumberOfRuns;
  28. PFN_NUMBER NumberOfPages;
  29. PHYSICAL_MEMORY_RUN Run[1];
  30. } PHYSICAL_MEMORY_DESCRIPTOR, *PPHYSICAL_MEMORY_DESCRIPTOR;
  31. //
  32. // Physical memory blocks.
  33. //
  34. extern PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock;
  35. //
  36. // The allocation granularity is 64k.
  37. //
  38. #define MM_ALLOCATION_GRANULARITY ((ULONG)0x10000)
  39. //
  40. // Maximum read ahead size for cache operations.
  41. //
  42. #define MM_MAXIMUM_READ_CLUSTER_SIZE (15)
  43. #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_)
  44. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  45. //
  46. // Indicates the system may do I/O to physical addresses above 4 GB.
  47. //
  48. extern PBOOLEAN Mm64BitPhysicalAddress;
  49. // end_ntddk end_wdm end_nthal end_ntifs
  50. #else
  51. //
  52. // Indicates the system may do I/O to physical addresses above 4 GB.
  53. //
  54. extern BOOLEAN Mm64BitPhysicalAddress;
  55. #endif
  56. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  57. //
  58. // Define maximum disk transfer size to be used by MM and Cache Manager,
  59. // so that packet-oriented disk drivers can optimize their packet allocation
  60. // to this size.
  61. //
  62. #define MM_MAXIMUM_DISK_IO_SIZE (0x10000)
  63. //++
  64. //
  65. // ULONG_PTR
  66. // ROUND_TO_PAGES (
  67. // IN ULONG_PTR Size
  68. // )
  69. //
  70. // Routine Description:
  71. //
  72. // The ROUND_TO_PAGES macro takes a size in bytes and rounds it up to a
  73. // multiple of the page size.
  74. //
  75. // NOTE: This macro fails for values 0xFFFFFFFF - (PAGE_SIZE - 1).
  76. //
  77. // Arguments:
  78. //
  79. // Size - Size in bytes to round up to a page multiple.
  80. //
  81. // Return Value:
  82. //
  83. // Returns the size rounded up to a multiple of the page size.
  84. //
  85. //--
  86. #define ROUND_TO_PAGES(Size) (((ULONG_PTR)(Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
  87. //++
  88. //
  89. // ULONG
  90. // BYTES_TO_PAGES (
  91. // IN ULONG Size
  92. // )
  93. //
  94. // Routine Description:
  95. //
  96. // The BYTES_TO_PAGES macro takes the size in bytes and calculates the
  97. // number of pages required to contain the bytes.
  98. //
  99. // Arguments:
  100. //
  101. // Size - Size in bytes.
  102. //
  103. // Return Value:
  104. //
  105. // Returns the number of pages required to contain the specified size.
  106. //
  107. //--
  108. #define BYTES_TO_PAGES(Size) ((ULONG)((ULONG_PTR)(Size) >> PAGE_SHIFT) + \
  109. (((ULONG)(Size) & (PAGE_SIZE - 1)) != 0))
  110. //++
  111. //
  112. // ULONG
  113. // BYTE_OFFSET (
  114. // IN PVOID Va
  115. // )
  116. //
  117. // Routine Description:
  118. //
  119. // The BYTE_OFFSET macro takes a virtual address and returns the byte offset
  120. // of that address within the page.
  121. //
  122. // Arguments:
  123. //
  124. // Va - Virtual address.
  125. //
  126. // Return Value:
  127. //
  128. // Returns the byte offset portion of the virtual address.
  129. //
  130. //--
  131. #define BYTE_OFFSET(Va) ((ULONG)((LONG_PTR)(Va) & (PAGE_SIZE - 1)))
  132. //++
  133. //
  134. // PVOID
  135. // PAGE_ALIGN (
  136. // IN PVOID Va
  137. // )
  138. //
  139. // Routine Description:
  140. //
  141. // The PAGE_ALIGN macro takes a virtual address and returns a page-aligned
  142. // virtual address for that page.
  143. //
  144. // Arguments:
  145. //
  146. // Va - Virtual address.
  147. //
  148. // Return Value:
  149. //
  150. // Returns the page aligned virtual address.
  151. //
  152. //--
  153. #define PAGE_ALIGN(Va) ((PVOID)((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
  154. //++
  155. //
  156. // ULONG
  157. // ADDRESS_AND_SIZE_TO_SPAN_PAGES (
  158. // IN PVOID Va,
  159. // IN ULONG Size
  160. // )
  161. //
  162. // Routine Description:
  163. //
  164. // The ADDRESS_AND_SIZE_TO_SPAN_PAGES macro takes a virtual address and
  165. // size and returns the number of pages spanned by the size.
  166. //
  167. // Arguments:
  168. //
  169. // Va - Virtual address.
  170. //
  171. // Size - Size in bytes.
  172. //
  173. // Return Value:
  174. //
  175. // Returns the number of pages spanned by the size.
  176. //
  177. //--
  178. #define ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size) \
  179. ((ULONG)((((ULONG_PTR)(Va) & (PAGE_SIZE -1)) + (Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT))
  180. #if PRAGMA_DEPRECATED_DDK
  181. #pragma deprecated(COMPUTE_PAGES_SPANNED) // Use ADDRESS_AND_SIZE_TO_SPAN_PAGES
  182. #endif
  183. #define COMPUTE_PAGES_SPANNED(Va, Size) ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size)
  184. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  185. //++
  186. //
  187. // BOOLEAN
  188. // IS_SYSTEM_ADDRESS
  189. // IN PVOID Va,
  190. // )
  191. //
  192. // Routine Description:
  193. //
  194. // This macro takes a virtual address and returns TRUE if the virtual address
  195. // is within system space, FALSE otherwise.
  196. //
  197. // Arguments:
  198. //
  199. // Va - Virtual address.
  200. //
  201. // Return Value:
  202. //
  203. // Returns TRUE is the address is in system space.
  204. //
  205. //--
  206. // begin_ntosp
  207. #define IS_SYSTEM_ADDRESS(VA) ((VA) >= MM_SYSTEM_RANGE_START)
  208. // end_ntosp
  209. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  210. //++
  211. // PPFN_NUMBER
  212. // MmGetMdlPfnArray (
  213. // IN PMDL Mdl
  214. // )
  215. //
  216. // Routine Description:
  217. //
  218. // The MmGetMdlPfnArray routine returns the virtual address of the
  219. // first element of the array of physical page numbers associated with
  220. // the MDL.
  221. //
  222. // Arguments:
  223. //
  224. // Mdl - Pointer to an MDL.
  225. //
  226. // Return Value:
  227. //
  228. // Returns the virtual address of the first element of the array of
  229. // physical page numbers associated with the MDL.
  230. //
  231. //--
  232. #define MmGetMdlPfnArray(Mdl) ((PPFN_NUMBER)(Mdl + 1))
  233. //++
  234. //
  235. // PVOID
  236. // MmGetMdlVirtualAddress (
  237. // IN PMDL Mdl
  238. // )
  239. //
  240. // Routine Description:
  241. //
  242. // The MmGetMdlVirtualAddress returns the virtual address of the buffer
  243. // described by the Mdl.
  244. //
  245. // Arguments:
  246. //
  247. // Mdl - Pointer to an MDL.
  248. //
  249. // Return Value:
  250. //
  251. // Returns the virtual address of the buffer described by the Mdl
  252. //
  253. //--
  254. #define MmGetMdlVirtualAddress(Mdl) \
  255. ((PVOID) ((PCHAR) ((Mdl)->StartVa) + (Mdl)->ByteOffset))
  256. //++
  257. //
  258. // ULONG
  259. // MmGetMdlByteCount (
  260. // IN PMDL Mdl
  261. // )
  262. //
  263. // Routine Description:
  264. //
  265. // The MmGetMdlByteCount returns the length in bytes of the buffer
  266. // described by the Mdl.
  267. //
  268. // Arguments:
  269. //
  270. // Mdl - Pointer to an MDL.
  271. //
  272. // Return Value:
  273. //
  274. // Returns the byte count of the buffer described by the Mdl
  275. //
  276. //--
  277. #define MmGetMdlByteCount(Mdl) ((Mdl)->ByteCount)
  278. //++
  279. //
  280. // ULONG
  281. // MmGetMdlByteOffset (
  282. // IN PMDL Mdl
  283. // )
  284. //
  285. // Routine Description:
  286. //
  287. // The MmGetMdlByteOffset returns the byte offset within the page
  288. // of the buffer described by the Mdl.
  289. //
  290. // Arguments:
  291. //
  292. // Mdl - Pointer to an MDL.
  293. //
  294. // Return Value:
  295. //
  296. // Returns the byte offset within the page of the buffer described by the Mdl
  297. //
  298. //--
  299. #define MmGetMdlByteOffset(Mdl) ((Mdl)->ByteOffset)
  300. //++
  301. //
  302. // PVOID
  303. // MmGetMdlStartVa (
  304. // IN PMDL Mdl
  305. // )
  306. //
  307. // Routine Description:
  308. //
  309. // The MmGetMdlBaseVa returns the virtual address of the buffer
  310. // described by the Mdl rounded down to the nearest page.
  311. //
  312. // Arguments:
  313. //
  314. // Mdl - Pointer to an MDL.
  315. //
  316. // Return Value:
  317. //
  318. // Returns the returns the starting virtual address of the MDL.
  319. //
  320. //
  321. //--
  322. #define MmGetMdlBaseVa(Mdl) ((Mdl)->StartVa)
  323. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  324. //
  325. // Section object type.
  326. //
  327. extern POBJECT_TYPE MmSectionObjectType;
  328. //
  329. // PAE PTE mask.
  330. //
  331. extern ULONG MmPaeErrMask;
  332. extern ULONGLONG MmPaeMask;
  333. //
  334. // Number of pages to read in a single I/O if possible.
  335. //
  336. extern ULONG MmReadClusterSize;
  337. //
  338. // Number of colors in system.
  339. //
  340. extern ULONG MmNumberOfColors;
  341. //
  342. // Number of physical pages.
  343. //
  344. extern PFN_COUNT MmNumberOfPhysicalPages;
  345. //
  346. // Virtual size of system cache in pages.
  347. //
  348. extern ULONG_PTR MmSizeOfSystemCacheInPages;
  349. //
  350. // System cache working set.
  351. //
  352. extern MMSUPPORT MmSystemCacheWs;
  353. //
  354. // Working set manager event.
  355. //
  356. extern KEVENT MmWorkingSetManagerEvent;
  357. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  358. typedef enum _MM_SYSTEM_SIZE {
  359. MmSmallSystem,
  360. MmMediumSystem,
  361. MmLargeSystem
  362. } MM_SYSTEMSIZE;
  363. NTKERNELAPI
  364. MM_SYSTEMSIZE
  365. MmQuerySystemSize(
  366. VOID
  367. );
  368. // end_wdm
  369. NTKERNELAPI
  370. BOOLEAN
  371. MmIsThisAnNtAsSystem(
  372. VOID
  373. );
  374. // begin_wdm
  375. typedef enum _LOCK_OPERATION {
  376. IoReadAccess,
  377. IoWriteAccess,
  378. IoModifyAccess
  379. } LOCK_OPERATION;
  380. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  381. //
  382. // NT product type.
  383. //
  384. extern ULONG MmProductType;
  385. typedef struct _MMINFO_COUNTERS {
  386. ULONG PageFaultCount;
  387. ULONG CopyOnWriteCount;
  388. ULONG TransitionCount;
  389. ULONG CacheTransitionCount;
  390. ULONG DemandZeroCount;
  391. ULONG PageReadCount;
  392. ULONG PageReadIoCount;
  393. ULONG CacheReadCount;
  394. ULONG CacheIoCount;
  395. ULONG DirtyPagesWriteCount;
  396. ULONG DirtyWriteIoCount;
  397. ULONG MappedPagesWriteCount;
  398. ULONG MappedWriteIoCount;
  399. } MMINFO_COUNTERS;
  400. typedef MMINFO_COUNTERS *PMMINFO_COUNTERS;
  401. extern MMINFO_COUNTERS MmInfoCounters;
  402. //
  403. // Memory management initialization routine (for both phases).
  404. //
  405. BOOLEAN
  406. MmInitSystem (
  407. IN ULONG Phase,
  408. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  409. );
  410. PPHYSICAL_MEMORY_DESCRIPTOR
  411. MmInitializeMemoryLimits (
  412. IN PLOADER_PARAMETER_BLOCK LoaderBlock,
  413. IN PBOOLEAN IncludedType,
  414. IN OUT PPHYSICAL_MEMORY_DESCRIPTOR Memory OPTIONAL
  415. );
  416. VOID
  417. MmFreeLoaderBlock (
  418. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  419. );
  420. VOID
  421. MmEnablePAT (
  422. VOID
  423. );
  424. PVOID
  425. MmAllocateIndependentPages(
  426. IN SIZE_T NumberOfBytes,
  427. IN ULONG NodeNumber
  428. );
  429. BOOLEAN
  430. MmSetPageProtection(
  431. IN PVOID VirtualAddress,
  432. IN SIZE_T NumberOfBytes,
  433. IN ULONG NewProtect
  434. );
  435. VOID
  436. MmFreeIndependentPages(
  437. IN PVOID VirtualAddress,
  438. IN SIZE_T NumberOfBytes
  439. );
  440. NTSTATUS
  441. MmCreateMirror (
  442. VOID
  443. );
  444. //
  445. // Shutdown routine - flushes dirty pages, etc for system shutdown.
  446. //
  447. BOOLEAN
  448. MmShutdownSystem (
  449. IN ULONG
  450. );
  451. //
  452. // Routines to deal with working set and commit enforcement.
  453. //
  454. LOGICAL
  455. MmAssignProcessToJob (
  456. IN PEPROCESS Process
  457. );
  458. LOGICAL
  459. MmEnforceWorkingSetLimit (
  460. IN PMMSUPPORT WsInfo,
  461. IN LOGICAL Enable
  462. );
  463. //
  464. // Routines to deal with session space.
  465. //
  466. NTSTATUS
  467. MmSessionCreate (
  468. OUT PULONG SessionId
  469. );
  470. NTSTATUS
  471. MmSessionDelete (
  472. IN ULONG SessionId
  473. );
  474. ULONG
  475. MmGetSessionId (
  476. IN PEPROCESS Process
  477. );
  478. LCID
  479. MmGetSessionLocaleId (
  480. VOID
  481. );
  482. VOID
  483. MmSetSessionLocaleId (
  484. IN LCID LocaleId
  485. );
  486. PVOID
  487. MmGetSessionById (
  488. IN ULONG SessionId
  489. );
  490. PVOID
  491. MmGetNextSession (
  492. IN PVOID OpaqueSession
  493. );
  494. PVOID
  495. MmGetPreviousSession (
  496. IN PVOID OpaqueSession
  497. );
  498. NTSTATUS
  499. MmQuitNextSession (
  500. IN PVOID OpaqueSession
  501. );
  502. NTSTATUS
  503. MmAttachSession (
  504. IN PVOID OpaqueSession,
  505. OUT PRKAPC_STATE ApcState
  506. );
  507. NTSTATUS
  508. MmDetachSession (
  509. IN PVOID OpaqueSession,
  510. IN PRKAPC_STATE ApcState
  511. );
  512. VOID
  513. MmSessionSetUnloadAddress (
  514. IN PDRIVER_OBJECT pWin32KDevice
  515. );
  516. //
  517. // Pool support routines to allocate complete pages, not for
  518. // general consumption, these are only used by the executive pool allocator.
  519. //
  520. SIZE_T
  521. MmAvailablePoolInPages (
  522. IN POOL_TYPE PoolType
  523. );
  524. LOGICAL
  525. MmResourcesAvailable (
  526. IN POOL_TYPE PoolType,
  527. IN SIZE_T NumberOfBytes,
  528. IN EX_POOL_PRIORITY Priority
  529. );
  530. PVOID
  531. MiAllocatePoolPages (
  532. IN POOL_TYPE PoolType,
  533. IN SIZE_T SizeInBytes,
  534. IN ULONG IsLargeSessionAllocation
  535. );
  536. ULONG
  537. MiFreePoolPages (
  538. IN PVOID StartingAddress
  539. );
  540. PVOID
  541. MiSessionPoolVector (
  542. VOID
  543. );
  544. PVOID
  545. MiSessionPoolMutex (
  546. VOID
  547. );
  548. VOID
  549. MiSessionPoolAllocated (
  550. IN PVOID VirtualAddress,
  551. IN SIZE_T NumberOfBytes,
  552. IN POOL_TYPE PoolType
  553. );
  554. VOID
  555. MiSessionPoolFreed (
  556. IN PVOID VirtualAddress,
  557. IN SIZE_T NumberOfBytes,
  558. IN POOL_TYPE PoolType
  559. );
  560. //
  561. // Routine for determining which pool a given address resides within.
  562. //
  563. POOL_TYPE
  564. MmDeterminePoolType (
  565. IN PVOID VirtualAddress
  566. );
  567. LOGICAL
  568. MmIsSystemAddressLocked (
  569. IN PVOID VirtualAddress
  570. );
  571. LOGICAL
  572. MmAreMdlPagesLocked (
  573. IN PMDL MemoryDescriptorList
  574. );
  575. //
  576. // First level fault routine.
  577. //
  578. NTSTATUS
  579. MmAccessFault (
  580. IN ULONG_PTR FaultStatus,
  581. IN PVOID VirtualAddress,
  582. IN KPROCESSOR_MODE PreviousMode,
  583. IN PVOID TrapInformation
  584. );
  585. #if defined(_IA64_)
  586. NTSTATUS
  587. MmX86Fault (
  588. IN ULONG_PTR FaultStatus,
  589. IN PVOID VirtualAddress,
  590. IN KPROCESSOR_MODE PreviousMode,
  591. IN PVOID TrapInformation
  592. );
  593. #endif
  594. //
  595. // Process Support Routines.
  596. //
  597. BOOLEAN
  598. MmCreateProcessAddressSpace (
  599. IN ULONG MinimumWorkingSetSize,
  600. IN PEPROCESS NewProcess,
  601. OUT PULONG_PTR DirectoryTableBase
  602. );
  603. NTSTATUS
  604. MmInitializeProcessAddressSpace (
  605. IN PEPROCESS ProcessToInitialize,
  606. IN PEPROCESS ProcessToClone OPTIONAL,
  607. IN PVOID SectionToMap OPTIONAL,
  608. OUT POBJECT_NAME_INFORMATION * pAuditName OPTIONAL
  609. );
  610. VOID
  611. MmInitializeHandBuiltProcess (
  612. IN PEPROCESS Process,
  613. OUT PULONG_PTR DirectoryTableBase
  614. );
  615. NTSTATUS
  616. MmInitializeHandBuiltProcess2 (
  617. IN PEPROCESS Process
  618. );
  619. VOID
  620. MmDeleteProcessAddressSpace (
  621. IN PEPROCESS Process
  622. );
  623. VOID
  624. MmCleanProcessAddressSpace (
  625. IN PEPROCESS Process
  626. );
  627. VOID
  628. MmCleanUserProcessAddressSpace (
  629. VOID
  630. );
  631. VOID
  632. MmCleanVirtualAddressDescriptor (
  633. VOID
  634. );
  635. PFN_NUMBER
  636. MmGetDirectoryFrameFromProcess (
  637. IN PEPROCESS Process
  638. );
  639. PFILE_OBJECT
  640. MmGetFileObjectForSection (
  641. IN PVOID Section
  642. );
  643. PVOID
  644. MmCreateKernelStack (
  645. BOOLEAN LargeStack,
  646. UCHAR Processor
  647. );
  648. VOID
  649. MmDeleteKernelStack (
  650. IN PVOID PointerKernelStack,
  651. IN BOOLEAN LargeStack
  652. );
  653. LOGICAL
  654. MmIsFileObjectAPagingFile (
  655. IN PFILE_OBJECT FileObject
  656. );
  657. // begin_ntosp
  658. NTKERNELAPI
  659. NTSTATUS
  660. MmGrowKernelStack (
  661. IN PVOID CurrentStack
  662. );
  663. // end_ntosp
  664. #if defined(_IA64_)
  665. NTSTATUS
  666. MmGrowKernelBackingStore (
  667. IN PVOID CurrentStack
  668. );
  669. #endif
  670. VOID
  671. MmOutPageKernelStack (
  672. IN PKTHREAD Thread
  673. );
  674. VOID
  675. MmInPageKernelStack (
  676. IN PKTHREAD Thread
  677. );
  678. VOID
  679. MmOutSwapProcess (
  680. IN PKPROCESS Process
  681. );
  682. VOID
  683. MmInSwapProcess (
  684. IN PKPROCESS Process
  685. );
  686. NTSTATUS
  687. MmCreateTeb (
  688. IN PEPROCESS TargetProcess,
  689. IN PINITIAL_TEB InitialTeb,
  690. IN PCLIENT_ID ClientId,
  691. OUT PTEB *Base
  692. );
  693. NTSTATUS
  694. MmCreatePeb (
  695. IN PEPROCESS TargetProcess,
  696. IN PINITIAL_PEB InitialPeb,
  697. OUT PPEB *Base
  698. );
  699. VOID
  700. MmDeleteTeb (
  701. IN PEPROCESS TargetProcess,
  702. IN PVOID TebBase
  703. );
  704. VOID
  705. MmAllowWorkingSetExpansion (
  706. VOID
  707. );
  708. // begin_ntosp
  709. NTKERNELAPI
  710. NTSTATUS
  711. MmAdjustWorkingSetSize (
  712. IN SIZE_T WorkingSetMinimum,
  713. IN SIZE_T WorkingSetMaximum,
  714. IN ULONG SystemCache,
  715. IN BOOLEAN IncreaseOkay
  716. );
  717. // end_ntosp
  718. VOID
  719. MmAdjustPageFileQuota (
  720. IN ULONG NewPageFileQuota
  721. );
  722. VOID
  723. MmWorkingSetManager (
  724. VOID
  725. );
  726. VOID
  727. MmEmptyAllWorkingSets (
  728. VOID
  729. );
  730. VOID
  731. MmSetMemoryPriorityProcess(
  732. IN PEPROCESS Process,
  733. IN UCHAR MemoryPriority
  734. );
  735. //
  736. // Dynamic system loading support
  737. //
  738. #define MM_LOAD_IMAGE_IN_SESSION 0x1
  739. #define MM_LOAD_IMAGE_AND_LOCKDOWN 0x2
  740. NTSTATUS
  741. MmLoadSystemImage (
  742. IN PUNICODE_STRING ImageFileName,
  743. IN PUNICODE_STRING NamePrefix OPTIONAL,
  744. IN PUNICODE_STRING LoadedBaseName OPTIONAL,
  745. IN ULONG LoadFlags,
  746. OUT PVOID *Section,
  747. OUT PVOID *ImageBaseAddress
  748. );
  749. VOID
  750. MmFreeDriverInitialization (
  751. IN PVOID Section
  752. );
  753. NTSTATUS
  754. MmUnloadSystemImage (
  755. IN PVOID Section
  756. );
  757. VOID
  758. MmMakeKernelResourceSectionWritable (
  759. VOID
  760. );
  761. VOID
  762. VerifierFreeTrackedPool(
  763. IN PVOID VirtualAddress,
  764. IN SIZE_T ChargedBytes,
  765. IN LOGICAL CheckType,
  766. IN LOGICAL SpecialPool
  767. );
  768. //
  769. // Triage support
  770. //
  771. ULONG
  772. MmSizeOfTriageInformation(
  773. VOID
  774. );
  775. ULONG
  776. MmSizeOfUnloadedDriverInformation(
  777. VOID
  778. );
  779. VOID
  780. MmWriteTriageInformation(
  781. IN PVOID
  782. );
  783. VOID
  784. MmWriteUnloadedDriverInformation(
  785. IN PVOID
  786. );
  787. typedef struct _UNLOADED_DRIVERS {
  788. UNICODE_STRING Name;
  789. PVOID StartAddress;
  790. PVOID EndAddress;
  791. LARGE_INTEGER CurrentTime;
  792. } UNLOADED_DRIVERS, *PUNLOADED_DRIVERS;
  793. //
  794. // Cache manager support
  795. //
  796. #if defined(_NTDDK_) || defined(_NTIFS_)
  797. // begin_ntifs
  798. NTKERNELAPI
  799. BOOLEAN
  800. MmIsRecursiveIoFault(
  801. VOID
  802. );
  803. // end_ntifs
  804. #else
  805. //++
  806. //
  807. // BOOLEAN
  808. // MmIsRecursiveIoFault (
  809. // VOID
  810. // );
  811. //
  812. // Routine Description:
  813. //
  814. //
  815. // This macro examines the thread's page fault clustering information
  816. // and determines if the current page fault is occurring during an I/O
  817. // operation.
  818. //
  819. // Arguments:
  820. //
  821. // None.
  822. //
  823. // Return Value:
  824. //
  825. // Returns TRUE if the fault is occurring during an I/O operation,
  826. // FALSE otherwise.
  827. //
  828. //--
  829. #define MmIsRecursiveIoFault() \
  830. ((PsGetCurrentThread()->DisablePageFaultClustering) | \
  831. (PsGetCurrentThread()->ForwardClusterOnly))
  832. #endif
  833. //++
  834. //
  835. // VOID
  836. // MmDisablePageFaultClustering
  837. // OUT PULONG SavedState
  838. // );
  839. //
  840. // Routine Description:
  841. //
  842. //
  843. // This macro disables page fault clustering for the current thread.
  844. // Note, that this indicates that file system I/O is in progress
  845. // for that thread.
  846. //
  847. // Arguments:
  848. //
  849. // SavedState - returns previous state of page fault clustering which
  850. // is guaranteed to be nonzero
  851. //
  852. // Return Value:
  853. //
  854. // None.
  855. //
  856. //--
  857. #define MmDisablePageFaultClustering(SavedState) { \
  858. *(SavedState) = 2 + (ULONG)PsGetCurrentThread()->DisablePageFaultClustering;\
  859. PsGetCurrentThread()->DisablePageFaultClustering = TRUE; }
  860. //++
  861. //
  862. // VOID
  863. // MmEnablePageFaultClustering
  864. // IN ULONG SavedState
  865. // );
  866. //
  867. // Routine Description:
  868. //
  869. //
  870. // This macro enables page fault clustering for the current thread.
  871. // Note, that this indicates that no file system I/O is in progress for
  872. // that thread.
  873. //
  874. // Arguments:
  875. //
  876. // SavedState - supplies previous state of page fault clustering
  877. //
  878. // Return Value:
  879. //
  880. // None.
  881. //
  882. //--
  883. #define MmEnablePageFaultClustering(SavedState) { \
  884. PsGetCurrentThread()->DisablePageFaultClustering = (BOOLEAN)(SavedState - 2); }
  885. //++
  886. //
  887. // VOID
  888. // MmSavePageFaultReadAhead
  889. // IN PETHREAD Thread,
  890. // OUT PULONG SavedState
  891. // );
  892. //
  893. // Routine Description:
  894. //
  895. //
  896. // This macro saves the page fault read ahead value for the specified
  897. // thread.
  898. //
  899. // Arguments:
  900. //
  901. // Thread - Supplies a pointer to the current thread.
  902. //
  903. // SavedState - returns previous state of page fault read ahead
  904. //
  905. // Return Value:
  906. //
  907. // None.
  908. //
  909. //--
  910. #define MmSavePageFaultReadAhead(Thread,SavedState) { \
  911. *(SavedState) = (Thread)->ReadClusterSize * 2 + \
  912. (Thread)->ForwardClusterOnly; }
  913. //++
  914. //
  915. // VOID
  916. // MmSetPageFaultReadAhead
  917. // IN PETHREAD Thread,
  918. // IN ULONG ReadAhead
  919. // );
  920. //
  921. // Routine Description:
  922. //
  923. //
  924. // This macro sets the page fault read ahead value for the specified
  925. // thread, and indicates that file system I/O is in progress for that
  926. // thread.
  927. //
  928. // Arguments:
  929. //
  930. // Thread - Supplies a pointer to the current thread.
  931. //
  932. // ReadAhead - Supplies the number of pages to read in addition to
  933. // the page the fault is taken on. A value of 0
  934. // reads only the faulting page, a value of 1 reads in
  935. // the faulting page and the following page, etc.
  936. //
  937. // Return Value:
  938. //
  939. // None.
  940. //
  941. //--
  942. #define MmSetPageFaultReadAhead(Thread,ReadAhead) { \
  943. (Thread)->ForwardClusterOnly = TRUE; \
  944. if ((ReadAhead) > MM_MAXIMUM_READ_CLUSTER_SIZE) { \
  945. (Thread)->ReadClusterSize = MM_MAXIMUM_READ_CLUSTER_SIZE;\
  946. } else { \
  947. (Thread)->ReadClusterSize = (ReadAhead); \
  948. } }
  949. //++
  950. //
  951. // VOID
  952. // MmResetPageFaultReadAhead
  953. // IN PETHREAD Thread,
  954. // IN ULONG SavedState
  955. // );
  956. //
  957. // Routine Description:
  958. //
  959. //
  960. // This macro resets the default page fault read ahead value for the specified
  961. // thread, and indicates that file system I/O is not in progress for that
  962. // thread.
  963. //
  964. // Arguments:
  965. //
  966. // Thread - Supplies a pointer to the current thread.
  967. //
  968. // SavedState - supplies previous state of page fault read ahead
  969. //
  970. // Return Value:
  971. //
  972. // None.
  973. //
  974. //--
  975. #define MmResetPageFaultReadAhead(Thread, SavedState) { \
  976. (Thread)->ForwardClusterOnly = (BOOLEAN)((SavedState) & 1); \
  977. (Thread)->ReadClusterSize = (SavedState) / 2; }
  978. //
  979. // The order of this list is important, the zeroed, free and standby
  980. // must occur before the modified or bad so comparisons can be
  981. // made when pages are added to a list.
  982. //
  983. // NOTE: This field is limited to 8 elements.
  984. // Also, if this field is expanded, update the MMPFNLIST_* defines in ntmmapi.h
  985. //
  986. #define NUMBER_OF_PAGE_LISTS 8
  987. typedef enum _MMLISTS {
  988. ZeroedPageList,
  989. FreePageList,
  990. StandbyPageList, //this list and before make up available pages.
  991. ModifiedPageList,
  992. ModifiedNoWritePageList,
  993. BadPageList,
  994. ActiveAndValid,
  995. TransitionPage
  996. } MMLISTS;
  997. typedef struct _MMPFNLIST {
  998. PFN_NUMBER Total;
  999. MMLISTS ListName;
  1000. PFN_NUMBER Flink;
  1001. PFN_NUMBER Blink;
  1002. } MMPFNLIST;
  1003. typedef MMPFNLIST *PMMPFNLIST;
  1004. extern MMPFNLIST MmModifiedPageListHead;
  1005. extern PFN_NUMBER MmThrottleTop;
  1006. extern PFN_NUMBER MmThrottleBottom;
  1007. //++
  1008. //
  1009. // BOOLEAN
  1010. // MmEnoughMemoryForWrite (
  1011. // VOID
  1012. // );
  1013. //
  1014. // Routine Description:
  1015. //
  1016. //
  1017. // This macro checks the modified pages and available pages to determine
  1018. // to allow the cache manager to throttle write operations.
  1019. //
  1020. // For NTAS:
  1021. // Writes are blocked if there are less than 127 available pages OR
  1022. // there are more than 1000 modified pages AND less than 450 available pages.
  1023. //
  1024. // For DeskTop:
  1025. // Writes are blocked if there are less than 30 available pages OR
  1026. // there are more than 1000 modified pages AND less than 250 available pages.
  1027. //
  1028. // Arguments:
  1029. //
  1030. // None.
  1031. //
  1032. // Return Value:
  1033. //
  1034. // TRUE if ample memory exists and the write should proceed.
  1035. //
  1036. //--
  1037. #define MmEnoughMemoryForWrite() \
  1038. ((MmAvailablePages > MmThrottleTop) \
  1039. || \
  1040. (((MmModifiedPageListHead.Total < 1000)) && \
  1041. (MmAvailablePages > MmThrottleBottom)))
  1042. // begin_ntosp
  1043. NTKERNELAPI
  1044. NTSTATUS
  1045. MmCreateSection (
  1046. OUT PVOID *SectionObject,
  1047. IN ACCESS_MASK DesiredAccess,
  1048. IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
  1049. IN PLARGE_INTEGER MaximumSize,
  1050. IN ULONG SectionPageProtection,
  1051. IN ULONG AllocationAttributes,
  1052. IN HANDLE FileHandle OPTIONAL,
  1053. IN PFILE_OBJECT File OPTIONAL
  1054. );
  1055. NTKERNELAPI
  1056. NTSTATUS
  1057. MmMapViewOfSection(
  1058. IN PVOID SectionToMap,
  1059. IN PEPROCESS Process,
  1060. IN OUT PVOID *CapturedBase,
  1061. IN ULONG_PTR ZeroBits,
  1062. IN SIZE_T CommitSize,
  1063. IN OUT PLARGE_INTEGER SectionOffset,
  1064. IN OUT PSIZE_T CapturedViewSize,
  1065. IN SECTION_INHERIT InheritDisposition,
  1066. IN ULONG AllocationType,
  1067. IN ULONG Protect
  1068. );
  1069. NTKERNELAPI
  1070. NTSTATUS
  1071. MmUnmapViewOfSection(
  1072. IN PEPROCESS Process,
  1073. IN PVOID BaseAddress
  1074. );
  1075. // end_ntosp begin_ntifs
  1076. BOOLEAN
  1077. MmForceSectionClosed (
  1078. IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
  1079. IN BOOLEAN DelayClose
  1080. );
  1081. // end_ntifs
  1082. NTSTATUS
  1083. MmGetFileNameForSection (
  1084. IN PVOID SectionObject,
  1085. OUT PSTRING FileName
  1086. );
  1087. NTSTATUS
  1088. MmGetFileNameForAddress (
  1089. IN PVOID ProcessVa,
  1090. OUT PUNICODE_STRING FileName
  1091. );
  1092. NTSTATUS
  1093. MmRemoveVerifierEntry (
  1094. IN PUNICODE_STRING ImageFileName
  1095. );
  1096. // begin_ntddk begin_wdm begin_ntifs begin_ntosp
  1097. NTSTATUS
  1098. MmIsVerifierEnabled (
  1099. OUT PULONG VerifierFlags
  1100. );
  1101. NTSTATUS
  1102. MmAddVerifierThunks (
  1103. IN PVOID ThunkBuffer,
  1104. IN ULONG ThunkBufferSize
  1105. );
  1106. // end_ntddk end_wdm end_ntifs end_ntosp
  1107. NTSTATUS
  1108. MmAddVerifierEntry (
  1109. IN PUNICODE_STRING ImageFileName
  1110. );
  1111. NTSTATUS
  1112. MmSetVerifierInformation (
  1113. IN OUT PVOID SystemInformation,
  1114. IN ULONG SystemInformationLength
  1115. );
  1116. NTSTATUS
  1117. MmGetVerifierInformation (
  1118. OUT PVOID SystemInformation,
  1119. IN ULONG SystemInformationLength,
  1120. OUT PULONG Length
  1121. );
  1122. NTSTATUS
  1123. MmGetPageFileInformation (
  1124. OUT PVOID SystemInformation,
  1125. IN ULONG SystemInformationLength,
  1126. OUT PULONG Length
  1127. );
  1128. HANDLE
  1129. MmGetSystemPageFile (
  1130. VOID
  1131. );
  1132. NTSTATUS
  1133. MmExtendSection (
  1134. IN PVOID SectionToExtend,
  1135. IN OUT PLARGE_INTEGER NewSectionSize,
  1136. IN ULONG IgnoreFileSizeChecking
  1137. );
  1138. NTSTATUS
  1139. MmFlushVirtualMemory (
  1140. IN PEPROCESS Process,
  1141. IN OUT PVOID *BaseAddress,
  1142. IN OUT PSIZE_T RegionSize,
  1143. OUT PIO_STATUS_BLOCK IoStatus
  1144. );
  1145. NTSTATUS
  1146. MmMapViewInSystemCache (
  1147. IN PVOID SectionToMap,
  1148. OUT PVOID *CapturedBase,
  1149. IN OUT PLARGE_INTEGER SectionOffset,
  1150. IN OUT PULONG CapturedViewSize
  1151. );
  1152. VOID
  1153. MmUnmapViewInSystemCache (
  1154. IN PVOID BaseAddress,
  1155. IN PVOID SectionToUnmap,
  1156. IN ULONG AddToFront
  1157. );
  1158. BOOLEAN
  1159. MmPurgeSection (
  1160. IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
  1161. IN PLARGE_INTEGER Offset OPTIONAL,
  1162. IN SIZE_T RegionSize,
  1163. IN ULONG IgnoreCacheViews
  1164. );
  1165. NTSTATUS
  1166. MmFlushSection (
  1167. IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
  1168. IN PLARGE_INTEGER Offset OPTIONAL,
  1169. IN SIZE_T RegionSize,
  1170. OUT PIO_STATUS_BLOCK IoStatus,
  1171. IN ULONG AcquireFile
  1172. );
  1173. // begin_ntifs
  1174. typedef enum _MMFLUSH_TYPE {
  1175. MmFlushForDelete,
  1176. MmFlushForWrite
  1177. } MMFLUSH_TYPE;
  1178. BOOLEAN
  1179. MmFlushImageSection (
  1180. IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
  1181. IN MMFLUSH_TYPE FlushType
  1182. );
  1183. BOOLEAN
  1184. MmCanFileBeTruncated (
  1185. IN PSECTION_OBJECT_POINTERS SectionPointer,
  1186. IN PLARGE_INTEGER NewFileSize
  1187. );
  1188. // end_ntifs
  1189. ULONG
  1190. MmDoesFileHaveUserWritableReferences (
  1191. IN PSECTION_OBJECT_POINTERS SectionPointer
  1192. );
  1193. BOOLEAN
  1194. MmDisableModifiedWriteOfSection (
  1195. IN PSECTION_OBJECT_POINTERS SectionObjectPointer
  1196. );
  1197. BOOLEAN
  1198. MmEnableModifiedWriteOfSection (
  1199. IN PSECTION_OBJECT_POINTERS SectionObjectPointer
  1200. );
  1201. VOID
  1202. MmPurgeWorkingSet (
  1203. IN PEPROCESS Process,
  1204. IN PVOID BaseAddress,
  1205. IN SIZE_T RegionSize
  1206. );
  1207. BOOLEAN // ntifs
  1208. MmSetAddressRangeModified ( // ntifs
  1209. IN PVOID Address, // ntifs
  1210. IN SIZE_T Length // ntifs
  1211. ); // ntifs
  1212. BOOLEAN
  1213. MmCheckCachedPageState (
  1214. IN PVOID Address,
  1215. IN BOOLEAN SetToZero
  1216. );
  1217. NTSTATUS
  1218. MmCopyToCachedPage (
  1219. IN PVOID Address,
  1220. IN PVOID UserBuffer,
  1221. IN ULONG Offset,
  1222. IN SIZE_T CountInBytes,
  1223. IN BOOLEAN DontZero
  1224. );
  1225. VOID
  1226. MmUnlockCachedPage (
  1227. IN PVOID AddressInCache
  1228. );
  1229. #define MMDBG_COPY_WRITE 0x00000001
  1230. #define MMDBG_COPY_PHYSICAL 0x00000002
  1231. #define MMDBG_COPY_UNSAFE 0x00000004
  1232. #define MMDBG_COPY_CACHED 0x00000008
  1233. #define MMDBG_COPY_UNCACHED 0x00000010
  1234. #define MMDBG_COPY_WRITE_COMBINED 0x00000020
  1235. #define MMDBG_COPY_MAX_SIZE 8
  1236. NTSTATUS
  1237. MmDbgCopyMemory (
  1238. IN ULONG64 UntrustedAddress,
  1239. IN PVOID Buffer,
  1240. IN ULONG Size,
  1241. IN ULONG Flags
  1242. );
  1243. LOGICAL
  1244. MmDbgIsLowMemOk (
  1245. IN PFN_NUMBER PageFrameIndex,
  1246. OUT PPFN_NUMBER NextPageFrameIndex,
  1247. IN OUT PULONG CorruptionOffset
  1248. );
  1249. VOID
  1250. MmHibernateInformation (
  1251. IN PVOID MemoryMap,
  1252. OUT PULONG_PTR HiberVa,
  1253. OUT PPHYSICAL_ADDRESS HiberPte
  1254. );
  1255. LOGICAL
  1256. MmUpdateMdlTracker (
  1257. IN PMDL MemoryDescriptorList,
  1258. IN PVOID CallingAddress,
  1259. IN PVOID CallersCaller
  1260. );
  1261. // begin_ntddk begin_ntifs begin_wdm begin_ntosp
  1262. NTKERNELAPI
  1263. VOID
  1264. MmProbeAndLockProcessPages (
  1265. IN OUT PMDL MemoryDescriptorList,
  1266. IN PEPROCESS Process,
  1267. IN KPROCESSOR_MODE AccessMode,
  1268. IN LOCK_OPERATION Operation
  1269. );
  1270. // begin_nthal
  1271. //
  1272. // I/O support routines.
  1273. //
  1274. NTKERNELAPI
  1275. VOID
  1276. MmProbeAndLockPages (
  1277. IN OUT PMDL MemoryDescriptorList,
  1278. IN KPROCESSOR_MODE AccessMode,
  1279. IN LOCK_OPERATION Operation
  1280. );
  1281. NTKERNELAPI
  1282. VOID
  1283. MmUnlockPages (
  1284. IN PMDL MemoryDescriptorList
  1285. );
  1286. NTKERNELAPI
  1287. VOID
  1288. MmBuildMdlForNonPagedPool (
  1289. IN OUT PMDL MemoryDescriptorList
  1290. );
  1291. NTKERNELAPI
  1292. PVOID
  1293. MmMapLockedPages (
  1294. IN PMDL MemoryDescriptorList,
  1295. IN KPROCESSOR_MODE AccessMode
  1296. );
  1297. NTKERNELAPI
  1298. PVOID
  1299. MmGetSystemRoutineAddress (
  1300. IN PUNICODE_STRING SystemRoutineName
  1301. );
  1302. NTKERNELAPI
  1303. NTSTATUS
  1304. MmAdvanceMdl (
  1305. IN PMDL Mdl,
  1306. IN ULONG NumberOfBytes
  1307. );
  1308. // end_wdm
  1309. NTKERNELAPI
  1310. NTSTATUS
  1311. MmMapUserAddressesToPage (
  1312. IN PVOID BaseAddress,
  1313. IN SIZE_T NumberOfBytes,
  1314. IN PVOID PageAddress
  1315. );
  1316. // begin_wdm
  1317. NTKERNELAPI
  1318. NTSTATUS
  1319. MmProtectMdlSystemAddress (
  1320. IN PMDL MemoryDescriptorList,
  1321. IN ULONG NewProtect
  1322. );
  1323. //
  1324. // _MM_PAGE_PRIORITY_ provides a method for the system to handle requests
  1325. // intelligently in low resource conditions.
  1326. //
  1327. // LowPagePriority should be used when it is acceptable to the driver for the
  1328. // mapping request to fail if the system is low on resources. An example of
  1329. // this could be for a non-critical network connection where the driver can
  1330. // handle the failure case when system resources are close to being depleted.
  1331. //
  1332. // NormalPagePriority should be used when it is acceptable to the driver for the
  1333. // mapping request to fail if the system is very low on resources. An example
  1334. // of this could be for a non-critical local filesystem request.
  1335. //
  1336. // HighPagePriority should be used when it is unacceptable to the driver for the
  1337. // mapping request to fail unless the system is completely out of resources.
  1338. // An example of this would be the paging file path in a driver.
  1339. //
  1340. // begin_ntndis
  1341. typedef enum _MM_PAGE_PRIORITY {
  1342. LowPagePriority,
  1343. NormalPagePriority = 16,
  1344. HighPagePriority = 32
  1345. } MM_PAGE_PRIORITY;
  1346. // end_ntndis
  1347. //
  1348. // Note: This function is not available in WDM 1.0
  1349. //
  1350. NTKERNELAPI
  1351. PVOID
  1352. MmMapLockedPagesSpecifyCache (
  1353. IN PMDL MemoryDescriptorList,
  1354. IN KPROCESSOR_MODE AccessMode,
  1355. IN MEMORY_CACHING_TYPE CacheType,
  1356. IN PVOID BaseAddress,
  1357. IN ULONG BugCheckOnFailure,
  1358. IN MM_PAGE_PRIORITY Priority
  1359. );
  1360. NTKERNELAPI
  1361. VOID
  1362. MmUnmapLockedPages (
  1363. IN PVOID BaseAddress,
  1364. IN PMDL MemoryDescriptorList
  1365. );
  1366. PVOID
  1367. MmAllocateMappingAddress (
  1368. IN SIZE_T NumberOfBytes,
  1369. IN ULONG PoolTag
  1370. );
  1371. VOID
  1372. MmFreeMappingAddress (
  1373. IN PVOID BaseAddress,
  1374. IN ULONG PoolTag
  1375. );
  1376. PVOID
  1377. MmMapLockedPagesWithReservedMapping (
  1378. IN PVOID MappingAddress,
  1379. IN ULONG PoolTag,
  1380. IN PMDL MemoryDescriptorList,
  1381. IN MEMORY_CACHING_TYPE CacheType
  1382. );
  1383. VOID
  1384. MmUnmapReservedMapping (
  1385. IN PVOID BaseAddress,
  1386. IN ULONG PoolTag,
  1387. IN PMDL MemoryDescriptorList
  1388. );
  1389. // end_wdm
  1390. typedef struct _PHYSICAL_MEMORY_RANGE {
  1391. PHYSICAL_ADDRESS BaseAddress;
  1392. LARGE_INTEGER NumberOfBytes;
  1393. } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
  1394. NTKERNELAPI
  1395. NTSTATUS
  1396. MmAddPhysicalMemory (
  1397. IN PPHYSICAL_ADDRESS StartAddress,
  1398. IN OUT PLARGE_INTEGER NumberOfBytes
  1399. );
  1400. NTKERNELAPI
  1401. NTSTATUS
  1402. MmAddPhysicalMemoryEx (
  1403. IN PPHYSICAL_ADDRESS StartAddress,
  1404. IN OUT PLARGE_INTEGER NumberOfBytes,
  1405. IN ULONG Flags
  1406. );
  1407. NTKERNELAPI
  1408. NTSTATUS
  1409. MmRemovePhysicalMemory (
  1410. IN PPHYSICAL_ADDRESS StartAddress,
  1411. IN OUT PLARGE_INTEGER NumberOfBytes
  1412. );
  1413. NTKERNELAPI
  1414. NTSTATUS
  1415. MmRemovePhysicalMemoryEx (
  1416. IN PPHYSICAL_ADDRESS StartAddress,
  1417. IN OUT PLARGE_INTEGER NumberOfBytes,
  1418. IN ULONG Flags
  1419. );
  1420. NTKERNELAPI
  1421. PPHYSICAL_MEMORY_RANGE
  1422. MmGetPhysicalMemoryRanges (
  1423. VOID
  1424. );
  1425. NTSTATUS
  1426. MmMarkPhysicalMemoryAsGood (
  1427. IN PPHYSICAL_ADDRESS StartAddress,
  1428. IN OUT PLARGE_INTEGER NumberOfBytes
  1429. );
  1430. NTSTATUS
  1431. MmMarkPhysicalMemoryAsBad (
  1432. IN PPHYSICAL_ADDRESS StartAddress,
  1433. IN OUT PLARGE_INTEGER NumberOfBytes
  1434. );
  1435. // begin_wdm
  1436. NTKERNELAPI
  1437. PMDL
  1438. MmAllocatePagesForMdl (
  1439. IN PHYSICAL_ADDRESS LowAddress,
  1440. IN PHYSICAL_ADDRESS HighAddress,
  1441. IN PHYSICAL_ADDRESS SkipBytes,
  1442. IN SIZE_T TotalBytes
  1443. );
  1444. NTKERNELAPI
  1445. VOID
  1446. MmFreePagesFromMdl (
  1447. IN PMDL MemoryDescriptorList
  1448. );
  1449. NTKERNELAPI
  1450. PVOID
  1451. MmMapIoSpace (
  1452. IN PHYSICAL_ADDRESS PhysicalAddress,
  1453. IN SIZE_T NumberOfBytes,
  1454. IN MEMORY_CACHING_TYPE CacheType
  1455. );
  1456. NTKERNELAPI
  1457. VOID
  1458. MmUnmapIoSpace (
  1459. IN PVOID BaseAddress,
  1460. IN SIZE_T NumberOfBytes
  1461. );
  1462. // end_wdm end_ntddk end_ntifs end_ntosp
  1463. NTKERNELAPI
  1464. VOID
  1465. MmProbeAndLockSelectedPages (
  1466. IN OUT PMDL MemoryDescriptorList,
  1467. IN PFILE_SEGMENT_ELEMENT SegmentArray,
  1468. IN KPROCESSOR_MODE AccessMode,
  1469. IN LOCK_OPERATION Operation
  1470. );
  1471. // begin_ntddk begin_ntifs begin_ntosp
  1472. NTKERNELAPI
  1473. PVOID
  1474. MmMapVideoDisplay (
  1475. IN PHYSICAL_ADDRESS PhysicalAddress,
  1476. IN SIZE_T NumberOfBytes,
  1477. IN MEMORY_CACHING_TYPE CacheType
  1478. );
  1479. NTKERNELAPI
  1480. VOID
  1481. MmUnmapVideoDisplay (
  1482. IN PVOID BaseAddress,
  1483. IN SIZE_T NumberOfBytes
  1484. );
  1485. NTKERNELAPI
  1486. PHYSICAL_ADDRESS
  1487. MmGetPhysicalAddress (
  1488. IN PVOID BaseAddress
  1489. );
  1490. NTKERNELAPI
  1491. PVOID
  1492. MmGetVirtualForPhysical (
  1493. IN PHYSICAL_ADDRESS PhysicalAddress
  1494. );
  1495. NTKERNELAPI
  1496. PVOID
  1497. MmAllocateContiguousMemory (
  1498. IN SIZE_T NumberOfBytes,
  1499. IN PHYSICAL_ADDRESS HighestAcceptableAddress
  1500. );
  1501. NTKERNELAPI
  1502. PVOID
  1503. MmAllocateContiguousMemorySpecifyCache (
  1504. IN SIZE_T NumberOfBytes,
  1505. IN PHYSICAL_ADDRESS LowestAcceptableAddress,
  1506. IN PHYSICAL_ADDRESS HighestAcceptableAddress,
  1507. IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL,
  1508. IN MEMORY_CACHING_TYPE CacheType
  1509. );
  1510. NTKERNELAPI
  1511. VOID
  1512. MmFreeContiguousMemory (
  1513. IN PVOID BaseAddress
  1514. );
  1515. NTKERNELAPI
  1516. VOID
  1517. MmFreeContiguousMemorySpecifyCache (
  1518. IN PVOID BaseAddress,
  1519. IN SIZE_T NumberOfBytes,
  1520. IN MEMORY_CACHING_TYPE CacheType
  1521. );
  1522. // end_ntddk end_ntifs end_ntosp end_nthal
  1523. NTKERNELAPI
  1524. ULONG
  1525. MmGatherMemoryForHibernate (
  1526. IN PMDL Mdl,
  1527. IN BOOLEAN Wait
  1528. );
  1529. NTKERNELAPI
  1530. VOID
  1531. MmReturnMemoryForHibernate (
  1532. IN PMDL Mdl
  1533. );
  1534. VOID
  1535. MmReleaseDumpAddresses (
  1536. IN PFN_NUMBER Pages
  1537. );
  1538. // begin_ntddk begin_ntifs begin_nthal begin_ntosp
  1539. NTKERNELAPI
  1540. PVOID
  1541. MmAllocateNonCachedMemory (
  1542. IN SIZE_T NumberOfBytes
  1543. );
  1544. NTKERNELAPI
  1545. VOID
  1546. MmFreeNonCachedMemory (
  1547. IN PVOID BaseAddress,
  1548. IN SIZE_T NumberOfBytes
  1549. );
  1550. NTKERNELAPI
  1551. BOOLEAN
  1552. MmIsAddressValid (
  1553. IN PVOID VirtualAddress
  1554. );
  1555. DECLSPEC_DEPRECATED_DDK
  1556. NTKERNELAPI
  1557. BOOLEAN
  1558. MmIsNonPagedSystemAddressValid (
  1559. IN PVOID VirtualAddress
  1560. );
  1561. // begin_wdm
  1562. NTKERNELAPI
  1563. SIZE_T
  1564. MmSizeOfMdl(
  1565. IN PVOID Base,
  1566. IN SIZE_T Length
  1567. );
  1568. DECLSPEC_DEPRECATED_DDK // Use IoCreateMdl
  1569. NTKERNELAPI
  1570. PMDL
  1571. MmCreateMdl(
  1572. IN PMDL MemoryDescriptorList OPTIONAL,
  1573. IN PVOID Base,
  1574. IN SIZE_T Length
  1575. );
  1576. NTKERNELAPI
  1577. PVOID
  1578. MmLockPagableDataSection(
  1579. IN PVOID AddressWithinSection
  1580. );
  1581. // end_wdm
  1582. NTKERNELAPI
  1583. VOID
  1584. MmLockPagableSectionByHandle (
  1585. IN PVOID ImageSectionHandle
  1586. );
  1587. // end_ntddk end_ntifs end_ntosp
  1588. NTKERNELAPI
  1589. VOID
  1590. MmLockPagedPool (
  1591. IN PVOID Address,
  1592. IN SIZE_T Size
  1593. );
  1594. NTKERNELAPI
  1595. VOID
  1596. MmUnlockPagedPool (
  1597. IN PVOID Address,
  1598. IN SIZE_T Size
  1599. );
  1600. // begin_wdm begin_ntddk begin_ntifs begin_ntosp
  1601. NTKERNELAPI
  1602. VOID
  1603. MmResetDriverPaging (
  1604. IN PVOID AddressWithinSection
  1605. );
  1606. NTKERNELAPI
  1607. PVOID
  1608. MmPageEntireDriver (
  1609. IN PVOID AddressWithinSection
  1610. );
  1611. NTKERNELAPI
  1612. VOID
  1613. MmUnlockPagableImageSection(
  1614. IN PVOID ImageSectionHandle
  1615. );
  1616. // end_wdm end_ntosp
  1617. // begin_ntosp
  1618. NTKERNELAPI
  1619. HANDLE
  1620. MmSecureVirtualMemory (
  1621. IN PVOID Address,
  1622. IN SIZE_T Size,
  1623. IN ULONG ProbeMode
  1624. );
  1625. NTKERNELAPI
  1626. VOID
  1627. MmUnsecureVirtualMemory (
  1628. IN HANDLE SecureHandle
  1629. );
  1630. // end_ntosp
  1631. NTKERNELAPI
  1632. NTSTATUS
  1633. MmMapViewInSystemSpace (
  1634. IN PVOID Section,
  1635. OUT PVOID *MappedBase,
  1636. IN PSIZE_T ViewSize
  1637. );
  1638. NTKERNELAPI
  1639. NTSTATUS
  1640. MmUnmapViewInSystemSpace (
  1641. IN PVOID MappedBase
  1642. );
  1643. // begin_ntosp
  1644. NTKERNELAPI
  1645. NTSTATUS
  1646. MmMapViewInSessionSpace (
  1647. IN PVOID Section,
  1648. OUT PVOID *MappedBase,
  1649. IN OUT PSIZE_T ViewSize
  1650. );
  1651. NTKERNELAPI
  1652. NTSTATUS
  1653. MmUnmapViewInSessionSpace (
  1654. IN PVOID MappedBase
  1655. );
  1656. // end_ntosp
  1657. // begin_wdm begin_ntosp
  1658. //++
  1659. //
  1660. // VOID
  1661. // MmInitializeMdl (
  1662. // IN PMDL MemoryDescriptorList,
  1663. // IN PVOID BaseVa,
  1664. // IN SIZE_T Length
  1665. // )
  1666. //
  1667. // Routine Description:
  1668. //
  1669. // This routine initializes the header of a Memory Descriptor List (MDL).
  1670. //
  1671. // Arguments:
  1672. //
  1673. // MemoryDescriptorList - Pointer to the MDL to initialize.
  1674. //
  1675. // BaseVa - Base virtual address mapped by the MDL.
  1676. //
  1677. // Length - Length, in bytes, of the buffer mapped by the MDL.
  1678. //
  1679. // Return Value:
  1680. //
  1681. // None.
  1682. //
  1683. //--
  1684. #define MmInitializeMdl(MemoryDescriptorList, BaseVa, Length) { \
  1685. (MemoryDescriptorList)->Next = (PMDL) NULL; \
  1686. (MemoryDescriptorList)->Size = (CSHORT)(sizeof(MDL) + \
  1687. (sizeof(PFN_NUMBER) * ADDRESS_AND_SIZE_TO_SPAN_PAGES((BaseVa), (Length)))); \
  1688. (MemoryDescriptorList)->MdlFlags = 0; \
  1689. (MemoryDescriptorList)->StartVa = (PVOID) PAGE_ALIGN((BaseVa)); \
  1690. (MemoryDescriptorList)->ByteOffset = BYTE_OFFSET((BaseVa)); \
  1691. (MemoryDescriptorList)->ByteCount = (ULONG)(Length); \
  1692. }
  1693. //++
  1694. //
  1695. // PVOID
  1696. // MmGetSystemAddressForMdlSafe (
  1697. // IN PMDL MDL,
  1698. // IN MM_PAGE_PRIORITY PRIORITY
  1699. // )
  1700. //
  1701. // Routine Description:
  1702. //
  1703. // This routine returns the mapped address of an MDL. If the
  1704. // Mdl is not already mapped or a system address, it is mapped.
  1705. //
  1706. // Arguments:
  1707. //
  1708. // MemoryDescriptorList - Pointer to the MDL to map.
  1709. //
  1710. // Priority - Supplies an indication as to how important it is that this
  1711. // request succeed under low available PTE conditions.
  1712. //
  1713. // Return Value:
  1714. //
  1715. // Returns the base address where the pages are mapped. The base address
  1716. // has the same offset as the virtual address in the MDL.
  1717. //
  1718. // Unlike MmGetSystemAddressForMdl, Safe guarantees that it will always
  1719. // return NULL on failure instead of bugchecking the system.
  1720. //
  1721. // This macro is not usable by WDM 1.0 drivers as 1.0 did not include
  1722. // MmMapLockedPagesSpecifyCache. The solution for WDM 1.0 drivers is to
  1723. // provide synchronization and set/reset the MDL_MAPPING_CAN_FAIL bit.
  1724. //
  1725. //--
  1726. #define MmGetSystemAddressForMdlSafe(MDL, PRIORITY) \
  1727. (((MDL)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | \
  1728. MDL_SOURCE_IS_NONPAGED_POOL)) ? \
  1729. ((MDL)->MappedSystemVa) : \
  1730. (MmMapLockedPagesSpecifyCache((MDL), \
  1731. KernelMode, \
  1732. MmCached, \
  1733. NULL, \
  1734. FALSE, \
  1735. (PRIORITY))))
  1736. //++
  1737. //
  1738. // PVOID
  1739. // MmGetSystemAddressForMdl (
  1740. // IN PMDL MDL
  1741. // )
  1742. //
  1743. // Routine Description:
  1744. //
  1745. // This routine returns the mapped address of an MDL, if the
  1746. // Mdl is not already mapped or a system address, it is mapped.
  1747. //
  1748. // Arguments:
  1749. //
  1750. // MemoryDescriptorList - Pointer to the MDL to map.
  1751. //
  1752. // Return Value:
  1753. //
  1754. // Returns the base address where the pages are mapped. The base address
  1755. // has the same offset as the virtual address in the MDL.
  1756. //
  1757. //--
  1758. //#define MmGetSystemAddressForMdl(MDL)
  1759. // (((MDL)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA)) ?
  1760. // ((MDL)->MappedSystemVa) :
  1761. // ((((MDL)->MdlFlags & (MDL_SOURCE_IS_NONPAGED_POOL)) ?
  1762. // ((PVOID)((ULONG)(MDL)->StartVa | (MDL)->ByteOffset)) :
  1763. // (MmMapLockedPages((MDL),KernelMode)))))
  1764. #if PRAGMA_DEPRECATED_DDK
  1765. #pragma deprecated(MmGetSystemAddressForMdl) // Use MmGetSystemAddressForMdlSafe
  1766. #endif
  1767. #define MmGetSystemAddressForMdl(MDL) \
  1768. (((MDL)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | \
  1769. MDL_SOURCE_IS_NONPAGED_POOL)) ? \
  1770. ((MDL)->MappedSystemVa) : \
  1771. (MmMapLockedPages((MDL),KernelMode)))
  1772. //++
  1773. //
  1774. // VOID
  1775. // MmPrepareMdlForReuse (
  1776. // IN PMDL MDL
  1777. // )
  1778. //
  1779. // Routine Description:
  1780. //
  1781. // This routine will take all of the steps necessary to allow an MDL to be
  1782. // re-used.
  1783. //
  1784. // Arguments:
  1785. //
  1786. // MemoryDescriptorList - Pointer to the MDL that will be re-used.
  1787. //
  1788. // Return Value:
  1789. //
  1790. // None.
  1791. //
  1792. //--
  1793. #define MmPrepareMdlForReuse(MDL) \
  1794. if (((MDL)->MdlFlags & MDL_PARTIAL_HAS_BEEN_MAPPED) != 0) { \
  1795. ASSERT(((MDL)->MdlFlags & MDL_PARTIAL) != 0); \
  1796. MmUnmapLockedPages( (MDL)->MappedSystemVa, (MDL) ); \
  1797. } else if (((MDL)->MdlFlags & MDL_PARTIAL) == 0) { \
  1798. ASSERT(((MDL)->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA) == 0); \
  1799. }
  1800. typedef NTSTATUS (*PMM_DLL_INITIALIZE)(
  1801. IN PUNICODE_STRING RegistryPath
  1802. );
  1803. typedef NTSTATUS (*PMM_DLL_UNLOAD)(
  1804. VOID
  1805. );
  1806. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  1807. #if DBG || (i386 && !FPO)
  1808. typedef NTSTATUS (*PMM_SNAPSHOT_POOL_PAGE)(
  1809. IN PVOID Address,
  1810. IN ULONG Size,
  1811. IN PSYSTEM_POOL_INFORMATION PoolInformation,
  1812. IN PSYSTEM_POOL_ENTRY *PoolEntryInfo,
  1813. IN ULONG Length,
  1814. IN OUT PULONG RequiredLength
  1815. );
  1816. NTSTATUS
  1817. MmSnapShotPool (
  1818. IN POOL_TYPE PoolType,
  1819. IN PMM_SNAPSHOT_POOL_PAGE SnapShotPoolPage,
  1820. IN PSYSTEM_POOL_INFORMATION PoolInformation,
  1821. IN ULONG Length,
  1822. IN OUT PULONG RequiredLength
  1823. );
  1824. #endif // DBG || (i386 && !FPO)
  1825. PVOID
  1826. MmAllocateSpecialPool (
  1827. IN SIZE_T NumberOfBytes,
  1828. IN ULONG Tag,
  1829. IN POOL_TYPE Type,
  1830. IN ULONG SpecialPoolType
  1831. );
  1832. VOID
  1833. MmFreeSpecialPool (
  1834. IN PVOID P
  1835. );
  1836. LOGICAL
  1837. MmSetSpecialPool (
  1838. IN LOGICAL Enable
  1839. );
  1840. LOGICAL
  1841. MmProtectSpecialPool (
  1842. IN PVOID VirtualAddress,
  1843. IN ULONG NewProtect
  1844. );
  1845. LOGICAL
  1846. MmIsSpecialPoolAddressFree (
  1847. IN PVOID VirtualAddress
  1848. );
  1849. SIZE_T
  1850. MmQuerySpecialPoolBlockSize (
  1851. IN PVOID P
  1852. );
  1853. LOGICAL
  1854. MmIsSpecialPoolAddress (
  1855. IN PVOID VirtualAddress
  1856. );
  1857. LOGICAL
  1858. MmUseSpecialPool (
  1859. IN SIZE_T NumberOfBytes,
  1860. IN ULONG Tag
  1861. );
  1862. LOGICAL
  1863. MmIsSessionAddress (
  1864. IN PVOID VirtualAddress
  1865. );
  1866. PUNICODE_STRING
  1867. MmLocateUnloadedDriver (
  1868. IN PVOID VirtualAddress
  1869. );
  1870. // begin_ntddk begin_wdm begin_ntosp
  1871. //
  1872. // Define an empty typedef for the _DRIVER_OBJECT structure so it may be
  1873. // referenced by function types before it is actually defined.
  1874. //
  1875. struct _DRIVER_OBJECT;
  1876. NTKERNELAPI
  1877. LOGICAL
  1878. MmIsDriverVerifying (
  1879. IN struct _DRIVER_OBJECT *DriverObject
  1880. );
  1881. // end_ntddk end_wdm end_ntosp
  1882. LOGICAL
  1883. MmTrimAllSystemPagableMemory (
  1884. IN LOGICAL PurgeTransition
  1885. );
  1886. #define MMNONPAGED_QUOTA_INCREASE (64*1024)
  1887. #define MMPAGED_QUOTA_INCREASE (512*1024)
  1888. #define MMNONPAGED_QUOTA_CHECK (256*1024)
  1889. #define MMPAGED_QUOTA_CHECK (1*1024*1024)
  1890. BOOLEAN
  1891. MmRaisePoolQuota (
  1892. IN POOL_TYPE PoolType,
  1893. IN SIZE_T OldQuotaLimit,
  1894. OUT PSIZE_T NewQuotaLimit
  1895. );
  1896. VOID
  1897. MmReturnPoolQuota (
  1898. IN POOL_TYPE PoolType,
  1899. IN SIZE_T ReturnedQuota
  1900. );
  1901. //
  1902. // Zero page thread routine.
  1903. //
  1904. VOID
  1905. MmZeroPageThread (
  1906. VOID
  1907. );
  1908. NTSTATUS
  1909. MmCopyVirtualMemory (
  1910. IN PEPROCESS FromProcess,
  1911. IN CONST VOID *FromAddress,
  1912. IN PEPROCESS ToProcess,
  1913. OUT PVOID ToAddress,
  1914. IN SIZE_T BufferSize,
  1915. IN KPROCESSOR_MODE PreviousMode,
  1916. OUT PSIZE_T NumberOfBytesCopied
  1917. );
  1918. NTSTATUS
  1919. MmGetSectionRange(
  1920. IN PVOID AddressWithinSection,
  1921. OUT PVOID *StartingSectionAddress,
  1922. OUT PULONG SizeofSection
  1923. );
  1924. // begin_ntosp
  1925. VOID
  1926. MmMapMemoryDumpMdl(
  1927. IN OUT PMDL MemoryDumpMdl
  1928. );
  1929. // begin_ntminiport
  1930. //
  1931. // Graphics support routines.
  1932. //
  1933. typedef
  1934. VOID
  1935. (*PBANKED_SECTION_ROUTINE) (
  1936. IN ULONG ReadBank,
  1937. IN ULONG WriteBank,
  1938. IN PVOID Context
  1939. );
  1940. // end_ntminiport
  1941. NTSTATUS
  1942. MmSetBankedSection (
  1943. IN HANDLE ProcessHandle,
  1944. IN PVOID VirtualAddress,
  1945. IN ULONG BankLength,
  1946. IN BOOLEAN ReadWriteBank,
  1947. IN PBANKED_SECTION_ROUTINE BankRoutine,
  1948. IN PVOID Context);
  1949. // end_ntosp
  1950. BOOLEAN
  1951. MmVerifyImageIsOkForMpUse (
  1952. IN PVOID BaseAddress
  1953. );
  1954. NTSTATUS
  1955. MmMemoryUsage (
  1956. IN PVOID Buffer,
  1957. IN ULONG Size,
  1958. IN ULONG Type,
  1959. OUT PULONG Length
  1960. );
  1961. typedef
  1962. VOID
  1963. (FASTCALL *PPAGE_FAULT_NOTIFY_ROUTINE) (
  1964. IN NTSTATUS Status,
  1965. IN PVOID VirtualAddress,
  1966. IN PVOID TrapInformation
  1967. );
  1968. NTKERNELAPI
  1969. VOID
  1970. FASTCALL
  1971. MmSetPageFaultNotifyRoutine (
  1972. IN PPAGE_FAULT_NOTIFY_ROUTINE NotifyRoutine
  1973. );
  1974. NTSTATUS
  1975. MmCallDllInitialize (
  1976. IN PKLDR_DATA_TABLE_ENTRY DataTableEntry,
  1977. IN PLIST_ENTRY ModuleListHead
  1978. );
  1979. //
  1980. // Crash dump only
  1981. // Called to initialize the kernel memory for a kernel
  1982. // memory dump.
  1983. //
  1984. typedef
  1985. NTSTATUS
  1986. (*PMM_SET_DUMP_RANGE) (
  1987. IN struct _MM_KERNEL_DUMP_CONTEXT* Context,
  1988. IN PVOID StartVa,
  1989. IN PFN_NUMBER Pages,
  1990. IN ULONG AddressFlags
  1991. );
  1992. typedef
  1993. NTSTATUS
  1994. (*PMM_FREE_DUMP_RANGE) (
  1995. IN struct _MM_KERNEL_DUMP_CONTEXT* Context,
  1996. IN PVOID StartVa,
  1997. IN PFN_NUMBER Pages,
  1998. IN ULONG AddressFlags
  1999. );
  2000. typedef struct _MM_KERNEL_DUMP_CONTEXT {
  2001. PVOID Context;
  2002. PMM_SET_DUMP_RANGE SetDumpRange;
  2003. PMM_FREE_DUMP_RANGE FreeDumpRange;
  2004. } MM_KERNEL_DUMP_CONTEXT, *PMM_KERNEL_DUMP_CONTEXT;
  2005. VOID
  2006. MmGetKernelDumpRange (
  2007. IN PMM_KERNEL_DUMP_CONTEXT Callback
  2008. );
  2009. // begin_ntifs
  2010. //
  2011. // Prefetch public interface.
  2012. //
  2013. typedef struct _READ_LIST {
  2014. PFILE_OBJECT FileObject;
  2015. ULONG NumberOfEntries;
  2016. LOGICAL IsImage;
  2017. FILE_SEGMENT_ELEMENT List[ANYSIZE_ARRAY];
  2018. } READ_LIST, *PREAD_LIST;
  2019. NTSTATUS
  2020. MmPrefetchPages (
  2021. IN ULONG NumberOfLists,
  2022. IN PREAD_LIST *ReadLists
  2023. );
  2024. // end_ntifs
  2025. NTSTATUS
  2026. MmPrefetchPagesIntoLockedMdl (
  2027. IN PFILE_OBJECT FileObject,
  2028. IN PLARGE_INTEGER FileOffset,
  2029. IN SIZE_T Length,
  2030. OUT PMDL *MdlOut
  2031. );
  2032. LOGICAL
  2033. MmIsMemoryAvailable (
  2034. IN ULONG PagesDesired
  2035. );
  2036. NTSTATUS
  2037. MmIdentifyPhysicalMemory (
  2038. VOID
  2039. );
  2040. PFILE_OBJECT *
  2041. MmPerfUnusedSegmentsEnumerate (
  2042. VOID
  2043. );
  2044. NTSTATUS
  2045. MmPerfSnapShotValidPhysicalMemory (
  2046. VOID
  2047. );
  2048. PFILE_OBJECT *
  2049. MmPerfVadTreeWalk (
  2050. PEPROCESS Process
  2051. );
  2052. #endif // MM