ReactOS  0.4.14-dev-358-gbef841c
page.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
#include <mm/ARM3/miarm.h>
Include dependency graph for page.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define InterlockedExchangePte(pte1, pte2)   InterlockedExchange64((LONG64*)&pte1->u.Long, pte2.u.Long)
 
#define PAGE_EXECUTE_ANY   (PAGE_EXECUTE|PAGE_EXECUTE_READ|PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY)
 
#define PAGE_WRITE_ANY   (PAGE_EXECUTE_READWRITE|PAGE_READWRITE|PAGE_EXECUTE_WRITECOPY|PAGE_WRITECOPY)
 
#define PAGE_WRITECOPY_ANY   (PAGE_EXECUTE_WRITECOPY|PAGE_WRITECOPY)
 

Functions

BOOLEAN FORCEINLINE MiIsHyperspaceAddress (PVOID Address)
 
VOID MiFlushTlb (PMMPTE Pte, PVOID Address)
 
static PMMPTE MiGetPteForProcess (PEPROCESS Process, PVOID Address, BOOLEAN Create)
 
static ULONG64 MiGetPteValueForProcess (PEPROCESS Process, PVOID Address)
 
ULONG NTAPI MiGetPteProtection (MMPTE Pte)
 
VOID NTAPI MiSetPteProtection (PMMPTE Pte, ULONG Protection)
 
PFN_NUMBER NTAPI MmGetPfnForProcess (PEPROCESS Process, PVOID Address)
 
BOOLEAN NTAPI MmIsPagePresent (PEPROCESS Process, PVOID Address)
 
BOOLEAN NTAPI MmIsDisabledPage (PEPROCESS Process, PVOID Address)
 
BOOLEAN NTAPI MmIsPageSwapEntry (PEPROCESS Process, PVOID Address)
 
static PMMPTE MmGetPageTableForProcess (PEPROCESS Process, PVOID Address, BOOLEAN Create)
 
BOOLEAN MmUnmapPageTable (PMMPTE Pt)
 
static ULONG64 MmGetPageEntryForProcess (PEPROCESS Process, PVOID Address)
 
VOID NTAPI MmGetPageFileMapping (PEPROCESS Process, PVOID Address, SWAPENTRY *SwapEntry)
 
BOOLEAN NTAPI MmIsDirtyPage (PEPROCESS Process, PVOID Address)
 
ULONG NTAPI MmGetPageProtect (PEPROCESS Process, PVOID Address)
 
VOID NTAPI MmSetPageProtect (PEPROCESS Process, PVOID Address, ULONG flProtect)
 
VOID NTAPI MmSetCleanPage (PEPROCESS Process, PVOID Address)
 
VOID NTAPI MmSetDirtyPage (PEPROCESS Process, PVOID Address)
 
VOID NTAPI MmDeleteVirtualMapping (PEPROCESS Process, PVOID Address, BOOLEAN *WasDirty, PPFN_NUMBER Page)
 
VOID NTAPI MmDeletePageFileMapping (PEPROCESS Process, PVOID Address, SWAPENTRY *SwapEntry)
 
NTSTATUS NTAPI MmCreatePageFileMapping (PEPROCESS Process, PVOID Address, SWAPENTRY SwapEntry)
 
NTSTATUS NTAPI MmCreateVirtualMappingUnsafe (PEPROCESS Process, PVOID Address, ULONG PageProtection, PPFN_NUMBER Pages, ULONG PageCount)
 
NTSTATUS NTAPI MmCreateVirtualMapping (PEPROCESS Process, PVOID Address, ULONG Protect, PPFN_NUMBER Pages, ULONG PageCount)
 
BOOLEAN NTAPI MmCreateProcessAddressSpace (IN ULONG MinWs, IN PEPROCESS Process, OUT PULONG_PTR DirectoryTableBase)
 

Variables

MMPTE HyperTemplatePte
 
const ULONG64 MmProtectToPteMask [32]
 
const ULONG MmProtectToValue [32]
 

Macro Definition Documentation

◆ InterlockedExchangePte

#define InterlockedExchangePte (   pte1,
  pte2 
)    InterlockedExchange64((LONG64*)&pte1->u.Long, pte2.u.Long)

Definition at line 19 of file page.c.

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file page.c.

◆ PAGE_EXECUTE_ANY

Definition at line 22 of file page.c.

◆ PAGE_WRITE_ANY

Definition at line 23 of file page.c.

◆ PAGE_WRITECOPY_ANY

#define PAGE_WRITECOPY_ANY   (PAGE_EXECUTE_WRITECOPY|PAGE_WRITECOPY)

Definition at line 24 of file page.c.

Function Documentation

◆ MiFlushTlb()

VOID MiFlushTlb ( PMMPTE  Pte,
PVOID  Address 
)

Definition at line 128 of file page.c.

129 {
130  if (MiIsHyperspaceAddress(Pte))
131  {
133  }
134  else
135  {
136  __invlpg(Address);
137  }
138 }
#define PAGE_ROUND_DOWN(x)
Definition: mmtypes.h:36
static WCHAR Address[46]
Definition: ping.c:68
#define MmDeleteHyperspaceMapping(x)
Definition: mm.h:1034
BOOLEAN FORCEINLINE MiIsHyperspaceAddress(PVOID Address)
Definition: page.c:121
__INTRIN_INLINE void __invlpg(void *Address)
Definition: intrin_x86.h:1865

Referenced by MmDeleteVirtualMapping(), MmSetCleanPage(), MmSetDirtyPage(), and MmSetPageProtect().

◆ MiGetPteForProcess()

static PMMPTE MiGetPteForProcess ( PEPROCESS  Process,
PVOID  Address,
BOOLEAN  Create 
)
static

Definition at line 142 of file page.c.

146 {
147  MMPTE TmplPte, *Pte;
148 
149  /* Check if we need hypersapce mapping */
150  if (Address < MmSystemRangeStart &&
152  {
154  __debugbreak();
155  return NULL;
156  }
157  else if (Create)
158  {
159  KIRQL OldIrql;
160  TmplPte.u.Long = 0;
161  TmplPte.u.Flush.Valid = 1;
162  TmplPte.u.Flush.Write = 1;
163 
164  /* All page table levels of user pages are user owned */
165  TmplPte.u.Flush.Owner = (Address < MmHighestUserAddress) ? 1 : 0;
166 
167  /* Lock the PFN database */
169 
170  /* Get the PXE */
171  Pte = MiAddressToPxe(Address);
172  if (!Pte->u.Hard.Valid)
173  {
174  TmplPte.u.Hard.PageFrameNumber = MiRemoveZeroPage(0);
175  MI_WRITE_VALID_PTE(Pte, TmplPte);
176  }
177 
178  /* Get the PPE */
179  Pte = MiAddressToPpe(Address);
180  if (!Pte->u.Hard.Valid)
181  {
182  TmplPte.u.Hard.PageFrameNumber = MiRemoveZeroPage(1);
183  MI_WRITE_VALID_PTE(Pte, TmplPte);
184  }
185 
186  /* Get the PDE */
187  Pte = MiAddressToPde(Address);
188  if (!Pte->u.Hard.Valid)
189  {
190  TmplPte.u.Hard.PageFrameNumber = MiRemoveZeroPage(2);
191  MI_WRITE_VALID_PTE(Pte, TmplPte);
192  }
193 
194  /* Unlock PFN database */
196  }
197  else
198  {
199  /* Get the PXE */
200  Pte = MiAddressToPxe(Address);
201  if (!Pte->u.Hard.Valid)
202  return NULL;
203 
204  /* Get the PPE */
205  Pte = MiAddressToPpe(Address);
206  if (!Pte->u.Hard.Valid)
207  return NULL;
208 
209  /* Get the PDE */
210  Pte = MiAddressToPde(Address);
211  if (!Pte->u.Hard.Valid)
212  return NULL;
213  }
214 
215  return MiAddressToPte(Address);
216 }
ULONG64 Valid
Definition: mmtypes.h:66
#define MiAddressToPde(x)
Definition: mmx86.c:20
_In_ BOOLEAN Create
Definition: pstypes.h:511
ULONG64 Owner
Definition: mmtypes.h:68
FORCEINLINE KIRQL MiAcquirePfnLock(VOID)
Definition: mm.h:901
HARDWARE_PTE Flush
Definition: mmtypes.h:216
union _MMPTE::@2255 u
PMMPTE FORCEINLINE MiAddressToPpe(PVOID Address)
Definition: mm.h:151
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698
FORCEINLINE VOID MiReleasePfnLock(_In_ KIRQL OldIrql)
Definition: mm.h:908
PFN_NUMBER NTAPI MiRemoveZeroPage(IN ULONG Color)
Definition: pfnlist.c:531
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define MiAddressToPte(x)
Definition: mmx86.c:19
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:951
#define PsGetCurrentProcess
Definition: psfuncs.h:17
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
ULONG64 Valid
Definition: mmtypes.h:150
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
PMMPTE FORCEINLINE MiAddressToPxe(PVOID Address)
Definition: mm.h:161
ULONG_PTR Long
Definition: mmtypes.h:215
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
PVOID MmHighestUserAddress
Definition: rtlcompat.c:29
ULONG64 Write
Definition: mmtypes.h:67
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define UNIMPLEMENTED
Definition: debug.h:114
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
#define MmSystemRangeStart
Definition: mm.h:32

Referenced by MiGetPteValueForProcess(), MmCreateVirtualMappingUnsafe(), MmDeleteVirtualMapping(), MmSetCleanPage(), MmSetDirtyPage(), and MmSetPageProtect().

◆ MiGetPteProtection()

ULONG NTAPI MiGetPteProtection ( MMPTE  Pte)

Definition at line 238 of file page.c.

239 {
240  ULONG Protect;
241 
242  if (!Pte.u.Flush.Valid)
243  {
245  }
246  else if (Pte.u.Flush.NoExecute)
247  {
248  if (Pte.u.Flush.CopyOnWrite)
250  else if (Pte.u.Flush.Write)
252  else
254  }
255  else
256  {
257  if (Pte.u.Flush.CopyOnWrite)
259  else if (Pte.u.Flush.Write)
261  else
263  }
264 
265  if (Pte.u.Flush.CacheDisable)
267 
268  if (Pte.u.Flush.WriteThrough)
270 
271  // PAGE_GUARD ?
272  return Protect;
273 }
#define PAGE_WRITETHROUGH
Definition: mm.h:85
ULONG64 Valid
Definition: mmtypes.h:66
#define PAGE_NOCACHE
Definition: nt_native.h:1311
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG _In_ ULONG Protect
Definition: zwfuncs.h:214
ULONG64 CacheDisable
Definition: mmtypes.h:70
HARDWARE_PTE Flush
Definition: mmtypes.h:216
union _MMPTE::@2255 u
ULONG64 CopyOnWrite
Definition: mmtypes.h:75
#define PAGE_EXECUTE_WRITECOPY
Definition: nt_native.h:1309
#define PAGE_NOACCESS
Definition: nt_native.h:1302
ULONG64 WriteThrough
Definition: mmtypes.h:69
#define PAGE_READONLY
Definition: compat.h:127
#define PAGE_WRITECOPY
Definition: nt_native.h:1305
ULONG64 Write
Definition: mmtypes.h:67
unsigned int ULONG
Definition: retypes.h:1
#define PAGE_EXECUTE_READ
Definition: nt_native.h:1307
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1308
ULONG64 NoExecute
Definition: mmtypes.h:81
#define PAGE_READWRITE
Definition: nt_native.h:1304

Referenced by MmGetPageProtect().

◆ MiGetPteValueForProcess()

static ULONG64 MiGetPteValueForProcess ( PEPROCESS  Process,
PVOID  Address 
)
static

Definition at line 220 of file page.c.

223 {
224  PMMPTE Pte;
225  ULONG64 PteValue;
226 
228  PteValue = Pte ? Pte->u.Long : 0;
229 
230  if (MiIsHyperspaceAddress(Pte))
232 
233  return PteValue;
234 }
#define PAGE_ROUND_DOWN(x)
Definition: mmtypes.h:36
union _MMPTE::@2255 u
static WCHAR Address[46]
Definition: ping.c:68
#define MmDeleteHyperspaceMapping(x)
Definition: mm.h:1034
unsigned __int64 ULONG64
Definition: imports.h:198
BOOLEAN FORCEINLINE MiIsHyperspaceAddress(PVOID Address)
Definition: page.c:121
ULONG_PTR Long
Definition: mmtypes.h:215
static PMMPTE MiGetPteForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
Definition: page.c:142
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

Referenced by MmGetPageProtect(), MmGetPfnForProcess(), MmIsDirtyPage(), MmIsDisabledPage(), MmIsPagePresent(), and MmIsPageSwapEntry().

◆ MiIsHyperspaceAddress()

BOOLEAN FORCEINLINE MiIsHyperspaceAddress ( PVOID  Address)

Definition at line 121 of file page.c.

122 {
123  return ((ULONG64)Address >= HYPER_SPACE &&
125 }
static WCHAR Address[46]
Definition: ping.c:68
#define HYPER_SPACE_END
Definition: mm.h:15
unsigned __int64 ULONG64
Definition: imports.h:198
#define HYPER_SPACE
Definition: mm.h:14

Referenced by MiFlushTlb(), MiGetPteValueForProcess(), MmCreateVirtualMappingUnsafe(), MmSetCleanPage(), and MmSetDirtyPage().

◆ MiSetPteProtection()

VOID NTAPI MiSetPteProtection ( PMMPTE  Pte,
ULONG  Protection 
)

Definition at line 277 of file page.c.

278 {
279  Pte->u.Flush.CopyOnWrite = (Protection & PAGE_WRITECOPY_ANY) ? 1 : 0;
280  Pte->u.Flush.Write = (Protection & PAGE_WRITE_ANY) ? 1 : 0;
281  Pte->u.Flush.CacheDisable = (Protection & PAGE_NOCACHE) ? 1 : 0;
282  Pte->u.Flush.WriteThrough = (Protection & PAGE_WRITETHROUGH) ? 1 : 0;
283 
284  // FIXME: This doesn't work. Why?
285 // Pte->u.Flush.NoExecute = (Protection & PAGE_EXECUTE_ANY) ? 0 : 1;
286 }
#define PAGE_WRITETHROUGH
Definition: mm.h:85
#define PAGE_NOCACHE
Definition: nt_native.h:1311
#define PAGE_WRITECOPY_ANY
Definition: page.c:24
ULONG64 CacheDisable
Definition: mmtypes.h:70
HARDWARE_PTE Flush
Definition: mmtypes.h:216
union _MMPTE::@2255 u
ULONG64 CopyOnWrite
Definition: mmtypes.h:75
ULONG64 WriteThrough
Definition: mmtypes.h:69
#define PAGE_WRITE_ANY
Definition: page.c:23
ULONG64 Write
Definition: mmtypes.h:67

Referenced by MmCreateVirtualMappingUnsafe(), and MmSetPageProtect().

◆ MmCreatePageFileMapping()

NTSTATUS NTAPI MmCreatePageFileMapping ( PEPROCESS  Process,
PVOID  Address,
SWAPENTRY  SwapEntry 
)

Definition at line 503 of file page.c.

506 {
508  return STATUS_UNSUCCESSFUL;
509 }
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define UNIMPLEMENTED
Definition: debug.h:114

◆ MmCreateProcessAddressSpace()

BOOLEAN NTAPI MmCreateProcessAddressSpace ( IN ULONG  MinWs,
IN PEPROCESS  Process,
OUT PULONG_PTR  DirectoryTableBase 
)

FIXME:

architecture specific

end architecture specific

Definition at line 592 of file page.c.

595 {
596  KIRQL OldIrql;
597  PFN_NUMBER TableBasePfn, HyperPfn, HyperPdPfn, HyperPtPfn, WorkingSetPfn;
598  PMMPTE SystemPte;
599  MMPTE TempPte, PdePte;
600  ULONG TableIndex;
601  PMMPTE PageTablePointer;
602 
603  /* Make sure we don't already have a page directory setup */
604  ASSERT(Process->Pcb.DirectoryTableBase[0] == 0);
605  ASSERT(Process->Pcb.DirectoryTableBase[1] == 0);
606  ASSERT(Process->WorkingSetPage == 0);
607 
608  /* Choose a process color */
609  Process->NextPageColor = (USHORT)RtlRandom(&MmProcessColorSeed);
610 
611  /* Setup the hyperspace lock */
612  KeInitializeSpinLock(&Process->HyperSpaceLock);
613 
614  /* Lock PFN database */
616 
617  /* Get a page for the table base and one for hyper space. The PFNs for
618  these pages will be initialized in MmInitializeProcessAddressSpace,
619  when we are already attached to the process. */
625 
626  /* Release PFN lock */
628 
629  /* Zero pages */
630  MiZeroPhysicalPage(HyperPfn);
631  MiZeroPhysicalPage(WorkingSetPfn);
632 
633  /* Set the base directory pointers */
634  Process->WorkingSetPage = WorkingSetPfn;
635  DirectoryTableBase[0] = TableBasePfn << PAGE_SHIFT;
636  DirectoryTableBase[1] = HyperPfn << PAGE_SHIFT;
637 
638  /* Get a PTE to map the page directory */
639  SystemPte = MiReserveSystemPtes(1, SystemPteSpace);
640  ASSERT(SystemPte != NULL);
641 
642  /* Get its address */
643  PageTablePointer = MiPteToAddress(SystemPte);
644 
645  /* Build the PTE for the page directory and map it */
646  PdePte = ValidKernelPte;
647  PdePte.u.Hard.PageFrameNumber = TableBasePfn;
648  *SystemPte = PdePte;
649 
651  //MiInitializePageDirectoryForProcess(
652 
653  /* Copy the kernel mappings and zero out the rest */
654  TableIndex = PXE_PER_PAGE / 2;
655  RtlZeroMemory(PageTablePointer, TableIndex * sizeof(MMPTE));
656  RtlCopyMemory(PageTablePointer + TableIndex,
657  MiAddressToPxe(0) + TableIndex,
658  PAGE_SIZE - TableIndex * sizeof(MMPTE));
659 
660  /* Sanity check */
661  ASSERT(MiAddressToPxi(MmHyperSpaceEnd) >= TableIndex);
662 
663  /* Setup a PTE for the page directory mappings */
665 
666  /* Update the self mapping of the PML4 */
667  TableIndex = MiAddressToPxi((PVOID)PXE_SELFMAP);
668  TempPte.u.Hard.PageFrameNumber = TableBasePfn;
669  PageTablePointer[TableIndex] = TempPte;
670 
671  /* Write the PML4 entry for hyperspace */
672  TableIndex = MiAddressToPxi((PVOID)HYPER_SPACE);
673  TempPte.u.Hard.PageFrameNumber = HyperPfn;
674  PageTablePointer[TableIndex] = TempPte;
675 
676  /* Map the hyperspace PDPT to the system PTE */
677  PdePte.u.Hard.PageFrameNumber = HyperPfn;
678  *SystemPte = PdePte;
679  __invlpg(PageTablePointer);
680 
681  /* Write the hyperspace entry for the first PD */
682  TempPte.u.Hard.PageFrameNumber = HyperPdPfn;
683  PageTablePointer[0] = TempPte;
684 
685  /* Map the hyperspace PD to the system PTE */
686  PdePte.u.Hard.PageFrameNumber = HyperPdPfn;
687  *SystemPte = PdePte;
688  __invlpg(PageTablePointer);
689 
690  /* Write the hyperspace entry for the first PT */
691  TempPte.u.Hard.PageFrameNumber = HyperPtPfn;
692  PageTablePointer[0] = TempPte;
693 
694  /* Map the hyperspace PT to the system PTE */
695  PdePte.u.Hard.PageFrameNumber = HyperPtPfn;
696  *SystemPte = PdePte;
697  __invlpg(PageTablePointer);
698 
699  /* Write the hyperspace PTE for the working set list index */
700  TempPte.u.Hard.PageFrameNumber = WorkingSetPfn;
701  TableIndex = MiAddressToPti(MmWorkingSetList);
702  PageTablePointer[TableIndex] = TempPte;
703 
705 
706  /* Release the system PTE */
707  MiReleaseSystemPtes(SystemPte, 1, SystemPteSpace);
708 
709  /* Switch to phase 1 initialization */
710  ASSERT(Process->AddressSpaceInitialized == 0);
711  Process->AddressSpaceInitialized = 1;
712 
713  return TRUE;
714 }
NTSYSAPI ULONG NTAPI RtlRandom(_Inout_ PULONG Seed)
ULONG MmProcessColorSeed
Definition: procsup.c:20
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define PXE_PER_PAGE
PMMPTE NTAPI MiReserveSystemPtes(IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
Definition: syspte.c:246
FORCEINLINE KIRQL MiAcquirePfnLock(VOID)
Definition: mm.h:901
union _MMPTE::@2255 u
VOID NTAPI MiZeroPhysicalPage(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:122
ULONG FORCEINLINE MiAddressToPti(PVOID Address)
Definition: mm.h:171
FORCEINLINE VOID MiReleasePfnLock(_In_ KIRQL OldIrql)
Definition: mm.h:908
UCHAR KIRQL
Definition: env_spec_w32.h:591
ULONG PFN_NUMBER
Definition: ke.h:8
ULONG FORCEINLINE MiAddressToPxi(PVOID Address)
Definition: mm.h:190
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
smooth NULL
Definition: ftsmooth.c:416
PVOID FORCEINLINE MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:198
VOID NTAPI MiReleaseSystemPtes(IN PMMPTE StartingPte, IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
Definition: syspte.c:275
#define PXE_SELFMAP
#define MI_GET_NEXT_PROCESS_COLOR(x)
Definition: miarm.h:247
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:76
MMPTE ValidKernelPte
Definition: page.c:111
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
PMMPTE FORCEINLINE MiAddressToPxe(PVOID Address)
Definition: mm.h:161
#define PAGE_SIZE
Definition: env_spec_w32.h:49
PMMWSL MmWorkingSetList
Definition: procsup.c:21
PFN_NUMBER NTAPI MiRemoveAnyPage(IN ULONG Color)
Definition: pfnlist.c:475
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
unsigned short USHORT
Definition: pedump.c:61
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
__INTRIN_INLINE void __invlpg(void *Address)
Definition: intrin_x86.h:1865
#define HYPER_SPACE
Definition: mm.h:14
PVOID MmHyperSpaceEnd
Definition: init.c:56
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
ULONG PageFrameNumber
Definition: mmtypes.h:109

◆ MmCreateVirtualMapping()

NTSTATUS NTAPI MmCreateVirtualMapping ( PEPROCESS  Process,
PVOID  Address,
ULONG  Protect,
PPFN_NUMBER  Pages,
ULONG  PageCount 
)

Definition at line 568 of file page.c.

573 {
574  ULONG i;
575 
577 
578  for (i = 0; i < PageCount; i++)
579  {
580  if (!MmIsPageInUse(Pages[i]))
581  {
582  DPRINT1("Page %x not in use\n", Pages[i]);
583  KeBugCheck(MEMORY_MANAGEMENT);
584  }
585  }
586 
587  return MmCreateVirtualMappingUnsafe(Process, Address, Protect, Pages, PageCount);
588 }
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG _In_ ULONG Protect
Definition: zwfuncs.h:214
BOOLEAN NTAPI MmIsPageInUse(PFN_NUMBER Page)
Definition: freelist.c:530
uint32_t ULONG_PTR
Definition: typedefs.h:63
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
static WCHAR Address[46]
Definition: ping.c:68
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1507
NTSTATUS NTAPI MmCreateVirtualMappingUnsafe(PEPROCESS Process, PVOID Address, ULONG PageProtection, PPFN_NUMBER Pages, ULONG PageCount)
Definition: page.c:514
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#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
unsigned int ULONG
Definition: retypes.h:1

◆ MmCreateVirtualMappingUnsafe()

NTSTATUS NTAPI MmCreateVirtualMappingUnsafe ( PEPROCESS  Process,
PVOID  Address,
ULONG  PageProtection,
PPFN_NUMBER  Pages,
ULONG  PageCount 
)

Definition at line 514 of file page.c.

520 {
521  ULONG i;
522  MMPTE TmplPte, *Pte;
523 
525 
526  /* Check if the range is valid */
527  if ((Process == NULL && Address < MmSystemRangeStart) ||
529  {
530  DPRINT1("Address 0x%p is invalid for process %p\n", Address, Process);
531  ASSERT(FALSE);
532  }
533 
534  TmplPte.u.Long = 0;
535  TmplPte.u.Hard.Valid = 1;
536  MiSetPteProtection(&TmplPte, PageProtection);
537 
538  TmplPte.u.Flush.Owner = (Address < MmHighestUserAddress) ? 1 : 0;
539 
540 //__debugbreak();
541 
542  for (i = 0; i < PageCount; i++)
543  {
544  TmplPte.u.Hard.PageFrameNumber = Pages[i];
545 
547 
548 DPRINT("MmCreateVirtualMappingUnsafe, Address=%p, TmplPte=%p, Pte=%p\n",
549  Address, TmplPte.u.Long, Pte);
550 
551  if (InterlockedExchangePte(Pte, TmplPte))
552  {
554  }
555 
556  if (MiIsHyperspaceAddress(Pte))
558 
560  }
561 
562 
563  return STATUS_SUCCESS;
564 }
#define TRUE
Definition: types.h:120
VOID NTAPI MiSetPteProtection(PMMPTE Pte, ULONG Protection)
Definition: page.c:277
ULONG64 Owner
Definition: mmtypes.h:68
#define PAGE_ROUND_DOWN(x)
Definition: mmtypes.h:36
#define InterlockedExchangePte(pte1, pte2)
Definition: page.c:19
HARDWARE_PTE Flush
Definition: mmtypes.h:216
union _MMPTE::@2255 u
uint32_t ULONG_PTR
Definition: typedefs.h:63
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
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
void DPRINT(...)
Definition: polytest.cpp:61
void * PVOID
Definition: retypes.h:9
FORCEINLINE VOID KeInvalidateTlbEntry(IN PVOID Address)
Definition: ke.h:201
ULONG64 Valid
Definition: mmtypes.h:150
#define MmDeleteHyperspaceMapping(x)
Definition: mm.h:1034
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned __int64 ULONG64
Definition: imports.h:198
#define PAGE_SIZE
Definition: env_spec_w32.h:49
BOOLEAN FORCEINLINE MiIsHyperspaceAddress(PVOID Address)
Definition: page.c:121
ULONG_PTR Long
Definition: mmtypes.h:215
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
static PMMPTE MiGetPteForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
Definition: page.c:142
PVOID MmHighestUserAddress
Definition: rtlcompat.c:29
#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
unsigned int ULONG
Definition: retypes.h:1
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define MmSystemRangeStart
Definition: mm.h:32

Referenced by MmCreateVirtualMapping().

◆ MmDeletePageFileMapping()

VOID NTAPI MmDeletePageFileMapping ( PEPROCESS  Process,
PVOID  Address,
SWAPENTRY SwapEntry 
)

Definition at line 495 of file page.c.

497 {
499 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ MmDeleteVirtualMapping()

VOID NTAPI MmDeleteVirtualMapping ( PEPROCESS  Process,
PVOID  Address,
BOOLEAN WasDirty,
PPFN_NUMBER  Page 
)

Definition at line 453 of file page.c.

458 {
459  PFN_NUMBER Pfn;
460  PMMPTE Pte;
461  MMPTE OldPte;
462 
464 
465  if (Pte)
466  {
467  /* Atomically set the entry to zero and get the old value. */
468  OldPte.u.Long = InterlockedExchange64((LONG64*)&Pte->u.Long, 0);
469 
470  if (OldPte.u.Hard.Valid)
471  {
472  Pfn = OldPte.u.Hard.PageFrameNumber;
473  }
474  else
475  Pfn = 0;
476  }
477  else
478  {
479  OldPte.u.Long = 0;
480  Pfn = 0;
481  }
482 
483  /* Return information to the caller */
484  if (WasDirty)
485  *WasDirty = (BOOLEAN)OldPte.u.Hard.Dirty;
486 
487  if (Page)
488  *Page = Pfn;
489 
490  MiFlushTlb(Pte, Address);
491 }
#define InterlockedExchange64
Definition: interlocked.h:171
union _MMPTE::@2255 u
ULONG64 Dirty
Definition: mmtypes.h:164
ULONG PFN_NUMBER
Definition: ke.h:8
static WCHAR Address[46]
Definition: ping.c:68
int64_t LONG64
Definition: typedefs.h:66
if(!(yy_init))
Definition: macro.lex.yy.c:714
ULONG64 Valid
Definition: mmtypes.h:150
VOID MiFlushTlb(PMMPTE Pte, PVOID Address)
Definition: page.c:128
ULONG_PTR Long
Definition: mmtypes.h:215
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
static PMMPTE MiGetPteForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
Definition: page.c:142
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define BOOLEAN
Definition: pedump.c:73
ULONG64 PageFrameNumber
Definition: mmtypes.h:171

◆ MmGetPageEntryForProcess()

static ULONG64 MmGetPageEntryForProcess ( PEPROCESS  Process,
PVOID  Address 
)
static

Definition at line 343 of file page.c.

344 {
345  MMPTE Pte, *PointerPte;
346 
348  if (PointerPte)
349  {
350  Pte = *PointerPte;
351  MmUnmapPageTable(PointerPte);
352  return Pte.u.Long;
353  }
354  return 0;
355 }
union _MMPTE::@2255 u
static PMMPTE MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
Definition: page.c:331
static WCHAR Address[46]
Definition: ping.c:68
BOOLEAN MmUnmapPageTable(PMMPTE Pt)
Definition: page.c:337
ULONG_PTR Long
Definition: mmtypes.h:215
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

Referenced by MmGetPageFileMapping().

◆ MmGetPageFileMapping()

VOID NTAPI MmGetPageFileMapping ( PEPROCESS  Process,
PVOID  Address,
SWAPENTRY SwapEntry 
)

Definition at line 359 of file page.c.

363 {
365  *SwapEntry = Entry >> 1;
366 }
static WCHAR Address[46]
Definition: ping.c:68
unsigned __int64 ULONG64
Definition: imports.h:198
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
static ULONG64 MmGetPageEntryForProcess(PEPROCESS Process, PVOID Address)
Definition: page.c:343
base of all file and directory entries
Definition: entries.h:82

◆ MmGetPageProtect()

ULONG NTAPI MmGetPageProtect ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 379 of file page.c.

380 {
381  MMPTE Pte;
382 
384 
385  return MiGetPteProtection(Pte);
386 }
union _MMPTE::@2255 u
static WCHAR Address[46]
Definition: ping.c:68
ULONG NTAPI MiGetPteProtection(MMPTE Pte)
Definition: page.c:238
ULONG_PTR Long
Definition: mmtypes.h:215
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
static ULONG64 MiGetPteValueForProcess(PEPROCESS Process, PVOID Address)
Definition: page.c:220

◆ MmGetPageTableForProcess()

static PMMPTE MmGetPageTableForProcess ( PEPROCESS  Process,
PVOID  Address,
BOOLEAN  Create 
)
static

Definition at line 331 of file page.c.

332 {
333  __debugbreak();
334  return 0;
335 }
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698

Referenced by MmGetPageEntryForProcess(), and MmSetPageProtect().

◆ MmGetPfnForProcess()

PFN_NUMBER NTAPI MmGetPfnForProcess ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 292 of file page.c.

294 {
295  MMPTE Pte;
297  return Pte.u.Hard.Valid ? Pte.u.Hard.PageFrameNumber : 0;
298 }
union _MMPTE::@2255 u
static WCHAR Address[46]
Definition: ping.c:68
ULONG64 Valid
Definition: mmtypes.h:150
ULONG_PTR Long
Definition: mmtypes.h:215
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
_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
static ULONG64 MiGetPteValueForProcess(PEPROCESS Process, PVOID Address)
Definition: page.c:220

◆ MmIsDirtyPage()

BOOLEAN NTAPI MmIsDirtyPage ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 370 of file page.c.

371 {
372  MMPTE Pte;
374  return Pte.u.Hard.Valid && Pte.u.Hard.Dirty;
375 }
union _MMPTE::@2255 u
ULONG64 Dirty
Definition: mmtypes.h:164
static WCHAR Address[46]
Definition: ping.c:68
ULONG64 Valid
Definition: mmtypes.h:150
ULONG_PTR Long
Definition: mmtypes.h:215
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
static ULONG64 MiGetPteValueForProcess(PEPROCESS Process, PVOID Address)
Definition: page.c:220

◆ MmIsDisabledPage()

BOOLEAN NTAPI MmIsDisabledPage ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 311 of file page.c.

312 {
313  MMPTE Pte;
315 
316  return (Pte.u.Hard.Valid == 0) &&
317  (Pte.u.Trans.Transition == 0) &&
318  (Pte.u.Hard.PageFrameNumber != 0);
319 }
union _MMPTE::@2255 u
ULONG64 Transition
Definition: mmtypes.h:105
static WCHAR Address[46]
Definition: ping.c:68
MMPTE_TRANSITION Trans
Definition: mmtypes.h:220
ULONG64 Valid
Definition: mmtypes.h:150
ULONG_PTR Long
Definition: mmtypes.h:215
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
_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
static ULONG64 MiGetPteValueForProcess(PEPROCESS Process, PVOID Address)
Definition: page.c:220

◆ MmIsPagePresent()

BOOLEAN NTAPI MmIsPagePresent ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 302 of file page.c.

303 {
304  MMPTE Pte;
306  return (BOOLEAN)Pte.u.Hard.Valid;
307 }
union _MMPTE::@2255 u
unsigned char BOOLEAN
static WCHAR Address[46]
Definition: ping.c:68
ULONG64 Valid
Definition: mmtypes.h:150
ULONG_PTR Long
Definition: mmtypes.h:215
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
static ULONG64 MiGetPteValueForProcess(PEPROCESS Process, PVOID Address)
Definition: page.c:220

◆ MmIsPageSwapEntry()

BOOLEAN NTAPI MmIsPageSwapEntry ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 323 of file page.c.

324 {
325  MMPTE Pte;
327  return Pte.u.Hard.Valid && Pte.u.Soft.Transition;
328 }
union _MMPTE::@2255 u
static WCHAR Address[46]
Definition: ping.c:68
ULONG64 Valid
Definition: mmtypes.h:150
ULONG_PTR Long
Definition: mmtypes.h:215
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
ULONG64 Transition
Definition: mmtypes.h:90
MMPTE_SOFTWARE Soft
Definition: mmtypes.h:219
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
static ULONG64 MiGetPteValueForProcess(PEPROCESS Process, PVOID Address)
Definition: page.c:220

◆ MmSetCleanPage()

VOID NTAPI MmSetCleanPage ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 409 of file page.c.

410 {
411  PMMPTE Pte;
412 
414  if (!Pte)
415  {
416  KeBugCheckEx(MEMORY_MANAGEMENT, 0x1234, (ULONG64)Address, 0, 0);
417  }
418 
419  /* Ckear the dirty bit */
420  if (InterlockedBitTestAndReset64((PVOID)Pte, 6))
421  {
422  if (!MiIsHyperspaceAddress(Pte))
423  __invlpg(Address);
424  }
425 
426  MiFlushTlb(Pte, Address);
427 }
static WCHAR Address[46]
Definition: ping.c:68
VOID MiFlushTlb(PMMPTE Pte, PVOID Address)
Definition: page.c:128
unsigned __int64 ULONG64
Definition: imports.h:198
BOOLEAN FORCEINLINE MiIsHyperspaceAddress(PVOID Address)
Definition: page.c:121
static PMMPTE MiGetPteForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
Definition: page.c:142
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
__INTRIN_INLINE void __invlpg(void *Address)
Definition: intrin_x86.h:1865
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:107

◆ MmSetDirtyPage()

VOID NTAPI MmSetDirtyPage ( PEPROCESS  Process,
PVOID  Address 
)

Definition at line 431 of file page.c.

432 {
433  PMMPTE Pte;
434 
436  if (!Pte)
437  {
438  KeBugCheckEx(MEMORY_MANAGEMENT, 0x1234, (ULONG64)Address, 0, 0);
439  }
440 
441  /* Ckear the dirty bit */
442  if (InterlockedBitTestAndSet64((PVOID)Pte, 6))
443  {
444  if (!MiIsHyperspaceAddress(Pte))
445  __invlpg(Address);
446  }
447 
448  MiFlushTlb(Pte, Address);
449 }
static WCHAR Address[46]
Definition: ping.c:68
VOID MiFlushTlb(PMMPTE Pte, PVOID Address)
Definition: page.c:128
unsigned __int64 ULONG64
Definition: imports.h:198
BOOLEAN FORCEINLINE MiIsHyperspaceAddress(PVOID Address)
Definition: page.c:121
static PMMPTE MiGetPteForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
Definition: page.c:142
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
__INTRIN_INLINE void __invlpg(void *Address)
Definition: intrin_x86.h:1865
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:107

◆ MmSetPageProtect()

VOID NTAPI MmSetPageProtect ( PEPROCESS  Process,
PVOID  Address,
ULONG  flProtect 
)

Definition at line 390 of file page.c.

391 {
392  PMMPTE Pte;
393  MMPTE NewPte;
394 
396  ASSERT(Pte != NULL);
397 
398  NewPte = *Pte;
399 
400  MiSetPteProtection(&NewPte, flProtect);
401 
402  InterlockedExchangePte(Pte, NewPte);
403 
404  MiFlushTlb(Pte, Address);
405 }
VOID NTAPI MiSetPteProtection(PMMPTE Pte, ULONG Protection)
Definition: page.c:277
#define InterlockedExchangePte(pte1, pte2)
Definition: page.c:19
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
VOID MiFlushTlb(PMMPTE Pte, PVOID Address)
Definition: page.c:128
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static PMMPTE MiGetPteForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
Definition: page.c:142
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

◆ MmUnmapPageTable()

BOOLEAN MmUnmapPageTable ( PMMPTE  Pt)

Definition at line 337 of file page.c.

338 {
339  ASSERT(FALSE);
340  return 0;
341 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

Referenced by MiFlushTlb(), MmCreatePageFileMapping(), MmCreateVirtualMappingUnsafe(), MmDeletePageFileMapping(), MmDeleteVirtualMapping(), MmGetPageEntryForProcess(), MmSetCleanPage(), MmSetDirtyPage(), and MmSetPageProtect().

Variable Documentation

◆ HyperTemplatePte

MMPTE HyperTemplatePte

Definition at line 22 of file hypermap.c.

Referenced by MiInitializePageTable().

◆ MmProtectToPteMask

const ULONG64 MmProtectToPteMask[32]

Definition at line 32 of file page.c.

Referenced by MiDispatchFault(), and MiResolveTransitionFault().

◆ MmProtectToValue