ReactOS  r76032
marea.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1998-2005 ReactOS Team (and the authors from the programmers section)
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  *
19  * PROJECT: ReactOS kernel
20  * FILE: ntoskrnl/mm/marea.c
21  * PURPOSE: Implements memory areas
22  *
23  * PROGRAMMERS: Rex Jolliff
24  * David Welch
25  * Eric Kohl
26  * Philip Susi
27  * Casper Hornstrup
28  * Eric Kohl
29  * Ge van Geldorp
30  * Royce Mitchell III
31  * Aleksey Bragin
32  * Jason Filby
33  * Thomas Weidenmueller
34  * Gunnar Andre' Dalsnes
35  * Mike Nordell
36  * Alex Ionescu
37  * Filip Navara
38  * Herve Poussineau
39  * Steven Edwards
40  */
41 
42 /* INCLUDES *****************************************************************/
43 
44 #include <ntoskrnl.h>
45 #define NDEBUG
46 #include <cache/section/newmm.h>
47 #include <debug.h>
48 
49 #include "ARM3/miarm.h"
50 
53 
56 
57 /* FUNCTIONS *****************************************************************/
58 
62  PVOID Address_)
63 {
64  ULONG_PTR StartVpn = (ULONG_PTR)Address_ / PAGE_SIZE;
70  PMMVAD_LONG Vad;
71 
72  Process = MmGetAddressSpaceOwner(AddressSpace);
73  Table = (Process != NULL) ? &Process->VadRoot : &MiRosKernelVadRoot;
74 
75  Result = MiCheckForConflictingNode(StartVpn, StartVpn, Table, &Node);
76  if (Result != TableFoundNode)
77  {
78  return NULL;
79  }
80 
81  Vad = (PMMVAD_LONG)Node;
82  if (Vad->u.VadFlags.Spare == 0)
83  {
84  /* Check if this is VM VAD */
85  if (Vad->ControlArea == NULL)
86  {
87  /* We store the reactos MEMORY_AREA here */
88  MemoryArea = (PMEMORY_AREA)Vad->FirstPrototypePte;
89  }
90  else
91  {
92  /* This is a section VAD. Store the MAREA here for now */
93  MemoryArea = (PMEMORY_AREA)Vad->u4.Banked;
94  }
95  }
96  else
97  {
98  MemoryArea = (PMEMORY_AREA)Node;
99  }
100 
101  return MemoryArea;
102 }
103 
105 NTAPI
108  PVOID Address_,
110 {
111  ULONG_PTR StartVpn = (ULONG_PTR)Address_ / PAGE_SIZE;
112  ULONG_PTR EndVpn = ((ULONG_PTR)Address_ + Length - 1) / PAGE_SIZE;
118  PMMVAD_LONG Vad;
119 
120  Process = MmGetAddressSpaceOwner(AddressSpace);
121  Table = (Process != NULL) ? &Process->VadRoot : &MiRosKernelVadRoot;
122 
123  Result = MiCheckForConflictingNode(StartVpn, EndVpn, Table, &Node);
124  if (Result != TableFoundNode)
125  {
126  return NULL;
127  }
128 
129  Vad = (PMMVAD_LONG)Node;
130  if (Vad->u.VadFlags.Spare == 0)
131  {
132  /* Check if this is VM VAD */
133  if (Vad->ControlArea == NULL)
134  {
135  /* We store the reactos MEMORY_AREA here */
136  MemoryArea = (PMEMORY_AREA)Vad->FirstPrototypePte;
137  }
138  else
139  {
140  /* This is a section VAD. Store the MAREA here for now */
141  MemoryArea = (PMEMORY_AREA)Vad->u4.Banked;
142  }
143  }
144  else
145  {
146  MemoryArea = (PMEMORY_AREA)Node;
147  }
148 
149  ASSERT(MemoryArea != NULL);
150  return MemoryArea;
151 }
152 
153 VOID
154 NTAPI
155 MiInsertVad(IN PMMVAD Vad,
156  IN PMM_AVL_TABLE VadRoot);
157 
158 ULONG
159 NTAPI
162 );
163 
164 
165 static VOID
168  PMEMORY_AREA marea)
169 {
170  PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
171 
172  marea->VadNode.u.VadFlags.Spare = 1;
174 
175  /* Build a lame VAD if this is a user-space allocation */
177  {
178  ASSERT(Process != NULL);
179  if (marea->Type != MEMORY_AREA_OWNED_BY_ARM3)
180  {
182 
183  /* Insert the VAD */
185  MiInsertVad(&marea->VadNode, &Process->VadRoot);
187  marea->Vad = &marea->VadNode;
188  }
189  }
190  else
191  {
192  ASSERT(Process == NULL);
193 
195  {
196  MiRosKernelVadRoot.BalancedRoot.u1.Parent = &MiRosKernelVadRoot.BalancedRoot;
197  MiRosKernelVadRoot.Unused = 1;
199  }
200 
201  /* Insert the VAD */
203  MiInsertVad(&marea->VadNode, &MiRosKernelVadRoot);
205  marea->Vad = NULL;
206  }
207 }
208 
209 PVOID NTAPI
213  ULONG_PTR Granularity,
214  BOOLEAN TopDown)
215 {
217  PMM_AVL_TABLE VadRoot;
220  ULONG_PTR StartingAddress, HighestAddress;
221 
222  Process = MmGetAddressSpaceOwner(AddressSpace);
223  VadRoot = Process ? &Process->VadRoot : &MiRosKernelVadRoot;
224  if (TopDown)
225  {
226  /* Find an address top-down */
227  HighestAddress = Process ? (ULONG_PTR)MM_HIGHEST_VAD_ADDRESS : (LONG_PTR)-1;
228  Result = MiFindEmptyAddressRangeDownTree(Length,
229  HighestAddress,
230  Granularity,
231  VadRoot,
232  &StartingAddress,
233  &Parent);
234  }
235  else
236  {
237  Result = MiFindEmptyAddressRangeInTree(Length,
238  Granularity,
239  VadRoot,
240  &Parent,
241  &StartingAddress);
242  }
243 
244  if (Result == TableFoundNode)
245  {
246  return NULL;
247  }
248 
249  return (PVOID)StartingAddress;
250 }
251 
252 VOID
253 NTAPI
256 
257 
282  PVOID FreePageContext)
283 {
285  PVOID EndAddress;
286 
287  /* Make sure we own the address space lock! */
288  ASSERT(CONTAINING_RECORD(AddressSpace, EPROCESS, Vm)->AddressCreationLock.Owner == KeGetCurrentThread());
289 
290  /* Check magic */
291  ASSERT(MemoryArea->Magic == 'erAM');
292 
293  if (MemoryArea->Type != MEMORY_AREA_OWNED_BY_ARM3)
294  {
296  PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
297 
298  if (Process != NULL &&
299  Process != CurrentProcess)
300  {
301  KeAttachProcess(&Process->Pcb);
302  }
303 
304  EndAddress = MM_ROUND_UP(MA_GetEndingAddress(MemoryArea), PAGE_SIZE);
305  for (Address = MA_GetStartingAddress(MemoryArea);
306  Address < (ULONG_PTR)EndAddress;
307  Address += PAGE_SIZE)
308  {
309  BOOLEAN Dirty = FALSE;
310  SWAPENTRY SwapEntry = 0;
311  PFN_NUMBER Page = 0;
312 
313  if (MmIsPageSwapEntry(Process, (PVOID)Address))
314  {
315  MmDeletePageFileMapping(Process, (PVOID)Address, &SwapEntry);
316  }
317  else
318  {
319  MmDeleteVirtualMapping(Process, (PVOID)Address, &Dirty, &Page);
320  }
321  if (FreePage != NULL)
322  {
323  FreePage(FreePageContext, MemoryArea, (PVOID)Address,
324  Page, SwapEntry, (BOOLEAN)Dirty);
325  }
326 #if (_MI_PAGING_LEVELS == 2)
327  /* Remove page table reference */
329  if ((SwapEntry || Page) && ((PVOID)Address < MmSystemRangeStart))
330  {
331  ASSERT(AddressSpace != MmGetKernelAddressSpace());
332  if (MiQueryPageTableReferences((PVOID)Address) == 0)
333  {
334  /* No PTE relies on this PDE. Release it */
336  PMMPDE PointerPde = MiAddressToPde(Address);
337  ASSERT(PointerPde->u.Hard.Valid == 1);
338  MiDeletePte(PointerPde, MiPdeToPte(PointerPde), Process, NULL);
339  ASSERT(PointerPde->u.Hard.Valid == 0);
341  }
342  }
343 #endif
344  }
345 
346  if (Process != NULL &&
347  Process != CurrentProcess)
348  {
349  KeDetachProcess();
350  }
351 
352  //if (MemoryArea->VadNode.StartingVpn < (ULONG_PTR)MmSystemRangeStart >> PAGE_SHIFT
353  if (MemoryArea->Vad)
354  {
356  ASSERT(MemoryArea->Type == MEMORY_AREA_SECTION_VIEW || MemoryArea->Type == MEMORY_AREA_CACHE);
357 
358  /* MmCleanProcessAddressSpace might have removed it (and this would be MmDeleteProcessAdressSpace) */
359  ASSERT(MemoryArea->VadNode.u.VadFlags.Spare != 0);
360  if (((PMMVAD)MemoryArea->Vad)->u.VadFlags.Spare == 1)
361  {
362  MiRemoveNode((PMMADDRESS_NODE)&MemoryArea->VadNode, &Process->VadRoot);
363  }
364 
365  MemoryArea->Vad = NULL;
366  }
367  else
368  {
369  MiRemoveNode((PMMADDRESS_NODE)&MemoryArea->VadNode, &MiRosKernelVadRoot);
370  }
371  }
372 
373 #if DBG
374  MemoryArea->Magic = 'daeD';
375 #endif
376  ExFreePoolWithTag(MemoryArea, TAG_MAREA);
377 
378  DPRINT("MmFreeMemoryAreaByNode() succeeded\n");
379 
380  return STATUS_SUCCESS;
381 }
382 
411  ULONG Type,
414  ULONG Protect,
416  ULONG AllocationFlags,
417  ULONG Granularity)
418 {
419  ULONG_PTR tmpLength;
421  ULONG_PTR EndingAddress;
422 
423  DPRINT("MmCreateMemoryArea(Type 0x%lx, BaseAddress %p, "
424  "*BaseAddress %p, Length %p, AllocationFlags %x, "
425  "Result %p)\n",
426  Type, BaseAddress, *BaseAddress, Length, AllocationFlags,
427  Result);
428 
429  /* Is this a static memory area? */
430  if (Type & MEMORY_AREA_STATIC)
431  {
432  /* Use the static array instead of the pool */
434  MemoryArea = &MiStaticMemoryAreas[MiStaticMemoryAreaCount++];
435  }
436  else
437  {
438  /* Allocate the memory area from nonpaged pool */
439  MemoryArea = ExAllocatePoolWithTag(NonPagedPool,
440  sizeof(MEMORY_AREA),
441  TAG_MAREA);
442  }
443 
444  if (!MemoryArea)
445  {
446  DPRINT1("Not enough memory.\n");
447  return STATUS_NO_MEMORY;
448  }
449 
450  RtlZeroMemory(MemoryArea, sizeof(MEMORY_AREA));
451  MemoryArea->Type = Type & ~MEMORY_AREA_STATIC;
452  MemoryArea->Protect = Protect;
453  MemoryArea->Flags = AllocationFlags;
454  MemoryArea->Magic = 'erAM';
455  MemoryArea->DeleteInProgress = FALSE;
456 
457  if (*BaseAddress == 0)
458  {
459  tmpLength = (ULONG_PTR)MM_ROUND_UP(Length, PAGE_SIZE);
460  *BaseAddress = MmFindGap(AddressSpace,
461  tmpLength,
462  Granularity,
463  (AllocationFlags & MEM_TOP_DOWN) == MEM_TOP_DOWN);
464  if ((*BaseAddress) == 0)
465  {
466  DPRINT("No suitable gap\n");
467  if (!(Type & MEMORY_AREA_STATIC)) ExFreePoolWithTag(MemoryArea, TAG_MAREA);
468  return STATUS_NO_MEMORY;
469  }
470 
471  MemoryArea->VadNode.StartingVpn = (ULONG_PTR)*BaseAddress >> PAGE_SHIFT;
472  MemoryArea->VadNode.EndingVpn = ((ULONG_PTR)*BaseAddress + tmpLength - 1) >> PAGE_SHIFT;
473  MmInsertMemoryArea(AddressSpace, MemoryArea);
474  }
475  else
476  {
477  EndingAddress = ((ULONG_PTR)*BaseAddress + Length - 1) | (PAGE_SIZE - 1);
478  *BaseAddress = ALIGN_DOWN_POINTER_BY(*BaseAddress, Granularity);
479  tmpLength = EndingAddress + 1 - (ULONG_PTR)*BaseAddress;
480 
481  if (!MmGetAddressSpaceOwner(AddressSpace) && *BaseAddress < MmSystemRangeStart)
482  {
483  ASSERT(FALSE);
484  if (!(Type & MEMORY_AREA_STATIC)) ExFreePoolWithTag(MemoryArea, TAG_MAREA);
486  }
487 
488  if (MmGetAddressSpaceOwner(AddressSpace) &&
489  (ULONG_PTR)(*BaseAddress) + tmpLength > (ULONG_PTR)MmSystemRangeStart)
490  {
491  DPRINT("Memory area for user mode address space exceeds MmSystemRangeStart\n");
492  if (!(Type & MEMORY_AREA_STATIC)) ExFreePoolWithTag(MemoryArea, TAG_MAREA);
494  }
495 
496  /* No need to check ARM3 owned memory areas, the range MUST be free */
497  if (MemoryArea->Type != MEMORY_AREA_OWNED_BY_ARM3)
498  {
499  if (MmLocateMemoryAreaByRegion(AddressSpace,
500  *BaseAddress,
501  tmpLength) != NULL)
502  {
503  DPRINT("Memory area already occupied\n");
504  if (!(Type & MEMORY_AREA_STATIC)) ExFreePoolWithTag(MemoryArea, TAG_MAREA);
506  }
507  }
508 
509  MemoryArea->VadNode.StartingVpn = (ULONG_PTR)*BaseAddress >> PAGE_SHIFT;
510  MemoryArea->VadNode.EndingVpn = ((ULONG_PTR)*BaseAddress + tmpLength - 1) >> PAGE_SHIFT;
511  MmInsertMemoryArea(AddressSpace, MemoryArea);
512  }
513 
514  *Result = MemoryArea;
515 
516  DPRINT("MmCreateMemoryArea() succeeded (%p)\n", *BaseAddress);
517  return STATUS_SUCCESS;
518 }
519 
520 VOID
521 NTAPI
524  PMMVAD Vad)
525 {
529 
530  /* We must be called from MmCleanupAddressSpace and nowhere else!
531  Make sure things are as expected... */
532  ASSERT(Process == PsGetCurrentProcess());
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 */
539  MmUnlockAddressSpace(&Process->Vm);
540 
541  MemoryArea = (PMEMORY_AREA)Vad;
542  BaseAddress = (PVOID)MA_GetStartingAddress(MemoryArea);
543 
544  if (MemoryArea->Type == MEMORY_AREA_SECTION_VIEW)
545  {
546  Status = MiRosUnmapViewOfSection(Process, BaseAddress, Process->ProcessExiting);
547  }
548  else if (MemoryArea->Type == MEMORY_AREA_CACHE)
549  {
550  Status = MmUnmapViewOfCacheSegment(&Process->Vm, BaseAddress);
551  }
552  else
553  {
554  /* There shouldn't be anything else! */
555  ASSERT(FALSE);
556  }
557 
558  /* Make sure this worked! */
559  ASSERT(NT_SUCCESS(Status));
560 
561  /* Lock the address space again */
562  MmLockAddressSpace(&Process->Vm);
563 }
564 
565 VOID
566 NTAPI
568 
569 NTSTATUS
570 NTAPI
572 {
573  KIRQL OldIrql;
574  PVOID Address;
575 
576  DPRINT("MmDeleteProcessAddressSpace(Process %p (%s))\n", Process,
577  Process->ImageFileName);
578 
579 #ifndef _M_AMD64
580  OldIrql = MiAcquireExpansionLock();
581  RemoveEntryList(&Process->MmProcessLinks);
582  MiReleaseExpansionLock(OldIrql);
583 #endif
584  MmLockAddressSpace(&Process->Vm);
585 
586  /* There should not be any memory areas left! */
588 
589 #if (_MI_PAGING_LEVELS == 2)
590  {
591  KIRQL OldIrql;
592  PMMPDE pointerPde;
593  /* Attach to Process */
594  KeAttachProcess(&Process->Pcb);
595 
596  /* Acquire PFN lock */
598 
599  for (Address = MI_LOWEST_VAD_ADDRESS;
600  Address < MM_HIGHEST_VAD_ADDRESS;
601  Address =(PVOID)((ULONG_PTR)Address + (PAGE_SIZE * PTE_COUNT)))
602  {
603  /* At this point all references should be dead */
604  if (MiQueryPageTableReferences(Address) != 0)
605  {
606  DPRINT1("Process %p, Address %p, UsedPageTableEntries %lu\n",
607  Process,
608  Address,
609  MiQueryPageTableReferences(Address));
610  ASSERT(MiQueryPageTableReferences(Address) == 0);
611  }
612 
613  pointerPde = MiAddressToPde(Address);
614  /* Unlike in ARM3, we don't necesarrily free the PDE page as soon as reference reaches 0,
615  * so we must clean up a bit when process closes */
616  if (pointerPde->u.Hard.Valid)
617  MiDeletePte(pointerPde, MiPdeToPte(pointerPde), Process, NULL);
618  ASSERT(pointerPde->u.Hard.Valid == 0);
619  }
620 
621  /* Release lock */
623 
624  /* Detach */
625  KeDetachProcess();
626  }
627 #endif
628 
629  MmUnlockAddressSpace(&Process->Vm);
630 
631  DPRINT("Finished MmDeleteProcessAddressSpace()\n");
633  return(STATUS_SUCCESS);
634 }
635 
636 /* EOF */
DWORD *typedef PVOID
Definition: winlogon.h:52
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
MM_AVL_TABLE MiRosKernelVadRoot
Definition: marea.c:54
ULONG NTAPI MiMakeProtectionMask(IN ULONG Protect)
Definition: section.c:158
union _MMVAD_LONG::@2317 u4
NTSTATUS NTAPI MmDeleteProcessAddressSpace(PEPROCESS Process)
Definition: marea.c:571
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define IN
Definition: typedefs.h:38
LIST_ENTRY MmProcessLinks
Definition: pstypes.h:1292
TABLE_SEARCH_RESULT NTAPI MiFindEmptyAddressRangeDownTree(IN SIZE_T Length, IN ULONG_PTR BoundaryAddress, IN ULONG_PTR Alignment, IN PMM_AVL_TABLE Table, OUT PULONG_PTR Base, OUT PMMADDRESS_NODE *Parent)
Definition: vadnode.c:597
#define TRUE
Definition: types.h:120
#define ALIGN_DOWN_POINTER_BY(ptr, align)
PVOID ULONG Address
Definition: oprghdlr.h:14
VOID NTAPI MiRemoveNode(IN PMMADDRESS_NODE Node, IN PMM_AVL_TABLE Table)
Definition: vadnode.c:360
ULONG Type
Definition: mm.h:210
struct _MEMORY_AREA * PMEMORY_AREA
Type
Definition: Type.h:6
FORCEINLINE VOID MiUnlockProcessWorkingSetUnsafe(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1177
#define MiAddressToPde(x)
Definition: mmx86.c:20
FORCEINLINE KIRQL MiAcquireExpansionLock(VOID)
Definition: miarm.h:1348
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define MI_LOWEST_VAD_ADDRESS
Definition: miarm.h:9
return STATUS_SUCCESS
Definition: btrfs.c:2664
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2268
VOID(* PMM_FREE_PAGE_FUNC)(PVOID Context, PMEMORY_AREA MemoryArea, PVOID Address, PFN_NUMBER Page, SWAPENTRY SwapEntry, BOOLEAN Dirty)
Definition: mm.h:434
FORCEINLINE VOID MmUnlockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1350
MMVAD_FLAGS VadFlags
Definition: mmtypes.h:764
enum _TABLE_SEARCH_RESULT TABLE_SEARCH_RESULT
FORCEINLINE USHORT MiQueryPageTableReferences(IN PVOID Address)
Definition: miarm.h:1659
ULONG_PTR Unused
Definition: mmtypes.h:665
PCONTROL_AREA ControlArea
Definition: mmtypes.h:766
ULONG_PTR Protection
Definition: mmtypes.h:697
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:718
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
VOID NTAPI MmDeletePageFileMapping(struct _EPROCESS *Process, PVOID Address, SWAPENTRY *SwapEntry)
#define MEMORY_AREA_STATIC
Definition: mm.h:72
MMVAD_FLAGS VadFlags
Definition: mmtypes.h:735
#define MEMORY_AREA_CACHE
Definition: mm.h:70
VOID NTAPI MiDeletePte(IN PMMPTE PointerPte, IN PVOID VirtualAddress, IN PEPROCESS CurrentProcess, IN PMMPTE PrototypePte)
Definition: virtual.c:391
MMADDRESS_NODE BalancedRoot
Definition: mmtypes.h:663
uint32_t ULONG_PTR
Definition: typedefs.h:63
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
ULONG_PTR EndingVpn
Definition: mmtypes.h:731
ULONG Magic
Definition: mm.h:214
ULONG PFN_NUMBER
Definition: ke.h:8
#define MEMORY_AREA_OWNED_BY_ARM3
Definition: mm.h:71
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
ULONG ProcessExiting
Definition: pstypes.h:1327
_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
NTSTATUS NTAPI MmCreateMemoryArea(PMMSUPPORT AddressSpace, ULONG Type, PVOID *BaseAddress, ULONG_PTR Length, ULONG Protect, PMEMORY_AREA *Result, ULONG AllocationFlags, ULONG Granularity)
Definition: marea.c:410
ULONG ActiveThreads
Definition: pstypes.h:1268
#define TAG_MAREA
Definition: tag.h:120
#define PsGetCurrentProcess
Definition: psfuncs.h:17
TABLE_SEARCH_RESULT NTAPI MiFindEmptyAddressRangeInTree(IN SIZE_T Length, IN ULONG_PTR Alignment, IN PMM_AVL_TABLE Table, OUT PMMADDRESS_NODE *PreviousVad, OUT PULONG_PTR Base)
Definition: vadnode.c:502
MMSUPPORT MmSystemCacheWs
Definition: init.c:55
smooth NULL
Definition: ftsmooth.c:557
VOID * Table
Definition: acefiex.h:656
ULONG Protect
Definition: mm.h:211
VOID NTAPI MmDeleteVirtualMapping(struct _EPROCESS *Process, PVOID Address, BOOLEAN *WasDirty, PPFN_NUMBER Page)
PVOID Banked
Definition: mmtypes.h:781
VOID NTAPI MmDeleteProcessAddressSpace2(IN PEPROCESS Process)
Definition: procsup.c:1328
void DPRINT(...)
Definition: polytest.cpp:61
FORCEINLINE VOID MiUnlockWorkingSet(IN PETHREAD Thread, IN PMMSUPPORT WorkingSet)
Definition: miarm.h:1247
ULONG_PTR StartingVpn
Definition: mmtypes.h:730
#define MEMORY_AREA_SECTION_VIEW
Definition: mm.h:69
union _MMVAD_LONG::@2314 u
TABLE_SEARCH_RESULT NTAPI MiCheckForConflictingNode(IN ULONG_PTR StartVpn, IN ULONG_PTR EndVpn, IN PMM_AVL_TABLE Table, OUT PMMADDRESS_NODE *NodeOrParent)
Definition: vadnode.c:78
#define MM_ROUND_UP(x, s)
Definition: mm.h:104
FORCEINLINE VOID MiLockProcessWorkingSetUnsafe(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1107
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
unsigned char BOOLEAN
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
union _MMADDRESS_NODE::@2309 u1
ULONG VmDeleted
Definition: pstypes.h:1330
ULONG CurrentProcess
Definition: shell.c:125
LIST_ENTRY WorkingSetExpansionLinks
Definition: mmtypes.h:899
union _MMVAD::@2311 u
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
PMEMORY_AREA NTAPI MmLocateMemoryAreaByAddress(PMMSUPPORT AddressSpace, PVOID Address_)
Definition: marea.c:60
struct _MMVAD_LONG * PMMVAD_LONG
ULONG64 Valid
Definition: mmtypes.h:150
BOOLEAN DeleteInProgress
Definition: mm.h:213
VOID FASTCALL KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber, IN KIRQL OldIrql)
Definition: spinlock.c:154
#define MA_GetEndingAddress(_MemoryArea)
Definition: mm.h:204
BOOLEAN NTAPI MmIsPageSwapEntry(struct _EPROCESS *Process, PVOID Address)
#define PTE_COUNT
Definition: miarm.h:31
MMVAD VadNode
Definition: mm.h:208
MEMORY_AREA MiStaticMemoryAreas[MI_STATIC_MEMORY_AREAS]
Definition: marea.c:51
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
VOID NTAPI KeDetachProcess(VOID)
Definition: procobj.c:566
VOID UINTN Length
Definition: acefiex.h:744
NTSTATUS NTAPI MmFreeMemoryArea(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_FREE_PAGE_FUNC FreePage, PVOID FreePageContext)
Definition: marea.c:278
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define PAGE_SIZE
Definition: env_spec_w32.h:49
KPROCESS Pcb
Definition: pstypes.h:1194
KIRQL FASTCALL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER LockNumber)
Definition: spinlock.c:108
#define MA_GetStartingAddress(_MemoryArea)
Definition: mm.h:203
MMSUPPORT Vm
Definition: pstypes.h:1288
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI MmUnmapViewOfCacheSegment(PMMSUPPORT AddressSpace, PVOID BaseAddress)
Definition: data.c:713
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
VOID NTAPI MiRosCleanupMemoryArea(PEPROCESS Process, PMMVAD Vad)
Definition: marea.c:522
FORCEINLINE PMMSUPPORT MmGetKernelAddressSpace(VOID)
Definition: mm.h:1372
LONG NTSTATUS
Definition: DriverTester.h:11
#define MiPdeToPte(_Pde)
Definition: mm.h:219
BOOLEAN MiRosKernelVadRootInitialized
Definition: marea.c:55
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:228
VOID NTAPI KeAttachProcess(IN PKPROCESS Process)
Definition: procobj.c:527
ULONG MiStaticMemoryAreaCount
Definition: marea.c:52
ULONG_PTR SWAPENTRY
Definition: mm.h:45
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
FORCEINLINE PEPROCESS MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace)
Definition: mm.h:1357
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
FORCEINLINE VOID MiReleaseExpansionLock(KIRQL OldIrql)
Definition: miarm.h:1361
#define DPRINT1
Definition: precomp.h:8
#define MM_HIGHEST_VAD_ADDRESS
Definition: mm.h:36
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define MI_STATIC_MEMORY_AREAS
Definition: mm.h:66
ULONG_PTR Spare
Definition: mmtypes.h:698
CHAR ImageFileName[16]
Definition: pstypes.h:1258
unsigned int ULONG
Definition: retypes.h:1
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:259
PMMPTE FirstPrototypePte
Definition: mmtypes.h:767
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID NTAPI MiInsertVad(IN PMMVAD Vad, IN PMM_AVL_TABLE VadRoot)
Definition: vadnode.c:183
#define ULONG_PTR
Definition: config.h:101
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1097
union _MMPTE::@2072 u
FORCEINLINE VOID MiLockWorkingSet(IN PETHREAD Thread, IN PMMSUPPORT WorkingSet)
Definition: miarm.h:1203
#define KeGetCurrentThread
Definition: hal.h:44
PVOID NTAPI MmFindGap(PMMSUPPORT AddressSpace, ULONG_PTR Length, ULONG_PTR Granularity, BOOLEAN TopDown)
Definition: marea.c:210
PMEMORY_AREA NTAPI MmLocateMemoryAreaByRegion(PMMSUPPORT AddressSpace, PVOID Address_, ULONG_PTR Length)
Definition: marea.c:106
#define MEM_TOP_DOWN
Definition: nt_native.h:1321
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:247
MM_AVL_TABLE VadRoot
Definition: pstypes.h:1385
static VOID MmInsertMemoryArea(PMMSUPPORT AddressSpace, PMEMORY_AREA marea)
Definition: marea.c:166
NTSTATUS NTAPI MiRosUnmapViewOfSection(IN PEPROCESS Process, IN PVOID BaseAddress, IN BOOLEAN SkipDebuggerNotify)
Definition: section.c:4126
struct _MEMORY_AREA * MemoryArea
Definition: newmm.h:65
PVOID Vad
Definition: mm.h:215
FORCEINLINE VOID MmLockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1343
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define MmSystemRangeStart
Definition: mm.h:25
ULONG Flags
Definition: mm.h:212
union gl_dlist_node Node
Definition: dlist.c:302
struct _MMADDRESS_NODE * Parent
Definition: mmtypes.h:650