ReactOS  0.4.15-dev-1627-gaf0f858
mm.h File Reference
#include <internal/arch/mm.h>
Include dependency graph for mm.h:

Go to the source code of this file.

Classes

struct  _MM_SECTION_SEGMENT
 
struct  _MM_IMAGE_SECTION_OBJECT
 
struct  _ROS_SECTION_OBJECT
 
struct  _MEMORY_AREA
 
struct  _MM_RMAP_ENTRY
 
struct  _MMPFNENTRY
 
struct  _MMPFN
 
struct  _MMPFNLIST
 
struct  _MM_MEMORY_CONSUMER
 
struct  _MM_REGION
 
struct  _MMFREE_POOL_ENTRY
 
struct  _MM_PAGED_POOL_INFO
 
struct  _MMPAGING_FILE
 

Macros

#define MMDBG_COPY_WRITE   0x00000001
 
#define MMDBG_COPY_PHYSICAL   0x00000002
 
#define MMDBG_COPY_UNSAFE   0x00000004
 
#define MMDBG_COPY_CACHED   0x00000008
 
#define MMDBG_COPY_UNCACHED   0x00000010
 
#define MMDBG_COPY_WRITE_COMBINED   0x00000020
 
#define MMDBG_COPY_MAX_SIZE   0x8
 
#define MI_STATIC_MEMORY_AREAS   (13)
 
#define MEMORY_AREA_SECTION_VIEW   (1)
 
#define MEMORY_AREA_CACHE   (2)
 
#define MEMORY_AREA_OWNED_BY_ARM3   (15)
 
#define MEMORY_AREA_STATIC   (0x80000000)
 
#define MM_VIRTMEM_GRANULARITY   (64 * 1024)
 
#define STATUS_MM_RESTART_OPERATION   ((NTSTATUS)0xD0000001)
 
#define PAGE_WRITETHROUGH   (1024)
 
#define PAGE_SYSTEM   (2048)
 
#define SEC_PHYSICALMEMORY   (0x80000000)
 
#define MM_PAGEFILE_SEGMENT   (0x1)
 
#define MM_DATAFILE_SEGMENT   (0x2)
 
#define MC_CACHE   (0)
 
#define MC_USER   (1)
 
#define MC_SYSTEM   (2)
 
#define MC_MAXIMUM   (3)
 
#define PAGED_POOL_MASK   1
 
#define MUST_SUCCEED_POOL_MASK   2
 
#define CACHE_ALIGNED_POOL_MASK   4
 
#define QUOTA_POOL_MASK   8
 
#define SESSION_POOL_MASK   32
 
#define VERIFIER_POOL_MASK   64
 
#define MAX_PAGING_FILES   (16)
 
#define MM_ROUND_UP(x, s)   ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))
 
#define MM_ROUND_DOWN(x, s)   ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))
 
#define PAGE_FLAGS_VALID_FOR_SECTION
 
#define PAGE_IS_READABLE
 
#define PAGE_IS_WRITABLE
 
#define PAGE_IS_EXECUTABLE
 
#define PAGE_IS_WRITECOPY
 
#define InterlockedCompareExchangePte(PointerPte, Exchange, Comperand)   InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)
 
#define InterlockedExchangePte(PointerPte, Value)   InterlockedExchange((PLONG)(PointerPte), Value)
 
#define MA_GetStartingAddress(_MemoryArea)   ((_MemoryArea)->VadNode.StartingVpn << PAGE_SHIFT)
 
#define MA_GetEndingAddress(_MemoryArea)   (((_MemoryArea)->VadNode.EndingVpn + 1) << PAGE_SHIFT)
 
#define MI_SET_USAGE(x)
 
#define MI_SET_PROCESS2(x)
 
#define StartOfAllocation   ReadInProgress
 
#define EndOfAllocation   WriteInProgress
 
#define MM_FREE_POOL_SIGNATURE   'ARM3'
 
#define MI_ASSERT_PFN_LOCK_HELD()   ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL)
 
#define MmDeleteHyperspaceMapping(x)   MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);
 

Typedefs

typedef ULONG_PTR SWAPENTRY
 
typedef struct _MM_SECTION_SEGMENT MM_SECTION_SEGMENT
 
typedef struct _MM_SECTION_SEGMENTPMM_SECTION_SEGMENT
 
typedef struct _MM_IMAGE_SECTION_OBJECT MM_IMAGE_SECTION_OBJECT
 
typedef struct _MM_IMAGE_SECTION_OBJECTPMM_IMAGE_SECTION_OBJECT
 
typedef struct _ROS_SECTION_OBJECT ROS_SECTION_OBJECT
 
typedef struct _ROS_SECTION_OBJECTPROS_SECTION_OBJECT
 
typedef struct _MEMORY_AREA MEMORY_AREA
 
typedef struct _MEMORY_AREAPMEMORY_AREA
 
typedef struct _MM_RMAP_ENTRY MM_RMAP_ENTRY
 
typedef struct _MM_RMAP_ENTRYPMM_RMAP_ENTRY
 
typedef enum _MI_PFN_USAGES MI_PFN_USAGES
 
typedef struct _MMPFNENTRY MMPFNENTRY
 
typedef struct _MMPFN MMPFN
 
typedef struct _MMPFNPMMPFN
 
typedef struct _MMPFNLIST MMPFNLIST
 
typedef struct _MMPFNLISTPMMPFNLIST
 
typedef struct _MM_MEMORY_CONSUMER MM_MEMORY_CONSUMER
 
typedef struct _MM_MEMORY_CONSUMERPMM_MEMORY_CONSUMER
 
typedef struct _MM_REGION MM_REGION
 
typedef struct _MM_REGIONPMM_REGION
 
typedef struct _MMFREE_POOL_ENTRY MMFREE_POOL_ENTRY
 
typedef struct _MMFREE_POOL_ENTRYPMMFREE_POOL_ENTRY
 
typedef struct _MM_PAGED_POOL_INFO MM_PAGED_POOL_INFO
 
typedef struct _MM_PAGED_POOL_INFOPMM_PAGED_POOL_INFO
 
typedef struct _MMPAGING_FILE MMPAGING_FILE
 
typedef struct _MMPAGING_FILEPMMPAGING_FILE
 
typedef VOID(* PMM_ALTER_REGION_FUNC) (PMMSUPPORT AddressSpace, PVOID BaseAddress, SIZE_T Length, ULONG OldType, ULONG OldProtect, ULONG NewType, ULONG NewProtect)
 
typedef VOID(* PMM_FREE_PAGE_FUNC) (PVOID Context, PMEMORY_AREA MemoryArea, PVOID Address, PFN_NUMBER Page, SWAPENTRY SwapEntry, BOOLEAN Dirty)
 

Enumerations

enum  _MI_PFN_USAGES {
  MI_USAGE_NOT_SET = 0, MI_USAGE_PAGED_POOL, MI_USAGE_NONPAGED_POOL, MI_USAGE_NONPAGED_POOL_EXPANSION,
  MI_USAGE_KERNEL_STACK, MI_USAGE_KERNEL_STACK_EXPANSION, MI_USAGE_SYSTEM_PTE, MI_USAGE_VAD,
  MI_USAGE_PEB_TEB, MI_USAGE_SECTION, MI_USAGE_PAGE_TABLE, MI_USAGE_PAGE_DIRECTORY,
  MI_USAGE_LEGACY_PAGE_DIRECTORY, MI_USAGE_DRIVER_PAGE, MI_USAGE_CONTINOUS_ALLOCATION, MI_USAGE_MDL,
  MI_USAGE_DEMAND_ZERO, MI_USAGE_ZERO_LOOP, MI_USAGE_CACHE, MI_USAGE_PFN_DATABASE,
  MI_USAGE_BOOT_DRIVER, MI_USAGE_INIT_MEMORY, MI_USAGE_FREE_PAGE
}
 

Functions

NTSTATUS NTAPI MmDbgCopyMemory (IN ULONG64 Address, IN PVOID Buffer, IN ULONG Size, IN ULONG Flags)
 
BOOLEAN NTAPI MmIsSessionAddress (IN PVOID Address)
 
ULONG NTAPI MmGetSessionId (IN PEPROCESS Process)
 
ULONG NTAPI MmGetSessionIdEx (IN PEPROCESS Process)
 
NTSTATUS NTAPI MmCreateMemoryArea (PMMSUPPORT AddressSpace, ULONG Type, PVOID *BaseAddress, SIZE_T Length, ULONG Protection, PMEMORY_AREA *Result, ULONG AllocationFlags, ULONG AllocationGranularity)
 
PMEMORY_AREA NTAPI MmLocateMemoryAreaByAddress (PMMSUPPORT AddressSpace, PVOID Address)
 
NTSTATUS NTAPI MmFreeMemoryArea (PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_FREE_PAGE_FUNC FreePage, PVOID FreePageContext)
 
VOID NTAPI MiRosCleanupMemoryArea (PEPROCESS Process, PMMVAD Vad)
 
PMEMORY_AREA NTAPI MmLocateMemoryAreaByRegion (PMMSUPPORT AddressSpace, PVOID Address, SIZE_T Length)
 
PVOID NTAPI MmFindGap (PMMSUPPORT AddressSpace, SIZE_T Length, ULONG_PTR Granularity, BOOLEAN TopDown)
 
VOID NTAPI MiRosCheckMemoryAreas (PMMSUPPORT AddressSpace)
 
VOID NTAPI MiCheckAllProcessMemoryAreas (VOID)
 
VOID NTAPI MiInitializeNonPagedPool (VOID)
 
PVOID NTAPI MiAllocatePoolPages (IN POOL_TYPE PoolType, IN SIZE_T SizeInBytes)
 
POOL_TYPE NTAPI MmDeterminePoolType (IN PVOID VirtualAddress)
 
ULONG NTAPI MiFreePoolPages (IN PVOID StartingAddress)
 
BOOLEAN NTAPI MiRaisePoolQuota (IN POOL_TYPE PoolType, IN ULONG CurrentMaxQuota, OUT PULONG NewMaxQuota)
 
VOID NTAPI MmBuildMdlFromPages (PMDL Mdl, PPFN_NUMBER Pages)
 
VOID NTAPI MmInit1 (VOID)
 
BOOLEAN NTAPI MmInitSystem (IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
SWAPENTRY NTAPI MmAllocSwapPage (VOID)
 
VOID NTAPI MmFreeSwapPage (SWAPENTRY Entry)
 
VOID NTAPI MmInitPagingFile (VOID)
 
BOOLEAN NTAPI MmIsFileObjectAPagingFile (PFILE_OBJECT FileObject)
 
NTSTATUS NTAPI MmReadFromSwapPage (SWAPENTRY SwapEntry, PFN_NUMBER Page)
 
NTSTATUS NTAPI MmWriteToSwapPage (SWAPENTRY SwapEntry, PFN_NUMBER Page)
 
VOID NTAPI MmShowOutOfSpaceMessagePagingFile (VOID)
 
NTSTATUS NTAPI MiReadPageFile (_In_ PFN_NUMBER Page, _In_ ULONG PageFileIndex, _In_ ULONG_PTR PageFileOffset)
 
NTSTATUS NTAPI MmInitializeProcessAddressSpace (IN PEPROCESS Process, IN PEPROCESS Clone OPTIONAL, IN PVOID Section OPTIONAL, IN OUT PULONG Flags, IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL)
 
NTSTATUS NTAPI MmCreatePeb (IN PEPROCESS Process, IN PINITIAL_PEB InitialPeb, OUT PPEB *BasePeb)
 
NTSTATUS NTAPI MmCreateTeb (IN PEPROCESS Process, IN PCLIENT_ID ClientId, IN PINITIAL_TEB InitialTeb, OUT PTEB *BaseTeb)
 
VOID NTAPI MmDeleteTeb (struct _EPROCESS *Process, PTEB Teb)
 
VOID NTAPI MmCleanProcessAddressSpace (IN PEPROCESS Process)
 
NTSTATUS NTAPI MmDeleteProcessAddressSpace (IN PEPROCESS Process)
 
ULONG NTAPI MmGetSessionLocaleId (VOID)
 
NTSTATUS NTAPI MmSetMemoryPriorityProcess (IN PEPROCESS Process, IN UCHAR MemoryPriority)
 
NTSTATUS NTAPI MmPageFault (ULONG Cs, PULONG Eip, PULONG Eax, ULONG Cr2, ULONG ErrorCode)
 
VOID NTAPI MiInitializeSpecialPool (VOID)
 
BOOLEAN NTAPI MmUseSpecialPool (IN SIZE_T NumberOfBytes, IN ULONG Tag)
 
BOOLEAN NTAPI MmIsSpecialPoolAddress (IN PVOID P)
 
BOOLEAN NTAPI MmIsSpecialPoolAddressFree (IN PVOID P)
 
PVOID NTAPI MmAllocateSpecialPool (IN SIZE_T NumberOfBytes, IN ULONG Tag, IN POOL_TYPE PoolType, IN ULONG SpecialType)
 
VOID NTAPI MmFreeSpecialPool (IN PVOID P)
 
NTSTATUS NTAPI MmAccessFault (IN ULONG FaultCode, IN PVOID Address, IN KPROCESSOR_MODE Mode, IN PVOID TrapInformation)
 
NTSTATUS NTAPI MiCopyFromUserPage (PFN_NUMBER DestPage, const VOID *SrcAddress)
 
PVOID NTAPI MmCreateKernelStack (BOOLEAN GuiStack, UCHAR Node)
 
VOID NTAPI MmDeleteKernelStack (PVOID Stack, BOOLEAN GuiStack)
 
VOID NTAPI MmInitializeMemoryConsumer (ULONG Consumer, NTSTATUS(*Trim)(ULONG Target, ULONG Priority, PULONG NrFreed))
 
VOID NTAPI MmInitializeBalancer (ULONG NrAvailablePages, ULONG NrSystemPages)
 
NTSTATUS NTAPI MmReleasePageMemoryConsumer (ULONG Consumer, PFN_NUMBER Page)
 
NTSTATUS NTAPI MmRequestPageMemoryConsumer (ULONG Consumer, BOOLEAN MyWait, PPFN_NUMBER AllocatedPage)
 
VOID NTAPI MiInitBalancerThread (VOID)
 
VOID NTAPI MmRebalanceMemoryConsumers (VOID)
 
VOID NTAPI MmSetRmapListHeadPage (PFN_NUMBER Page, struct _MM_RMAP_ENTRY *ListHead)
 
struct _MM_RMAP_ENTRY *NTAPI MmGetRmapListHeadPage (PFN_NUMBER Page)
 
VOID NTAPI MmInsertRmap (PFN_NUMBER Page, struct _EPROCESS *Process, PVOID Address)
 
VOID NTAPI MmDeleteAllRmaps (PFN_NUMBER Page, PVOID Context, VOID(*DeleteMapping)(PVOID Context, struct _EPROCESS *Process, PVOID Address))
 
VOID NTAPI MmDeleteRmap (PFN_NUMBER Page, struct _EPROCESS *Process, PVOID Address)
 
VOID NTAPI MmInitializeRmapList (VOID)
 
VOID NTAPI MmSetCleanAllRmaps (PFN_NUMBER Page)
 
VOID NTAPI MmSetDirtyAllRmaps (PFN_NUMBER Page)
 
BOOLEAN NTAPI MmIsDirtyPageRmap (PFN_NUMBER Page)
 
NTSTATUS NTAPI MmPageOutPhysicalAddress (PFN_NUMBER Page)
 
FORCEINLINE KIRQL MiAcquirePfnLock (VOID)
 
FORCEINLINE VOID MiReleasePfnLock (_In_ KIRQL OldIrql)
 
FORCEINLINE VOID MiAcquirePfnLockAtDpcLevel (VOID)
 
FORCEINLINE VOID MiReleasePfnLockFromDpcLevel (VOID)
 
FORCEINLINE PMMPFN MiGetPfnEntry (IN PFN_NUMBER Pfn)
 
FORCEINLINE PFN_NUMBER MiGetPfnEntryIndex (IN PMMPFN Pfn1)
 
PFN_NUMBER NTAPI MmGetLRUNextUserPage (PFN_NUMBER PreviousPage)
 
PFN_NUMBER NTAPI MmGetLRUFirstUserPage (VOID)
 
VOID NTAPI MmInsertLRULastUserPage (PFN_NUMBER Page)
 
VOID NTAPI MmRemoveLRUUserPage (PFN_NUMBER Page)
 
VOID NTAPI MmDumpArmPfnDatabase (IN BOOLEAN StatusOnly)
 
VOID NTAPI MmZeroPageThread (VOID)
 
PVOID NTAPI MiMapPageInHyperSpace (IN PEPROCESS Process, IN PFN_NUMBER Page, IN PKIRQL OldIrql)
 
VOID NTAPI MiUnmapPageInHyperSpace (IN PEPROCESS Process, IN PVOID Address, IN KIRQL OldIrql)
 
PVOID NTAPI MiMapPagesInZeroSpace (IN PMMPFN Pfn1, IN PFN_NUMBER NumberOfPages)
 
VOID NTAPI MiUnmapPagesInZeroSpace (IN PVOID VirtualAddress, IN PFN_NUMBER NumberOfPages)
 
FORCEINLINE PVOID MmCreateHyperspaceMapping (IN PFN_NUMBER Page)
 
NTSTATUS NTAPI MmCreateVirtualMapping (struct _EPROCESS *Process, PVOID Address, ULONG flProtect, PPFN_NUMBER Pages, ULONG PageCount)
 
NTSTATUS NTAPI MmCreateVirtualMappingUnsafe (struct _EPROCESS *Process, PVOID Address, ULONG flProtect, PPFN_NUMBER Pages, ULONG PageCount)
 
ULONG NTAPI MmGetPageProtect (struct _EPROCESS *Process, PVOID Address)
 
VOID NTAPI MmSetPageProtect (struct _EPROCESS *Process, PVOID Address, ULONG flProtect)
 
BOOLEAN NTAPI MmIsPagePresent (struct _EPROCESS *Process, PVOID Address)
 
BOOLEAN NTAPI MmIsDisabledPage (struct _EPROCESS *Process, PVOID Address)
 
VOID NTAPI MmInitGlobalKernelPageDirectory (VOID)
 
VOID NTAPI MmGetPageFileMapping (struct _EPROCESS *Process, PVOID Address, SWAPENTRY *SwapEntry)
 
VOID NTAPI MmDeletePageFileMapping (struct _EPROCESS *Process, PVOID Address, SWAPENTRY *SwapEntry)
 
NTSTATUS NTAPI MmCreatePageFileMapping (struct _EPROCESS *Process, PVOID Address, SWAPENTRY SwapEntry)
 
BOOLEAN NTAPI MmIsPageSwapEntry (struct _EPROCESS *Process, PVOID Address)
 
VOID NTAPI MmSetDirtyPage (struct _EPROCESS *Process, PVOID Address)
 
PFN_NUMBER NTAPI MmAllocPage (ULONG Consumer)
 
VOID NTAPI MmDereferencePage (PFN_NUMBER Page)
 
VOID NTAPI MmReferencePage (PFN_NUMBER Page)
 
ULONG NTAPI MmGetReferenceCountPage (PFN_NUMBER Page)
 
BOOLEAN NTAPI MmIsPageInUse (PFN_NUMBER Page)
 
VOID NTAPI MmSetSavedSwapEntryPage (PFN_NUMBER Page, SWAPENTRY SavedSwapEntry)
 
SWAPENTRY NTAPI MmGetSavedSwapEntryPage (PFN_NUMBER Page)
 
VOID NTAPI MmSetCleanPage (struct _EPROCESS *Process, PVOID Address)
 
VOID NTAPI MmDeletePageTable (struct _EPROCESS *Process, PVOID Address)
 
PFN_NUMBER NTAPI MmGetPfnForProcess (struct _EPROCESS *Process, PVOID Address)
 
BOOLEAN NTAPI MmCreateProcessAddressSpace (IN ULONG MinWs, IN PEPROCESS Dest, IN PULONG_PTR DirectoryTableBase)
 
NTSTATUS NTAPI MmInitializeHandBuiltProcess (IN PEPROCESS Process, IN PULONG_PTR DirectoryTableBase)
 
NTSTATUS NTAPI MmInitializeHandBuiltProcess2 (IN PEPROCESS Process)
 
NTSTATUS NTAPI MmSetExecuteOptions (IN ULONG ExecuteOptions)
 
NTSTATUS NTAPI MmGetExecuteOptions (IN PULONG ExecuteOptions)
 
VOID NTAPI MmDeleteVirtualMapping (struct _EPROCESS *Process, PVOID Address, BOOLEAN *WasDirty, PPFN_NUMBER Page)
 
BOOLEAN NTAPI MmIsDirtyPage (struct _EPROCESS *Process, PVOID Address)
 
NTSTATUS MmTrimUserMemory (ULONG Target, ULONG Priority, PULONG NrFreedPages)
 
NTSTATUS NTAPI MmAlterRegion (PMMSUPPORT AddressSpace, PVOID BaseAddress, PLIST_ENTRY RegionListHead, PVOID StartAddress, SIZE_T Length, ULONG NewType, ULONG NewProtect, PMM_ALTER_REGION_FUNC AlterFunc)
 
VOID NTAPI MmInitializeRegion (PLIST_ENTRY RegionListHead, SIZE_T Length, ULONG Type, ULONG Protect)
 
PMM_REGION NTAPI MmFindRegion (PVOID BaseAddress, PLIST_ENTRY RegionListHead, PVOID Address, PVOID *RegionBaseAddress)
 
VOID NTAPI MmGetImageInformation (OUT PSECTION_IMAGE_INFORMATION ImageInformation)
 
PFILE_OBJECT NTAPI MmGetFileObjectForSection (IN PVOID Section)
 
NTSTATUS NTAPI MmGetFileNameForAddress (IN PVOID Address, OUT PUNICODE_STRING ModuleName)
 
NTSTATUS NTAPI MmGetFileNameForSection (IN PVOID Section, OUT POBJECT_NAME_INFORMATION *ModuleName)
 
NTSTATUS NTAPI MmQuerySectionView (PMEMORY_AREA MemoryArea, PVOID Address, PMEMORY_BASIC_INFORMATION Info, PSIZE_T ResultLength)
 
NTSTATUS NTAPI MmProtectSectionView (PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PVOID BaseAddress, SIZE_T Length, ULONG Protect, PULONG OldProtect)
 
NTSTATUS NTAPI MmInitSectionImplementation (VOID)
 
NTSTATUS NTAPI MmNotPresentFaultSectionView (PMMSUPPORT AddressSpace, MEMORY_AREA *MemoryArea, PVOID Address, BOOLEAN Locked)
 
NTSTATUS NTAPI MmPageOutSectionView (PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PVOID Address, ULONG_PTR Entry)
 
NTSTATUS NTAPI MmCreatePhysicalMemorySection (VOID)
 
NTSTATUS NTAPI MmAccessFaultSectionView (PMMSUPPORT AddressSpace, MEMORY_AREA *MemoryArea, PVOID Address)
 
VOID NTAPI MmFreeSectionSegments (PFILE_OBJECT FileObject)
 
VOID NTAPI MiReloadBootLoadedDrivers (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
BOOLEAN NTAPI MiInitializeLoadedModuleList (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
BOOLEAN NTAPI MmChangeKernelResourceSectionProtection (IN ULONG_PTR ProtectionMask)
 
VOID NTAPI MmMakeKernelResourceSectionWritable (VOID)
 
NTSTATUS NTAPI MmLoadSystemImage (IN PUNICODE_STRING FileName, IN PUNICODE_STRING NamePrefix OPTIONAL, IN PUNICODE_STRING LoadedName OPTIONAL, IN ULONG Flags, OUT PVOID *ModuleObject, OUT PVOID *ImageBaseAddress)
 
NTSTATUS NTAPI MmUnloadSystemImage (IN PVOID ImageHandle)
 
NTSTATUS NTAPI MmCheckSystemImage (IN HANDLE ImageHandle, IN BOOLEAN PurgeSection)
 
NTSTATUS NTAPI MmCallDllInitialize (IN PLDR_DATA_TABLE_ENTRY LdrEntry, IN PLIST_ENTRY ListHead)
 
VOID NTAPI MmFreeDriverInitialization (IN PLDR_DATA_TABLE_ENTRY LdrEntry)
 
NTSTATUS NTAPI MmGrowKernelStack (IN PVOID StackPointer)
 
FORCEINLINE VOID MmLockAddressSpace (PMMSUPPORT AddressSpace)
 
FORCEINLINE VOID MmUnlockAddressSpace (PMMSUPPORT AddressSpace)
 
FORCEINLINE PEPROCESS MmGetAddressSpaceOwner (IN PMMSUPPORT AddressSpace)
 
FORCEINLINE PMMSUPPORT MmGetCurrentAddressSpace (VOID)
 
FORCEINLINE PMMSUPPORT MmGetKernelAddressSpace (VOID)
 
VOID NTAPI ExpCheckPoolAllocation (PVOID P, POOL_TYPE PoolType, ULONG Tag)
 
VOID NTAPI ExReturnPoolQuota (IN PVOID P)
 
NTSTATUS NTAPI MmAdjustWorkingSetSize (IN SIZE_T WorkingSetMinimumInBytes, IN SIZE_T WorkingSetMaximumInBytes, IN ULONG SystemCache, IN BOOLEAN IncreaseOkay)
 
 _IRQL_requires_max_ (APC_LEVEL) NTSTATUS NTAPI MmAttachSession(_Inout_ PVOID SessionEntry
 
VOID NTAPI MmQuitNextSession (_Inout_ PVOID SessionEntry)
 
PVOID NTAPI MmGetSessionById (_In_ ULONG SessionId)
 
VOID MmShutdownSystem (IN ULONG Phase)
 
NTSTATUS NTAPI MmCopyVirtualMemory (IN PEPROCESS SourceProcess, IN PVOID SourceAddress, IN PEPROCESS TargetProcess, OUT PVOID TargetAddress, IN SIZE_T BufferSize, IN KPROCESSOR_MODE PreviousMode, OUT PSIZE_T ReturnSize)
 

Variables

PMMSUPPORT MmKernelAddressSpace
 
PFN_COUNT MiFreeSwapPages
 
PFN_COUNT MiUsedSwapPages
 
PFN_COUNT MmNumberOfPhysicalPages
 
UCHAR MmDisablePagingExecutive
 
PFN_NUMBER MmLowestPhysicalPage
 
PFN_NUMBER MmHighestPhysicalPage
 
PFN_NUMBER MmAvailablePages
 
PFN_NUMBER MmResidentAvailablePages
 
ULONG MmThrottleTop
 
ULONG MmThrottleBottom
 
LIST_ENTRY MmLoadedUserImageList
 
KMUTANT MmSystemLoadLock
 
ULONG MmNumberOfPagingFiles
 
PVOID MmUnloadedDrivers
 
PVOID MmLastUnloadedDrivers
 
PVOID MmTriageActionTaken
 
PVOID KernelVerifier
 
MM_DRIVER_VERIFIER_DATA MmVerifierData
 
SIZE_T MmTotalCommitLimit
 
SIZE_T MmTotalCommittedPages
 
SIZE_T MmSharedCommit
 
SIZE_T MmDriverCommit
 
SIZE_T MmProcessCommit
 
SIZE_T MmPagedPoolCommit
 
SIZE_T MmPeakCommitment
 
SIZE_T MmtotalCommitLimitMaximum
 
PVOID MiDebugMapping
 
PMMPTE MmDebugPte
 
PMMPFN MmPfnDatabase
 
MMPFNLIST MmZeroedPageListHead
 
MMPFNLIST MmFreePageListHead
 
MMPFNLIST MmStandbyPageListHead
 
MMPFNLIST MmModifiedPageListHead
 
MMPFNLIST MmModifiedNoWritePageListHead
 
MM_MEMORY_CONSUMER MiMemoryConsumers [MC_MAXIMUM]
 
PMMPAGING_FILE MmPagingFile [MAX_PAGING_FILES]
 
PEPROCESS HyperProcess
 
KIRQL HyperIrql
 
_Out_ PKAPC_STATE ApcState
 

Macro Definition Documentation

◆ CACHE_ALIGNED_POOL_MASK

#define CACHE_ALIGNED_POOL_MASK   4

Definition at line 100 of file mm.h.

◆ EndOfAllocation

#define EndOfAllocation   WriteInProgress

Definition at line 294 of file mm.h.

◆ InterlockedCompareExchangePte

#define InterlockedCompareExchangePte (   PointerPte,
  Exchange,
  Comperand 
)    InterlockedCompareExchange((PLONG)(PointerPte), Exchange, Comperand)

Definition at line 160 of file mm.h.

◆ InterlockedExchangePte

#define InterlockedExchangePte (   PointerPte,
  Value 
)    InterlockedExchange((PLONG)(PointerPte), Value)

Definition at line 163 of file mm.h.

◆ MA_GetEndingAddress

#define MA_GetEndingAddress (   _MemoryArea)    (((_MemoryArea)->VadNode.EndingVpn + 1) << PAGE_SHIFT)

Definition at line 214 of file mm.h.

◆ MA_GetStartingAddress

#define MA_GetStartingAddress (   _MemoryArea)    ((_MemoryArea)->VadNode.StartingVpn << PAGE_SHIFT)

Definition at line 213 of file mm.h.

◆ MAX_PAGING_FILES

#define MAX_PAGING_FILES   (16)

Definition at line 105 of file mm.h.

◆ MC_CACHE

#define MC_CACHE   (0)

Definition at line 93 of file mm.h.

◆ MC_MAXIMUM

#define MC_MAXIMUM   (3)

Definition at line 96 of file mm.h.

◆ MC_SYSTEM

#define MC_SYSTEM   (2)

Definition at line 95 of file mm.h.

◆ MC_USER

#define MC_USER   (1)

Definition at line 94 of file mm.h.

◆ MEMORY_AREA_CACHE

#define MEMORY_AREA_CACHE   (2)

Definition at line 72 of file mm.h.

◆ MEMORY_AREA_OWNED_BY_ARM3

#define MEMORY_AREA_OWNED_BY_ARM3   (15)

Definition at line 73 of file mm.h.

◆ MEMORY_AREA_SECTION_VIEW

#define MEMORY_AREA_SECTION_VIEW   (1)

Definition at line 71 of file mm.h.

◆ MEMORY_AREA_STATIC

#define MEMORY_AREA_STATIC   (0x80000000)

Definition at line 74 of file mm.h.

◆ MI_ASSERT_PFN_LOCK_HELD

#define MI_ASSERT_PFN_LOCK_HELD ( )    ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL)

Definition at line 935 of file mm.h.

◆ MI_SET_PROCESS2

#define MI_SET_PROCESS2 (   x)

Definition at line 260 of file mm.h.

◆ MI_SET_USAGE

#define MI_SET_USAGE (   x)

Definition at line 259 of file mm.h.

◆ MI_STATIC_MEMORY_AREAS

#define MI_STATIC_MEMORY_AREAS   (13)

Definition at line 68 of file mm.h.

◆ MM_DATAFILE_SEGMENT

#define MM_DATAFILE_SEGMENT   (0x2)

Definition at line 91 of file mm.h.

◆ MM_FREE_POOL_SIGNATURE

#define MM_FREE_POOL_SIGNATURE   'ARM3'

Definition at line 415 of file mm.h.

◆ MM_PAGEFILE_SEGMENT

#define MM_PAGEFILE_SEGMENT   (0x1)

Definition at line 90 of file mm.h.

◆ MM_ROUND_DOWN

#define MM_ROUND_DOWN (   x,
  s 
)    ((PVOID)(((ULONG_PTR)(x)) & ~((ULONG_PTR)(s)-1)))

Definition at line 111 of file mm.h.

◆ MM_ROUND_UP

#define MM_ROUND_UP (   x,
  s 
)    ((PVOID)(((ULONG_PTR)(x)+(s)-1) & ~((ULONG_PTR)(s)-1)))

Definition at line 108 of file mm.h.

◆ MM_VIRTMEM_GRANULARITY

#define MM_VIRTMEM_GRANULARITY   (64 * 1024)

Definition at line 78 of file mm.h.

◆ MMDBG_COPY_CACHED

#define MMDBG_COPY_CACHED   0x00000008

Definition at line 56 of file mm.h.

◆ MMDBG_COPY_MAX_SIZE

#define MMDBG_COPY_MAX_SIZE   0x8

Definition at line 63 of file mm.h.

◆ MMDBG_COPY_PHYSICAL

#define MMDBG_COPY_PHYSICAL   0x00000002

Definition at line 54 of file mm.h.

◆ MMDBG_COPY_UNCACHED

#define MMDBG_COPY_UNCACHED   0x00000010

Definition at line 57 of file mm.h.

◆ MMDBG_COPY_UNSAFE

#define MMDBG_COPY_UNSAFE   0x00000004

Definition at line 55 of file mm.h.

◆ MMDBG_COPY_WRITE

#define MMDBG_COPY_WRITE   0x00000001

Definition at line 53 of file mm.h.

◆ MMDBG_COPY_WRITE_COMBINED

#define MMDBG_COPY_WRITE_COMBINED   0x00000020

Definition at line 58 of file mm.h.

◆ MmDeleteHyperspaceMapping

#define MmDeleteHyperspaceMapping (   x)    MiUnmapPageInHyperSpace(HyperProcess, x, HyperIrql);

Definition at line 1033 of file mm.h.

◆ MUST_SUCCEED_POOL_MASK

#define MUST_SUCCEED_POOL_MASK   2

Definition at line 99 of file mm.h.

◆ PAGE_FLAGS_VALID_FOR_SECTION

#define PAGE_FLAGS_VALID_FOR_SECTION
Value:
PAGE_READWRITE | \
PAGE_WRITECOPY | \
PAGE_EXECUTE | \
PAGE_EXECUTE_READ | \
PAGE_EXECUTE_READWRITE | \
PAGE_EXECUTE_WRITECOPY | \
PAGE_NOACCESS | \
PAGE_NOCACHE)
#define PAGE_READONLY
Definition: compat.h:138

Definition at line 114 of file mm.h.

◆ PAGE_IS_EXECUTABLE

#define PAGE_IS_EXECUTABLE
Value:
PAGE_EXECUTE_READ | \
PAGE_EXECUTE_READWRITE | \
PAGE_EXECUTE_WRITECOPY)
#define PAGE_EXECUTE
Definition: nt_native.h:1306

Definition at line 139 of file mm.h.

◆ PAGE_IS_READABLE

#define PAGE_IS_READABLE
Value:
PAGE_READWRITE | \
PAGE_WRITECOPY | \
PAGE_EXECUTE_READ | \
PAGE_EXECUTE_READWRITE | \
PAGE_EXECUTE_WRITECOPY)
#define PAGE_READONLY
Definition: compat.h:138

Definition at line 125 of file mm.h.

◆ PAGE_IS_WRITABLE

#define PAGE_IS_WRITABLE
Value:
PAGE_WRITECOPY | \
PAGE_EXECUTE_READWRITE | \
PAGE_EXECUTE_WRITECOPY)
#define PAGE_READWRITE
Definition: nt_native.h:1304

Definition at line 133 of file mm.h.

◆ PAGE_IS_WRITECOPY

#define PAGE_IS_WRITECOPY
Value:
PAGE_EXECUTE_WRITECOPY)
#define PAGE_WRITECOPY
Definition: nt_native.h:1305

Definition at line 145 of file mm.h.

◆ PAGE_SYSTEM

#define PAGE_SYSTEM   (2048)

Definition at line 86 of file mm.h.

◆ PAGE_WRITETHROUGH

#define PAGE_WRITETHROUGH   (1024)

Definition at line 85 of file mm.h.

◆ PAGED_POOL_MASK

#define PAGED_POOL_MASK   1

Definition at line 98 of file mm.h.

◆ QUOTA_POOL_MASK

#define QUOTA_POOL_MASK   8

Definition at line 101 of file mm.h.

◆ SEC_PHYSICALMEMORY

#define SEC_PHYSICALMEMORY   (0x80000000)

Definition at line 88 of file mm.h.

◆ SESSION_POOL_MASK

#define SESSION_POOL_MASK   32

Definition at line 102 of file mm.h.

◆ StartOfAllocation

#define StartOfAllocation   ReadInProgress

Definition at line 293 of file mm.h.

◆ STATUS_MM_RESTART_OPERATION

#define STATUS_MM_RESTART_OPERATION   ((NTSTATUS)0xD0000001)

Definition at line 80 of file mm.h.

◆ VERIFIER_POOL_MASK

#define VERIFIER_POOL_MASK   64

Definition at line 103 of file mm.h.

Typedef Documentation

◆ MEMORY_AREA

◆ MI_PFN_USAGES

◆ MM_IMAGE_SECTION_OBJECT

◆ MM_MEMORY_CONSUMER

◆ MM_PAGED_POOL_INFO

◆ MM_REGION

◆ MM_RMAP_ENTRY

◆ MM_SECTION_SEGMENT

◆ MMFREE_POOL_ENTRY

◆ MMPAGING_FILE

◆ MMPFN

typedef struct _MMPFN MMPFN

◆ MMPFNENTRY

◆ MMPFNLIST

◆ PMEMORY_AREA

◆ PMM_ALTER_REGION_FUNC

typedef VOID(* PMM_ALTER_REGION_FUNC) (PMMSUPPORT AddressSpace, PVOID BaseAddress, SIZE_T Length, ULONG OldType, ULONG OldProtect, ULONG NewType, ULONG NewProtect)

Definition at line 450 of file mm.h.

◆ PMM_FREE_PAGE_FUNC

typedef VOID(* PMM_FREE_PAGE_FUNC) (PVOID Context, PMEMORY_AREA MemoryArea, PVOID Address, PFN_NUMBER Page, SWAPENTRY SwapEntry, BOOLEAN Dirty)

Definition at line 461 of file mm.h.

◆ PMM_IMAGE_SECTION_OBJECT

◆ PMM_MEMORY_CONSUMER

◆ PMM_PAGED_POOL_INFO

◆ PMM_REGION

◆ PMM_RMAP_ENTRY

◆ PMM_SECTION_SEGMENT

◆ PMMFREE_POOL_ENTRY

◆ PMMPAGING_FILE

◆ PMMPFN

typedef struct _MMPFN * PMMPFN

◆ PMMPFNLIST

◆ PROS_SECTION_OBJECT

◆ ROS_SECTION_OBJECT

◆ SWAPENTRY

Definition at line 47 of file mm.h.

Enumeration Type Documentation

◆ _MI_PFN_USAGES

Enumerator
MI_USAGE_NOT_SET 
MI_USAGE_PAGED_POOL 
MI_USAGE_NONPAGED_POOL 
MI_USAGE_NONPAGED_POOL_EXPANSION 
MI_USAGE_KERNEL_STACK 
MI_USAGE_KERNEL_STACK_EXPANSION 
MI_USAGE_SYSTEM_PTE 
MI_USAGE_VAD 
MI_USAGE_PEB_TEB 
MI_USAGE_SECTION 
MI_USAGE_PAGE_TABLE 
MI_USAGE_PAGE_DIRECTORY 
MI_USAGE_LEGACY_PAGE_DIRECTORY 
MI_USAGE_DRIVER_PAGE 
MI_USAGE_CONTINOUS_ALLOCATION 
MI_USAGE_MDL 
MI_USAGE_DEMAND_ZERO 
MI_USAGE_ZERO_LOOP 
MI_USAGE_CACHE 
MI_USAGE_PFN_DATABASE 
MI_USAGE_BOOT_DRIVER 
MI_USAGE_INIT_MEMORY 
MI_USAGE_FREE_PAGE 

Definition at line 263 of file mm.h.

264 {
265  MI_USAGE_NOT_SET = 0,
272  MI_USAGE_VAD,
280  MI_USAGE_MDL,
288 } MI_PFN_USAGES;
enum _MI_PFN_USAGES MI_PFN_USAGES

Function Documentation

◆ _IRQL_requires_max_()

_IRQL_requires_max_ ( APC_LEVEL  )

Definition at line 197 of file cddata.c.

254 {
255  THREAD_CONTEXT ThreadContext = {0};
256  PIRP_CONTEXT IrpContext = NULL;
257  BOOLEAN Wait;
258 
259 #ifdef CD_SANITY
260  PVOID PreviousTopLevel;
261 #endif
262 
264 
265 #if DBG
266 
267  KIRQL SaveIrql = KeGetCurrentIrql();
268 
269 #endif
270 
272 
274 
276 
277 #ifdef CD_SANITY
278  PreviousTopLevel = IoGetTopLevelIrp();
279 #endif
280 
281  //
282  // Loop until this request has been completed or posted.
283  //
284 
285  do {
286 
287  //
288  // Use a try-except to handle the exception cases.
289  //
290 
291  _SEH2_TRY {
292 
293  //
294  // If the IrpContext is NULL then this is the first pass through
295  // this loop.
296  //
297 
298  if (IrpContext == NULL) {
299 
300  //
301  // Decide if this request is waitable an allocate the IrpContext.
302  // If the file object in the stack location is NULL then this
303  // is a mount which is always waitable. Otherwise we look at
304  // the file object flags.
305  //
306 
308 
309  Wait = TRUE;
310 
311  } else {
312 
313  Wait = CanFsdWait( Irp );
314  }
315 
316  IrpContext = CdCreateIrpContext( Irp, Wait );
317 
318  //
319  // Update the thread context information.
320  //
321 
322  CdSetThreadContext( IrpContext, &ThreadContext );
323 
324 #ifdef CD_SANITY
325  NT_ASSERT( !CdTestTopLevel ||
326  SafeNodeType( IrpContext->TopLevel ) == CDFS_NTC_IRP_CONTEXT );
327 #endif
328 
329  //
330  // Otherwise cleanup the IrpContext for the retry.
331  //
332 
333  } else {
334 
335  //
336  // Set the MORE_PROCESSING flag to make sure the IrpContext
337  // isn't inadvertently deleted here. Then cleanup the
338  // IrpContext to perform the retry.
339  //
340 
341  SetFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_MORE_PROCESSING );
342  CdCleanupIrpContext( IrpContext, FALSE );
343  }
344 
345  //
346  // Case on the major irp code.
347  //
348 
349  switch (IrpContext->MajorFunction) {
350 
351  case IRP_MJ_CREATE :
352 
353  Status = CdCommonCreate( IrpContext, Irp );
354  break;
355 
356  case IRP_MJ_CLOSE :
357 
358  Status = CdCommonClose( IrpContext, Irp );
359  break;
360 
361  case IRP_MJ_READ :
362 
363  //
364  // If this is an Mdl complete request, don't go through
365  // common read.
366  //
367 
368  if (FlagOn( IrpContext->MinorFunction, IRP_MN_COMPLETE )) {
369 
370  Status = CdCompleteMdl( IrpContext, Irp );
371 
372  } else {
373 
374  Status = CdCommonRead( IrpContext, Irp );
375  }
376 
377  break;
378 
379  case IRP_MJ_WRITE :
380 
381  Status = CdCommonWrite( IrpContext, Irp );
382  break;
383 
385 
386  Status = CdCommonQueryInfo( IrpContext, Irp );
387  break;
388 
390 
391  Status = CdCommonSetInfo( IrpContext, Irp );
392  break;
393 
395 
396  Status = CdCommonQueryVolInfo( IrpContext, Irp );
397  break;
398 
400 
401  Status = CdCommonDirControl( IrpContext, Irp );
402  break;
403 
405 
406  Status = CdCommonFsControl( IrpContext, Irp );
407  break;
408 
409  case IRP_MJ_DEVICE_CONTROL :
410 
411  Status = CdCommonDevControl( IrpContext, Irp );
412  break;
413 
414  case IRP_MJ_LOCK_CONTROL :
415 
416  Status = CdCommonLockControl( IrpContext, Irp );
417  break;
418 
419  case IRP_MJ_CLEANUP :
420 
421  Status = CdCommonCleanup( IrpContext, Irp );
422  break;
423 
424  case IRP_MJ_PNP :
425 
426  Status = CdCommonPnp( IrpContext, Irp );
427  break;
428 
429  case IRP_MJ_SHUTDOWN :
430 
431  Status = CdCommonShutdown( IrpContext, Irp );
432  break;
433 
434  default :
435 
437  CdCompleteRequest( IrpContext, Irp, Status );
438  }
439 
441 
442  Status = CdProcessException( IrpContext, Irp, _SEH2_GetExceptionCode() );
443  } _SEH2_END;
444 
445  } while (Status == STATUS_CANT_WAIT);
446 
447 #ifdef CD_SANITY
448  NT_ASSERT( !CdTestTopLevel ||
449  (PreviousTopLevel == IoGetTopLevelIrp()) );
450 #endif
451 
453 
454  NT_ASSERT( SaveIrql == KeGetCurrentIrql( ));
455 
456  return Status;
457 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
VOID CdSetThreadContext(_Inout_ PIRP_CONTEXT IrpContext, _In_ PTHREAD_CONTEXT ThreadContext)
Definition: cddata.c:981
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define IRP_MJ_SHUTDOWN
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define IRP_CONTEXT_FLAG_MORE_PROCESSING
Definition: cdstruc.h:1214
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
#define SafeNodeType(Ptr)
Definition: nodetype.h:54
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_SEH2_TRY
Definition: create.c:4226
#define IRP_MN_COMPLETE
Definition: iotypes.h:4416
UCHAR KIRQL
Definition: env_spec_w32.h:591
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
VOID CdCompleteRequest(_Inout_opt_ PIRP_CONTEXT IrpContext, _Inout_opt_ PIRP Irp, _In_ NTSTATUS Status)
Definition: cddata.c:914
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:11
unsigned char BOOLEAN
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
Status
Definition: gdiplustypes.h:24
#define IRP_MJ_FILE_SYSTEM_CONTROL
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
#define CanFsdWait(I)
Definition: cdprocs.h:2001
NTSTATUS CdCompleteMdl(_In_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: cachesup.c:411
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
NTSTATUS CdCommonDevControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: devctrl.c:46
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4400
LONG CdExceptionFilter(_Inout_ PIRP_CONTEXT IrpContext, _In_ PEXCEPTION_POINTERS ExceptionPointer)
Definition: cddata.c:525
#define ASSERT_OPTIONAL_IRP(I)
Definition: cddata.h:251
#define NULL
Definition: types.h:112
VOID CdCleanupIrpContext(_In_ PIRP_CONTEXT IrpContext, _In_ BOOLEAN Post)
Definition: strucsup.c:1733
NTSTATUS CdCommonLockControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: lockctrl.c:35
#define CDFS_NTC_IRP_CONTEXT
Definition: nodetype.h:34
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_CLEANUP
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
_Ret_valid_ PIRP_CONTEXT CdCreateIrpContext(_In_ PIRP Irp, _In_ BOOLEAN Wait)
Definition: strucsup.c:1573
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define STATUS_CANT_WAIT
Definition: ntstatus.h:452
#define NT_ASSERT
Definition: rtlfuncs.h:3312

◆ ExpCheckPoolAllocation()

VOID NTAPI ExpCheckPoolAllocation ( PVOID  P,
POOL_TYPE  PoolType,
ULONG  Tag 
)

Definition at line 288 of file expool.c.

292 {
294  ULONG i;
295  KIRQL OldIrql;
296  POOL_TYPE RealPoolType;
297 
298  /* Get the pool header */
299  Entry = ((PPOOL_HEADER)P) - 1;
300 
301  /* Check if this is a large allocation */
302  if (PAGE_ALIGN(P) == P)
303  {
304  /* Lock the pool table */
306 
307  /* Find the pool tag */
308  for (i = 0; i < PoolBigPageTableSize; i++)
309  {
310  /* Check if this is our allocation */
311  if (PoolBigPageTable[i].Va == P)
312  {
313  /* Make sure the tag is ok */
314  if (PoolBigPageTable[i].Key != Tag)
315  {
316  KeBugCheckEx(BAD_POOL_CALLER, 0x0A, (ULONG_PTR)P, PoolBigPageTable[i].Key, Tag);
317  }
318 
319  break;
320  }
321  }
322 
323  /* Release the lock */
325 
326  if (i == PoolBigPageTableSize)
327  {
328  /* Did not find the allocation */
329  //ASSERT(FALSE);
330  }
331 
332  /* Get Pool type by address */
333  RealPoolType = MmDeterminePoolType(P);
334  }
335  else
336  {
337  /* Verify the tag */
338  if (Entry->PoolTag != Tag)
339  {
340  DPRINT1("Allocation has wrong pool tag! Expected '%.4s', got '%.4s' (0x%08lx)\n",
341  &Tag, &Entry->PoolTag, Entry->PoolTag);
342  KeBugCheckEx(BAD_POOL_CALLER, 0x0A, (ULONG_PTR)P, Entry->PoolTag, Tag);
343  }
344 
345  /* Check the rest of the header */
347 
348  /* Get Pool type from entry */
349  RealPoolType = (Entry->PoolType - 1);
350  }
351 
352  /* Should we check the pool type? */
353  if (PoolType != -1)
354  {
355  /* Verify the pool type */
356  if (RealPoolType != PoolType)
357  {
358  DPRINT1("Wrong pool type! Expected %s, got %s\n",
359  PoolType & BASE_POOL_TYPE_MASK ? "PagedPool" : "NonPagedPool",
360  (Entry->PoolType - 1) & BASE_POOL_TYPE_MASK ? "PagedPool" : "NonPagedPool");
361  KeBugCheckEx(BAD_POOL_CALLER, 0xCC, (ULONG_PTR)P, Entry->PoolTag, Tag);
362  }
363  }
364 }
struct _Entry Entry
Definition: kefuncs.h:627
uint32_t ULONG_PTR
Definition: typedefs.h:65
KSPIN_LOCK ExpLargePoolTableLock
Definition: expool.c:46
UCHAR KIRQL
Definition: env_spec_w32.h:591
SIZE_T PoolBigPageTableSize
Definition: expool.c:39
VOID NTAPI ExpCheckPoolHeader(IN PPOOL_HEADER Entry)
Definition: expool.c:185
#define BASE_POOL_TYPE_MASK
Definition: ExPools.c:15
struct _POOL_HEADER * PPOOL_HEADER
POOL_TYPE NTAPI MmDeterminePoolType(IN PVOID VirtualAddress)
Definition: pool.c:406
INT POOL_TYPE
Definition: typedefs.h:78
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define PAGE_ALIGN(Va)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
#define P(row, col)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define DPRINT1
Definition: precomp.h:8
PPOOL_TRACKER_BIG_PAGES PoolBigPageTable
Definition: expool.c:42
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
unsigned int ULONG
Definition: retypes.h:1
base of all file and directory entries
Definition: entries.h:82
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

◆ ExReturnPoolQuota()

VOID NTAPI ExReturnPoolQuota ( IN PVOID  P)

Definition at line 1798 of file expool.c.

1799 {
1802  USHORT BlockSize;
1804 
1807  {
1808  return;
1809  }
1810 
1811  Entry = P;
1812  Entry--;
1814 
1815  PoolType = Entry->PoolType - 1;
1816  BlockSize = Entry->BlockSize;
1817 
1818  if (PoolType & QUOTA_POOL_MASK)
1819  {
1820  Process = ((PVOID *)POOL_NEXT_BLOCK(Entry))[-1];
1821  ASSERT(Process != NULL);
1822  if (Process)
1823  {
1824  if (Process->Pcb.Header.Type != ProcessObject)
1825  {
1826  DPRINT1("Object %p is not a process. Type %u, pool type 0x%x, block size %u\n",
1827  Process, Process->Pcb.Header.Type, Entry->PoolType, BlockSize);
1828  KeBugCheckEx(BAD_POOL_CALLER,
1830  (ULONG_PTR)P,
1831  Entry->PoolTag,
1832  (ULONG_PTR)Process);
1833  }
1834  ((PVOID *)POOL_NEXT_BLOCK(Entry))[-1] = NULL;
1837  BlockSize * POOL_BLOCK_SIZE);
1839  }
1840  }
1841 }
struct _Entry Entry
Definition: kefuncs.h:627
#define POOL_FLAG_SPECIAL_POOL
Definition: miarm.h:289
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define POOL_NEXT_BLOCK(x)
Definition: expool.c:56
VOID NTAPI PsReturnPoolQuota(IN PEPROCESS Process, IN POOL_TYPE PoolType, IN SIZE_T Amount)
Definition: quota.c:236
#define BASE_POOL_TYPE_MASK
Definition: ExPools.c:15
#define ASSERT(a)
Definition: mode.c:45
INT POOL_TYPE
Definition: typedefs.h:78
#define ObDereferenceObject
Definition: obfuncs.h:203
#define P(row, col)
#define QUOTA_POOL_MASK
Definition: ExPools.c:16
unsigned short USHORT
Definition: pedump.c:61
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
ULONG ExpPoolFlags
Definition: expool.c:48
#define POOL_BLOCK_SIZE
Definition: miarm.h:275
BOOLEAN NTAPI MmIsSpecialPoolAddress(IN PVOID P)
base of all file and directory entries
Definition: entries.h:82
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
#define POOL_BILLED_PROCESS_INVALID
Definition: miarm.h:312

Referenced by IoFreeIrp().

◆ MiAcquirePfnLock()

FORCEINLINE KIRQL MiAcquirePfnLock ( VOID  )

Definition at line 900 of file mm.h.

901 {
903 }
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108

Referenced by _MiFlushMappedSection(), MiAllocatePagesForMdl(), MiAllocatePoolPages(), MiBalancerThread(), MiBuildPagedPool(), MiBuildPfnDatabase(), MiBuildPfnDatabaseFromLoaderBlock(), MiCheckPurgeAndUpMapCount(), MiDeleteARM3Section(), MiDeleteSystemPageableVm(), MiDeleteVirtualAddresses(), MiDereferenceControlArea(), MiDispatchFault(), MiFillSystemPageDirectory(), MiFindContiguousPages(), MiFlushTbAndCapture(), MiFreeContiguousMemory(), MiGetPageProtection(), MiInitializeAndChargePfn(), MiInitMachineDependent(), MiLoadImageSection(), MiMakeSystemAddressValidPfn(), MiMapLockedPagesInUserSpace(), MiProcessValidPteList(), MiProtectVirtualMemory(), MiReleaseProcessReferenceToSessionDataPage(), MiRemoveMappedPtes(), MiRemoveMappedView(), MiResolveDemandZeroFault(), MiResolvePageFileFault(), MiResolveProtoPteFault(), MiSegmentDelete(), MiSessionCommitPageTables(), MiSessionCreateInternal(), MiSessionInitializeWorkingSetList(), MiSetControlAreaSymbolsLoaded(), MiUnmapLockedPagesInUserSpace(), MmAllocateSpecialPool(), MmAllocPage(), MmArmAccessFault(), MmCreateArm3Section(), MmCreateKernelStack(), MmCreateProcessAddressSpace(), MmDeleteKernelStack(), MmDeleteProcessAddressSpace(), MmDeleteProcessAddressSpace2(), MmDereferencePage(), MmFreeLoaderBlock(), MmFreeMemoryArea(), MmFreePagesFromMdl(), MmFreeSpecialPool(), MmGetLRUFirstUserPage(), MmGetLRUNextUserPage(), MmGetPhysicalMemoryRanges(), MmGetReferenceCountPage(), MmGetRmapListHeadPage(), MmGetSavedSwapEntryPage(), MmGrowKernelStackEx(), MmInitializeProcessAddressSpace(), MmInsertLRULastUserPage(), MmNotPresentFaultCachePage(), MmPageOutSectionView(), MmProbeAndLockPages(), MmRemoveLRUUserPage(), MmSetRmapListHeadPage(), MmSetSavedSwapEntryPage(), MmUnlockPages(), and MmZeroPageThread().

◆ MiAcquirePfnLockAtDpcLevel()

FORCEINLINE VOID MiAcquirePfnLockAtDpcLevel ( VOID  )

Definition at line 915 of file mm.h.

916 {
917  PKSPIN_LOCK_QUEUE LockQueue;
918 
920  LockQueue = &KeGetCurrentPrcb()->LockQueue[LockQueuePfnLock];
922 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1075
VOID FASTCALL KeAcquireQueuedSpinLockAtDpcLevel(IN OUT PKSPIN_LOCK_QUEUE LockQueue)
#define ASSERT(a)
Definition: mode.c:45
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696

Referenced by MiAllocatePoolPages().

◆ MiAllocatePoolPages()

PVOID NTAPI MiAllocatePoolPages ( IN POOL_TYPE  PoolType,
IN SIZE_T  SizeInBytes 
)

Definition at line 420 of file pool.c.

422 {
423  PFN_NUMBER PageFrameNumber;
424  PFN_COUNT SizeInPages, PageTableCount;
425  ULONG i;
426  KIRQL OldIrql;
427  PLIST_ENTRY NextEntry, NextHead, LastHead;
428  PMMPTE PointerPte, StartPte;
429  PMMPDE PointerPde;
430  ULONG EndAllocation;
431  MMPTE TempPte;
432  MMPDE TempPde;
433  PMMPFN Pfn1;
434  PVOID BaseVa, BaseVaStart;
435  PMMFREE_POOL_ENTRY FreeEntry;
436 
437  //
438  // Figure out how big the allocation is in pages
439  //
440  SizeInPages = (PFN_COUNT)BYTES_TO_PAGES(SizeInBytes);
441 
442  //
443  // Check for overflow
444  //
445  if (SizeInPages == 0)
446  {
447  //
448  // Fail
449  //
450  return NULL;
451  }
452 
453  //
454  // Handle paged pool
455  //
457  {
458  //
459  // If only one page is being requested, try to grab it from the S-LIST
460  //
461  if ((SizeInPages == 1) && (ExQueryDepthSList(&MiPagedPoolSListHead)))
462  {
464  if (BaseVa) return BaseVa;
465  }
466 
467  //
468  // Lock the paged pool mutex
469  //
471 
472  //
473  // Find some empty allocation space
474  //
476  SizeInPages,
478  if (i == 0xFFFFFFFF)
479  {
480  //
481  // Get the page bit count
482  //
483  i = ((SizeInPages - 1) / PTE_PER_PAGE) + 1;
484  DPRINT("Paged pool expansion: %lu %x\n", i, SizeInPages);
485 
486  //
487  // Check if there is enougn paged pool expansion space left
488  //
491  {
492  //
493  // Out of memory!
494  //
495  DPRINT1("FAILED to allocate %Iu bytes from paged pool\n", SizeInBytes);
497  return NULL;
498  }
499 
500  //
501  // Check if we'll have to expand past the last PTE we have available
502  //
505  {
506  //
507  // We can only support this much then
508  //
510  PageTableCount = (PFN_COUNT)(PointerPde + 1 -
512  ASSERT(PageTableCount < i);
513  i = PageTableCount;
514  }
515  else
516  {
517  //
518  // Otherwise, there is plenty of space left for this expansion
519  //
520  PageTableCount = i;
521  }
522 
523  //
524  // Get the template PDE we'll use to expand
525  //
527 
528  //
529  // Get the first PTE in expansion space
530  //
532  BaseVa = MiPdeToPte(PointerPde);
533  BaseVaStart = BaseVa;
534 
535  //
536  // Lock the PFN database and loop pages
537  //
539  do
540  {
541  //
542  // It should not already be valid
543  //
544  ASSERT(PointerPde->u.Hard.Valid == 0);
545 
546  /* Request a page */
548  MI_SET_PROCESS2("Kernel");
549  PageFrameNumber = MiRemoveAnyPage(MI_GET_NEXT_COLOR());
550  TempPde.u.Hard.PageFrameNumber = PageFrameNumber;
551 #if (_MI_PAGING_LEVELS >= 3)
552  /* On PAE/x64 systems, there's no double-buffering */
553  /* Initialize the PFN entry for it */
554  MiInitializePfnForOtherProcess(PageFrameNumber,
555  (PMMPTE)PointerPde,
556  PFN_FROM_PTE(MiAddressToPte(PointerPde)));
557 
558  /* Write the actual PDE now */
559  MI_WRITE_VALID_PDE(PointerPde, TempPde);
560 #else
561  //
562  // Save it into our double-buffered system page directory
563  //
564  MmSystemPagePtes[((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE - 1)) / sizeof(MMPTE)] = TempPde;
565 
566  /* Initialize the PFN */
567  MiInitializePfnForOtherProcess(PageFrameNumber,
568  (PMMPTE)PointerPde,
570 #endif
571 
572  //
573  // Move on to the next expansion address
574  //
575  PointerPde++;
576  BaseVa = (PVOID)((ULONG_PTR)BaseVa + PAGE_SIZE);
577  i--;
578  } while (i > 0);
579 
580  //
581  // Release the PFN database lock
582  //
584 
585  //
586  // These pages are now available, clear their availablity bits
587  //
590  PTE_PER_PAGE;
592  EndAllocation,
593  PageTableCount * PTE_PER_PAGE);
594 
595  //
596  // Update the next expansion location
597  //
599 
600  //
601  // Zero out the newly available memory
602  //
603  RtlZeroMemory(BaseVaStart, PageTableCount * PAGE_SIZE);
604 
605  //
606  // Now try consuming the pages again
607  //
609  SizeInPages,
610  0);
611  if (i == 0xFFFFFFFF)
612  {
613  //
614  // Out of memory!
615  //
616  DPRINT1("FAILED to allocate %Iu bytes from paged pool\n", SizeInBytes);
618  return NULL;
619  }
620  }
621 
622  //
623  // Update the pool hint if the request was just one page
624  //
625  if (SizeInPages == 1) MmPagedPoolInfo.PagedPoolHint = i + 1;
626 
627  //
628  // Update the end bitmap so we know the bounds of this allocation when
629  // the time comes to free it
630  //
631  EndAllocation = i + SizeInPages - 1;
633 
634  //
635  // Now we can release the lock (it mainly protects the bitmap)
636  //
638 
639  //
640  // Now figure out where this allocation starts
641  //
642  BaseVa = (PVOID)((ULONG_PTR)MmPagedPoolStart + (i << PAGE_SHIFT));
643 
644  //
645  // Flush the TLB
646  //
648 
649  /* Setup a demand-zero writable PTE */
651 
652  //
653  // Find the first and last PTE, then loop them all
654  //
655  PointerPte = MiAddressToPte(BaseVa);
656  StartPte = PointerPte + SizeInPages;
657  do
658  {
659  //
660  // Write the demand zero PTE and keep going
661  //
662  MI_WRITE_INVALID_PTE(PointerPte, TempPte);
663  } while (++PointerPte < StartPte);
664 
665  //
666  // Return the allocation address to the caller
667  //
668  return BaseVa;
669  }
670 
671  //
672  // If only one page is being requested, try to grab it from the S-LIST
673  //
674  if ((SizeInPages == 1) && (ExQueryDepthSList(&MiNonPagedPoolSListHead)))
675  {
677  if (BaseVa) return BaseVa;
678  }
679 
680  //
681  // Allocations of less than 4 pages go into their individual buckets
682  //
683  i = SizeInPages - 1;
685 
686  //
687  // Loop through all the free page lists based on the page index
688  //
689  NextHead = &MmNonPagedPoolFreeListHead[i];
691 
692  //
693  // Acquire the nonpaged pool lock
694  //
696  do
697  {
698  //
699  // Now loop through all the free page entries in this given list
700  //
701  NextEntry = NextHead->Flink;
702  while (NextEntry != NextHead)
703  {
704  /* Is freed non paged pool enabled */
706  {
707  /* We need to be able to touch this page, unprotect it */
708  MiUnProtectFreeNonPagedPool(NextEntry, 0);
709  }
710 
711  //
712  // Grab the entry and see if it can handle our allocation
713  //
714  FreeEntry = CONTAINING_RECORD(NextEntry, MMFREE_POOL_ENTRY, List);
715  ASSERT(FreeEntry->Signature == MM_FREE_POOL_SIGNATURE);
716  if (FreeEntry->Size >= SizeInPages)
717  {
718  //
719  // It does, so consume the pages from here
720  //
721  FreeEntry->Size -= SizeInPages;
722 
723  //
724  // The allocation will begin in this free page area
725  //
726  BaseVa = (PVOID)((ULONG_PTR)FreeEntry +
727  (FreeEntry->Size << PAGE_SHIFT));
728 
729  /* Remove the item from the list, depending if pool is protected */
732  else
733  RemoveEntryList(&FreeEntry->List);
734 
735  //
736  // However, check if its' still got space left
737  //
738  if (FreeEntry->Size != 0)
739  {
740  /* Check which list to insert this entry into */
741  i = FreeEntry->Size - 1;
743 
744  /* Insert the entry into the free list head, check for prot. pool */
747  else
749 
750  /* Is freed non paged pool protected? */
752  {
753  /* Protect the freed pool! */
754  MiProtectFreeNonPagedPool(FreeEntry, FreeEntry->Size);
755  }
756  }
757 
758  //
759  // Grab the PTE for this allocation
760  //
761  PointerPte = MiAddressToPte(BaseVa);
762  ASSERT(PointerPte->u.Hard.Valid == 1);
763 
764  //
765  // Grab the PFN NextEntry and index
766  //
767  Pfn1 = MiGetPfnEntry(PFN_FROM_PTE(PointerPte));
768 
769  //
770  // Now mark it as the beginning of an allocation
771  //
772  ASSERT(Pfn1->u3.e1.StartOfAllocation == 0);
773  Pfn1->u3.e1.StartOfAllocation = 1;
774 
775  /* Mark it as special pool if needed */
776  ASSERT(Pfn1->u4.VerifierAllocation == 0);
778  {
779  Pfn1->u4.VerifierAllocation = 1;
780  }
781 
782  //
783  // Check if the allocation is larger than one page
784  //
785  if (SizeInPages != 1)
786  {
787  //
788  // Navigate to the last PFN entry and PTE
789  //
790  PointerPte += SizeInPages - 1;
791  ASSERT(PointerPte->u.Hard.Valid == 1);
792  Pfn1 = MiGetPfnEntry(PointerPte->u.Hard.PageFrameNumber);
793  }
794 
795  //
796  // Mark this PFN as the last (might be the same as the first)
797  //
798  ASSERT(Pfn1->u3.e1.EndOfAllocation == 0);
799  Pfn1->u3.e1.EndOfAllocation = 1;
800 
801  //
802  // Release the nonpaged pool lock, and return the allocation
803  //
805  return BaseVa;
806  }
807 
808  //
809  // Try the next free page entry
810  //
811  NextEntry = FreeEntry->List.Flink;
812 
813  /* Is freed non paged pool protected? */
815  {
816  /* Protect the freed pool! */
817  MiProtectFreeNonPagedPool(FreeEntry, FreeEntry->Size);
818  }
819  }
820  } while (++NextHead < LastHead);
821 
822  //
823  // If we got here, we're out of space.
824  // Start by releasing the lock
825  //
827 
828  //
829  // Allocate some system PTEs
830  //
831  StartPte = MiReserveSystemPtes(SizeInPages, NonPagedPoolExpansion);
832  PointerPte = StartPte;
833  if (StartPte == NULL)
834  {
835  //
836  // Ran out of memory
837  //
838  DPRINT1("Out of NP Expansion Pool\n");
839  return NULL;
840  }
841 
842  //
843  // Acquire the pool lock now
844  //
846 
847  //
848  // Lock the PFN database too
849  //
851 
852  //
853  // Loop the pages
854  //
856  do
857  {
858  /* Allocate a page */
860  MI_SET_PROCESS2("Kernel");
861  PageFrameNumber = MiRemoveAnyPage(MI_GET_NEXT_COLOR());
862 
863  /* Get the PFN entry for it and fill it out */
864  Pfn1 = MiGetPfnEntry(PageFrameNumber);
865  Pfn1->u3.e2.ReferenceCount = 1;
866  Pfn1->u2.ShareCount = 1;
867  Pfn1->PteAddress = PointerPte;
869  Pfn1->u4.VerifierAllocation = 0;
870 
871  /* Write the PTE for it */
872  TempPte.u.Hard.PageFrameNumber = PageFrameNumber;
873  MI_WRITE_VALID_PTE(PointerPte++, TempPte);
874  } while (--SizeInPages > 0);
875 
876  //
877  // This is the last page
878  //
879  Pfn1->u3.e1.EndOfAllocation = 1;
880 
881  //
882  // Get the first page and mark it as such
883  //
884  Pfn1 = MiGetPfnEntry(StartPte->u.Hard.PageFrameNumber);
885  Pfn1->u3.e1.StartOfAllocation = 1;
886 
887  /* Mark it as a verifier allocation if needed */
888  ASSERT(Pfn1->u4.VerifierAllocation == 0);
890 
891  //
892  // Release the PFN and nonpaged pool lock
893  //
896 
897  //
898  // Return the address
899  //
900  return MiPteToAddress(StartPte);
901 }
#define MI_MAKE_SOFTWARE_PTE(p, x)
Definition: miarm.h:185
PRTL_BITMAP PagedPoolAllocationMap
Definition: mm.h:420
#define PDE_PER_PAGE
Definition: mm.h:21
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
union _MMPFN::@1792 u2
BOOLEAN NTAPI MiUnProtectFreeNonPagedPool(IN PVOID VirtualAddress, IN ULONG PageCount)
Definition: pool.c:68
#define MiAddressToPde(x)
Definition: mmx86.c:20
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
ULONG PFN_COUNT
Definition: mmtypes.h:102
#define TRUE
Definition: types.h:120
PMMPTE NTAPI MiReserveSystemPtes(IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
Definition: syspte.c:246
ULONG Signature
Definition: mm.h:410
#define VERIFIER_POOL_MASK
Definition: mm.h:103
NTSYSAPI VOID NTAPI RtlSetBit(_In_ PRTL_BITMAP BitMapHeader, _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber)
Definition: bitmap.c:304
#define MI_GET_NEXT_COLOR()
Definition: miarm.h:238
HARDWARE_PDE_ARMV6 TempPde
Definition: winldr.c:78
FORCEINLINE KIRQL MiAcquirePfnLock(VOID)
Definition: mm.h:900
VOID NTAPI MiInitializePfnForOtherProcess(IN PFN_NUMBER PageFrameIndex, IN PVOID PteAddress, IN PFN_NUMBER PteFrame)
Definition: pfnlist.c:1280
#define InsertTailList(ListHead, Entry)
FORCEINLINE VOID MiReleasePfnLock(_In_ KIRQL OldIrql)
Definition: mm.h:907
USHORT PageLocation
Definition: mm.h:303
PSLIST_ENTRY WINAPI InterlockedPopEntrySList(PSLIST_HEADER ListHead)
Definition: interlocked.c:55
FORCEINLINE VOID MiReleasePfnLockFromDpcLevel(VOID)
Definition: mm.h:926
SLIST_HEADER MiNonPagedPoolSListHead
Definition: pool.c:30
uint32_t ULONG_PTR
Definition: typedefs.h:65
FORCEINLINE VOID MiAcquirePfnLockAtDpcLevel(VOID)
Definition: mm.h:915
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
MMPFNENTRY e1
Definition: mm.h:335
#define MiAddressToPte(x)
Definition: mmx86.c:19
ULONG PFN_NUMBER
Definition: ke.h:9
PMMPTE LastPteForPagedPool
Definition: mm.h:423
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:942
union _MMPFN::@1796 u4
ULONG_PTR ShareCount
Definition: mm.h:328
VOID NTAPI MiProtectedPoolRemoveEntryList(IN PLIST_ENTRY Entry)
Definition: pool.c:166
#define MI_SET_PROCESS2(x)
Definition: mm.h:260
LIST_ENTRY List
Definition: mm.h:408
PFN_NUMBER MmSystemPageDirectory[PPE_PER_PAGE]
Definition: init.c:40
#define MI_MAX_FREE_PAGE_LISTS
Definition: mm.h:80
ULONG_PTR VerifierAllocation
Definition: mm.h:358
NTSYSAPI ULONG WINAPI RtlFindClearBitsAndSet(PRTL_BITMAP, ULONG, ULONG)
void DPRINT(...)
Definition: polytest.cpp:61
#define BASE_POOL_TYPE_MASK
Definition: ExPools.c:15
FORCEINLINE VOID MI_WRITE_VALID_PDE(IN PMMPDE PointerPde, IN MMPDE TempPde)
Definition: miarm.h:1001
#define MI_SET_USAGE(x)
Definition: mm.h:259
void * PVOID
Definition: retypes.h:9
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
VOID NTAPI KeFlushEntireTb(IN BOOLEAN Invalid, IN BOOLEAN AllProcessors)
Definition: cpu.c:416
PMMPDE MmSystemPagePtes
Definition: init.c:41
KGUARDED_MUTEX MmPagedPoolMutex
Definition: pool.c:24
PFN_COUNT Size
Definition: mm.h:409
ULONG PageFrameNumber
Definition: mmtypes.h:74
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define MM_FREE_POOL_SIGNATURE
Definition: mm.h:415
#define ASSERT(a)
Definition: mode.c:45
Definition: mm.h:406
ULONG64 Valid
Definition: mmtypes.h:150
MM_PAGED_POOL_INFO MmPagedPoolInfo
Definition: pool.c:25
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
#define PTE_PER_PAGE
Definition: mm.h:20
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:76
FORCEINLINE USHORT ExQueryDepthSList(_In_ PSLIST_HEADER SListHead)
Definition: exfuncs.h:153
MMPTE ValidKernelPte
Definition: init.c:29
VOID NTAPI MiProtectedPoolInsertList(IN PLIST_ENTRY ListHead, IN PLIST_ENTRY Entry, IN BOOLEAN Critical)
Definition: pool.c:148
#define BYTES_TO_PAGES(Size)
union _MMPFN::@1793 u3
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define MM_READWRITE
Definition: inbv.c:12
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: mm.h:311
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:119
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
struct _MMPFN::@1793::@1799 e2
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:939
union _MMPTE::@2319 u
MMPTE ValidKernelPde
Definition: init.c:28
PVOID MmPagedPoolStart
Definition: miarm.h:581
NTSYSAPI void WINAPI RtlClearBits(PRTL_BITMAP, ULONG, ULONG)
PFN_NUMBER NTAPI MiRemoveAnyPage(IN ULONG Color)
Definition: pfnlist.c:475
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define SYSTEM_PD_SIZE
Definition: miarm.h:28
#define MiPteToPde(_Pte)
Definition: mm.h:236
FORCEINLINE VOID MI_WRITE_INVALID_PTE(IN PMMPTE PointerPte, IN MMPTE InvalidPte)
Definition: miarm.h:975
BOOLEAN MmProtectFreedNonPagedPool
Definition: pool.c:29
#define MiPdeToPte(_Pde)
Definition: mm.h:235
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PRTL_BITMAP EndOfPagedPoolBitmap
Definition: mm.h:421
PMMPTE PteAddress
Definition: mm.h:324
#define NULL
Definition: types.h:112
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
#define DPRINT1
Definition: precomp.h:8
SLIST_HEADER MiPagedPoolSListHead
Definition: pool.c:32
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
VOID NTAPI MiProtectFreeNonPagedPool(IN PVOID VirtualAddress, IN ULONG PageCount)
Definition: pool.c:39
ULONG PagedPoolHint
Definition: mm.h:425
PMMPTE FirstPteForPagedPool
Definition: mm.h:422
FORCEINLINE PVOID MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:201
LIST_ENTRY MmNonPagedPoolFreeListHead[MI_MAX_FREE_PAGE_LISTS]
Definition: pool.c:20
#define PFN_FROM_PTE(v)
Definition: mm.h:92
ULONG PageFrameNumber
Definition: mmtypes.h:109
PMMPDE NextPdeForPagedPoolExpansion
Definition: mm.h:424

Referenced by _IRQL_requires_(), ExAllocatePoolWithTag(), and InitializePool().

◆ MiCheckAllProcessMemoryAreas()

VOID NTAPI MiCheckAllProcessMemoryAreas ( VOID  )

◆ MiCopyFromUserPage()

NTSTATUS NTAPI MiCopyFromUserPage ( PFN_NUMBER  DestPage,
const VOID SrcAddress 
)

Definition at line 1044 of file section.c.

1045 {
1047  KIRQL Irql;
1048  PVOID DestAddress;
1049 
1051  DestAddress = MiMapPageInHyperSpace(Process, DestPage, &Irql);
1052  if (DestAddress == NULL)
1053  {
1054  return(STATUS_NO_MEMORY);
1055  }
1056  ASSERT((ULONG_PTR)DestAddress % PAGE_SIZE == 0);
1057  ASSERT((ULONG_PTR)SrcAddress % PAGE_SIZE == 0);
1058  RtlCopyMemory(DestAddress, SrcAddress, PAGE_SIZE);
1059  MiUnmapPageInHyperSpace(Process, DestAddress, Irql);
1060  return(STATUS_SUCCESS);
1061 }
_Out_ PKIRQL Irql
Definition: csq.h:179
uint32_t ULONG_PTR
Definition: typedefs.h:65
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define PsGetCurrentProcess
Definition: psfuncs.h:17
PVOID NTAPI MiMapPageInHyperSpace(IN PEPROCESS Process, IN PFN_NUMBER Page, IN PKIRQL OldIrql)
Definition: hypermap.c:30
#define ASSERT(a)
Definition: mode.c:45
VOID NTAPI MiUnmapPageInHyperSpace(IN PEPROCESS Process, IN PVOID Address, IN KIRQL OldIrql)
Definition: hypermap.c:93
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by MmAccessFaultSectionView().

◆ MiFreePoolPages()

ULONG NTAPI MiFreePoolPages ( IN PVOID  StartingAddress)

Definition at line 905 of file pool.c.

906 {
907  PMMPTE PointerPte, StartPte;
908  PMMPFN Pfn1, StartPfn;
909  PFN_COUNT FreePages, NumberOfPages;
910  KIRQL OldIrql;
911  PMMFREE_POOL_ENTRY FreeEntry, NextEntry, LastEntry;
912  ULONG i, End;
914 
915  //
916  // Handle paged pool
917  //
918  if ((StartingVa >= MmPagedPoolStart) && (StartingVa <= MmPagedPoolEnd))
919  {
920  //
921  // Calculate the offset from the beginning of paged pool, and convert it
922  // into pages
923  //
924  Offset = (ULONG_PTR)StartingVa - (ULONG_PTR)MmPagedPoolStart;
925  i = (ULONG)(Offset >> PAGE_SHIFT);
926  End = i;
927 
928  //
929  // Now use the end bitmap to scan until we find a set bit, meaning that
930  // this allocation finishes here
931  //
932  while (!RtlTestBit(MmPagedPoolInfo.EndOfPagedPoolBitmap, End)) End++;
933 
934  //
935  // Now calculate the total number of pages this allocation spans. If it's
936  // only one page, add it to the S-LIST instead of freeing it
937  //
938  NumberOfPages = End - i + 1;
939  if ((NumberOfPages == 1) &&
941  {
943  return 1;
944  }
945 
946  /* Delete the actual pages */
947  PointerPte = MmPagedPoolInfo.FirstPteForPagedPool + i;
948  FreePages = MiDeleteSystemPageableVm(PointerPte, NumberOfPages, 0, NULL);
949  ASSERT(FreePages == NumberOfPages);
950 
951  //
952  // Acquire the paged pool lock
953  //
955 
956  //
957  // Clear the allocation and free bits
958  //
961 
962  //
963  // Update the hint if we need to
964  //
966 
967  //
968  // Release the lock protecting the bitmaps
969  //
971 
972  //
973  // And finally return the number of pages freed
974  //
975  return NumberOfPages;
976  }
977 
978  //
979  // Get the first PTE and its corresponding PFN entry. If this is also the
980  // last PTE, meaning that this allocation was only for one page, push it into
981  // the S-LIST instead of freeing it
982  //
983  StartPte = PointerPte = MiAddressToPte(StartingVa);
984  StartPfn = Pfn1 = MiGetPfnEntry(PointerPte->u.Hard.PageFrameNumber);
985  if ((Pfn1->u3.e1.EndOfAllocation == 1) &&
987  {
989  return 1;
990  }
991 
992  //
993  // Loop until we find the last PTE
994  //
995  while (Pfn1->u3.e1.EndOfAllocation == 0)
996  {
997  //
998  // Keep going
999  //
1000  PointerPte++;
1001  Pfn1 = MiGetPfnEntry(PointerPte->u.Hard.PageFrameNumber);
1002  }
1003 
1004  //
1005  // Now we know how many pages we have
1006  //
1007  NumberOfPages = (PFN_COUNT)(PointerPte - StartPte + 1);
1008 
1009  //
1010  // Acquire the nonpaged pool lock
1011  //
1013 
1014  //
1015  // Mark the first and last PTEs as not part of an allocation anymore
1016  //
1017  StartPfn->u3.e1.StartOfAllocation = 0;
1018  Pfn1->u3.e1.EndOfAllocation = 0;
1019 
1020  //
1021  // Assume we will free as many pages as the allocation was
1022  //
1023  FreePages = NumberOfPages;
1024 
1025  //
1026  // Peek one page past the end of the allocation
1027  //
1028  PointerPte++;
1029 
1030  //
1031  // Guard against going past initial nonpaged pool
1032  //
1034  {
1035  //
1036  // This page is on the outskirts of initial nonpaged pool, so ignore it
1037  //
1038  Pfn1 = NULL;
1039  }
1040  else
1041  {
1042  /* Sanity check */
1043  ASSERT((ULONG_PTR)StartingVa + NumberOfPages <= (ULONG_PTR)MmNonPagedPoolEnd);
1044 
1045  /* Check if protected pool is enabled */
1047  {
1048  /* The freed block will be merged, it must be made accessible */
1050  }
1051 
1052  //
1053  // Otherwise, our entire allocation must've fit within the initial non
1054  // paged pool, or the expansion nonpaged pool, so get the PFN entry of
1055  // the next allocation
1056  //
1057  if (PointerPte->u.Hard.Valid == 1)
1058  {
1059  //
1060  // It's either expansion or initial: get the PFN entry
1061  //
1062  Pfn1 = MiGetPfnEntry(PointerPte->u.Hard.PageFrameNumber);
1063  }
1064  else
1065  {
1066  //
1067  // This means we've reached the guard page that protects the end of
1068  // the expansion nonpaged pool
1069  //
1070  Pfn1 = NULL;
1071  }
1072 
1073  }
1074 
1075  //
1076  // Check if this allocation actually exists
1077  //
1078  if ((Pfn1) && (Pfn1->u3.e1.StartOfAllocation == 0))
1079  {
1080  //
1081  // It doesn't, so we should actually locate a free entry descriptor
1082  //
1083  FreeEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)StartingVa +
1084  (NumberOfPages << PAGE_SHIFT));
1085  ASSERT(FreeEntry->Signature == MM_FREE_POOL_SIGNATURE);
1086  ASSERT(FreeEntry->Owner == FreeEntry);
1087 
1088  /* Consume this entry's pages */
1089  FreePages += FreeEntry->Size;
1090 
1091  /* Remove the item from the list, depending if pool is protected */
1093  MiProtectedPoolRemoveEntryList(&FreeEntry->List);
1094  else
1095  RemoveEntryList(&FreeEntry->List);
1096  }
1097 
1098  //
1099  // Now get the official free entry we'll create for the caller's allocation
1100  //
1101  FreeEntry = StartingVa;
1102 
1103  //
1104  // Check if the our allocation is the very first page
1105  //
1107  {
1108  //
1109  // Then we can't do anything or we'll risk underflowing
1110  //
1111  Pfn1 = NULL;
1112  }
1113  else
1114  {
1115  //
1116  // Otherwise, get the PTE for the page right before our allocation
1117  //
1118  PointerPte -= NumberOfPages + 1;
1119 
1120  /* Check if protected pool is enabled */
1122  {
1123  /* The freed block will be merged, it must be made accessible */
1125  }
1126 
1127  /* Check if this is valid pool, or a guard page */
1128  if (PointerPte->u.Hard.Valid == 1)
1129  {
1130  //
1131  // It's either expansion or initial nonpaged pool, get the PFN entry
1132  //
1133  Pfn1 = MiGetPfnEntry(PointerPte->u.Hard.PageFrameNumber);
1134  }
1135  else
1136  {
1137  //
1138  // We must've reached the guard page, so don't risk touching it
1139  //
1140  Pfn1 = NULL;
1141  }
1142  }
1143 
1144  //
1145  // Check if there is a valid PFN entry for the page before the allocation
1146  // and then check if this page was actually the end of an allocation.
1147  // If it wasn't, then we know for sure it's a free page
1148  //
1149  if ((Pfn1) && (Pfn1->u3.e1.EndOfAllocation == 0))
1150  {
1151  //
1152  // Get the free entry descriptor for that given page range
1153  //
1154  FreeEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)StartingVa - PAGE_SIZE);
1155  ASSERT(FreeEntry->Signature == MM_FREE_POOL_SIGNATURE);
1156  FreeEntry = FreeEntry->Owner;
1157 
1158  /* Check if protected pool is enabled */
1160  {
1161  /* The freed block will be merged, it must be made accessible */
1162  MiUnProtectFreeNonPagedPool(FreeEntry, 0);
1163  }
1164 
1165  //
1166  // Check if the entry is small enough to be indexed on a free list
1167  // If it is, we'll want to re-insert it, since we're about to
1168  // collapse our pages on top of it, which will change its count
1169  //
1170  if (FreeEntry->Size < (MI_MAX_FREE_PAGE_LISTS - 1))
1171  {
1172  /* Remove the item from the list, depending if pool is protected */
1174  MiProtectedPoolRemoveEntryList(&FreeEntry->List);
1175  else
1176  RemoveEntryList(&FreeEntry->List);
1177 
1178  //
1179  // Update its size
1180  //
1181  FreeEntry->Size += FreePages;
1182 
1183  //
1184  // And now find the new appropriate list to place it in
1185  //
1186  i = (ULONG)(FreeEntry->Size - 1);
1188 
1189  /* Insert the entry into the free list head, check for prot. pool */
1192  else
1194  }
1195  else
1196  {
1197  //
1198  // Otherwise, just combine our free pages into this entry
1199  //
1200  FreeEntry->Size += FreePages;
1201  }
1202  }
1203 
1204  //
1205  // Check if we were unable to do any compaction, and we'll stick with this
1206  //
1207  if (FreeEntry == StartingVa)
1208  {
1209  //
1210  // Well, now we are a free entry. At worse we just have our newly freed
1211  // pages, at best we have our pages plus whatever entry came after us
1212  //
1213  FreeEntry->Size = FreePages;
1214 
1215  //
1216  // Find the appropriate list we should be on
1217  //
1218  i = FreeEntry->Size - 1;
1220 
1221  /* Insert the entry into the free list head, check for prot. pool */
1224  else
1226  }
1227 
1228  //
1229  // Just a sanity check
1230  //
1231  ASSERT(FreePages != 0);
1232 
1233  //
1234  // Get all the pages between our allocation and its end. These will all now
1235  // become free page chunks.
1236  //
1237  NextEntry = StartingVa;
1238  LastEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)NextEntry + (FreePages << PAGE_SHIFT));
1239  do
1240  {
1241  //
1242  // Link back to the parent free entry, and keep going
1243  //
1244  NextEntry->Owner = FreeEntry;
1245  NextEntry->Signature = MM_FREE_POOL_SIGNATURE;
1246  NextEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)NextEntry + PAGE_SIZE);
1247  } while (NextEntry != LastEntry);
1248 
1249  /* Is freed non paged pool protected? */
1251  {
1252  /* Protect the freed pool! */
1253  MiProtectFreeNonPagedPool(FreeEntry, FreeEntry->Size);
1254  }
1255 
1256  //
1257  // We're done, release the lock and let the caller know how much we freed
1258  //
1260  return NumberOfPages;
1261 }
PRTL_BITMAP PagedPoolAllocationMap
Definition: mm.h:420
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
BOOLEAN NTAPI MiUnProtectFreeNonPagedPool(IN PVOID VirtualAddress, IN ULONG PageCount)
Definition: pool.c:68
PFN_NUMBER MiEndOfInitialPoolFrame
Definition: pool.c:23
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
ULONG PFN_COUNT
Definition: mmtypes.h:102
#define TRUE
Definition: types.h:120
ULONG Signature
Definition: mm.h:410
PVOID MmPagedPoolEnd
Definition: init.c:26
#define InsertTailList(ListHead, Entry)
SLIST_HEADER MiNonPagedPoolSListHead
Definition: pool.c:30
PVOID MmNonPagedPoolEnd
Definition: mminit.c:99
uint32_t ULONG_PTR
Definition: typedefs.h:65
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
MMPFNENTRY e1
Definition: mm.h:335
#define MiAddressToPte(x)
Definition: mmx86.c:19
VOID NTAPI MiProtectedPoolRemoveEntryList(IN PLIST_ENTRY Entry)
Definition: pool.c:166
PFN_NUMBER MiStartOfInitialPoolFrame
Definition: pool.c:23
LIST_ENTRY List
Definition: mm.h:408
#define MI_MAX_FREE_PAGE_LISTS
Definition: mm.h:80
KGUARDED_MUTEX MmPagedPoolMutex
Definition: pool.c:24
PFN_COUNT Size
Definition: mm.h:409
#define MM_FREE_POOL_SIGNATURE
Definition: mm.h:415
#define ASSERT(a)
Definition: mode.c:45
Definition: mm.h:406
ULONG64 Valid
Definition: mmtypes.h:150
MM_PAGED_POOL_INFO MmPagedPoolInfo
Definition: pool.c:25
VOID NTAPI RtlClearBit(_In_ PRTL_BITMAP BitMapHeader, _In_ BITMAP_INDEX BitNumber)
Definition: bitmap.c:294
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
FORCEINLINE USHORT ExQueryDepthSList(_In_ PSLIST_HEADER SListHead)
Definition: exfuncs.h:153
_Must_inspect_result_ NTSYSAPI BOOLEAN NTAPI RtlTestBit(_In_ PRTL_BITMAP BitMapHeader, _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber)
Definition: bitmap.c:434
ULONG MiNonPagedPoolSListMaximum
Definition: pool.c:31
VOID NTAPI MiProtectedPoolInsertList(IN PLIST_ENTRY ListHead, IN PLIST_ENTRY Entry, IN BOOLEAN Critical)
Definition: pool.c:148
struct _MMFREE_POOL_ENTRY * Owner
Definition: mm.h:411
ULONG MiPagedPoolSListMaximum
Definition: pool.c:33
union _MMPFN::@1793 u3
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
Definition: mm.h:311
#define PAGE_SIZE
Definition: env_spec_w32.h:49
NTKERNELAPI PSLIST_ENTRY FASTCALL InterlockedPushEntrySList(IN PSLIST_HEADER ListHead, IN PSLIST_ENTRY ListEntry)
Definition: interlocked.c:82
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:939
union _MMPTE::@2319 u
PVOID MmPagedPoolStart
Definition: miarm.h:581
PFN_COUNT NTAPI MiDeleteSystemPageableVm(IN PMMPTE PointerPte, IN PFN_NUMBER PageCount, IN ULONG Flags, OUT PPFN_NUMBER ValidPages)
Definition: virtual.c:297
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
NTSYSAPI void WINAPI RtlClearBits(PRTL_BITMAP, ULONG, ULONG)
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
BOOLEAN MmProtectFreedNonPagedPool
Definition: pool.c:29
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct _MMFREE_POOL_ENTRY * PMMFREE_POOL_ENTRY
PRTL_BITMAP EndOfPagedPoolBitmap
Definition: mm.h:421
#define NULL
Definition: types.h:112
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
SLIST_HEADER MiPagedPoolSListHead
Definition: pool.c:32
FORCEINLINE PFN_NUMBER MiGetPfnEntryIndex(IN PMMPFN Pfn1)
Definition: mm.h:959
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
VOID NTAPI MiProtectFreeNonPagedPool(IN PVOID VirtualAddress, IN ULONG PageCount)
Definition: pool.c:39
ULONG PagedPoolHint
Definition: mm.h:425
PMMPTE FirstPteForPagedPool
Definition: mm.h:422
FORCEINLINE PVOID MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:201
LIST_ENTRY MmNonPagedPoolFreeListHead[MI_MAX_FREE_PAGE_LISTS]
Definition: pool.c:20

Referenced by _IRQL_requires_(), and ExFreePoolWithTag().

◆ MiGetPfnEntry()

FORCEINLINE PMMPFN MiGetPfnEntry ( IN PFN_NUMBER  Pfn)

Definition at line 939 of file mm.h.

940 {
941  PMMPFN Page;
942  extern RTL_BITMAP MiPfnBitMap;
943 
944  /* Make sure the PFN number is valid */
945  if (Pfn > MmHighestPhysicalPage) return NULL;
946 
947  /* Make sure this page actually has a PFN entry */
948  if ((MiPfnBitMap.Buffer) && !(RtlTestBit(&MiPfnBitMap, (ULONG)Pfn))) return NULL;
949 
950  /* Get the entry */
951  Page = &MmPfnDatabase[Pfn];
952 
953  /* Return it */
954  return Page;
955 };
PULONG Buffer
Definition: typedefs.h:91
PMMPFN MmPfnDatabase
Definition: freelist.c:24
RTL_BITMAP MiPfnBitMap
Definition: init.c:44
_Must_inspect_result_ NTSYSAPI BOOLEAN NTAPI RtlTestBit(_In_ PRTL_BITMAP BitMapHeader, _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber)
Definition: bitmap.c:434
Definition: mm.h:311
#define NULL
Definition: types.h:112
PFN_NUMBER MmHighestPhysicalPage
Definition: meminit.c:31
unsigned int ULONG
Definition: retypes.h:1

Referenced by MiAddHalIoMappings(), MiAllocatePagesForMdl(), MiAllocatePoolPages(), MiBuildPfnDatabaseFromLoaderBlock(), MiBuildPfnDatabaseFromPages(), MiBuildPfnDatabaseFromPageTables(), MiBuildPfnDatabaseSelf(), MiBuildPfnDatabaseZeroPage(), MiCompleteProtoPteFault(), MiCopyPfn(), MiDbgTranslatePhysicalAddress(), MiDecommitPages(), MiDeletePte(), MiDeleteSystemPageableVm(), MiFindContiguousMemory(), MiFreeContiguousMemory(), MiFreePoolPages(), MiGetPageProtection(), MiInitializeWorkingSetList(), MiInitMachineDependent(), MiLockVirtualMemory(), MiMapLockedPagesInUserSpace(), MiMapPageInHyperSpace(), MiProcessValidPteList(), MiProtectVirtualMemory(), MiReloadBootLoadedDrivers(), MiRemoveMappedPtes(), MiResolveProtoPteFault(), MiResolveTransitionFault(), MiSetPagingOfDriver(), MiSetProtectionOnSection(), MiSetupPfnForPageTable(), MiUnlockVirtualMemory(), MiUnmapLockedPagesInUserSpace(), MiZeroPfn(), MmAllocPage(), MmBuildMdlForNonPagedPool(), MmDeleteKernelStack(), MmDeleteProcessAddressSpace2(), MmDereferencePage(), MmDumpArmPfnDatabase(), MmFreeLoaderBlock(), MmFreePagesFromMdl(), MmGetLRUFirstUserPage(), MmGetLRUNextUserPage(), MmGetReferenceCountPage(), MmGetRmapListHeadPage(), MmGetSavedSwapEntryPage(), MmInsertLRULastUserPage(), MmIsPageInUse(), MmMapIoSpace(), MmNotPresentFaultCachePage(), MmProbeAndLockPages(), MmReferencePage(), MmRemoveLRUUserPage(), MmRosNotifyAvailablePage(), MmSetRmapListHeadPage(), MmSetSavedSwapEntryPage(), MmUnlockPages(), MmUnmapIoSpace(), MmZeroPageThread(), and PspCreateProcess().

◆ MiGetPfnEntryIndex()

FORCEINLINE PFN_NUMBER MiGetPfnEntryIndex ( IN PMMPFN  Pfn1)

Definition at line 959 of file mm.h.

960 {
961  //
962  // This will return the Page Frame Number (PFN) from the MMPFN
963  //
964  return Pfn1 - MmPfnDatabase;
965 }
PMMPFN MmPfnDatabase
Definition: freelist.c:24

Referenced by MiAllocatePagesForMdl(), MiDecrementShareCount(), MiDereferencePfnAndDropLockCount(), MiFreePoolPages(), MiInitializeWorkingSetList(), MiInsertPageInFreeList(), MiMapPagesInZeroSpace(), and MiUnlinkFreeOrZeroedPage().

◆ MiInitBalancerThread()

VOID NTAPI MiInitBalancerThread ( VOID  )

Definition at line 442 of file balance.c.

443 {
446 #if !defined(__GNUC__)
447 
448  LARGE_INTEGER dummyJunkNeeded;
449  dummyJunkNeeded.QuadPart = -20000000; /* 2 sec */
450  ;
451 #endif
452 
453 
457 #if defined(__GNUC__)
458  (LARGE_INTEGER)(LONGLONG)-20000000LL, /* 2 sec */
459 #else
460  dummyJunkNeeded,
461 #endif
462  2000, /* 2 sec */
463  NULL);
464 
467  NULL,
468  NULL,
471  NULL);
472  if (!NT_SUCCESS(Status))
473  {
474  KeBugCheck(MEMORY_MANAGEMENT);
475  }
476 
480  &Priority,
481  sizeof(Priority));
482 
483 }
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
#define LL
Definition: tui.h:84
VOID NTAPI MiBalancerThread(PVOID Unused)
Definition: balance.c:321
#define __GNUC__
Definition: _icc.h:38
LONG NTSTATUS
Definition: precomp.h:26
#define LOW_REALTIME_PRIORITY
BOOLEAN NTAPI KeSetTimerEx(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN LONG Period, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:294
LONG KPRIORITY
Definition: compat.h:662
static KEVENT MiBalancerEvent
Definition: balance.c:38
#define FALSE
Definition: types.h:117
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1427
static CLIENT_ID MiBalancerThreadId
Definition: balance.c:36
NTSTATUS NTAPI NtSetInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: query.c:2018
Status
Definition: gdiplustypes.h:24
int64_t LONGLONG
Definition: typedefs.h:68
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:651
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
#define NULL
Definition: types.h:112
static HANDLE MiBalancerThreadHandle
Definition: balance.c:37
VOID NTAPI KeInitializeTimerEx(OUT PKTIMER Timer, IN TIMER_TYPE Type)
Definition: timerobj.c:244
LONGLONG QuadPart
Definition: typedefs.h:114
static KTIMER MiBalancerTimer
Definition: balance.c:39

Referenced by MmInitSystem().

◆ MiInitializeLoadedModuleList()

BOOLEAN NTAPI MiInitializeLoadedModuleList ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 2205 of file sysldr.c.

2206 {
2207  PLDR_DATA_TABLE_ENTRY LdrEntry, NewEntry;
2208  PLIST_ENTRY ListHead, NextEntry;
2209  ULONG EntrySize;
2210 
2211  /* Setup the loaded module list and locks */
2215 
2216  /* Get loop variables and the kernel entry */
2217  ListHead = &LoaderBlock->LoadOrderListHead;
2218  NextEntry = ListHead->Flink;
2219  LdrEntry = CONTAINING_RECORD(NextEntry,
2221  InLoadOrderLinks);
2222  PsNtosImageBase = (ULONG_PTR)LdrEntry->DllBase;
2223 
2224  /* Locate resource section, pool code, and system pte code */
2225  MiLocateKernelSections(LdrEntry);
2226 
2227  /* Loop the loader block */
2228  while (NextEntry != ListHead)
2229  {
2230  /* Get the loader entry */
2231  LdrEntry = CONTAINING_RECORD(NextEntry,
2233  InLoadOrderLinks);
2234 
2235  /* FIXME: ROS HACK. Make sure this is a driver */
2236  if (!RtlImageNtHeader(LdrEntry->DllBase))
2237  {
2238  /* Skip this entry */
2239  NextEntry = NextEntry->Flink;
2240  continue;
2241  }
2242 
2243  /* Calculate the size we'll need and allocate a copy */
2244  EntrySize = sizeof(LDR_DATA_TABLE_ENTRY) +
2245  LdrEntry->BaseDllName.MaximumLength +
2246  sizeof(UNICODE_NULL);
2248  if (!NewEntry) return FALSE;
2249 
2250  /* Copy the entry over */
2251  *NewEntry = *LdrEntry;
2252 
2253  /* Allocate the name */
2254  NewEntry->FullDllName.Buffer =
2256  LdrEntry->FullDllName.MaximumLength +
2257  sizeof(UNICODE_NULL),
2258  TAG_LDR_WSTR);
2259  if (!NewEntry->FullDllName.Buffer)
2260  {
2262  return FALSE;
2263  }
2264 
2265  /* Set the base name */
2266  NewEntry->BaseDllName.Buffer = (PVOID)(NewEntry + 1);
2267 
2268  /* Copy the full and base name */
2269  RtlCopyMemory(NewEntry->FullDllName.Buffer,
2270  LdrEntry->FullDllName.Buffer,
2271  LdrEntry->FullDllName.MaximumLength);
2272  RtlCopyMemory(NewEntry->BaseDllName.Buffer,
2273  LdrEntry->BaseDllName.Buffer,
2274  LdrEntry->BaseDllName.MaximumLength);
2275 
2276  /* Null-terminate the base name */
2277  NewEntry->BaseDllName.Buffer[NewEntry->BaseDllName.Length /
2278  sizeof(WCHAR)] = UNICODE_NULL;
2279 
2280  /* Insert the entry into the list */
2282  NextEntry = NextEntry->Flink;
2283  }
2284 
2285  /* Build the import lists for the boot drivers */
2287 
2288  /* We're done */
2289  return TRUE;
2290 }
ERESOURCE PsLoadedModuleResource
Definition: sysldr.c:37
struct _LDR_DATA_TABLE_ENTRY LDR_DATA_TABLE_ENTRY
VOID NTAPI MiLocateKernelSections(IN PLDR_DATA_TABLE_ENTRY LdrEntry)
Definition: sysldr.c:2148
USHORT MaximumLength
Definition: env_spec_w32.h:370
ULONG_PTR PsNtosImageBase
Definition: sysldr.c:38
#define TRUE
Definition: types.h:120
LIST_ENTRY PsLoadedModuleList
Definition: sysldr.c:34
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
#define InsertTailList(ListHead, Entry)
_In_ UCHAR EntrySize
Definition: iofuncs.h:640
KSPIN_LOCK PsLoadedModuleSpinLock
Definition: sysldr.c:36
PVOID DllBase
Definition: btrfs_drv.h:1926
#define TAG_LDR_WSTR
Definition: tag.h:110
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
void * PVOID
Definition: retypes.h:9
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Definition: btrfs_drv.h:1922
Definition: typedefs.h:119
LIST_ENTRY InLoadOrderLinks
Definition: ldrtypes.h:138
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NTSTATUS NTAPI MiBuildImportsForBootDrivers(VOID)
Definition: sysldr.c:1883
UNICODE_STRING FullDllName
Definition: btrfs_drv.h:1928
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:145
#define RtlImageNtHeader
Definition: compat.h:665
#define TAG_MODULE_OBJECT
Definition: tag.h:109
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by MmArmInitSystem().

◆ MiInitializeNonPagedPool()

VOID NTAPI MiInitializeNonPagedPool ( VOID  )

Definition at line 276 of file pool.c.

277 {
278  ULONG i;
279  PFN_COUNT PoolPages;
280  PMMFREE_POOL_ENTRY FreeEntry, FirstEntry;
281  PMMPTE PointerPte;
282  PAGED_CODE();
283 
284  //
285  // Initialize the pool S-LISTs as well as their maximum count. In general,
286  // we'll allow 8 times the default on a 2GB system, and two times the default
287  // on a 1GB system.
288  //
291  if (MmNumberOfPhysicalPages >= ((2 * _1GB) /PAGE_SIZE))
292  {
295  }
296  else if (MmNumberOfPhysicalPages >= (_1GB /PAGE_SIZE))
297  {
300  }
301 
302  //
303  // However if debugging options for the pool are enabled, turn off the S-LIST
304  // to reduce the risk of messing things up even more
305  //
307  {
310  }
311 
312  //
313  // We keep 4 lists of free pages (4 lists help avoid contention)
314  //
315  for (i = 0; i < MI_MAX_FREE_PAGE_LISTS; i++)
316  {
317  //
318  // Initialize each of them
319  //
321  }
322 
323  //
324  // Calculate how many pages the initial nonpaged pool has
325  //
327  MmNumberOfFreeNonPagedPool = PoolPages;
328 
329  //
330  // Initialize the first free entry
331  //
332  FreeEntry = MmNonPagedPoolStart;
333  FirstEntry = FreeEntry;
334  FreeEntry->Size = PoolPages;
335  FreeEntry->Signature = MM_FREE_POOL_SIGNATURE;
336  FreeEntry->Owner = FirstEntry;
337 
338  //
339  // Insert it into the last list
340  //
342  &FreeEntry->List);
343 
344  //
345  // Now create free entries for every single other page
346  //
347  while (PoolPages-- > 1)
348  {
349  //
350  // Link them all back to the original entry
351  //
352  FreeEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)FreeEntry + PAGE_SIZE);
353  FreeEntry->Owner = FirstEntry;
354  FreeEntry->Signature = MM_FREE_POOL_SIGNATURE;
355  }
356 
357  //
358  // Validate and remember first allocated pool page
359  //
360  PointerPte = MiAddressToPte(MmNonPagedPoolStart);
361  ASSERT(PointerPte->u.Hard.Valid == 1);
363 
364  //
365  // Keep track of where initial nonpaged pool ends
366  //
369 
370  //
371  // Validate and remember last allocated pool page
372  //
373  PointerPte = MiAddressToPte((PVOID)((ULONG_PTR)MmNonPagedPoolEnd0 - 1));
374  ASSERT(PointerPte->u.Hard.Valid == 1);
376 
377  //
378  // Validate the first nonpaged pool expansion page (which is a guard page)
379  //
381  ASSERT(PointerPte->u.Hard.Valid == 0);
382 
383  //
384  // Calculate the size of the expansion region alone
385  //
388 
389  //
390  // Remove 2 pages, since there's a guard page on top and on the bottom
391  //
393 
394  //
395  // Now initialize the nonpaged pool expansion PTE space. Remember there's a
396  // guard page on top so make sure to skip it. The bottom guard page will be
397  // guaranteed by the fact our size is off by one.
398  //
399  MiInitializeSystemPtes(PointerPte + 1,
402 }
PFN_NUMBER MiEndOfInitialPoolFrame
Definition: pool.c:23
ULONG PFN_COUNT
Definition: mmtypes.h:102
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
ULONG Signature
Definition: mm.h:410
PVOID MmNonPagedPoolExpansionStart
Definition: init.c:25
SLIST_HEADER MiNonPagedPoolSListHead
Definition: pool.c:30
uint32_t ULONG_PTR
Definition: typedefs.h:65
PFN_COUNT MmNumberOfFreeNonPagedPool
Definition: pool.c:21
#define MiAddressToPte(x)
Definition: mmx86.c:19
VOID NTAPI MiInitializeSystemPtes(IN PMMPTE StartingPte, IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE PoolType)
Definition: syspte.c:399
PFN_NUMBER MiStartOfInitialPoolFrame
Definition: pool.c:23
LIST_ENTRY List
Definition: mm.h:408
#define MI_MAX_FREE_PAGE_LISTS
Definition: mm.h:80
PVOID MmNonPagedPoolEnd0
Definition: pool.c:22
PFN_COUNT MiExpansionPoolPagesInitialCharge
Definition: pool.c:21
void * PVOID
Definition: retypes.h:9
FORCEINLINE VOID InitializeSListHead(_Out_ PSLIST_HEADER SListHead)
Definition: rtlfuncs.h:3353
PFN_COUNT Size
Definition: mm.h:409
#define MM_FREE_POOL_SIGNATURE
Definition: mm.h:415
#define ASSERT(a)
Definition: mode.c:45
Definition: mm.h:406
ULONG64 Valid
Definition: mmtypes.h:150
ULONG MiNonPagedPoolSListMaximum
Definition: pool.c:31
struct _MMFREE_POOL_ENTRY * Owner
Definition: mm.h:411
#define BYTES_TO_PAGES(Size)
ULONG MiPagedPoolSListMaximum
Definition: pool.c:33
#define PAGE_SIZE
Definition: env_spec_w32.h:49
union _MMPTE::@2319 u
PVOID MmNonPagedPoolStart
Definition: init.c:24
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
PFN_COUNT MmNumberOfPhysicalPages
Definition: init.c:48
BOOLEAN MmProtectFreedNonPagedPool
Definition: pool.c:29
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct _MMFREE_POOL_ENTRY * PMMFREE_POOL_ENTRY
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
ULONG MmMaximumNonPagedPoolInBytes
Definition: init.c:22
SLIST_HEADER MiPagedPoolSListHead
Definition: pool.c:32
unsigned int ULONG
Definition: retypes.h:1
ULONG MmSizeOfNonPagedPoolInBytes
Definition: init.c:21
LIST_ENTRY MmNonPagedPoolFreeListHead[MI_MAX_FREE_PAGE_LISTS]
Definition: pool.c:20
#define PFN_FROM_PTE(v)
Definition: mm.h:92
#define _1GB
Definition: miarm.h:16
#define PAGED_CODE()

Referenced by MiBuildNonPagedPool(), and MiInitMachineDependent().

◆ MiInitializeSpecialPool()

VOID NTAPI MiInitializeSpecialPool ( VOID  )

Definition at line 123 of file special.c.

124 {
125  ULONG SpecialPoolPtes, i;
126  PMMPTE PointerPte;
127 
128  /* Check if there is a special pool tag */
129  if ((MmSpecialPoolTag == 0) ||
130  (MmSpecialPoolTag == -1)) return;
131 
132  /* Calculate number of system PTEs for the special pool */
133  if (MmNumberOfSystemPtes >= 0x3000)
134  SpecialPoolPtes = MmNumberOfSystemPtes / 3;
135  else
136  SpecialPoolPtes = MmNumberOfSystemPtes / 6;
137 
138  /* Don't let the number go too high */
139  if (SpecialPoolPtes > 0x6000) SpecialPoolPtes = 0x6000;
140 
141  /* Round up to the page size */
142  SpecialPoolPtes = PAGE_ROUND_UP(SpecialPoolPtes);
143 
144  ASSERT((SpecialPoolPtes & (PTE_PER_PAGE - 1)) == 0);
145 
146  /* Reserve those PTEs */
147  do
148  {
149  PointerPte = MiReserveAlignedSystemPtes(SpecialPoolPtes,
151  /*0x400000*/0); // FIXME:
152  if (PointerPte) break;
153 
154  /* Reserving didn't work, so try to reduce the requested size */
155  ASSERT(SpecialPoolPtes >= PTE_PER_PAGE);
156  SpecialPoolPtes -= PTE_PER_PAGE;
157  } while (SpecialPoolPtes);
158 
159  /* Fail if we couldn't reserve them at all */
160  if (!SpecialPoolPtes) return;
161 
162  /* Make sure we got enough */
163  ASSERT(SpecialPoolPtes >= PTE_PER_PAGE);
164 
165  /* Save first PTE and its address */
166  MiSpecialPoolFirstPte = PointerPte;
167  MmSpecialPoolStart = MiPteToAddress(PointerPte);
168 
169  for (i = 0; i < PTE_PER_PAGE / 2; i++)
170  {
171  /* Point it to the next entry */
172  PointerPte->u.List.NextEntry = &PointerPte[2] - MmSystemPteBase;
173 
174  /* Move to the next pair */
175  PointerPte += 2;
176  }
177 
178  /* Save extra values */
179  MiSpecialPoolExtra = PointerPte;
180  MiSpecialPoolExtraCount = SpecialPoolPtes - PTE_PER_PAGE;
181 
182  /* Mark the previous PTE as the last one */
183  MiSpecialPoolLastPte = PointerPte - 2;
185 
186  /* Save end address of the special pool */
188 
189  /* Calculate maximum non-paged part of the special pool */
191 
192  /* And limit it if it turned out to be too big */
193  if (MmNumberOfPhysicalPages > 0x3FFF)
195 
196  DPRINT1("Special pool start %p - end %p\n", MmSpecialPoolStart, MmSpecialPoolEnd);
198 
199  //MiTestSpecialPool();
200 }
PFN_NUMBER MmResidentAvailablePages
Definition: freelist.c:27
ULONG MiSpecialPoolExtraCount
Definition: special.c:41
ULONG64 NextEntry
Definition: mmtypes.h:145
#define MM_EMPTY_PTE_LIST
Definition: mm.h:87
#define POOL_FLAG_SPECIAL_POOL
Definition: miarm.h:289
ULONG MmNumberOfSystemPtes
Definition: init.c:42
PMMPTE MiSpecialPoolLastPte
Definition: special.c:44
PVOID MmSpecialPoolEnd
Definition: special.c:39
ULONG MmSpecialPoolTag
Definition: pool.c:27
PFN_COUNT MiSpecialPagesNonPagedMaximum
Definition: special.c:52
PVOID MiSpecialPoolExtra
Definition: special.c:40
#define ASSERT(a)
Definition: mode.c:45
MMPTE_LIST List
Definition: mmtypes.h:222
#define PTE_PER_PAGE
Definition: mm.h:20
union _MMPTE::@2319 u
PMMPTE NTAPI MiReserveAlignedSystemPtes(IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType, IN ULONG Alignment)
Definition: syspte.c:88
PFN_COUNT MmNumberOfPhysicalPages
Definition: init.c:48
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PVOID MmSpecialPoolStart
Definition: special.c:38
#define PAGE_ROUND_UP(x)
Definition: mmtypes.h:38
PMMPTE MmSystemPteBase
Definition: syspte.c:21
#define DPRINT1
Definition: precomp.h:8
ULONG ExpPoolFlags
Definition: expool.c:48
unsigned int ULONG
Definition: retypes.h:1
FORCEINLINE PVOID MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:201
PMMPTE MiSpecialPoolFirstPte
Definition: special.c:43

Referenced by MiBuildPagedPool().

◆ MiMapPageInHyperSpace()

PVOID NTAPI MiMapPageInHyperSpace ( IN PEPROCESS  Process,
IN PFN_NUMBER  Page,
IN PKIRQL  OldIrql 
)

Definition at line 30 of file hypermap.c.

33 {
34  MMPTE TempPte;
35  PMMPTE PointerPte;
37 
38  //
39  // Never accept page 0 or non-physical pages
40  //
41  ASSERT(Page != 0);
42  ASSERT(MiGetPfnEntry(Page) != NULL);
43 
44  //
45  // Build the PTE
46  //
48  TempPte.u.Hard.PageFrameNumber = Page;
49 
50  //
51  // Pick the first hyperspace PTE
52  //
53  PointerPte = MmFirstReservedMappingPte;
54 
55  //
56  // Acquire the hyperlock
57  //
59  KeAcquireSpinLock(&Process->HyperSpaceLock, OldIrql);
60 
61  //
62  // Now get the first free PTE
63  //
64  Offset = PFN_FROM_PTE(PointerPte);
65  if (!Offset)
66  {
67  //
68  // Reset the PTEs
69  //
72  }
73 
74  //
75  // Prepare the next PTE
76  //
77  PointerPte->u.Hard.PageFrameNumber = Offset - 1;
78 
79  //
80  // Write the current PTE
81  //
82  PointerPte += Offset;
83  MI_WRITE_VALID_PTE(PointerPte, TempPte);
84 
85  //
86  // Return the address
87  //
88  return MiPteToAddress(PointerPte);
89 }
ULONG PFN_NUMBER
Definition: ke.h:9
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:942
PMMPTE MmFirstReservedMappingPte
Definition: hypermap.c:20
#define PsGetCurrentProcess
Definition: psfuncs.h:17
#define MI_HYPERSPACE_PTES
Definition: mm.h:81
#define ASSERT(a)
Definition: mode.c:45
MMPTE ValidKernelPteLocal
Definition: init.c:33
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:76
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:939
union _MMPTE::@2319 u
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define NULL
Definition: types.h:112
FORCEINLINE VOID KeFlushProcessTb(VOID)
Definition: ke.h:209
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
FORCEINLINE PVOID MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:201
#define PFN_FROM_PTE(v)
Definition: mm.h:92
ULONG PageFrameNumber
Definition: mmtypes.h:109

Referenced by _MiWriteBackPage(), MiCopyFromUserPage(), MiCopyPageToPage(), MiReadFilePage(), MiReadPage(), MiZeroPhysicalPage(), and MmCreateHyperspaceMapping().

◆ MiMapPagesInZeroSpace()

PVOID NTAPI MiMapPagesInZeroSpace ( IN PMMPFN  Pfn1,
IN PFN_NUMBER  NumberOfPages 
)

Definition at line 113 of file hypermap.c.

115 {
116  MMPTE TempPte;
117  PMMPTE PointerPte;
118  PFN_NUMBER Offset, PageFrameIndex;
119 
120  //
121  // Sanity checks
122  //
124  ASSERT(NumberOfPages != 0);
125  ASSERT(NumberOfPages <= MI_ZERO_PTES);
126 
127  //
128  // Pick the first zeroing PTE
129  //
130  PointerPte = MiFirstReservedZeroingPte;
131 
132  //
133  // Now get the first free PTE
134  //
135  Offset = PFN_FROM_PTE(PointerPte);
136  if (NumberOfPages > Offset)
137  {
138  //
139  // Reset the PTEs
140  //
142  PointerPte->u.Hard.PageFrameNumber = Offset;
144  }
145 
146  //
147  // Prepare the next PTE
148  //
149  PointerPte->u.Hard.PageFrameNumber = Offset - NumberOfPages;
150 
151  /* Choose the correct PTE to use, and which template */
152  PointerPte += (Offset + 1);
154 
155  /* Make sure the list isn't empty and loop it */
156  ASSERT(Pfn1 != (PVOID)LIST_HEAD);
157  while (Pfn1 != (PVOID)LIST_HEAD)
158  {
159  /* Get the page index for this PFN */
160  PageFrameIndex = MiGetPfnEntryIndex(Pfn1);
161 
162  //
163  // Write the PFN
164  //
165  TempPte.u.Hard.PageFrameNumber = PageFrameIndex;
166 
167  //
168  // Set the correct PTE to write to, and set its new value
169  //
170  PointerPte--;
171  MI_WRITE_VALID_PTE(PointerPte, TempPte);
172 
173  /* Move to the next PFN */
174  Pfn1 = (PMMPFN)Pfn1->u1.Flink;
175  }
176 
177  //
178  // Return the address
179  //
180  return MiPteToAddress(PointerPte);
181 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ULONG PFN_NUMBER
Definition: ke.h:9
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:942
#define ASSERT(a)
Definition: mode.c:45
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:76
MMPTE ValidKernelPte
Definition: init.c:29
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
LIST_HEAD(acpi_bus_event_list)
union _MMPTE::@2319 u
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
struct _MMPFN * PMMPFN
FORCEINLINE VOID KeFlushProcessTb(VOID)
Definition: ke.h:209
FORCEINLINE PFN_NUMBER MiGetPfnEntryIndex(IN PMMPFN Pfn1)
Definition: mm.h:959
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
PMMPTE MiFirstReservedZeroingPte
Definition: hypermap.c:21
FORCEINLINE PVOID MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:201
#define MI_ZERO_PTES
Definition: mm.h:82
#define PFN_FROM_PTE(v)
Definition: mm.h:92
ULONG PageFrameNumber
Definition: mmtypes.h:109

Referenced by MmZeroPageThread().

◆ MiRaisePoolQuota()

BOOLEAN NTAPI MiRaisePoolQuota ( IN POOL_TYPE  PoolType,
IN ULONG  CurrentMaxQuota,
OUT PULONG  NewMaxQuota 
)

Definition at line 1266 of file pool.c.

1269 {
1270  //
1271  // Not implemented
1272  //
1273  UNIMPLEMENTED;
1274  *NewMaxQuota = CurrentMaxQuota + 65536;
1275  return TRUE;
1276 }
#define TRUE
Definition: types.h:120
#define UNIMPLEMENTED
Definition: debug.h:115

◆ MiReadPageFile()

NTSTATUS NTAPI MiReadPageFile ( _In_ PFN_NUMBER  Page,
_In_ ULONG  PageFileIndex,
_In_ ULONG_PTR  PageFileOffset 
)

Definition at line 197 of file pagefile.c.

201 {
202  LARGE_INTEGER file_offset;
205  KEVENT Event;
206  UCHAR MdlBase[sizeof(MDL) + sizeof(ULONG)];
207  PMDL Mdl = (PMDL)MdlBase;
208  PMMPAGING_FILE PagingFile;
209 
210  DPRINT("MiReadSwapFile\n");
211 
212  if (PageFileOffset == 0)
213  {
214  KeBugCheck(MEMORY_MANAGEMENT);
215  return(STATUS_UNSUCCESSFUL);
216  }
217 
218  ASSERT(PageFileIndex < MAX_PAGING_FILES);
219 
220  PagingFile = MmPagingFile[PageFileIndex];
221 
222  if (PagingFile->FileObject == NULL || PagingFile->FileObject->DeviceObject == NULL)
223  {
224  DPRINT1("Bad paging file %u\n", PageFileIndex);
225  KeBugCheck(MEMORY_MANAGEMENT);
226  }
227 
229  MmBuildMdlFromPages(Mdl, &Page);
230  Mdl->MdlFlags |= MDL_PAGES_LOCKED;
231 
232  file_offset.QuadPart = PageFileOffset * PAGE_SIZE;
233 
235  Status = IoPageRead(PagingFile->FileObject,
236  Mdl,
237  &file_offset,
238  &Event,
239  &Iosb);
240  if (Status == STATUS_PENDING)
241  {
243  Status = Iosb.Status;
244  }
245  if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
246  {
247  MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
248  }
249  return(Status);
250 }
#define MmInitializeMdl(_MemoryDescriptorList, _BaseVa, _Length)
VOID NTAPI MmBuildMdlFromPages(PMDL Mdl, PPFN_NUMBER Pages)
Definition: pagefile.c:94
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IoPageRead(IN PFILE_OBJECT FileObject, IN PMDL Mdl, IN PLARGE_INTEGER Offset, IN PKEVENT Event, IN PIO_STATUS_BLOCK StatusBlock)
Definition: iofunc.c:1199
PFILE_OBJECT FileObject
Definition: mm.h:440
PVOID PMDL
Definition: usb.h:39
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define MDL_MAPPED_TO_SYSTEM_VA
Definition: mmtypes.h:18
#define FALSE
Definition: types.h:117
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1427
VOID NTAPI MmUnmapLockedPages(IN PVOID BaseAddress, IN PMDL Mdl)
Definition: mdlsup.c:841
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:467
void DPRINT(...)
Definition: polytest.cpp:61
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:45
#define MAX_PAGING_FILES
Definition: mm.h:105
return Iosb
Definition: create.c:4402
#define MDL_PAGES_LOCKED
Definition: mmtypes.h:19
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
unsigned char UCHAR
Definition: xmlstorage.h:181
MDL
Definition: mmtypes.h:117
#define PAGE_SIZE
Definition: env_spec_w32.h:49
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:40
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define NULL
Definition: types.h:112
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by MiResolvePageFileFault(), and MmReadFromSwapPage().

◆ MiReleasePfnLock()

FORCEINLINE VOID MiReleasePfnLock ( _In_ KIRQL  OldIrql)

Definition at line 907 of file mm.h.

909 {
911 }
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790

Referenced by _MiFlushMappedSection(), MiAllocatePagesForMdl(), MiAllocatePoolPages(), MiBalancerThread(), MiBuildPagedPool(), MiBuildPfnDatabase(), MiBuildPfnDatabaseFromLoaderBlock(), MiCheckControlArea(), MiCheckPurgeAndUpMapCount(), MiCompleteProtoPteFault(), MiDeleteSystemPageableVm(), MiDeleteVirtualAddresses(), MiDispatchFault(), MiFillSystemPageDirectory(), MiFindContiguousPages(), MiFlushTbAndCapture(), MiFreeContiguousMemory(), MiGetPageProtection(), MiInitializeAndChargePfn(), MiInitMachineDependent(), MiLoadImageSection(), MiMakeSystemAddressValidPfn(), MiMapLockedPagesInUserSpace(), MiProcessValidPteList(), MiProtectVirtualMemory(), MiReleaseProcessReferenceToSessionDataPage(), MiRemoveMappedPtes(), MiResolveDemandZeroFault(), MiResolvePageFileFault(), MiResolveProtoPteFault(), MiSegmentDelete(), MiSessionCommitPageTables(), MiSessionCreateInternal(), MiSessionInitializeWorkingSetList(), MiSetControlAreaSymbolsLoaded(), MiUnmapLockedPagesInUserSpace(), MmAllocateSpecialPool(), MmAllocPage(), MmArmAccessFault(), MmCreateArm3Section(), MmCreateKernelStack(), MmCreateProcessAddressSpace(), MmDeleteKernelStack(), MmDeleteProcessAddressSpace(), MmDeleteProcessAddressSpace2(), MmDereferencePage(), MmFreeLoaderBlock(), MmFreeMemoryArea(), MmFreePagesFromMdl(), MmFreeSpecialPool(), MmGetLRUFirstUserPage(), MmGetLRUNextUserPage(), MmGetPhysicalMemoryRanges(), MmGetReferenceCountPage(), MmGetRmapListHeadPage(), MmGetSavedSwapEntryPage(), MmGrowKernelStackEx(), MmInitializeProcessAddressSpace(), MmInsertLRULastUserPage(), MmNotPresentFaultCachePage(), MmPageOutSectionView(), MmProbeAndLockPages(), MmRemoveLRUUserPage(), MmSetRmapListHeadPage(), MmSetSavedSwapEntryPage(), MmUnlockPages(), and MmZeroPageThread().

◆ MiReleasePfnLockFromDpcLevel()

FORCEINLINE VOID MiReleasePfnLockFromDpcLevel ( VOID  )

Definition at line 926 of file mm.h.

927 {
928  PKSPIN_LOCK_QUEUE LockQueue;
929 
930  LockQueue = &KeGetCurrentPrcb()->LockQueue[LockQueuePfnLock];
933 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
VOID FASTCALL KeReleaseQueuedSpinLockFromDpcLevel(IN OUT PKSPIN_LOCK_QUEUE LockQueue)
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1075
#define ASSERT(a)
Definition: mode.c:45
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696

Referenced by MiAllocatePoolPages().

◆ MiReloadBootLoadedDrivers()

VOID NTAPI MiReloadBootLoadedDrivers ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 1694 of file sysldr.c.

1695 {
1696  PLIST_ENTRY NextEntry;
1697  ULONG i = 0;
1698  PIMAGE_NT_HEADERS NtHeader;
1699  PLDR_DATA_TABLE_ENTRY LdrEntry;
1700  PIMAGE_FILE_HEADER FileHeader;
1701  BOOLEAN ValidRelocs;
1702  PIMAGE_DATA_DIRECTORY DataDirectory;
1703  PVOID DllBase, NewImageAddress;
1704  NTSTATUS Status;
1705  PMMPTE PointerPte, StartPte, LastPte;
1706  PFN_COUNT PteCount;
1707  PMMPFN Pfn1;
1708  MMPTE TempPte, OldPte;
1709 
1710  /* Loop driver list */
1711  for (NextEntry = LoaderBlock->LoadOrderListHead.Flink;
1712  NextEntry != &LoaderBlock->LoadOrderListHead;
1713  NextEntry = NextEntry->Flink)
1714  {
1715  /* Get the loader entry and NT header */
1716  LdrEntry = CONTAINING_RECORD(NextEntry,
1718  InLoadOrderLinks);
1719  NtHeader = RtlImageNtHeader(LdrEntry->DllBase);
1720 
1721  /* Debug info */
1722  DPRINT("[Mm0]: Driver at: %p ending at: %p for module: %wZ\n",
1723  LdrEntry->DllBase,
1724  (ULONG_PTR)LdrEntry->DllBase + LdrEntry->SizeOfImage,
1725  &LdrEntry->FullDllName);
1726 
1727  /* Get the first PTE and the number of PTEs we'll need */
1728  PointerPte = StartPte = MiAddressToPte(LdrEntry->DllBase);
1729  PteCount = ROUND_TO_PAGES(LdrEntry->SizeOfImage) >> PAGE_SHIFT;
1730  LastPte = StartPte + PteCount;
1731 
1732 #if MI_TRACE_PFNS
1733  /* Loop the PTEs */
1734  while (PointerPte < LastPte)
1735  {
1736  ULONG len;
1737  ASSERT(PointerPte->u.Hard.Valid == 1);
1738  Pfn1 = MiGetPfnEntry(PFN_FROM_PTE(PointerPte));
1739  len = wcslen(LdrEntry->BaseDllName.Buffer) * sizeof(WCHAR);
1740  snprintf(Pfn1->ProcessName, min(16, len), "%S", LdrEntry->BaseDllName.Buffer);
1741  PointerPte++;
1742  }
1743 #endif
1744  /* Skip kernel and HAL */
1745  /* ROS HACK: Skip BOOTVID/KDCOM too */
1746  i++;
1747  if (i <= 4) continue;
1748 
1749  /* Skip non-drivers */
1750  if (!NtHeader) continue;
1751 
1752  /* Get the file header and make sure we can relocate */
1753  FileHeader = &NtHeader->FileHeader;
1754  if (FileHeader->Characteristics & IMAGE_FILE_RELOCS_STRIPPED) continue;
1755  if (NtHeader->OptionalHeader.NumberOfRvaAndSizes <
1757 
1758  /* Everything made sense until now, check the relocation section too */
1759  DataDirectory = &NtHeader->OptionalHeader.
1760  DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC];
1761  if (!DataDirectory->VirtualAddress)
1762  {
1763  /* We don't really have relocations */
1764  ValidRelocs = FALSE;
1765  }
1766  else
1767  {
1768  /* Make sure the size is valid */
1769  if ((DataDirectory->VirtualAddress + DataDirectory->Size) >
1770  LdrEntry->SizeOfImage)
1771  {
1772  /* They're not, skip */
1773  continue;
1774  }
1775 
1776  /* We have relocations */
1777  ValidRelocs = TRUE;
1778  }
1779 
1780  /* Remember the original address */
1781  DllBase = LdrEntry->DllBase;
1782 
1783  /* Loop the PTEs */
1784  PointerPte = StartPte;
1785  while (PointerPte < LastPte)
1786  {
1787  /* Mark the page modified in the PFN database */
1788  ASSERT(PointerPte->u.Hard.Valid == 1);
1789  Pfn1 = MiGetPfnEntry(PFN_FROM_PTE(PointerPte));
1790  ASSERT(Pfn1->u3.e1.Rom == 0);
1791  Pfn1->u3.e1.Modified = TRUE;
1792 
1793  /* Next */
1794  PointerPte++;
1795  }
1796 
1797  /* Now reserve system PTEs for the image */
1798  PointerPte = MiReserveSystemPtes(PteCount, SystemPteSpace);
1799  if (!PointerPte)
1800  {
1801  /* Shouldn't happen */
1802  ERROR_FATAL("[Mm0]: Couldn't allocate driver section!\n");
1803  return;
1804  }
1805 
1806  /* This is the new virtual address for the module */
1807  LastPte = PointerPte + PteCount;
1808  NewImageAddress = MiPteToAddress(PointerPte);
1809 
1810  /* Sanity check */
1811  DPRINT("[Mm0]: Copying from: %p to: %p\n", DllBase, NewImageAddress);
1813 
1814  /* Loop the new driver PTEs */
1816  while (PointerPte < LastPte)
1817  {
1818  /* Copy the old data */
1819  OldPte = *StartPte;
1820  ASSERT(OldPte.u.Hard.Valid == 1);
1821 
1822  /* Set page number from the loader's memory */
1823  TempPte.u.Hard.PageFrameNumber = OldPte.u.Hard.PageFrameNumber;
1824 
1825  /* Write it */
1826  MI_WRITE_VALID_PTE(PointerPte, TempPte);
1827 
1828  /* Move on */
1829  PointerPte++;
1830  StartPte++;
1831  }
1832 
1833  /* Update position */
1834  PointerPte -= PteCount;
1835 
1836  /* Sanity check */
1837  ASSERT(*(PULONG)NewImageAddress == *(PULONG)DllBase);
1838 
1839  /* Set the image base to the address where the loader put it */
1840  NtHeader->OptionalHeader.ImageBase = (ULONG_PTR)DllBase;
1841 
1842  /* Check if we had relocations */
1843  if (ValidRelocs)
1844  {
1845  /* Relocate the image */
1846  Status = LdrRelocateImageWithBias(NewImageAddress,
1847  0,
1848  "SYSLDR",
1852  if (!NT_SUCCESS(Status))
1853  {
1854  /* This shouldn't happen */
1855  ERROR_FATAL("Relocations failed!\n");
1856  return;
1857  }
1858  }
1859 
1860  /* Update the loader entry */
1861  LdrEntry->DllBase = NewImageAddress;
1862 
1863  /* Update the thunks */
1864  DPRINT("[Mm0]: Updating thunks to: %wZ\n", &LdrEntry->BaseDllName);
1865  MiUpdateThunks(LoaderBlock,
1866  DllBase,
1867  NewImageAddress,
1868  LdrEntry->SizeOfImage);
1869 
1870  /* Update the loader entry */
1871  LdrEntry->Flags |= LDRP_SYSTEM_MAPPED;
1872  LdrEntry->EntryPoint = (PVOID)((ULONG_PTR)NewImageAddress +
1874  LdrEntry->SizeOfImage = PteCount << PAGE_SHIFT;
1875 
1876  /* FIXME: We'll need to fixup the PFN linkage when switching to ARM3 */
1877  }
1878 }
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
ULONG PFN_COUNT
Definition: mmtypes.h:102
#define TRUE
Definition: types.h:120
PMMPTE NTAPI MiReserveSystemPtes(IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
Definition: syspte.c:246
LONG NTSTATUS
Definition: precomp.h:26
ULONG SizeOfImage
Definition: ldrtypes.h:143
#define snprintf
Definition: wintirpc.h:48
USHORT Modified
Definition: mm.h:298
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define ERROR_FATAL(...)
Definition: debug.h:238
PVOID DllBase
Definition: btrfs_drv.h:1926
MMPFNENTRY e1
Definition: mm.h:335
#define MiAddressToPte(x)
Definition: mmx86.c:19
#define FALSE
Definition: types.h:117
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:942
PVOID EntryPoint
Definition: ntddk_ex.h:203
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
void * PVOID
Definition: retypes.h:9
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define STATUS_INVALID_IMAGE_FORMAT
Definition: ntstatus.h:359
#define ASSERT(a)
Definition: mode.c:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG64 Valid
Definition: mmtypes.h:150
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:76
MMPTE ValidKernelPte
Definition: init.c:29
union _MMPFN::@1793 u3
Definition: mm.h:311
Definition: btrfs_drv.h:1922
ULONG ExpInitializationPhase
Definition: init.c:66
GLenum GLsizei len
Definition: glext.h:6722
Definition: typedefs.h:119
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:939
union _MMPTE::@2319 u
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
NTSYSAPI ULONG NTAPI LdrRelocateImageWithBias(_In_ PVOID NewAddress, _In_ LONGLONG AdditionalBias, _In_ PCCH LoaderName, _In_ ULONG Success, _In_ ULONG Conflict, _In_ ULONG Invalid)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ROUND_TO_PAGES(Size)
UNICODE_STRING FullDllName
Definition: btrfs_drv.h:1928
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:145
USHORT Rom
Definition: mm.h:306
unsigned int * PULONG
Definition: retypes.h:1
#define min(a, b)
Definition: monoChain.cc:55
#define IMAGE_DIRECTORY_ENTRY_BASERELOC
Definition: pedump.c:264
#define RtlImageNtHeader
Definition: compat.h:665
ULONG Flags
Definition: ntddk_ex.h:207
VOID NTAPI MiUpdateThunks(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PVOID OldBase, IN PVOID NewBase, IN ULONG Size)
Definition: sysldr.c:593
unsigned int ULONG
Definition: retypes.h:1
#define IMAGE_FILE_RELOCS_STRIPPED
Definition: pedump.c:159
#define ULONG_PTR
Definition: config.h:101
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
#define STATUS_SUCCESS
Definition: shellext.h:65
FORCEINLINE PVOID MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:201
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:261
#define PFN_FROM_PTE(v)
Definition: mm.h:92
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
ULONG PageFrameNumber
Definition: mmtypes.h:109
#define LDRP_SYSTEM_MAPPED
Definition: ldrtypes.h:54

Referenced by MmArmInitSystem().

◆ MiRosCheckMemoryAreas()

VOID NTAPI MiRosCheckMemoryAreas ( PMMSUPPORT  AddressSpace)

◆ MiRosCleanupMemoryArea()

VOID NTAPI MiRosCleanupMemoryArea ( PEPROCESS  Process,
PMMVAD  Vad 
)

Definition at line 522 of file marea.c.

525 {
529 
530  /* We must be called from MmCleanupAddressSpace and nowhere else!
531  Make sure things are as expected... */
533  ASSERT(Process->VmDeleted == TRUE);
534  ASSERT(((PsGetCurrentThread()->ThreadsProcess == Process) &&
535  (Process->ActiveThreads == 1)) ||
536  (Process->ActiveThreads == 0));
537 
538  /* We are in cleanup, we don't need to synchronize */
540 
541  MemoryArea = (PMEMORY_AREA)Vad;
543 
545  {
547  }
548  else if (MemoryArea->Type == MEMORY_AREA_CACHE)
549  {
551  }
552  else
553  {
554  /* There shouldn't be anything else! */
555  ASSERT(FALSE);
556  }
557 
558  /* Make sure this worked! */
560 
561  /* Lock the address space again */
563 }
ULONG Type
Definition: mm.h:220
struct _MEMORY_AREA * PMEMORY_AREA
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define TRUE
Definition: types.h:120
FORCEINLINE VOID MmUnlockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1427
LONG NTSTATUS
Definition: precomp.h:26
#define MEMORY_AREA_CACHE
Definition: mm.h:72
#define FALSE
Definition: types.h:117
#define PsGetCurrentProcess
Definition: psfuncs.h:17
void * PVOID
Definition: retypes.h:9
#define MEMORY_AREA_SECTION_VIEW
Definition: mm.h:71
Status
Definition: gdiplustypes.h:24
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MA_GetStartingAddress(_MemoryArea)
Definition: mm.h:213
NTSTATUS NTAPI MmUnmapViewOfCacheSegment(PMMSUPPORT AddressSpace, PVOID BaseAddress)
Definition: data.c:713
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI MiRosUnmapViewOfSection(IN PEPROCESS Process, IN PVOID BaseAddress, IN BOOLEAN SkipDebuggerNotify)
Definition: section.c:4135
struct _MEMORY_AREA * MemoryArea
Definition: newmm.h:65
FORCEINLINE VOID MmLockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1420

Referenced by MmCleanProcessAddressSpace().

◆ MiUnmapPageInHyperSpace()

VOID NTAPI MiUnmapPageInHyperSpace ( IN PEPROCESS  Process,
IN PVOID  Address,
IN KIRQL  OldIrql 
)

Definition at line 93 of file hypermap.c.

96 {
98 
99  //
100  // Blow away the mapping
101  //
102  MiAddressToPte(Address)->u.Long = 0;
103 
104  //
105  // Release the hyperlock
106  //
108  KeReleaseSpinLock(&Process->HyperSpaceLock, OldIrql);
109 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define MiAddressToPte(x)
Definition: mmx86.c:19
#define PsGetCurrentProcess
Definition: psfuncs.h:17
static WCHAR Address[46]
Definition: ping.c:68
#define ASSERT(a)
Definition: mode.c:45
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

Referenced by _MiWriteBackPage(), MiCopyFromUserPage(), MiCopyPageToPage(), MiReadFilePage(), MiReadPage(), and MiZeroPhysicalPage().

◆ MiUnmapPagesInZeroSpace()

VOID NTAPI MiUnmapPagesInZeroSpace ( IN PVOID  VirtualAddress,
IN PFN_NUMBER  NumberOfPages 
)

Definition at line 185 of file hypermap.c.

187 {
188  PMMPTE PointerPte;
189 
190  //
191  // Sanity checks
192  //
194  ASSERT (NumberOfPages != 0);
195  ASSERT(NumberOfPages <= MI_ZERO_PTES);
196 
197  //
198  // Get the first PTE for the mapped zero VA
199  //
200  PointerPte = MiAddressToPte(VirtualAddress);
201 
202  //
203  // Blow away the mapped zero PTEs
204  //
205  RtlZeroMemory(PointerPte, NumberOfPages * sizeof(MMPTE));
206 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define MiAddressToPte(x)
Definition: mmx86.c:19
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
#define ASSERT(a)
Definition: mode.c:45
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define MI_ZERO_PTES
Definition: mm.h:82

Referenced by MmZeroPageThread().

◆ MmAccessFault()

NTSTATUS NTAPI MmAccessFault ( IN ULONG  FaultCode,
IN PVOID  Address,
IN KPROCESSOR_MODE  Mode,
IN PVOID  TrapInformation 
)

Definition at line 204 of file mmfault.c.

208 {