ReactOS 0.4.16-dev-1067-ge98bba2
marea.c File Reference
#include <ntoskrnl.h>
#include <cache/section/newmm.h>
#include <debug.h>
#include "ARM3/miarm.h"
Include dependency graph for marea.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

PMEMORY_AREA NTAPI MmLocateMemoryAreaByAddress (PMMSUPPORT AddressSpace, PVOID Address)
 
PMEMORY_AREA NTAPI MmLocateMemoryAreaByRegion (PMMSUPPORT AddressSpace, PVOID Address_, ULONG_PTR Length)
 
BOOLEAN NTAPI MmIsAddressRangeFree (_In_ PMMSUPPORT AddressSpace, _In_ PVOID Address, _In_ ULONG_PTR Length)
 
VOID NTAPI MiInsertVad (IN PMMVAD Vad, IN PMM_AVL_TABLE VadRoot)
 
ULONG NTAPI MiMakeProtectionMask (IN ULONG Protect)
 
static VOID MmInsertMemoryArea (PMMSUPPORT AddressSpace, PMEMORY_AREA marea, ULONG Protect)
 
PVOID NTAPI MmFindGap (PMMSUPPORT AddressSpace, ULONG_PTR Length, ULONG_PTR Granularity, BOOLEAN TopDown)
 
VOID NTAPI MiRemoveNode (IN PMMADDRESS_NODE Node, IN PMM_AVL_TABLE Table)
 
MmFreeMemoryArea

Free an existing memory area.

Parameters
AddressSpaceAddress space to free the area from.
MemoryAreaMemory area we're about to free.
FreePageCallback function for each freed page.
FreePageContextContext passed to the callback function.
Returns
Status
Remarks
Lock the address space before calling this function.
NTSTATUS NTAPI MmFreeMemoryArea (PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_FREE_PAGE_FUNC FreePage, PVOID FreePageContext)
 
MmCreateMemoryArea

Create a memory area.

Parameters
AddressSpaceAddress space to create the area in.
TypeType of the memory area.
BaseAddressBase address for the memory area we're about the create. On input it contains either 0 (auto-assign address) or preferred address. On output it contains the starting address of the newly created area.
LengthLength of the area to allocate.
AttributesProtection attributes for the memory area.
ResultReceives a pointer to the memory area on successful exit.
Returns
Status
Remarks
Lock the address space before calling this function.
NTSTATUS NTAPI MmCreateMemoryArea (PMMSUPPORT AddressSpace, ULONG Type, PVOID *BaseAddress, ULONG_PTR Length, ULONG Protect, PMEMORY_AREA *Result, ULONG AllocationFlags, ULONG Granularity)
 
VOID NTAPI MiRosCleanupMemoryArea (PEPROCESS Process, PMMVAD Vad)
 

Variables

MEMORY_AREA MiStaticMemoryAreas [MI_STATIC_MEMORY_AREAS]
 
ULONG MiStaticMemoryAreaCount
 
MM_AVL_TABLE MiRosKernelVadRoot
 
BOOLEAN MiRosKernelVadRootInitialized
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 45 of file marea.c.

Function Documentation

◆ MiInsertVad()

VOID NTAPI MiInsertVad ( IN PMMVAD  Vad,
IN PMM_AVL_TABLE  VadRoot 
)

Definition at line 222 of file vadnode.c.

224{
227
229
230 /* Validate the VAD and set it as the current hint */
231 ASSERT(Vad->EndingVpn >= Vad->StartingVpn);
232 VadRoot->NodeHint = Vad;
233
234 /* Find the parent VAD and where this child should be inserted */
235 Result = RtlpFindAvlTableNodeOrParent(VadRoot, (PVOID)Vad->StartingVpn, &Parent);
236 ASSERT(Result != TableFoundNode);
237 ASSERT((Parent != NULL) || (Result == TableEmptyTree));
238
239 /* Do the actual insert operation */
240 MiInsertNode(VadRoot, (PVOID)Vad, Parent, Result);
241}
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx 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:732
#define NULL
Definition: types.h:112
#define RtlpFindAvlTableNodeOrParent
Definition: miavl.h:32
#define ASSERT(a)
Definition: mode.c:44
VOID NTAPI MiInsertNode(IN PMM_AVL_TABLE Table, IN PMMADDRESS_NODE NewNode, IN PMMADDRESS_NODE Parent, IN TABLE_SEARCH_RESULT Result)
Definition: vadnode.c:209
#define ASSERT_LOCKED_FOR_WRITE(Table)
Definition: vadnode.c:110
_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:409
TABLE_SEARCH_RESULT
Definition: rtltypes.h:386

Referenced by MmInsertMemoryArea().

◆ MiMakeProtectionMask()

ULONG NTAPI MiMakeProtectionMask ( IN ULONG  Protect)

Definition at line 140 of file section.c.

141{
142 ULONG Mask1, Mask2, ProtectMask;
143
144 /* PAGE_EXECUTE_WRITECOMBINE is theoretically the maximum */
146
147 /*
148 * Windows API protection mask can be understood as two bitfields, differing
149 * by whether or not execute rights are being requested
150 */
151 Mask1 = Protect & 0xF;
152 Mask2 = (Protect >> 4) & 0xF;
153
154 /* Check which field is there */
155 if (!Mask1)
156 {
157 /* Mask2 must be there, use it to determine the PTE protection */
158 if (!Mask2) return MM_INVALID_PROTECTION;
159 ProtectMask = MmUserProtectionToMask2[Mask2];
160 }
161 else
162 {
163 /* Mask2 should not be there, use Mask1 to determine the PTE mask */
164 if (Mask2) return MM_INVALID_PROTECTION;
165 ProtectMask = MmUserProtectionToMask1[Mask1];
166 }
167
168 /* Make sure the final mask is a valid one */
169 if (ProtectMask == MM_INVALID_PROTECTION) return MM_INVALID_PROTECTION;
170
171 /* Check for PAGE_GUARD option */
172 if (Protect & PAGE_GUARD)
173 {
174 /* It's not valid on no-access, nocache, or writecombine pages */
175 if ((ProtectMask == MM_NOACCESS) ||
177 {
178 /* Fail such requests */
180 }
181
182 /* This actually turns on guard page in this scenario! */
183 ProtectMask |= MM_GUARDPAGE;
184 }
185
186 /* Check for nocache option */
187 if (Protect & PAGE_NOCACHE)
188 {
189 /* The earlier check should've eliminated this possibility */
190 ASSERT((Protect & PAGE_GUARD) == 0);
191
192 /* Check for no-access page or write combine page */
193 if ((ProtectMask == MM_NOACCESS) || (Protect & PAGE_WRITECOMBINE))
194 {
195 /* Such a request is invalid */
197 }
198
199 /* Add the PTE flag */
200 ProtectMask |= MM_NOCACHE;
201 }
202
203 /* Check for write combine option */
205 {
206 /* The two earlier scenarios should've caught this */
208
209 /* Don't allow on no-access pages */
210 if (ProtectMask == MM_NOACCESS) return MM_INVALID_PROTECTION;
211
212 /* This actually turns on write-combine in this scenario! */
213 ProtectMask |= MM_NOACCESS;
214 }
215
216 /* Return the final MM PTE protection mask */
217 return ProtectMask;
218}
CHAR MmUserProtectionToMask1[16]
Definition: section.c:44
CHAR MmUserProtectionToMask2[16]
Definition: section.c:64
#define MM_GUARDPAGE
Definition: miarm.h:57
#define MM_NOCACHE
Definition: miarm.h:56
#define MM_INVALID_PROTECTION
Definition: miarm.h:67
#define MM_NOACCESS
Definition: miarm.h:65
#define PAGE_NOCACHE
Definition: nt_native.h:1311
#define PAGE_NOACCESS
Definition: nt_native.h:1302
#define PAGE_GUARD
Definition: nt_native.h:1310
uint32_t ULONG
Definition: typedefs.h:59
#define PAGE_WRITECOMBINE
Definition: mmtypes.h:78
_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:221

Referenced by MiIsProtectionCompatible(), MmCreateArm3Section(), MmCreateSection(), MmInsertMemoryArea(), MmMapViewOfArm3Section(), and NtMapViewOfSection().

◆ MiRemoveNode()

VOID NTAPI MiRemoveNode ( IN PMMADDRESS_NODE  Node,
IN PMM_AVL_TABLE  Table 
)

Definition at line 403 of file vadnode.c.

405{
407
408 /* Call the AVL code */
410
411 /* Decrease element count */
412 Table->NumberGenericTableElements--;
413
414 /* Check if this node was the hint */
415 if (Table->NodeHint == Node)
416 {
417 /* Get a new hint, unless we're empty now, in which case nothing */
418 if (!Table->NumberGenericTableElements) Table->NodeHint = NULL;
419 else Table->NodeHint = Table->BalancedRoot.RightChild;
420 }
421}
ASMGENDATA Table[]
Definition: genincdata.c:61
#define RtlpDeleteAvlTreeNode
Definition: miavl.h:36
Definition: dlist.c:348

Referenced by MmFreeMemoryArea().

◆ MiRosCleanupMemoryArea()

VOID NTAPI MiRosCleanupMemoryArea ( PEPROCESS  Process,
PMMVAD  Vad 
)

Definition at line 493 of file marea.c.

496{
500
501 /* We must be called from MmCleanupAddressSpace and nowhere else!
502 Make sure things are as expected... */
504 ASSERT(Process->VmDeleted == TRUE);
505 ASSERT(((PsGetCurrentThread()->ThreadsProcess == Process) &&
506 (Process->ActiveThreads == 1)) ||
507 (Process->ActiveThreads == 0));
508
511
513 {
515 }
516#ifdef NEWCC
517 else if (MemoryArea->Type == MEMORY_AREA_CACHE)
518 {
520 }
521#endif
522 else
523 {
524 /* There shouldn't be anything else! */
525 ASSERT(FALSE);
526 }
527
528 /* Make sure this worked! */
530}
LONG NTSTATUS
Definition: precomp.h:26
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI MiRosUnmapViewOfSection(_In_ PEPROCESS Process, _In_ PMEMORY_AREA MemoryArea, _In_ PVOID BaseAddress, _In_ BOOLEAN SkipDebuggerNotify)
Definition: section.c:3602
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
_In_ PMEMORY_AREA MemoryArea
Definition: newmm.h:207
NTSTATUS NTAPI MmUnmapViewOfCacheSegment(PMMSUPPORT AddressSpace, PVOID BaseAddress)
struct _MEMORY_AREA * PMEMORY_AREA
#define MA_GetStartingAddress(_MemoryArea)
Definition: mm.h:251
#define MEMORY_AREA_SECTION_VIEW
Definition: mm.h:93
ULONG Type
Definition: mm.h:258
void * PVOID
Definition: typedefs.h:50
#define PsGetCurrentProcess
Definition: psfuncs.h:17

Referenced by MmCleanProcessAddressSpace().

◆ MmCreateMemoryArea()

NTSTATUS NTAPI MmCreateMemoryArea ( PMMSUPPORT  AddressSpace,
ULONG  Type,
PVOID BaseAddress,
ULONG_PTR  Length,
ULONG  Protect,
PMEMORY_AREA Result,
ULONG  AllocationFlags,
ULONG  Granularity 
)

Definition at line 379 of file marea.c.

387{
388 ULONG_PTR tmpLength;
390 ULONG_PTR EndingAddress;
391
392 DPRINT("MmCreateMemoryArea(Type 0x%lx, BaseAddress %p, "
393 "*BaseAddress %p, Length %p, AllocationFlags %x, "
394 "Result %p)\n",
395 Type, BaseAddress, *BaseAddress, Length, AllocationFlags,
396 Result);
397
398 /* Is this a static memory area? */
400 {
401 /* Use the static array instead of the pool */
404 }
405 else
406 {
407 /* Allocate the memory area from nonpaged pool */
409 sizeof(MEMORY_AREA),
410 TAG_MAREA);
411 }
412
413 if (!MemoryArea)
414 {
415 DPRINT1("Not enough memory.\n");
416 return STATUS_NO_MEMORY;
417 }
418
420 MemoryArea->Type = Type & ~MEMORY_AREA_STATIC;
421 MemoryArea->Flags = AllocationFlags;
422 MemoryArea->Magic = 'erAM';
426 {
428 }
429
430 if (*BaseAddress == 0)
431 {
432 tmpLength = (ULONG_PTR)MM_ROUND_UP(Length, PAGE_SIZE);
434 tmpLength,
435 Granularity,
436 (AllocationFlags & MEM_TOP_DOWN) == MEM_TOP_DOWN);
437 if ((*BaseAddress) == 0)
438 {
439 DPRINT("No suitable gap\n");
441 return STATUS_NO_MEMORY;
442 }
443
447 }
448 else
449 {
450 EndingAddress = ((ULONG_PTR)*BaseAddress + Length - 1) | (PAGE_SIZE - 1);
452 tmpLength = EndingAddress + 1 - (ULONG_PTR)*BaseAddress;
453
455 {
456 ASSERT(FALSE);
459 }
460
463 {
464 DPRINT("Memory area for user mode address space exceeds MmSystemRangeStart\n");
467 }
468
469 /* No need to check ARM3 owned memory areas, the range MUST be free */
471 {
473 {
474 DPRINT("Memory area already occupied\n");
477 }
478 }
479
483 }
484
486
487 DPRINT("MmCreateMemoryArea() succeeded (%p)\n", *BaseAddress);
488 return STATUS_SUCCESS;
489}
Type
Definition: Type.h:7
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define ULONG_PTR
Definition: config.h:101
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define NonPagedPool
Definition: env_spec_w32.h:307
MEMORY_AREA MiStaticMemoryAreas[MI_STATIC_MEMORY_AREAS]
Definition: marea.c:51
ULONG MiStaticMemoryAreaCount
Definition: marea.c:52
PVOID NTAPI MmFindGap(PMMSUPPORT AddressSpace, ULONG_PTR Length, ULONG_PTR Granularity, BOOLEAN TopDown)
Definition: marea.c:190
BOOLEAN NTAPI MmIsAddressRangeFree(_In_ PMMSUPPORT AddressSpace, _In_ PVOID Address, _In_ ULONG_PTR Length)
Definition: marea.c:111
static VOID MmInsertMemoryArea(PMMSUPPORT AddressSpace, PMEMORY_AREA marea, ULONG Protect)
Definition: marea.c:144
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define MEM_TOP_DOWN
Definition: nt_native.h:1321
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define MmSystemRangeStart
Definition: mm.h:32
#define MI_STATIC_MEMORY_AREAS
Definition: mm.h:90
#define MM_ROUND_UP(x, s)
Definition: mm.h:128
#define MEMORY_AREA_STATIC
Definition: mm.h:98
#define MEMORY_AREA_OWNED_BY_ARM3
Definition: mm.h:97
FORCEINLINE PEPROCESS MmGetAddressSpaceOwner(IN PMMSUPPORT AddressSpace)
Definition: mm.h:1707
#define MI_SET_ROSMM_VAD(Vad)
Definition: mm.h:273
#define MI_SET_MEMORY_AREA_VAD(Vad)
Definition: mm.h:271
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:261
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
ULONG Flags
Definition: mm.h:259
ULONG Magic
Definition: mm.h:261
BOOLEAN DeleteInProgress
Definition: mm.h:260
MMVAD VadNode
Definition: mm.h:256
ULONG_PTR EndingVpn
Definition: mmtypes.h:730
ULONG_PTR StartingVpn
Definition: mmtypes.h:729
#define TAG_MAREA
Definition: tag.h:106
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define ALIGN_DOWN_POINTER_BY(ptr, align)
Definition: umtypes.h:82
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2274

Referenced by MiCreateArm3StaticMemoryArea(), and MmMapViewOfSegment().

◆ MmFindGap()

PVOID NTAPI MmFindGap ( PMMSUPPORT  AddressSpace,
ULONG_PTR  Length,
ULONG_PTR  Granularity,
BOOLEAN  TopDown 
)

Definition at line 190 of file marea.c.

195{
197 PMM_AVL_TABLE VadRoot;
200 ULONG_PTR StartingAddress, HighestAddress;
201
203 VadRoot = Process ? &Process->VadRoot : &MiRosKernelVadRoot;
204 if (TopDown)
205 {
206 /* Find an address top-down */
207 HighestAddress = Process ? (ULONG_PTR)MM_HIGHEST_VAD_ADDRESS : (LONG_PTR)-1;
209 HighestAddress,
210 Granularity,
211 VadRoot,
212 &StartingAddress,
213 &Parent);
214 }
215 else
216 {
218 Granularity,
219 VadRoot,
220 &Parent,
221 &StartingAddress);
222 }
223
224 if (Result == TableFoundNode)
225 {
226 return NULL;
227 }
228
229 return (PVOID)StartingAddress;
230}
MM_AVL_TABLE MiRosKernelVadRoot
Definition: marea.c:54
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:593
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:496
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define MM_HIGHEST_VAD_ADDRESS
Definition: mm.h:46

Referenced by MmCreateMemoryArea(), and MmMapViewOfSection().

◆ MmFreeMemoryArea()

NTSTATUS NTAPI MmFreeMemoryArea ( PMMSUPPORT  AddressSpace,
PMEMORY_AREA  MemoryArea,
PMM_FREE_PAGE_FUNC  FreePage,
PVOID  FreePageContext 
)

Definition at line 258 of file marea.c.

263{
265 PVOID EndAddress;
266
267 /* Make sure we own the address space lock! */
268 ASSERT(CONTAINING_RECORD(AddressSpace, EPROCESS, Vm)->AddressCreationLock.Owner == KeGetCurrentThread());
269
270 /* Check magic */
271 ASSERT(MemoryArea->Magic == 'erAM');
272
274 {
275 PEPROCESS CurrentProcess = PsGetCurrentProcess();
277
278 if ((Process != NULL) && (Process != CurrentProcess))
279 {
281 }
282
285 Address < (ULONG_PTR)EndAddress;
287 {
288 BOOLEAN Dirty = FALSE;
289 SWAPENTRY SwapEntry = 0;
290 PFN_NUMBER Page = 0;
291 BOOLEAN DoFree;
292
294 {
296 /* We'll have to do some cleanup when we're on the page file */
297 DoFree = TRUE;
298 }
299 else if (FreePage == NULL)
300 {
301 DoFree = MmDeletePhysicalMapping(Process, (PVOID)Address, &Dirty, &Page);
302 }
303 else
304 {
305 DoFree = MmDeleteVirtualMapping(Process, (PVOID)Address, &Dirty, &Page);
306 }
307 if (DoFree && (FreePage != NULL))
308 {
309 FreePage(FreePageContext, MemoryArea, (PVOID)Address,
310 Page, SwapEntry, (BOOLEAN)Dirty);
311 }
312 }
313
315 {
317#ifdef NEWCC
318 ASSERT(MemoryArea->Type == MEMORY_AREA_SECTION_VIEW || MemoryArea->Type == MEMORY_AREA_CACHE);
319#else
321#endif
322
323 /* We do not have fake ARM3 memory areas anymore. */
328 }
329 else
330 {
334 }
335
336 if ((Process != NULL) && (Process != CurrentProcess))
337 {
339 }
340 }
341
342#if DBG
343 MemoryArea->Magic = 'daeD';
344#endif
346
347 DPRINT("MmFreeMemoryArea() succeeded\n");
348
349 return STATUS_SUCCESS;
350}
ULONG_PTR PFN_NUMBER
unsigned char BOOLEAN
#define KeGetCurrentThread
Definition: hal.h:55
VOID NTAPI MiRemoveNode(IN PMMADDRESS_NODE Node, IN PMM_AVL_TABLE Table)
Definition: vadnode.c:403
FORCEINLINE VOID MiLockWorkingSet(IN PETHREAD Thread, IN PMMSUPPORT WorkingSet)
Definition: miarm.h:1278
FORCEINLINE VOID MiUnlockProcessWorkingSet(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1207
FORCEINLINE VOID MiUnlockWorkingSet(IN PETHREAD Thread, IN PMMSUPPORT WorkingSet)
Definition: miarm.h:1364
FORCEINLINE VOID MiLockProcessWorkingSet(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1137
BOOLEAN NTAPI MmIsPageSwapEntry(struct _EPROCESS *Process, PVOID Address)
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
Definition: mm.h:1297
ULONG_PTR SWAPENTRY
Definition: mm.h:57
#define MA_GetEndingAddress(_MemoryArea)
Definition: mm.h:252
VOID NTAPI MmDeletePageFileMapping(struct _EPROCESS *Process, PVOID Address, SWAPENTRY *SwapEntry)
#define MI_IS_MEMORY_AREA_VAD(Vad)
Definition: mm.h:272
MMSUPPORT MmSystemCacheWs
Definition: init.c:55
VOID NTAPI MmDeleteVirtualMapping(IN PEPROCESS Process, IN PVOID Address, OUT PBOOLEAN WasDirty, OUT PPFN_NUMBER Page)
Definition: page.c:177
static WCHAR Address[46]
Definition: ping.c:68
VOID NTAPI KeDetachProcess(VOID)
Definition: procobj.c:621
VOID NTAPI KeAttachProcess(IN PKPROCESS Process)
Definition: procobj.c:582
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
@ FreePage
Definition: ketypes.h:416

Referenced by MmUnmapViewOfSegment().

◆ MmInsertMemoryArea()

static VOID MmInsertMemoryArea ( PMMSUPPORT  AddressSpace,
PMEMORY_AREA  marea,
ULONG  Protect 
)
static

Definition at line 144 of file marea.c.

148{
150
152
153 /* Build a lame VAD if this is a user-space allocation */
155 {
156 ASSERT(Process != NULL);
157 if (marea->Type != MEMORY_AREA_OWNED_BY_ARM3)
158 {
159#ifdef NEWCC
160 ASSERT(marea->Type == MEMORY_AREA_SECTION_VIEW || marea->Type == MEMORY_AREA_CACHE);
161#else
163#endif
164
165 /* Insert the VAD */
167 MiInsertVad(&marea->VadNode, &Process->VadRoot);
169 }
170 }
171 else
172 {
173 ASSERT(Process == NULL);
174
176 {
180 }
181
182 /* Insert the VAD */
186 }
187}
VOID NTAPI MiInsertVad(IN PMMVAD Vad, IN PMM_AVL_TABLE VadRoot)
Definition: vadnode.c:222
BOOLEAN MiRosKernelVadRootInitialized
Definition: marea.c:55
ULONG NTAPI MiMakeProtectionMask(IN ULONG Protect)
Definition: section.c:140
FORCEINLINE VOID MiUnlockProcessWorkingSetUnsafe(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1252
FORCEINLINE VOID MiLockProcessWorkingSetUnsafe(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1182
union _MMADDRESS_NODE::@2709 u1
struct _MMADDRESS_NODE * Parent
Definition: mmtypes.h:649
ULONG_PTR Protection
Definition: mmtypes.h:696
union _MMVAD::@2711 u
MMVAD_FLAGS VadFlags
Definition: mmtypes.h:734
ULONG_PTR Unused
Definition: mmtypes.h:664
MMADDRESS_NODE BalancedRoot
Definition: mmtypes.h:662

Referenced by MmCreateMemoryArea().

◆ MmIsAddressRangeFree()

BOOLEAN NTAPI MmIsAddressRangeFree ( _In_ PMMSUPPORT  AddressSpace,
_In_ PVOID  Address,
_In_ ULONG_PTR  Length 
)

Definition at line 111 of file marea.c.

115{
116 ULONG_PTR StartVpn = (ULONG_PTR)Address / PAGE_SIZE;
117 ULONG_PTR EndVpn = ((ULONG_PTR)Address + Length - 1) / PAGE_SIZE;
122
124 Table = (Process != NULL) ? &Process->VadRoot : &MiRosKernelVadRoot;
125
126 Result = MiCheckForConflictingNode(StartVpn, EndVpn, Table, &Node);
127
128 return (Result != TableFoundNode);
129}
union node Node
Definition: types.h:1255
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:157

Referenced by MmCreateMemoryArea(), and MmMapViewOfSection().

◆ MmLocateMemoryAreaByAddress()

PMEMORY_AREA NTAPI MmLocateMemoryAreaByAddress ( PMMSUPPORT  AddressSpace,
PVOID  Address 
)

Definition at line 61 of file marea.c.

64{
65 /* Do it the simple way */
67}
PMEMORY_AREA NTAPI MmLocateMemoryAreaByRegion(PMMSUPPORT AddressSpace, PVOID Address_, ULONG_PTR Length)
Definition: marea.c:71

Referenced by MmAlterViewAttributes(), MmNotPresentFault(), MmpAccessFault(), MmPageOutPhysicalAddress(), MmpPageOutPhysicalAddress(), MmUnmapViewInSystemSpace(), and MmUnmapViewOfSegment().

◆ MmLocateMemoryAreaByRegion()

PMEMORY_AREA NTAPI MmLocateMemoryAreaByRegion ( PMMSUPPORT  AddressSpace,
PVOID  Address_,
ULONG_PTR  Length 
)

Definition at line 71 of file marea.c.

75{
76 ULONG_PTR StartVpn = (ULONG_PTR)Address_ / PAGE_SIZE;
77 ULONG_PTR EndVpn = ((ULONG_PTR)Address_ + Length - 1) / PAGE_SIZE;
83 PMMVAD_LONG Vad;
84
86 Table = (Process != NULL) ? &Process->VadRoot : &MiRosKernelVadRoot;
87
88 Result = MiCheckForConflictingNode(StartVpn, EndVpn, Table, &Node);
89 if (Result != TableFoundNode)
90 {
91 return NULL;
92 }
93
94 Vad = (PMMVAD_LONG)Node;
95 if (!MI_IS_MEMORY_AREA_VAD(Vad))
96 {
97 /* This is an ARM3 VAD, we don't return it. */
98 return NULL;
99 }
100 else
101 {
103 }
104
106 return MemoryArea;
107}
struct _MMVAD_LONG * PMMVAD_LONG

Referenced by MmLocateMemoryAreaByAddress().

Variable Documentation

◆ MiRosKernelVadRoot

◆ MiRosKernelVadRootInitialized

BOOLEAN MiRosKernelVadRootInitialized

Definition at line 55 of file marea.c.

Referenced by MmInsertMemoryArea().

◆ MiStaticMemoryAreaCount

ULONG MiStaticMemoryAreaCount

Definition at line 52 of file marea.c.

Referenced by MmCreateMemoryArea().

◆ MiStaticMemoryAreas

MEMORY_AREA MiStaticMemoryAreas[MI_STATIC_MEMORY_AREAS]

Definition at line 51 of file marea.c.

Referenced by MmCreateMemoryArea().