ReactOS  0.4.13-dev-479-gec9c8fd
stubs.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for stubs.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOLEAN NTAPI MiUnmapPageTable (IN PMMPTE PointerPde)
 
VOID NTAPI MiFlushTlb (IN PMMPTE PointerPte, IN PVOID Address)
 
PMMPTE NTAPI MiGetPageTableForProcess (IN PEPROCESS Process, IN PVOID Address, IN BOOLEAN Create)
 
MMPTE NTAPI MiGetPageEntryForProcess (IN PEPROCESS Process, IN PVOID Address)
 
BOOLEAN NTAPI MmCreateProcessAddressSpace (IN ULONG MinWs, IN PEPROCESS Process, IN PULONG DirectoryTableBase)
 
NTSTATUS NTAPI MmCreateVirtualMappingInternal (IN PEPROCESS Process, IN PVOID Address, IN ULONG Protection, IN PPFN_NUMBER Pages, IN ULONG PageCount, IN BOOLEAN MarkAsMapped)
 
NTSTATUS NTAPI MmCreateVirtualMappingUnsafe (IN PEPROCESS Process, IN PVOID Address, IN ULONG Protection, IN PPFN_NUMBER Pages, IN ULONG PageCount)
 
NTSTATUS NTAPI MmCreateVirtualMapping (IN PEPROCESS Process, IN PVOID Address, IN ULONG Protection, IN PPFN_NUMBER Pages, IN ULONG PageCount)
 
VOID NTAPI MmDeleteVirtualMapping (IN PEPROCESS Process, IN PVOID Address, OUT PBOOLEAN WasDirty, OUT PPFN_NUMBER Page)
 
VOID NTAPI MmDeletePageFileMapping (IN PEPROCESS Process, IN PVOID Address, IN SWAPENTRY *SwapEntry)
 
NTSTATUS NTAPI MmCreatePageFileMapping (IN PEPROCESS Process, IN PVOID Address, IN SWAPENTRY SwapEntry)
 
PFN_NUMBER NTAPI MmGetPfnForProcess (IN PEPROCESS Process, IN PVOID Address)
 
BOOLEAN NTAPI MmIsDirtyPage (IN PEPROCESS Process, IN PVOID Address)
 
VOID NTAPI MmSetCleanPage (IN PEPROCESS Process, IN PVOID Address)
 
VOID NTAPI MmSetDirtyPage (IN PEPROCESS Process, IN PVOID Address)
 
BOOLEAN NTAPI MmIsPagePresent (IN PEPROCESS Process, IN PVOID Address)
 
BOOLEAN NTAPI MmIsPageSwapEntry (IN PEPROCESS Process, IN PVOID Address)
 
ULONG NTAPI MmGetPageProtect (IN PEPROCESS Process, IN PVOID Address)
 
VOID NTAPI MmSetPageProtect (IN PEPROCESS Process, IN PVOID Address, IN ULONG Protection)
 
VOID NTAPI MmInitGlobalKernelPageDirectory (VOID)
 
PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress (IN PVOID Address)
 

Variables

ULONG MmGlobalKernelPageDirectory [1024]
 
MMPTE MiArmTemplatePte
 
MMPDE_HARDWARE MiArmTemplatePde
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file stubs.c.

Function Documentation

◆ MiFlushTlb()

VOID NTAPI MiFlushTlb ( IN PMMPTE  PointerPte,
IN PVOID  Address 
)

Definition at line 48 of file stubs.c.

50 {
51  //
52  // Make sure the PTE is valid, and unmap the pagetable if user-mode
53  //
54  if (((PointerPte) && (MiUnmapPageTable(PointerPte))) ||
56  {
57  //
58  // Invalidate this page
59  //
61  }
62 }
FORCEINLINE VOID KeArmInvalidateTlbEntry(IN PVOID Address)
Definition: intrin_i.h:185
BOOLEAN NTAPI MiUnmapPageTable(IN PMMPTE PointerPde)
Definition: stubs.c:25
static WCHAR Address[46]
Definition: ping.c:68
#define MmSystemRangeStart
Definition: mm.h:32

Referenced by MmDeleteVirtualMapping().

◆ MiGetPageEntryForProcess()

MMPTE NTAPI MiGetPageEntryForProcess ( IN PEPROCESS  Process,
IN PVOID  Address 
)

Definition at line 214 of file stubs.c.

216 {
217  PMMPTE PointerPte;
218  MMPTE Pte;
219  Pte.u.Hard.AsUlong = 0;
220 
221  //
222  // Get the PTE
223  //
225  if (PointerPte)
226  {
227  //
228  // Capture the PTE value and unmap the page table
229  //
230  Pte = *PointerPte;
231  MiUnmapPageTable(PointerPte);
232  }
233 
234  //
235  // Return the PTE value
236  //
237  return Pte;
238 }
union _MMPTE::@2234 u
BOOLEAN NTAPI MiUnmapPageTable(IN PMMPTE PointerPde)
Definition: stubs.c:25
static WCHAR Address[46]
Definition: ping.c:68
PMMPTE NTAPI MiGetPageTableForProcess(IN PEPROCESS Process, IN PVOID Address, IN BOOLEAN Create)
Definition: stubs.c:66
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

Referenced by MmGetPfnForProcess(), MmGetPhysicalAddress(), MmIsPagePresent(), and MmIsPageSwapEntry().

◆ MiGetPageTableForProcess()

PMMPTE NTAPI MiGetPageTableForProcess ( IN PEPROCESS  Process,
IN PVOID  Address,
IN BOOLEAN  Create 
)

Definition at line 66 of file stubs.c.

69 {
70  //ULONG PdeOffset;
71  PMMPTE PointerPte;
72  PMMPDE_HARDWARE PointerPde;
74  MMPTE TempPte;
76  PFN_NUMBER Pfn;
77 
78  //
79  // Check if this is a user-mode, non-kernel or non-current address
80  //
81  if ((Address < MmSystemRangeStart) &&
82  (Process) &&
84  {
85  //
86  // FIXME-USER: No user-mode memory support
87  //
88  ASSERT(FALSE);
89  }
90 
91  //
92  // Get our templates
93  //
96 
97  //
98  // Get the PDE
99  //
100  PointerPde = MiAddressToPde(Address);
101  if (PointerPde->u.Hard.Coarse.Valid)
102  {
103  //
104  // Invalid PDE, is this a kernel address?
105  //
107  {
108  //
109  // Does it exist in the kernel page directory?
110  //
111  //PdeOffset = MiGetPdeOffset(Address);
112  //if (MmGlobalKernelPageDirectory[PdeOffset] == 0)
113  {
114  //
115  // It doesn't. Is this a create operation? If not, fail
116  //
117  if (Create == FALSE) return NULL;
118  kernelHack:
119  DPRINT1("Must create a page for: %p PDE: %p\n", // Offset: %lx!\n",
120  Address, PointerPde);//, PdeOffset);
121 
122  //
123  // Allocate a non paged pool page for the PDE
124  //
125  Status = MmRequestPageMemoryConsumer(MC_NPPOOL, FALSE, &Pfn);
126  if (!NT_SUCCESS(Status)) return NULL;
127 
128  //
129  // Setup the PFN
130  //
131  TempPde.u.Hard.Coarse.PageFrameNumber = (Pfn << PAGE_SHIFT) >> CPT_SHIFT;
132 
133  //
134  // Write the PDE
135  //
136  ASSERT(PointerPde->u.Hard.Coarse.Valid == 0);
137  ASSERT(TempPde.u.Hard.Coarse.Valid == 1);
138  *PointerPde = TempPde;
139 
140  //
141  // Save it
142  //
143  //MmGlobalKernelPageDirectory[PdeOffset] = TempPde.u.Hard.AsUlong;
144  //DPRINT1("KPD: %p PDEADDR: %p\n", &MmGlobalKernelPageDirectory[PdeOffset], MiAddressToPde(Address));
145 
146  //
147  // FIXFIX: Double check with Felix tomorrow
148  //
150  //
151  // Get the PTE for this 1MB region
152  //
153  PointerPte = MiAddressToPte(MiAddressToPte(Address));
154  DPRINT1("PointerPte: %p\n", PointerPte);
155 
156  //
157  // Write the PFN of the PDE
158  //
159  TempPte.u.Hard.PageFrameNumber = Pfn;
160 
161  //
162  // Write the PTE
163  //
164  ASSERT(PointerPte->u.Hard.Valid == 0);
165  ASSERT(TempPte.u.Hard.Valid == 1);
166  *PointerPte = TempPte;
168  }
169 
170  //
171  // Now set the actual PDE
172  //
173  //PointerPde = (PMMPTE)&MmGlobalKernelPageDirectory[PdeOffset];
174  }
175  else
176  {
177  //
178  // Is this a create operation? If not, fail
179  //
180  if (Create == FALSE) return NULL;
181 
182  //
183  // THIS WHOLE PATH IS TODO
184  //
185  goto kernelHack;
186  ASSERT(FALSE);
187 
188  //
189  // Allocate a non paged pool page for the PDE
190  //
191  Status = MmRequestPageMemoryConsumer(MC_NPPOOL, FALSE, &Pfn);
192  if (!NT_SUCCESS(Status)) return NULL;
193 
194  //
195  // Make the entry valid
196  //
197  TempPde.u.Hard.AsUlong = 0xDEADBEEF;
198 
199  //
200  // Set it
201  //
202  *PointerPde = TempPde;
203  }
204  }
205 
206  //
207  // Return the PTE
208  //
209  return MiAddressToPte(Address);
210 }
#define MiAddressToPde(x)
Definition: mmx86.c:20
_In_ BOOLEAN Create
Definition: pstypes.h:511
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN MyWait, PPFN_NUMBER AllocatedPage)
Definition: balance.c:229
HARDWARE_PDE_ARMV6 TempPde
Definition: winldr.c:77
union _MMPTE::@2234 u
#define MiAddressToPte(x)
Definition: mmx86.c:19
ULONG PFN_NUMBER
Definition: ke.h:8
#define PsGetCurrentProcess
Definition: psfuncs.h:17
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
ULONG PageFrameNumber
Definition: mmtypes.h:74
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG64 Valid
Definition: mmtypes.h:150
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:75
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define CPT_SHIFT
Definition: mm.h:149
Status
Definition: gdiplustypes.h:24
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
MMPTE MiArmTemplatePte
Definition: stubs.c:18
#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
MMPDE_HARDWARE MiArmTemplatePde
Definition: stubs.c:19
#define MmSystemRangeStart
Definition: mm.h:32
ULONG PageFrameNumber
Definition: mmtypes.h:109

Referenced by MiGetPageEntryForProcess(), MmCreateVirtualMappingInternal(), and MmDeleteVirtualMapping().

◆ MiUnmapPageTable()

BOOLEAN NTAPI MiUnmapPageTable ( IN PMMPTE  PointerPde)

Definition at line 25 of file stubs.c.

26 {
27  //
28  // Check if this address belongs to the kernel
29  //
30  if (((ULONG_PTR)PointerPde > PDE_BASE) ||
31  ((ULONG_PTR)PointerPde < (PDE_BASE + 1024*1024)))
32  {
33  //
34  // Nothing to do
35  //
36  return TRUE;
37  }
38 
39  //
40  // FIXME-USER: Shouldn't get here yet
41  //
42  ERROR_FATAL();
43  return FALSE;
44 }
#define TRUE
Definition: types.h:120
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define ERROR_FATAL(...)
Definition: debug.h:238
#define PDE_BASE
Definition: winldr.c:20

Referenced by MiFlushTlb(), MiGetPageEntryForProcess(), and MmCreateVirtualMappingInternal().

◆ MmCreatePageFileMapping()

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

Definition at line 523 of file stubs.c.

526 {
527  //
528  // TODO
529  //
531  return STATUS_NOT_IMPLEMENTED;
532 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57

◆ MmCreateProcessAddressSpace()

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

Definition at line 242 of file stubs.c.

245 {
247  ULONG i;
248  PFN_NUMBER Pfn[2];
249  PMMPDE_HARDWARE PageDirectory, PointerPde;
251  ASSERT(FALSE);
252 
253  //
254  // Loop two tables (Hyperspace and TTB). Each one is 16KB
255  //
256  //
257  for (i = 0; i < sizeof(Pfn) / sizeof(Pfn[0]); i++)
258  {
259  //
260  // Allocate a page
261  //
262  Status = MmRequestPageMemoryConsumer(MC_NPPOOL, FALSE, &Pfn[i]);
263  if (!NT_SUCCESS(Status)) ASSERT(FALSE);
264  }
265 
266  //
267  // Map the base
268  //
269  PageDirectory = MmCreateHyperspaceMapping(Pfn[0]);
270 
271  //
272  // Copy the PDEs for kernel-mode
273  //
276  (1024 - MiGetPdeOffset(MmSystemRangeStart)) * sizeof(ULONG));
277 
278 
279  //
280  // Setup the PDE for the table base
281  //
283  TempPde.u.Hard.Coarse.PageFrameNumber = (Pfn[0] << PAGE_SHIFT) >> CPT_SHIFT;
284  PointerPde = &PageDirectory[MiGetPdeOffset(PTE_BASE)];
285 
286  //
287  // Write the PDE
288  //
289  ASSERT(PointerPde->u.Hard.Coarse.Valid == 0);
290  ASSERT(TempPde.u.Hard.Coarse.Valid == 1);
291  *PointerPde = TempPde;
292 
293  //
294  // Setup the PDE for the hyperspace
295  //
296  TempPde.u.Hard.Coarse.PageFrameNumber = (Pfn[1] << PAGE_SHIFT) >> CPT_SHIFT;
297  PointerPde = &PageDirectory[MiGetPdeOffset(HYPER_SPACE)];
298 
299  //
300  // Write the PDE
301  //
302  ASSERT(PointerPde->u.Hard.Coarse.Valid == 0);
303  ASSERT(TempPde.u.Hard.Coarse.Valid == 1);
304  *PointerPde = TempPde;
305 
306  //
307  // Unmap the page directory
308  //
309  MmDeleteHyperspaceMapping(PageDirectory);
310 
311  //
312  // Return the page table base
313  //
314  DirectoryTableBase[0] = Pfn[0] << PAGE_SHIFT;
315  return TRUE;
316 }
#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)
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN MyWait, PPFN_NUMBER AllocatedPage)
Definition: balance.c:229
HARDWARE_PDE_ARMV6 TempPde
Definition: winldr.c:77
#define MiGetPdeOffset(x)
Definition: mm.h:185
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
ULONG PFN_NUMBER
Definition: ke.h:8
ULONG PageFrameNumber
Definition: mmtypes.h:74
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MmDeleteHyperspaceMapping(x)
Definition: mm.h:1034
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define CPT_SHIFT
Definition: mm.h:149
#define PTE_BASE
Definition: mmx86.c:14
Status
Definition: gdiplustypes.h:24
FORCEINLINE PVOID MmCreateHyperspaceMapping(IN PFN_NUMBER Page)
Definition: mm.h:1028
#define HYPER_SPACE
Definition: mm.h:14
ULONG MmGlobalKernelPageDirectory[1024]
Definition: stubs.c:17
unsigned int ULONG
Definition: retypes.h:1
MMPDE_HARDWARE MiArmTemplatePde
Definition: stubs.c:19
#define MmSystemRangeStart
Definition: mm.h:32

◆ MmCreateVirtualMapping()

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

Definition at line 434 of file stubs.c.

439 {
440  ULONG i;
441 
442  //
443  // Loop each page
444  //
445  for (i = 0; i < PageCount; i++)
446  {
447  //
448  // Make sure the page is marked as in use
449  //
450  ASSERT(MmIsPageInUse(Pages[i]));
451  }
452 
453  //
454  // Call the unsafe version
455  //
457  Address,
458  Protection,
459  Pages,
460  PageCount);
461 }
BOOLEAN NTAPI MmIsPageInUse(PFN_NUMBER Page)
Definition: freelist.c:530
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
NTSTATUS NTAPI MmCreateVirtualMappingUnsafe(IN PEPROCESS Process, IN PVOID Address, IN ULONG Protection, IN PPFN_NUMBER Pages, IN ULONG PageCount)
Definition: stubs.c:403
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_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

◆ MmCreateVirtualMappingInternal()

NTSTATUS NTAPI MmCreateVirtualMappingInternal ( IN PEPROCESS  Process,
IN PVOID  Address,
IN ULONG  Protection,
IN PPFN_NUMBER  Pages,
IN ULONG  PageCount,
IN BOOLEAN  MarkAsMapped 
)

Definition at line 320 of file stubs.c.

326 {
327  PMMPTE PointerPte = NULL;
328  MMPTE TempPte;
329  PVOID Addr;
330  ULONG OldPdeOffset, PdeOffset, i;
331  DPRINT("[KMAP]: %p %d\n", Address, PageCount);
332  //ASSERT(Address >= MmSystemRangeStart);
333 
334  //
335  // Get our template PTE
336  //
338 
339  //
340  // Loop every page
341  //
342  Addr = Address;
343  OldPdeOffset = MiGetPdeOffset(Addr) + 1;
344  for (i = 0; i < PageCount; i++)
345  {
346  //
347  // Get the next PDE offset and check if it's a new one
348  //
349  PdeOffset = MiGetPdeOffset(Addr);
350  if (OldPdeOffset != PdeOffset)
351  {
352  //
353  // Get rid of the old L2 Table, if this was the last PTE on it
354  //
355  MiUnmapPageTable(PointerPte);
356 
357  //
358  // Get the PTE for this address, and create the PDE for it
359  //
360  PointerPte = MiGetPageTableForProcess(NULL, Addr, TRUE);
361  ASSERT(PointerPte);
362  }
363  else
364  {
365  //
366  // Go to the next PTE on this PDE
367  //
368  ASSERT(PointerPte);
369  PointerPte++;
370  }
371 
372  //
373  // Save the current PDE
374  //
375  OldPdeOffset = PdeOffset;
376 
377  //
378  // Set the PFN
379  //
380  TempPte.u.Hard.PageFrameNumber = *Pages++;
381 
382  //
383  // Write the PTE
384  //
385  ASSERT(PointerPte->u.Hard.Valid == 0);
386  ASSERT(TempPte.u.Hard.Valid == 1);
387  *PointerPte = TempPte;
388 
389  //
390  // Move to the next page
391  //
392  Addr = (PVOID)((ULONG_PTR)Addr + PAGE_SIZE);
393  }
394 
395  //
396  // All done
397  //
398  return STATUS_SUCCESS;
399 }
#define TRUE
Definition: types.h:120
#define MiGetPdeOffset(x)
Definition: mm.h:185
uint32_t ULONG_PTR
Definition: typedefs.h:63
union _MMPTE::@2234 u
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
BOOLEAN NTAPI MiUnmapPageTable(IN PMMPTE PointerPde)
Definition: stubs.c:25
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
PMMPTE NTAPI MiGetPageTableForProcess(IN PEPROCESS Process, IN PVOID Address, IN BOOLEAN Create)
Definition: stubs.c:66
ULONG64 Valid
Definition: mmtypes.h:150
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:75
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define PAGE_SIZE
Definition: env_spec_w32.h:49
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
MMPTE MiArmTemplatePte
Definition: stubs.c:18
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2777
ULONG PageFrameNumber
Definition: mmtypes.h:109

Referenced by MmCreateVirtualMappingUnsafe().

◆ MmCreateVirtualMappingUnsafe()

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

Definition at line 403 of file stubs.c.

408 {
409  //
410  // Are we only handling the kernel?
411  //
412  if (!(Process) || (Process == PsGetCurrentProcess()))
413  {
414  //
415  // Call the internal version
416  //
418  Address,
419  Protection,
420  Pages,
421  PageCount,
422  TRUE);
423  }
424 
425  //
426  // FIXME-USER: Support user-mode mappings
427  //
428  ASSERT(FALSE);
429  return 0;
430 }
#define TRUE
Definition: types.h:120
#define PsGetCurrentProcess
Definition: psfuncs.h:17
static WCHAR Address[46]
Definition: ping.c:68
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS NTAPI MmCreateVirtualMappingInternal(IN PEPROCESS Process, IN PVOID Address, IN ULONG Protection, IN PPFN_NUMBER Pages, IN ULONG PageCount, IN BOOLEAN MarkAsMapped)
Definition: stubs.c:320
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

Referenced by MmCreateVirtualMapping().

◆ MmDeletePageFileMapping()

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

Definition at line 511 of file stubs.c.

514 {
515  //
516  // TODO
517  //
519 }
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57

◆ MmDeleteVirtualMapping()

VOID NTAPI MmDeleteVirtualMapping ( IN PEPROCESS  Process,
IN PVOID  Address,
OUT PBOOLEAN  WasDirty,
OUT PPFN_NUMBER  Page 
)

Definition at line 465 of file stubs.c.

469 {
470  PMMPTE PointerPte;
471  MMPTE Pte;
472  PFN_NUMBER Pfn = 0;
473 
474  //
475  // Get the PTE
476  //
477  PointerPte = MiGetPageTableForProcess(NULL, Address, FALSE);
478  if (PointerPte)
479  {
480  //
481  // Save and destroy the PTE
482  //
483  Pte = *PointerPte;
484  PointerPte->u.Hard.AsUlong = 0;
485 
486  //
487  // Flush the TLB
488  //
489  MiFlushTlb(PointerPte, Address);
490 
491  //
492  // Unmap the PFN
493  //
494  Pfn = Pte.u.Hard.PageFrameNumber;
495 
496  //
497  // Release the PFN if it was ours
498  //
499  if ((FreePage) && (Pfn)) MmReleasePageMemoryConsumer(MC_NPPOOL, Pfn);
500  }
501 
502  //
503  // Return if the page was dirty
504  //
505  if (WasDirty) *WasDirty = FALSE; // LIE!!!
506  if (Page) *Page = Pfn;
507 }
NTSTATUS NTAPI MmReleasePageMemoryConsumer(ULONG Consumer, PFN_NUMBER Page)
Definition: balance.c:97
union _MMPTE::@2234 u
ULONG PFN_NUMBER
Definition: ke.h:8
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
PMMPTE NTAPI MiGetPageTableForProcess(IN PEPROCESS Process, IN PVOID Address, IN BOOLEAN Create)
Definition: stubs.c:66
VOID NTAPI MiFlushTlb(IN PMMPTE PointerPte, IN PVOID Address)
Definition: stubs.c:48
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
ULONG64 PageFrameNumber
Definition: mmtypes.h:171

◆ MmGetPageProtect()

ULONG NTAPI MmGetPageProtect ( IN PEPROCESS  Process,
IN PVOID  Address 
)

Definition at line 618 of file stubs.c.

620 {
621  //
622  // We don't enforce any protection on the pages -- they are all RWX
623  //
624  return PAGE_READWRITE;
625 }
#define PAGE_READWRITE
Definition: nt_native.h:1304

◆ MmGetPfnForProcess()

PFN_NUMBER NTAPI MmGetPfnForProcess ( IN PEPROCESS  Process,
IN PVOID  Address 
)

Definition at line 536 of file stubs.c.

538 {
539  MMPTE Pte;
540 
541  //
542  // Get the PTE
543  //
545  if (Pte.u.Hard.Valid == 0) return 0;
546 
547  //
548  // Return PFN
549  //
550  return Pte.u.Hard.PageFrameNumber;
551 }
union _MMPTE::@2234 u
static WCHAR Address[46]
Definition: ping.c:68
ULONG64 Valid
Definition: mmtypes.h:150
MMPTE NTAPI MiGetPageEntryForProcess(IN PEPROCESS Process, IN PVOID Address)
Definition: stubs.c:214
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

◆ MmGetPhysicalAddress()

PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress ( IN PVOID  Address)

Definition at line 682 of file stubs.c.

683 {
685  MMPTE Pte;
686 
687  //
688  // Early boot PCR check
689  //
690  if (Address == PCR)
691  {
692  //
693  // ARM Hack while we still use a section PTE
694  //
695  PMMPDE_HARDWARE PointerPde;
696  PointerPde = MiAddressToPde(PCR);
697  ASSERT(PointerPde->u.Hard.Section.Valid == 1);
698  PhysicalAddress.QuadPart = PointerPde->u.Hard.Section.PageFrameNumber;
701  return PhysicalAddress;
702  }
703 
704  //
705  // Get the PTE
706  //
708  if (Pte.u.Hard.Valid)
709  {
710  //
711  // Return the information
712  //
716  }
717  else
718  {
719  //
720  // Invalid or unmapped
721  //
723  }
724 
725  //
726  // Return the physical address
727  //
728  return PhysicalAddress;
729 }
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define MiAddressToPde(x)
Definition: mmx86.c:20
union _MMPTE::@2234 u
#define PCR
Definition: ke.h:8
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
ULONG64 Valid
Definition: mmtypes.h:150
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1060
MMPTE NTAPI MiGetPageEntryForProcess(IN PEPROCESS Process, IN PVOID Address)
Definition: stubs.c:214
#define CPT_SHIFT
Definition: mm.h:149
ULONG LowPart
Definition: typedefs.h:104
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
#define BYTE_OFFSET(Va)
LONGLONG QuadPart
Definition: typedefs.h:112
ULONG PageFrameNumber
Definition: mmtypes.h:213

Referenced by AcpiOsGetPhysicalAddress(), AtapiVirtToPhysAddr_(), CUSBRequest::BuildControlTransferDescriptor(), CUSBRequest::BuildIsochronousEndpoint(), CcRosTrimCache(), HalAllocateCommonBuffer(), HalpGrowMapBuffers(), HDA_InitCorbRirbPos(), CUSBRequest::InitDescriptor(), KdDebuggerInitialize0(), Ki386BuildIdentityBuffer(), Ki386ConvertPte(), Ki386CreateIdentityMap(), MiReadPage(), SoundProgramDMA(), StorPortGetPhysicalAddress(), StorPortGetUncachedExtension(), TestPhysicalMemorySection(), and VidInitialize().

◆ MmInitGlobalKernelPageDirectory()

VOID NTAPI MmInitGlobalKernelPageDirectory ( VOID  )

Definition at line 641 of file stubs.c.

642 {
643  ULONG i;
644  PULONG CurrentPageDirectory = (PULONG)PDE_BASE;
645 
646  //
647  // Good place to setup template PTE/PDEs.
648  // We are lazy and pick a known-good PTE
649  //
650  MiArmTemplatePte = *MiAddressToPte(0x80000000);
651  MiArmTemplatePde = *MiAddressToPde(0x80000000);
652 
653  //
654  // Loop the 2GB of address space which belong to the kernel
655  //
656  for (i = MiGetPdeOffset(MmSystemRangeStart); i < 1024; i++)
657  {
658  //
659  // Check if we have an entry for this already
660  //
661  if ((i != MiGetPdeOffset(PTE_BASE)) &&
662  (i != MiGetPdeOffset(HYPER_SPACE)) &&
664  (CurrentPageDirectory[i]))
665  {
666  //
667  // We don't, link it in our global page directory
668  //
669  MmGlobalKernelPageDirectory[i] = CurrentPageDirectory[i];
670  }
671  }
672 }
#define MiAddressToPde(x)
Definition: mmx86.c:20
#define MiGetPdeOffset(x)
Definition: mm.h:185
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 MiAddressToPte(x)
Definition: mmx86.c:19
#define PDE_BASE
Definition: winldr.c:20
#define PTE_BASE
Definition: mmx86.c:14
unsigned int * PULONG
Definition: retypes.h:1
MMPTE MiArmTemplatePte
Definition: stubs.c:18
#define HYPER_SPACE
Definition: mm.h:14
ULONG MmGlobalKernelPageDirectory[1024]
Definition: stubs.c:17
unsigned int ULONG
Definition: retypes.h:1
MMPDE_HARDWARE MiArmTemplatePde
Definition: stubs.c:19
#define MmSystemRangeStart
Definition: mm.h:32

◆ MmIsDirtyPage()

BOOLEAN NTAPI MmIsDirtyPage ( IN PEPROCESS  Process,
IN PVOID  Address 
)

Definition at line 555 of file stubs.c.

557 {
558  //
559  // TODO
560  //
562  return FALSE;
563 }
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57

◆ MmIsPagePresent()

BOOLEAN NTAPI MmIsPagePresent ( IN PEPROCESS  Process,
IN PVOID  Address 
)

Definition at line 589 of file stubs.c.

591 {
592  //
593  // Fault PTEs are 0, which is FALSE (non-present)
594  //
596 }
union _MMPTE::@2234 u
static WCHAR Address[46]
Definition: ping.c:68
ULONG64 Valid
Definition: mmtypes.h:150
MMPTE NTAPI MiGetPageEntryForProcess(IN PEPROCESS Process, IN PVOID Address)
Definition: stubs.c:214
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

◆ MmIsPageSwapEntry()

BOOLEAN NTAPI MmIsPageSwapEntry ( IN PEPROCESS  Process,
IN PVOID  Address 
)

Definition at line 600 of file stubs.c.

602 {
603  MMPTE Pte;
604 
605  //
606  // Get the PTE
607  //
609 
610  //
611  // Make sure it exists, but is faulting
612  //
613  return (Pte.u.Hard.Valid == 0) && (Pte.u.Hard.AsUlong);
614 }
union _MMPTE::@2234 u
static WCHAR Address[46]
Definition: ping.c:68
ULONG64 Valid
Definition: mmtypes.h:150
MMPTE NTAPI MiGetPageEntryForProcess(IN PEPROCESS Process, IN PVOID Address)
Definition: stubs.c:214
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

◆ MmSetCleanPage()

VOID NTAPI MmSetCleanPage ( IN PEPROCESS  Process,
IN PVOID  Address 
)

Definition at line 567 of file stubs.c.

569 {
570  //
571  // TODO
572  //
574 }
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57

◆ MmSetDirtyPage()

VOID NTAPI MmSetDirtyPage ( IN PEPROCESS  Process,
IN PVOID  Address 
)

Definition at line 578 of file stubs.c.

580 {
581  //
582  // TODO
583  //
585 }
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57

◆ MmSetPageProtect()

VOID NTAPI MmSetPageProtect ( IN PEPROCESS  Process,
IN PVOID  Address,
IN ULONG  Protection 
)

Definition at line 629 of file stubs.c.

632 {
633  //
634  // We don't enforce any protection on the pages -- they are all RWX
635  //
636  return;
637 }

Variable Documentation

◆ MiArmTemplatePde

◆ MiArmTemplatePte

MMPTE MiArmTemplatePte

◆ MmGlobalKernelPageDirectory

ULONG MmGlobalKernelPageDirectory[1024]

Definition at line 17 of file stubs.c.

Referenced by MmCreateProcessAddressSpace(), and MmInitGlobalKernelPageDirectory().