16#define MODULE_INVOLVED_IN_ARM3
104#define ASSERT_LOCKED_FOR_READ(Table) MiDbgAssertIsLockedForRead(Table)
105#define ASSERT_LOCKED_FOR_WRITE(Table) MiDbgAssertIsLockedForWrite(Table)
109#define ASSERT_LOCKED_FOR_READ(Table)
110#define ASSERT_LOCKED_FOR_WRITE(Table)
127 if (!FoundVad)
return NULL;
137 if (SearchResult != TableFoundNode)
return NULL;
144 Table->NodeHint = FoundVad;
160 if (
Table->NumberGenericTableElements == 0)
return TableEmptyTree;
167 ParentNode = CurrentNode;
175 else if (EndVpn < CurrentNode->StartingVpn)
183 *NodeOrParent = ParentNode;
184 return TableFoundNode;
189 *NodeOrParent = ParentNode;
192 return TableInsertAsRight;
196 return TableInsertAsLeft;
226 if (AllocatedBase ==
NULL)
268 ASSERT(Vad->EndingVpn >= Vad->StartingVpn);
269 VadRoot->NodeHint = Vad;
290 ULONG_PTR StartingAddress, EndingAddress;
307 DPRINT1(
"The process is dying\n");
339 EndingAddress = StartingAddress +
ViewSize - 1;
342 if ((
Result == TableFoundNode) || (EndingAddress > HighestAddress))
344 DPRINT1(
"Not enough free space to insert this VAD node!\n");
349 ASSERT(StartingAddress != 0);
351 ASSERT(EndingAddress > StartingAddress);
357 EndingAddress = StartingAddress +
ViewSize - 1;
364 if (
Result == TableFoundNode)
366 DPRINT(
"Given address conflicts with existing node\n");
373 Vad->StartingVpn = StartingAddress >>
PAGE_SHIFT;
377 if ((Vad->u.VadFlags.PrivateMemory && Vad->u.VadFlags.MemCommit) ||
378 (!Vad->u.VadFlags.PrivateMemory &&
386 if (Vad->u2.VadFlags2.OneSecured)
389 ASSERT(Vad->u2.VadFlags2.LongVad);
392 ((
PMMVAD_LONG)Vad)->u3.Secured.StartVpn = StartingAddress;
393 ((
PMMVAD_LONG)Vad)->u3.Secured.EndVpn = EndingAddress;
427 ASSERT(Section->Address.EndingVpn >= Section->Address.StartingVpn);
451 Table->NumberGenericTableElements--;
458 else Table->NodeHint =
Table->BalancedRoot.RightChild;
591 ULONG_PTR PageCount, AlignmentVpn, LowVpn, HighestVpn;
602 if (
Table->Unused == 1)
608 if (
Table->NumberGenericTableElements == 0)
612 return TableEmptyTree;
624 if (
Node->StartingVpn >= LowVpn + PageCount)
634 return TableInsertAsLeft;
644 *PreviousVad = PreviousNode;
645 return TableInsertAsRight;
650 if (
Node->EndingVpn >= LowVpn)
662 if (
Table->Unused == 1)
667 if (HighestVpn >= LowVpn + PageCount)
670 *PreviousVad = PreviousNode;
672 return TableInsertAsRight;
676 return TableFoundNode;
705 if (
Table->Unused == 1)
715 if ((LowVpn +
Length) > (BoundaryAddress + 1))
717 return TableFoundNode;
721 if (
Table->NumberGenericTableElements == 0)
725 return TableEmptyTree;
729 HighVpn = (BoundaryAddress + 1) >>
PAGE_SHIFT;
734 while ((
Node->EndingVpn < HighVpn) &&
744 if ((HighVpn > LowVpn) && ((HighVpn - LowVpn) >= PageCount))
755 return TableInsertAsRight;
768 return TableInsertAsLeft;
773 if (
Node->StartingVpn < HighVpn) HighVpn =
Node->StartingVpn;
782 if ((HighVpn > LowVpn) && ((HighVpn - LowVpn) >= PageCount))
788 return TableInsertAsLeft;
794 return TableFoundNode;
821 if (
Table->NumberGenericTableElements == 0)
834 if ((LowVpn < BoundaryAddress) && (
Length <= (BoundaryAddress - LowVpn)))
836#if (NTDDI_VERSION >= NTDDI_VISTA)
853 if (!LowestNode)
break;
858 (LowVpn < Node->StartingVpn) &&
862 if (BoundaryAddress < Node->StartingVpn)
885 if (BoundaryAddress < Node->StartingVpn)
912 EndAddress = StartAddress +
Size - 1;
918 if ((Vad->u.VadFlags.NoChange == 1) &&
919 (Vad->u2.VadFlags2.SecNoChange == 1) &&
920 (Vad->u.VadFlags.Protection != ProtectionMask))
923 DPRINT1(
"Trying to mess with a no-change VAD!\n");
934 ASSERT(Vad->u2.VadFlags2.MultipleSecured == 0);
937 if (Vad->u2.VadFlags2.OneSecured)
940 if ((StartAddress <= ((
PMMVAD_LONG)Vad)->
u3.Secured.EndVpn) &&
941 (EndAddress >= ((
PMMVAD_LONG)Vad)->u3.Secured.StartVpn))
946 DPRINT1(
"Not allowed to change protection on guard page!\n");
956 DPRINT1(
"Invalid protection mask for RW access!\n");
#define ALIGN_DOWN_BY(size, align)
#define ALIGN_UP_BY(size, align)
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
#define MM_LOWEST_USER_ADDRESS
#define NT_SUCCESS(StatCode)
#define PsGetCurrentThread()
#define ROUND_UP(n, align)
#define ROUND_DOWN(n, align)
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
#define KeGetCurrentThread
KGUARDED_MUTEX MmSectionBasedMutex
#define MI_LOWEST_VAD_ADDRESS
#define MM_READ_WRITE_ALLOWED
#define MM_NO_ACCESS_ALLOWED
FORCEINLINE VOID MiUnlockProcessWorkingSetUnsafe(IN PEPROCESS Process, IN PETHREAD Thread)
#define MM_READ_ONLY_ALLOWED
FORCEINLINE BOOLEAN MI_WS_OWNER(IN PEPROCESS Process)
MM_AVL_TABLE MmSectionBasedRoot
FORCEINLINE VOID MiLockProcessWorkingSetUnsafe(IN PEPROCESS Process, IN PETHREAD Thread)
#define RtlpFindAvlTableNodeOrParent
#define RtlIsRightChildAvl
#define RtlpInsertAvlTreeNode
#define RtlIsLeftChildAvl
#define RtlpDeleteAvlTreeNode
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
_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 AllocationType
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
struct _MMVAD_LONG * PMMVAD_LONG
_In_ PMEMORY_AREA MemoryArea
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define MM_HIGHEST_VAD_ADDRESS
#define MmSystemRangeStart
NTSTATUS NTAPI MmCreateMemoryArea(PMMSUPPORT AddressSpace, ULONG Type, PVOID *BaseAddress, SIZE_T Length, ULONG Protection, PMEMORY_AREA *Result, ULONG AllocationFlags, ULONG AllocationGranularity)
NTSTATUS NTAPI MmFreeMemoryArea(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_FREE_PAGE_FUNC FreePage, PVOID FreePageContext)
#define MEMORY_AREA_OWNED_BY_ARM3
struct _MEMORY_AREA * PMEMORY_AREA
#define STATUS_PROCESS_IS_TERMINATING
#define STATUS_CONFLICTING_ADDRESSES
#define STATUS_INVALID_PAGE_PROTECTION
EX_PUSH_LOCK AddressCreationLock
union _MMVAD_LONG::@2623 u2
union _MMVAD_LONG::@2625 u4
PCONTROL_AREA ControlArea
union _MMVAD_LONG::@2622 u
#define CONTAINING_RECORD(address, type, field)
PMMVAD NTAPI MiLocateAddress(IN PVOID VirtualAddress)
VOID NTAPI MiInsertBasedSection(IN PSECTION Section)
VOID NTAPI MiRemoveNode(IN PMMADDRESS_NODE Node, IN PMM_AVL_TABLE Table)
MM_AVL_TABLE MiRosKernelVadRoot
NTSTATUS NTAPI MiFindEmptyAddressRangeDownBasedTree(IN SIZE_T Length, IN ULONG_PTR BoundaryAddress, IN ULONG_PTR Alignment, IN PMM_AVL_TABLE Table, OUT PULONG_PTR Base)
VOID NTAPI MiInsertVad(IN PMMVAD Vad, IN PMM_AVL_TABLE VadRoot)
PMMADDRESS_NODE NTAPI MiGetPreviousNode(IN PMMADDRESS_NODE Node)
VOID NTAPI MiInsertNode(IN PMM_AVL_TABLE Table, IN PMMADDRESS_NODE NewNode, IN PMMADDRESS_NODE Parent, IN TABLE_SEARCH_RESULT Result)
#define ASSERT_LOCKED_FOR_READ(Table)
NTSTATUS NTAPI MiInsertVadEx(_Inout_ PMMVAD Vad, _In_ ULONG_PTR *BaseAddress, _In_ SIZE_T ViewSize, _In_ ULONG_PTR HighestAddress, _In_ ULONG_PTR Alignment, _In_ ULONG AllocationType)
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)
NTSTATUS NTAPI MiCheckSecuredVad(IN PMMVAD Vad, IN PVOID Base, IN SIZE_T Size, IN ULONG ProtectionMask)
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)
#define ASSERT_LOCKED_FOR_WRITE(Table)
TABLE_SEARCH_RESULT NTAPI MiCheckForConflictingNode(IN ULONG_PTR StartVpn, IN ULONG_PTR EndVpn, IN PMM_AVL_TABLE Table, OUT PMMADDRESS_NODE *NodeOrParent)
PMMADDRESS_NODE NTAPI MiGetNextNode(IN PMMADDRESS_NODE Node)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
_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
#define ROUND_TO_PAGES(Size)
#define BYTES_TO_PAGES(Size)
#define PsGetCurrentProcess