ReactOS 0.4.17-dev-684-ga6524ef
procsup.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
#include <mm/ARM3/miarm.h>
Include dependency graph for procsup.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define MODULE_INVOLVED_IN_ARM3
 

Functions

NTSTATUS NTAPI MiCreatePebOrTeb (IN PEPROCESS Process, IN ULONG Size, OUT PULONG_PTR BaseAddress)
 
VOID NTAPI MmDeleteTeb (IN PEPROCESS Process, IN PTEB Teb)
 
VOID NTAPI MmDeleteKernelStack (IN PVOID StackBase, IN BOOLEAN GuiStack)
 
PVOID NTAPI MmCreateKernelStack (IN BOOLEAN GuiStack, IN UCHAR Node)
 
NTSTATUS NTAPI MmGrowKernelStackEx (IN PVOID StackPointer, IN ULONG GrowSize)
 
NTSTATUS NTAPI MmGrowKernelStack (IN PVOID StackPointer)
 
NTSTATUS NTAPI MmSetMemoryPriorityProcess (IN PEPROCESS Process, IN UCHAR MemoryPriority)
 
NTSTATUS NTAPI MmCreatePeb (IN PEPROCESS Process, IN PINITIAL_PEB InitialPeb, OUT PPEB *BasePeb)
 
NTSTATUS NTAPI MmCreateTeb (IN PEPROCESS Process, IN PCLIENT_ID ClientId, IN PINITIAL_TEB InitialTeb, OUT PTEB *BaseTeb)
 
NTSTATUS NTAPI MmInitializeProcessAddressSpace (IN PEPROCESS Process, IN PEPROCESS ProcessClone OPTIONAL, IN PVOID Section OPTIONAL, IN OUT PULONG Flags, IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL)
 
NTSTATUS NTAPI MmInitializeHandBuiltProcess (IN PEPROCESS Process, IN PULONG_PTR DirectoryTableBase)
 
NTSTATUS NTAPI MmInitializeHandBuiltProcess2 (IN PEPROCESS Process)
 
BOOLEAN NTAPI MmCreateProcessAddressSpace (IN ULONG MinWs, IN PEPROCESS Process, OUT PULONG_PTR DirectoryTableBase)
 
VOID NTAPI MmCleanProcessAddressSpace (IN PEPROCESS Process)
 
VOID NTAPI MmDeleteProcessAddressSpace (IN PEPROCESS Process)
 
NTSTATUS NTAPI NtAllocateUserPhysicalPages (IN HANDLE ProcessHandle, IN OUT PULONG_PTR NumberOfPages, IN OUT PULONG_PTR UserPfnArray)
 
NTSTATUS NTAPI NtMapUserPhysicalPages (IN PVOID VirtualAddresses, IN ULONG_PTR NumberOfPages, IN OUT PULONG_PTR UserPfnArray)
 
NTSTATUS NTAPI NtMapUserPhysicalPagesScatter (IN PVOID *VirtualAddresses, IN ULONG_PTR NumberOfPages, IN OUT PULONG_PTR UserPfnArray)
 
NTSTATUS NTAPI NtFreeUserPhysicalPages (IN HANDLE ProcessHandle, IN OUT PULONG_PTR NumberOfPages, IN OUT PULONG_PTR UserPfnArray)
 

Variables

ULONG MmProcessColorSeed = 0x12345678
 
ULONG MmMaximumDeadKernelStacks = 5
 
SLIST_HEADER MmDeadStackSListHead
 
ULONG MmRotatingUniprocessorNumber = 0
 

Macro Definition Documentation

◆ MODULE_INVOLVED_IN_ARM3

#define MODULE_INVOLVED_IN_ARM3

Definition at line 15 of file procsup.c.

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file procsup.c.

Function Documentation

◆ MiCreatePebOrTeb()

NTSTATUS NTAPI MiCreatePebOrTeb ( IN PEPROCESS  Process,
IN ULONG  Size,
OUT PULONG_PTR  BaseAddress 
)

Definition at line 29 of file procsup.c.

32{
33 PMMVAD_LONG Vad;
35 ULONG_PTR HighestAddress, RandomBase;
36 ULONG AlignedSize;
37 LARGE_INTEGER CurrentTime;
38#if defined(_WIN64) && defined(BUILD_WOW64_ENABLED)
40#endif
41 BOOLEAN IsPeb;
42
43 C_ASSERT(sizeof(TEB) != sizeof(PEB));
44 IsPeb = (Size == sizeof(PEB));
45
47 if (!NT_SUCCESS(Status))
48 return Status;
49
50 /* Allocate a VAD */
51 Vad = ExAllocatePoolWithTag(NonPagedPool, sizeof(MMVAD_LONG), 'ldaV');
52 if (!Vad)
53 {
55 goto FailPath;
56 }
57
58 /* Setup the primary flags with the size, and make it commited, private, RW */
59 Vad->u.LongFlags = 0;
61 Vad->u.VadFlags.MemCommit = TRUE;
64 Vad->u.VadFlags.NoChange = TRUE;
65 Vad->u1.Parent = NULL;
66
67 /* Setup the secondary flags to make it a secured, writable, long VAD */
68 Vad->u2.LongFlags2 = 0;
70 Vad->u2.VadFlags2.LongVad = TRUE;
72
73 Vad->ControlArea = NULL; // For Memory-Area hack
75
76 HighestAddress = (ULONG_PTR)MM_HIGHEST_VAD_ADDRESS;
77
78#if defined(_WIN64) && defined(BUILD_WOW64_ENABLED)
79 IsWow64 = FALSE;
80
81 if (Process->SectionBaseAddress != NULL)
82 {
83 PIMAGE_NT_HEADERS NtHeader = RtlImageNtHeader(Process->SectionBaseAddress);
84
85 if (NtHeader != NULL && NtHeader->FileHeader.Machine != IMAGE_FILE_MACHINE_AMD64)
86 {
87 IsWow64 = TRUE;
88 }
89 }
90
91 if (IsWow64)
92 {
93 /* Make sure the structure resides in the 32-bit address space */
94 HighestAddress = MM_HIGHEST_USER_ADDRESS_WOW64;
95 }
96#endif
97
98 /* Check if this is a PEB creation */
99 if (IsPeb)
100 {
101#if defined(_WIN64) && defined(BUILD_WOW64_ENABLED)
102 /* If this is a WOW64 process, allocate enough space for the 32 bit PEB */
103 if (IsWow64)
104 {
106 }
107#endif
108
109 /* Create a random value to select one page in a 64k region */
110 KeQueryTickCount(&CurrentTime);
111 CurrentTime.LowPart &= (_64K / PAGE_SIZE) - 1;
112
113 /* Calculate a random base address */
114 RandomBase = HighestAddress + 1;
115 RandomBase -= CurrentTime.LowPart << PAGE_SHIFT;
116
117 /* Make sure the base address is not too high */
118 AlignedSize = ROUND_TO_PAGES(Size);
119 if ((RandomBase + AlignedSize) > HighestAddress + 1)
120 {
121 RandomBase = HighestAddress + 1 - AlignedSize;
122 }
123
124 /* Calculate the highest allowed address */
125 HighestAddress = RandomBase + AlignedSize - 1;
126 }
127 else
128 {
129#if defined(_WIN64) && defined(BUILD_WOW64_ENABLED)
130 /* If this is a WOW64 process, allocate enough space for the 32 bit TEB */
131 if (IsWow64)
132 {
134 }
135#endif
136 }
137
138 *BaseAddress = 0;
141 Size,
142 HighestAddress,
143 PAGE_SIZE,
145 if (!NT_SUCCESS(Status))
146 {
147 ExFreePoolWithTag(Vad, 'ldaV');
149 goto FailPath;
150 }
151
152#if defined(_WIN64) && defined(BUILD_WOW64_ENABLED)
153 if (IsPeb && IsWow64)
154 {
155 Process->Wow64Process = UlongToPtr(1);
156 }
157#endif
158
159 /* Success */
160 return STATUS_SUCCESS;
161
162FailPath:
164
165 return Status;
166}
#define IsWow64()
Definition: NtReadFile.c:37
unsigned char BOOLEAN
Definition: actypes.h:127
LONG NTSTATUS
Definition: precomp.h:26
#define MM_READWRITE
Definition: bootanim.c:19
struct _PEB PEB
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define RtlImageNtHeader
Definition: compat.h:806
#define UlongToPtr(u)
Definition: config.h:106
#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
_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:24
#define C_ASSERT(e)
Definition: intsafe.h:73
#define _64K
Definition: miarm.h:23
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)
Definition: vadnode.c:245
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID * BaseAddress
Definition: mmfuncs.h:408
#define MEM_TOP_DOWN
Definition: nt_native.h:1324
#define IMAGE_FILE_MACHINE_AMD64
Definition: ntimage.h:17
#define MM_HIGHEST_USER_ADDRESS_WOW64
Definition: mm.h:35
#define MM_HIGHEST_VAD_ADDRESS
Definition: mm.h:46
NTSTATUS NTAPI PsChargeProcessNonPagedPoolQuota(_In_ PEPROCESS Process, _In_ SIZE_T Amount)
Charges the non paged pool quota of a given process.
Definition: quota.c:811
VOID NTAPI PsReturnProcessNonPagedPoolQuota(_In_ PEPROCESS Process, _In_ SIZE_T Amount)
Returns the non paged quota pool that the process was taking up.
Definition: quota.c:938
#define KeQueryTickCount(CurrentCount)
Definition: ke.h:43
#define STATUS_SUCCESS
Definition: shellext.h:65
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
ULONG ReadOnly
Definition: mmtypes.h:710
ULONG OneSecured
Definition: mmtypes.h:708
ULONG LongVad
Definition: mmtypes.h:711
ULONG_PTR NoChange
Definition: mmtypes.h:693
ULONG_PTR MemCommit
Definition: mmtypes.h:695
ULONG_PTR Protection
Definition: mmtypes.h:696
ULONG_PTR CommitCharge
Definition: mmtypes.h:691
ULONG_PTR PrivateMemory
Definition: mmtypes.h:698
PMMPTE FirstPrototypePte
Definition: mmtypes.h:766
MMVAD_FLAGS VadFlags
Definition: mmtypes.h:763
union _MMVAD_LONG::@2882 u1
ULONG_PTR LongFlags
Definition: mmtypes.h:762
union _MMVAD_LONG::@2884 u2
PCONTROL_AREA ControlArea
Definition: mmtypes.h:765
PMMVAD Parent
Definition: mmtypes.h:754
ULONG LongFlags2
Definition: mmtypes.h:770
MMVAD_FLAGS2 VadFlags2
Definition: mmtypes.h:771
union _MMVAD_LONG::@2883 u
Definition: compat.h:836
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
ULONG LowPart
Definition: typedefs.h:106
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
#define ROUND_TO_PAGES(Size)
#define BYTES_TO_PAGES(Size)

Referenced by MmCreatePeb(), and MmCreateTeb().

◆ MmCleanProcessAddressSpace()

VOID NTAPI MmCleanProcessAddressSpace ( IN PEPROCESS  Process)

Definition at line 1319 of file procsup.c.

1320{
1321 PMMVAD Vad;
1322 PMM_AVL_TABLE VadTree;
1324
1325 /* Remove from the session */
1327
1328 /* Abort early, when the address space wasn't fully initialized */
1329 if (Process->AddressSpaceInitialized < 2)
1330 {
1331 DPRINT1("Incomplete address space for Process %p. Might leak resources.\n",
1332 Process);
1333 return;
1334 }
1335
1336 /* Lock the process address space from changes */
1339
1340 /* VM is deleted now */
1341 Process->VmDeleted = TRUE;
1343
1344 /* Enumerate the VADs */
1345 VadTree = &Process->VadRoot;
1346 while (VadTree->NumberGenericTableElements)
1347 {
1348 /* Grab the current VAD */
1349 Vad = (PMMVAD)VadTree->BalancedRoot.RightChild;
1350
1351 /* Check for old-style memory areas */
1353 {
1354 /* We do not expect ARM3 memory areas here, those are kernel only */
1355 ASSERT(MI_IS_ROSMM_VAD(Vad));
1356
1357 /* Let RosMm handle this */
1359 continue;
1360 }
1361
1362 /* Lock the working set */
1364
1365 /* Remove this VAD from the tree */
1366 ASSERT(VadTree->NumberGenericTableElements >= 1);
1367 MiRemoveNode((PMMADDRESS_NODE)Vad, VadTree);
1368
1369 /* Only regular VADs supported for now */
1370 ASSERT(Vad->u.VadFlags.VadType == VadNone);
1371
1372 /* Check if this is a section VAD */
1373 if (!(Vad->u.VadFlags.PrivateMemory) && (Vad->ControlArea))
1374 {
1375 /* Remove the view */
1377 }
1378 else
1379 {
1380 /* Delete the addresses */
1382 (Vad->EndingVpn << PAGE_SHIFT) | (PAGE_SIZE - 1),
1383 Vad);
1384
1385 /* Release the working set */
1387 }
1388
1389 /* Free the VAD memory */
1390 ExFreePool(Vad);
1391
1392 /* Return the quota the VAD used */
1394 }
1395
1396 /* Lock the working set */
1398 ASSERT(Process->CloneRoot == NULL);
1399 ASSERT(Process->PhysicalVadRoot == NULL);
1400
1401 /* Delete the shared user data section */
1403
1404 /* Release the working set */
1406
1407 /* Release the address space */
1409}
#define DPRINT1
Definition: precomp.h:8
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
if(dx< 0)
Definition: linetemp.h:194
VOID NTAPI MiRemoveNode(IN PMMADDRESS_NODE Node, IN PMM_AVL_TABLE Table)
Definition: vadnode.c:403
VOID NTAPI MiRemoveMappedView(IN PEPROCESS CurrentProcess, IN PMMVAD Vad)
Definition: section.c:768
FORCEINLINE VOID MiUnlockProcessWorkingSetUnsafe(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1246
VOID NTAPI MiSessionRemoveProcess(VOID)
Definition: session.c:392
VOID NTAPI MiDeleteVirtualAddresses(_In_ ULONG_PTR Va, _In_ ULONG_PTR EndingAddress, _In_opt_ PMMVAD Vad)
Definition: virtual.c:530
FORCEINLINE VOID MiLockProcessWorkingSetUnsafe(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1176
#define ASSERT(a)
Definition: mode.c:44
#define USER_SHARED_DATA
Definition: ketypes.h:165
@ VadNone
Definition: mmtypes.h:204
struct _MMVAD * PMMVAD
FORCEINLINE VOID MmLockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1695
VOID NTAPI MiRosCleanupMemoryArea(PEPROCESS Process, PMMVAD Vad)
Definition: marea.c:493
FORCEINLINE VOID MmUnlockAddressSpace(PMMSUPPORT AddressSpace)
Definition: mm.h:1708
#define MI_IS_MEMORY_AREA_VAD(Vad)
Definition: mm.h:271
#define MI_IS_ROSMM_VAD(Vad)
Definition: mm.h:273
struct _MMADDRESS_NODE * RightChild
Definition: mmtypes.h:652
ULONG_PTR VadType
Definition: mmtypes.h:694
ULONG_PTR EndingVpn
Definition: mmtypes.h:730
union _MMVAD::@2880 u
PCONTROL_AREA ControlArea
Definition: mmtypes.h:736
ULONG_PTR StartingVpn
Definition: mmtypes.h:729
MMVAD_FLAGS VadFlags
Definition: mmtypes.h:734
ULONG_PTR NumberGenericTableElements
Definition: mmtypes.h:668
MMADDRESS_NODE BalancedRoot
Definition: mmtypes.h:662

Referenced by PspExitProcess(), and PspExitThread().

◆ MmCreateKernelStack()

PVOID NTAPI MmCreateKernelStack ( IN BOOLEAN  GuiStack,
IN UCHAR  Node 
)

Definition at line 332 of file procsup.c.

334{
335 PFN_COUNT StackPtes, StackPages;
336 PMMPTE PointerPte, StackPte;
338 MMPTE TempPte, InvalidPte;
340 PFN_NUMBER PageFrameIndex;
341 ULONG i;
342 PSLIST_ENTRY SListEntry;
343
344 //
345 // Calculate pages needed
346 //
347 if (GuiStack)
348 {
349 //
350 // We'll allocate 64KB stack, but only commit 12K
351 //
352 StackPtes = BYTES_TO_PAGES(MmLargeStackSize);
354 }
355 else
356 {
357 //
358 // If the dead stack S-LIST has a stack on it, use it instead of allocating
359 // new system PTEs for this stack
360 //
362 {
364 if (SListEntry != NULL)
365 {
366 BaseAddress = (SListEntry + 1);
367 return BaseAddress;
368 }
369 }
370
371 //
372 // We'll allocate 12K and that's it
373 //
375 StackPages = StackPtes;
376 }
377
378 //
379 // Reserve stack pages, plus a guard page
380 //
381 StackPte = MiReserveSystemPtes(StackPtes + 1, SystemPteSpace);
382 if (!StackPte) return NULL;
383
384 //
385 // Get the stack address
386 //
387 BaseAddress = MiPteToAddress(StackPte + StackPtes + 1);
388
389 //
390 // Select the right PTE address where we actually start committing pages
391 //
392 PointerPte = StackPte;
393 if (GuiStack) PointerPte += BYTES_TO_PAGES(MmLargeStackSize -
395
396
397 /* Setup the temporary invalid PTE */
398 MI_MAKE_SOFTWARE_PTE(&InvalidPte, MM_NOACCESS);
399
400 /* Setup the template stack PTE */
402
403 //
404 // Acquire the PFN DB lock
405 //
406 OldIrql = MiAcquirePfnLock();
407
408 //
409 // Loop each stack page
410 //
411 for (i = 0; i < StackPages; i++)
412 {
413 //
414 // Next PTE
415 //
416 PointerPte++;
417
418 /* Get a page and write the current invalid PTE */
420 MI_SET_PROCESS2(PsGetCurrentProcess()->ImageFileName);
421 PageFrameIndex = MiRemoveAnyPage(MI_GET_NEXT_COLOR());
422 MI_WRITE_INVALID_PTE(PointerPte, InvalidPte);
423
424 /* Initialize the PFN entry for this page */
425 MiInitializePfn(PageFrameIndex, PointerPte, 1);
426
427 /* Write the valid PTE */
428 TempPte.u.Hard.PageFrameNumber = PageFrameIndex;
429 MI_WRITE_VALID_PTE(PointerPte, TempPte);
430 }
431
432 //
433 // Release the PFN lock
434 //
435 MiReleasePfnLock(OldIrql);
436
437 //
438 // Return the stack address
439 //
440 return BaseAddress;
441}
ULONG_PTR PFN_NUMBER
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:76
UCHAR KIRQL
Definition: env_spec_w32.h:591
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
@ SystemPteSpace
Definition: miarm.h:407
#define MI_GET_NEXT_COLOR()
Definition: miarm.h:236
PFN_NUMBER NTAPI MiRemoveAnyPage(IN ULONG Color)
Definition: pfnlist.c:477
#define MI_MAKE_SOFTWARE_PTE(p, x)
Definition: miarm.h:203
FORCEINLINE VOID MI_MAKE_HARDWARE_PTE_KERNEL(IN PMMPTE NewPte, IN PMMPTE MappingPte, IN ULONG_PTR ProtectionMask, IN PFN_NUMBER PageFrameNumber)
Definition: miarm.h:778
FORCEINLINE VOID MI_WRITE_INVALID_PTE(IN PMMPTE PointerPte, IN MMPTE InvalidPte)
Definition: miarm.h:1000
PMMPTE NTAPI MiReserveSystemPtes(IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
Definition: syspte.c:246
#define MM_NOACCESS
Definition: miarm.h:65
ULONG MmLargeStackSize
Definition: mminit.c:263
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:967
VOID NTAPI MiInitializePfn(IN PFN_NUMBER PageFrameIndex, IN PMMPTE PointerPte, IN BOOLEAN Modified)
Definition: pfnlist.c:970
#define MiPteToAddress(_Pte)
Definition: mm.h:116
#define MI_SET_PROCESS2(x)
Definition: mm.h:329
@ MI_USAGE_KERNEL_STACK
Definition: mm.h:338
#define MI_SET_USAGE(x)
Definition: mm.h:327
SLIST_HEADER MmDeadStackSListHead
Definition: procsup.c:22
#define KERNEL_STACK_SIZE
#define KERNEL_LARGE_STACK_COMMIT
ULONG PageFrameNumber
Definition: mmtypes.h:109
FORCEINLINE USHORT ExQueryDepthSList(_In_ PSLIST_HEADER SListHead)
Definition: exfuncs.h:153
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
ULONG PFN_COUNT
Definition: mmtypes.h:102
#define PsGetCurrentProcess
Definition: psfuncs.h:17
#define InterlockedPopEntrySList(SListHead)
Definition: rtlfuncs.h:3409
#define PSLIST_ENTRY
Definition: rtltypes.h:134

◆ MmCreatePeb()

NTSTATUS NTAPI MmCreatePeb ( IN PEPROCESS  Process,
IN PINITIAL_PEB  InitialPeb,
OUT PPEB BasePeb 
)

Definition at line 574 of file procsup.c.

577{
578 PPEB Peb = NULL;
580 SIZE_T ViewSize = 0;
581 PVOID TableBase = NULL;
582 PIMAGE_NT_HEADERS NtHeaders;
583 PIMAGE_LOAD_CONFIG_DIRECTORY ImageConfigData;
585 USHORT Characteristics;
586 SectionOffset.QuadPart = (ULONGLONG)0;
587 *BasePeb = NULL;
588
589 //
590 // Attach to Process
591 //
593
594 //
595 // Map NLS Tables
596 //
599 &TableBase,
600 0,
601 0,
603 &ViewSize,
604 ViewShare,
607 DPRINT("NLS Tables at: %p\n", TableBase);
608 if (!NT_SUCCESS(Status))
609 {
610 /* Cleanup and exit */
612 return Status;
613 }
614
615 //
616 // Allocate the PEB
617 //
619 DPRINT("PEB at: %p\n", Peb);
620 if (!NT_SUCCESS(Status))
621 {
622 /* Cleanup and exit */
624 return Status;
625 }
626
627 //
628 // Use SEH in case we can't load the PEB
629 //
631 {
632 //
633 // Initialize the PEB
634 //
635 RtlZeroMemory(Peb, sizeof(PEB));
636
637 //
638 // Set up data
639 //
640 Peb->ImageBaseAddress = Process->SectionBaseAddress;
641 Peb->InheritedAddressSpace = InitialPeb->InheritedAddressSpace;
642 Peb->Mutant = InitialPeb->Mutant;
643 Peb->ImageUsesLargePages = InitialPeb->ImageUsesLargePages;
644
645 //
646 // NLS
647 //
651
652 //
653 // Default Version Data (could get changed below)
654 //
657 Peb->OSBuildNumber = (USHORT)(NtBuildNumber & 0x3FFF);
659 Peb->OSCSDVersion = (USHORT)CmNtCSDVersion;
660
661 //
662 // Heap and Debug Data
663 //
666 Peb->BeingDebugged = (BOOLEAN)(Process->DebugPort != NULL);
674 Peb->MaximumNumberOfHeaps = (PAGE_SIZE - sizeof(PEB)) / sizeof(PVOID);
675 Peb->ProcessHeaps = (PVOID*)(Peb + 1);
676
677 //
678 // Session ID
679 //
680 if (Process->Session) Peb->SessionId = MmGetSessionId(Process);
681 }
683 {
684 //
685 // Fail
686 //
689 }
690 _SEH2_END;
691
692 //
693 // Use SEH in case we can't load the image
694 //
696 {
697 //
698 // Get NT Headers
699 //
701 Characteristics = NtHeaders->FileHeader.Characteristics;
702 }
704 {
705 //
706 // Fail
707 //
710 }
711 _SEH2_END;
712
713 //
714 // Parse the headers
715 //
716 if (NtHeaders)
717 {
718 //
719 // Use SEH in case we can't load the headers
720 //
722 {
723 //
724 // Get the Image Config Data too
725 //
727 TRUE,
729 (PULONG)&ViewSize);
730 if (ImageConfigData)
731 {
732 //
733 // Probe it
734 //
735 ProbeForRead(ImageConfigData,
737 sizeof(ULONG));
738 }
739
740 //
741 // Write subsystem data
742 //
746
747 //
748 // Check for version data
749 //
750 if (NtHeaders->OptionalHeader.Win32VersionValue)
751 {
752 //
753 // Extract values and write them
754 //
756 Peb->OSMinorVersion = (NtHeaders->OptionalHeader.Win32VersionValue >> 8) & 0xFF;
757 Peb->OSBuildNumber = (NtHeaders->OptionalHeader.Win32VersionValue >> 16) & 0x3FFF;
758 Peb->OSPlatformId = (NtHeaders->OptionalHeader.Win32VersionValue >> 30) ^ 2;
759
760 /* Process CSD version override */
761 if ((ImageConfigData) && (ImageConfigData->CSDVersion))
762 {
763 /* Take the value from the image configuration directory */
764 Peb->OSCSDVersion = ImageConfigData->CSDVersion;
765 }
766 }
767
768 /* Process optional process affinity mask override */
769 if ((ImageConfigData) && (ImageConfigData->ProcessAffinityMask))
770 {
771 /* Take the value from the image configuration directory */
773 }
774
775 //
776 // Check if this is a UP image
777 if (Characteristics & IMAGE_FILE_UP_SYSTEM_ONLY)
778 {
779 //
780 // Set single processor rotating affinity.
781 // See https://www.microsoftpressstore.com/articles/article.aspx?p=2233328&seqNum=3
782 //
786 }
787 }
789 {
790 //
791 // Fail
792 //
795 }
796 _SEH2_END;
797 }
798
799 //
800 // Detach from the Process
801 //
803 *BasePeb = Peb;
804 return STATUS_SUCCESS;
805}
SIZE_T MmHeapSegmentReserve
Definition: mminit.c:367
SIZE_T MmHeapDeCommitFreeBlockThreshold
Definition: mminit.c:370
SIZE_T MmHeapDeCommitTotalFreeThreshold
Definition: mminit.c:369
SIZE_T MmHeapSegmentCommit
Definition: mminit.c:368
#define PAGE_READONLY
Definition: compat.h:138
#define RtlImageDirectoryEntryToData
Definition: compat.h:809
#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG
Definition: compat.h:153
PPEB Peb
Definition: dllmain.c:27
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
SIZE_T MmMinimumStackCommitInBytes
Definition: mminit.c:371
LARGE_INTEGER MmCriticalSectionTimeout
Definition: mminit.c:389
#define PCHAR
Definition: match.c:90
FORCEINLINE KAFFINITY AFFINITY_MASK(ULONG Index)
Definition: kefuncs.h:39
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER SectionOffset
Definition: mmfuncs.h:411
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:412
#define VER_PLATFORM_WIN32_NT
Definition: rtltypes.h:246
@ ViewShare
Definition: nt_native.h:1281
ULONG ExpOemCodePageDataOffset
Definition: init.c:86
ULONG NtMajorVersion
Definition: init.c:45
ULONG ExpUnicodeCaseTableDataOffset
Definition: init.c:87
ULONG NtGlobalFlag
Definition: init.c:54
PVOID ExpNlsSectionPointer
Definition: init.c:90
ULONG ExpAnsiCodePageDataOffset
Definition: init.c:86
ULONG NtMinorVersion
Definition: init.c:46
ULONG CmNtCSDVersion
Definition: init.c:59
KAFFINITY KeActiveProcessors
Definition: processor.c:16
ULONG NTAPI MmGetSessionId(IN PEPROCESS Process)
Definition: session.c:179
CCHAR KeNumberProcessors
Definition: processor.c:19
ULONG MmRotatingUniprocessorNumber
Definition: procsup.c:23
NTSTATUS NTAPI MiCreatePebOrTeb(IN PEPROCESS Process, IN ULONG Size, OUT PULONG_PTR BaseAddress)
Definition: procsup.c:29
#define STATUS_INVALID_IMAGE_PROTECT
Definition: ntstatus.h:634
#define BOOLEAN
Definition: pedump.c:73
unsigned short USHORT
Definition: pedump.c:61
#define IMAGE_FILE_UP_SYSTEM_ONLY
Definition: pedump.c:170
VOID NTAPI KeDetachProcess(VOID)
Definition: procobj.c:621
VOID NTAPI KeAttachProcess(IN PKPROCESS Process)
Definition: procobj.c:582
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:204
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:207
NTSTATUS NTAPI MmMapViewOfSection(_In_ PVOID SectionObject, _In_ PEPROCESS Process, _Outptr_result_bytebuffer_(*ViewSize) _Pre_opt_valid_ PVOID *BaseAddress, _In_ ULONG_PTR ZeroBits, _In_ SIZE_T CommitSize, _Inout_opt_ PLARGE_INTEGER SectionOffset, _Inout_ PSIZE_T ViewSize, _In_range_(ViewShare, ViewUnmap) SECTION_INHERIT InheritDisposition, _In_ ULONG AllocationType, _In_ ULONG Protect)
Definition: section.c:4031
#define DPRINT
Definition: sndvol32.h:73
ULONG NtBuildNumber
Definition: init.c:50
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
ULONG ImageSubsystem
Definition: ntddk_ex.h:304
ULONG NumberOfProcessors
Definition: ntddk_ex.h:269
ULONG ImageProcessAffinityMask
Definition: ntddk_ex.h:307
PVOID ImageBaseAddress
Definition: ntddk_ex.h:245
ULONG SessionId
Definition: btrfs_drv.h:1919
ULONG HeapSegmentReserve
Definition: ntddk_ex.h:275
LARGE_INTEGER CriticalSectionTimeout
Definition: ntddk_ex.h:274
ULONG MaximumNumberOfHeaps
Definition: ntddk_ex.h:287
ULONG OSMinorVersion
Definition: ntddk_ex.h:301
ULONG HeapDeCommitFreeBlockThreshold
Definition: ntddk_ex.h:278
PVOID * ProcessHeaps
Definition: ntddk_ex.h:288
PVOID AnsiCodePageData
Definition: ntddk_ex.h:264
ULONG ImageSubsystemMinorVersion
Definition: ntddk_ex.h:306
BYTE BeingDebugged
Definition: btrfs_drv.h:1909
SIZE_T MinimumStackCommit
Definition: winternl.h:550
HANDLE Mutant
Definition: ntddk_ex.h:243
ULONG OSMajorVersion
Definition: ntddk_ex.h:300
ULONG HeapDeCommitTotalFreeThreshold
Definition: ntddk_ex.h:277
ULONG OSBuildNumber
Definition: ntddk_ex.h:302
PVOID OemCodePageData
Definition: ntddk_ex.h:265
ULONG HeapSegmentCommit
Definition: ntddk_ex.h:276
ULONG NtGlobalFlag
Definition: ntddk_ex.h:270
BOOLEAN InheritedAddressSpace
Definition: ntddk_ex.h:239
ULONG ImageSubsystemMajorVersion
Definition: ntddk_ex.h:305
ULONG OSPlatformId
Definition: ntddk_ex.h:303
PVOID UnicodeCaseTableData
Definition: ntddk_ex.h:266
uint32_t * PULONG_PTR
Definition: typedefs.h:65
uint32_t * PULONG
Definition: typedefs.h:59
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint64_t ULONGLONG
Definition: typedefs.h:67
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by PspCreateProcess().

◆ MmCreateProcessAddressSpace()

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

Definition at line 1217 of file procsup.c.

1220{
1221 KIRQL OldIrql;
1222 PFN_NUMBER TableBaseIndex, HyperIndex, WsListIndex;
1223 ULONG Color;
1224
1225 /* Make sure we don't already have a page directory setup */
1226 ASSERT(Process->Pcb.DirectoryTableBase[0] == 0);
1227 ASSERT(Process->Pcb.DirectoryTableBase[1] == 0);
1228 ASSERT(Process->WorkingSetPage == 0);
1229
1230 /* Choose a process color */
1231 Process->NextPageColor = (USHORT)RtlRandom(&MmProcessColorSeed);
1232
1233 /* Setup the hyperspace lock */
1234 KeInitializeSpinLock(&Process->HyperSpaceLock);
1235
1236 /* Lock PFN database */
1237 OldIrql = MiAcquirePfnLock();
1238
1239 /*
1240 * Get a page for the table base, one for hyper space & one for the working set list.
1241 * The PFNs for these pages will be initialized in MmInitializeProcessAddressSpace,
1242 * when we are already attached to the process.
1243 * The other pages (if any) are allocated in the arch-specific part.
1244 */
1247 TableBaseIndex = MiRemoveZeroPageSafe(Color);
1248 if (!TableBaseIndex)
1249 {
1250 /* No zero pages, grab a free one */
1251 TableBaseIndex = MiRemoveAnyPage(Color);
1252
1253 /* Zero it outside the PFN lock */
1254 MiReleasePfnLock(OldIrql);
1255 MiZeroPhysicalPage(TableBaseIndex);
1256 OldIrql = MiAcquirePfnLock();
1257 }
1260 HyperIndex = MiRemoveZeroPageSafe(Color);
1261 if (!HyperIndex)
1262 {
1263 /* No zero pages, grab a free one */
1264 HyperIndex = MiRemoveAnyPage(Color);
1265
1266 /* Zero it outside the PFN lock */
1267 MiReleasePfnLock(OldIrql);
1268 MiZeroPhysicalPage(HyperIndex);
1269 OldIrql = MiAcquirePfnLock();
1270 }
1273 WsListIndex = MiRemoveZeroPageSafe(Color);
1274 if (!WsListIndex)
1275 {
1276 /* No zero pages, grab a free one */
1277 WsListIndex = MiRemoveAnyPage(Color);
1278
1279 /* Zero it outside the PFN lock */
1280 MiReleasePfnLock(OldIrql);
1281 MiZeroPhysicalPage(WsListIndex);
1282 }
1283 else
1284 {
1285 /* Release the PFN lock */
1286 MiReleasePfnLock(OldIrql);
1287 }
1288
1289 /* Set the base directory pointers */
1290 Process->WorkingSetPage = WsListIndex;
1291 DirectoryTableBase[0] = TableBaseIndex << PAGE_SHIFT;
1292 DirectoryTableBase[1] = HyperIndex << PAGE_SHIFT;
1293
1294 /* Perform the arch-specific parts */
1295 if (!MiArchCreateProcessAddressSpace(Process, DirectoryTableBase))
1296 {
1297 OldIrql = MiAcquirePfnLock();
1298 MiInsertPageInFreeList(WsListIndex);
1299 MiInsertPageInFreeList(HyperIndex);
1300 MiInsertPageInFreeList(TableBaseIndex);
1301 MiReleasePfnLock(OldIrql);
1302 Process->WorkingSetPage = 0;
1303 DirectoryTableBase[0] = 0;
1304 DirectoryTableBase[1] = 0;
1305 return FALSE;
1306 }
1307
1308 /* Switch to phase 1 initialization */
1309 ASSERT(Process->AddressSpaceInitialized == 0);
1310 Process->AddressSpaceInitialized = 1;
1311
1312 /* Add the process to the session */
1314 return TRUE;
1315}
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
VOID NTAPI MiSessionAddProcess(IN PEPROCESS NewProcess)
Definition: session.c:423
VOID NTAPI MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:611
#define MI_GET_NEXT_PROCESS_COLOR(x)
Definition: miarm.h:237
FORCEINLINE PFN_NUMBER MiRemoveZeroPageSafe(IN ULONG Color)
Definition: miarm.h:2413
NTSYSAPI ULONG NTAPI RtlRandom(_Inout_ PULONG Seed)
VOID NTAPI MiZeroPhysicalPage(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:122
@ MI_USAGE_PAGE_TABLE
Definition: mm.h:344
@ MI_USAGE_PAGE_DIRECTORY
Definition: mm.h:345
BOOLEAN MiArchCreateProcessAddressSpace(_In_ PEPROCESS Process, _In_ PULONG_PTR DirectoryTableBase)
Definition: procsup.c:21
ULONG MmProcessColorSeed
Definition: procsup.c:20

◆ MmCreateTeb()

NTSTATUS NTAPI MmCreateTeb ( IN PEPROCESS  Process,
IN PCLIENT_ID  ClientId,
IN PINITIAL_TEB  InitialTeb,
OUT PTEB BaseTeb 
)

Definition at line 809 of file procsup.c.

813{
814 PTEB Teb;
816 *BaseTeb = NULL;
817
818 //
819 // Attach to Target
820 //
822
823 //
824 // Allocate the TEB
825 //
826 Status = MiCreatePebOrTeb(Process, sizeof(TEB), (PULONG_PTR)&Teb);
827 if (!NT_SUCCESS(Status))
828 {
829 /* Cleanup and exit */
831 return Status;
832 }
833
834 //
835 // Use SEH in case we can't load the TEB
836 //
838 {
839 //
840 // Initialize the PEB
841 //
842 RtlZeroMemory(Teb, sizeof(TEB));
843
844 //
845 // Set TIB Data
846 //
847#ifdef _M_AMD64
848 Teb->NtTib.ExceptionList = NULL;
849#else
851#endif
852 Teb->NtTib.Self = (PNT_TIB)Teb;
853
854 //
855 // Identify this as an OS/2 V3.0 ("Cruiser") TIB
856 //
857 Teb->NtTib.Version = 30 << 8;
858
859 //
860 // Set TEB Data
861 //
862 Teb->ClientId = *ClientId;
863 Teb->RealClientId = *ClientId;
866
867 //
868 // Check if we have a grandparent TEB
869 //
870 if ((InitialTeb->PreviousStackBase == NULL) &&
871 (InitialTeb->PreviousStackLimit == NULL))
872 {
873 //
874 // Use initial TEB values
875 //
876 Teb->NtTib.StackBase = InitialTeb->StackBase;
877 Teb->NtTib.StackLimit = InitialTeb->StackLimit;
878 Teb->DeallocationStack = InitialTeb->AllocatedStackBase;
879 }
880 else
881 {
882 //
883 // Use grandparent TEB values
884 //
885 Teb->NtTib.StackBase = InitialTeb->PreviousStackBase;
886 Teb->NtTib.StackLimit = InitialTeb->PreviousStackLimit;
887 }
888
889 //
890 // Initialize the static unicode string
891 //
894 }
896 {
897 //
898 // Get error code
899 //
901 }
902 _SEH2_END;
903
904 //
905 // Return
906 //
908 *BaseTeb = Teb;
909 return Status;
910}
struct _NT_TIB * PNT_TIB
#define EXCEPTION_CHAIN_END
Definition: rtltypes.h:63
LCID PsDefaultThreadLocaleId
Definition: locale.c:24
struct _NT_TIB * Self
Definition: compat.h:720
PVOID StackLimit
Definition: compat.h:713
DWORD Version
Definition: compat.h:717
PVOID StackBase
Definition: compat.h:712
struct _EXCEPTION_REGISTRATION_RECORD * ExceptionList
Definition: compat.h:711
WCHAR StaticUnicodeBuffer[261]
Definition: compat.h:877
ULONG CurrentLocale
Definition: compat.h:849
NT_TIB NtTib
Definition: ntddk_ex.h:332
UNICODE_STRING StaticUnicodeString
Definition: compat.h:876
CLIENT_ID ClientId
Definition: compat.h:839
CLIENT_ID RealClientId
Definition: compat.h:861
PPEB ProcessEnvironmentBlock
Definition: ntddk_ex.h:337
PVOID DeallocationStack
Definition: compat.h:878
USHORT MaximumLength
Definition: env_spec_w32.h:370
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1151

Referenced by PspCreateThread().

◆ MmDeleteKernelStack()

VOID NTAPI MmDeleteKernelStack ( IN PVOID  StackBase,
IN BOOLEAN  GuiStack 
)

Definition at line 243 of file procsup.c.

245{
246 PMMPTE PointerPte;
247 PFN_NUMBER PageFrameNumber, PageTableFrameNumber;
248 PFN_COUNT StackPages;
249 PMMPFN Pfn1, Pfn2;
250 ULONG i;
252 PSLIST_ENTRY SListEntry;
253
254 //
255 // This should be the guard page, so decrement by one
256 //
257 PointerPte = MiAddressToPte(StackBase);
258 PointerPte--;
259
260 //
261 // If this is a small stack, just push the stack onto the dead stack S-LIST
262 //
263 if (!GuiStack)
264 {
266 {
267 SListEntry = ((PSLIST_ENTRY)StackBase) - 1;
269 return;
270 }
271 }
272
273 //
274 // Calculate pages used
275 //
276 StackPages = BYTES_TO_PAGES(GuiStack ?
278
279 /* Acquire the PFN lock */
280 OldIrql = MiAcquirePfnLock();
281
282 //
283 // Loop them
284 //
285 for (i = 0; i < StackPages; i++)
286 {
287 //
288 // Check if this is a valid PTE
289 //
290 if (PointerPte->u.Hard.Valid == 1)
291 {
292 /* Get the PTE's page */
293 PageFrameNumber = PFN_FROM_PTE(PointerPte);
294 Pfn1 = MiGetPfnEntry(PageFrameNumber);
295
296 /* Now get the page of the page table mapping it */
297 PageTableFrameNumber = Pfn1->u4.PteFrame;
298 Pfn2 = MiGetPfnEntry(PageTableFrameNumber);
299
300 /* Remove a shared reference, since the page is going away */
301 MiDecrementShareCount(Pfn2, PageTableFrameNumber);
302
303 /* Set the special pending delete marker */
304 MI_SET_PFN_DELETED(Pfn1);
305
306 /* And now delete the actual stack page */
307 MiDecrementShareCount(Pfn1, PageFrameNumber);
308 }
309
310 //
311 // Next one
312 //
313 PointerPte--;
314 }
315
316 //
317 // We should be at the guard page now
318 //
319 ASSERT(PointerPte->u.Hard.Valid == 0);
320
321 /* Release the PFN lock */
322 MiReleasePfnLock(OldIrql);
323
324 //
325 // Release the PTEs
326 //
327 MiReleaseSystemPtes(PointerPte, StackPages + 1, SystemPteSpace);
328}
#define MI_SET_PFN_DELETED(x)
Definition: miarm.h:208
VOID NTAPI MiReleaseSystemPtes(IN PMMPTE StartingPte, IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
Definition: syspte.c:264
VOID NTAPI MiDecrementShareCount(IN PMMPFN Pfn1, IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:1141
#define MiAddressToPte(x)
Definition: mm.h:145
#define PFN_FROM_PTE(v)
Definition: mm.h:92
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:1046
ULONG MmMaximumDeadKernelStacks
Definition: procsup.c:21
Definition: mm.h:390
union _MMPFN::@1983 u4
ULONG_PTR PteFrame
Definition: mm.h:437
ULONG64 Valid
Definition: mmtypes.h:150
union _MMPTE::@2559 u
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define InterlockedPushEntrySList(SListHead, SListEntry)
Definition: rtlfuncs.h:3406

◆ MmDeleteProcessAddressSpace()

VOID NTAPI MmDeleteProcessAddressSpace ( IN PEPROCESS  Process)

Definition at line 1413 of file procsup.c.

1414{
1415 PMMPFN Pfn1, Pfn2;
1416 KIRQL OldIrql;
1417 PFN_NUMBER PageFrameIndex;
1418
1419#ifndef _M_AMD64
1421 RemoveEntryList(&Process->MmProcessLinks);
1423#endif
1424
1425 //ASSERT(Process->CommitCharge == 0);
1426
1427 /* Remove us from the list */
1429 if (Process->Vm.WorkingSetExpansionLinks.Flink != NULL)
1430 RemoveEntryList(&Process->Vm.WorkingSetExpansionLinks);
1432
1433 /* Acquire the PFN lock */
1434 OldIrql = MiAcquirePfnLock();
1435
1436 /* Check for fully initialized process */
1437 if (Process->AddressSpaceInitialized == 2)
1438 {
1439 /* Map the working set page and its page table */
1440 Pfn1 = MiGetPfnEntry(Process->WorkingSetPage);
1441 Pfn2 = MiGetPfnEntry(Pfn1->u4.PteFrame);
1442
1443 /* Nuke it */
1444 MI_SET_PFN_DELETED(Pfn1);
1445 MiDecrementShareCount(Pfn2, Pfn1->u4.PteFrame);
1446 MiDecrementShareCount(Pfn1, Process->WorkingSetPage);
1447 ASSERT((Pfn1->u3.e2.ReferenceCount == 0) || (Pfn1->u3.e1.WriteInProgress));
1448
1449 /* Now map hyperspace and its page table */
1450 PageFrameIndex = Process->Pcb.DirectoryTableBase[1] >> PAGE_SHIFT;
1451 Pfn1 = MiGetPfnEntry(PageFrameIndex);
1452 Pfn2 = MiGetPfnEntry(Pfn1->u4.PteFrame);
1453
1454 /* Nuke it */
1455 MI_SET_PFN_DELETED(Pfn1);
1456 MiDecrementShareCount(Pfn2, Pfn1->u4.PteFrame);
1457 MiDecrementShareCount(Pfn1, PageFrameIndex);
1458 ASSERT((Pfn1->u3.e2.ReferenceCount == 0) || (Pfn1->u3.e1.WriteInProgress));
1459
1460 /* Finally, nuke the PDE itself */
1461 PageFrameIndex = Process->Pcb.DirectoryTableBase[0] >> PAGE_SHIFT;
1462 Pfn1 = MiGetPfnEntry(PageFrameIndex);
1463 MI_SET_PFN_DELETED(Pfn1);
1464 MiDecrementShareCount(Pfn1, PageFrameIndex);
1465 MiDecrementShareCount(Pfn1, PageFrameIndex);
1466
1467 /* Page table is now dead. Bye bye... */
1468 ASSERT((Pfn1->u3.e2.ReferenceCount == 0) || (Pfn1->u3.e1.WriteInProgress));
1469 }
1470 else
1471 {
1472 DPRINT1("Deleting partially initialized address space of Process %p. Might leak resources.\n",
1473 Process);
1474 }
1475
1476 /* Release the PFN lock */
1477 MiReleasePfnLock(OldIrql);
1478
1479 /* Drop a reference on the session */
1481
1482 /* Clear out the PDE pages */
1483 Process->Pcb.DirectoryTableBase[0] = 0;
1484 Process->Pcb.DirectoryTableBase[1] = 0;
1485}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
FORCEINLINE KIRQL MiAcquireExpansionLock(VOID)
Definition: miarm.h:1538
VOID NTAPI MiReleaseProcessReferenceToSessionDataPage(IN PMM_SESSION_SPACE SessionGlobal)
Definition: session.c:209
FORCEINLINE VOID MiReleaseExpansionLock(KIRQL OldIrql)
Definition: miarm.h:1551
USHORT WriteInProgress
Definition: mm.h:372
union _MMPFN::@1980 u3
MMPFNENTRY e1
Definition: mm.h:413
struct _MMPFN::@1980::@1986 e2

Referenced by PspDeleteProcess().

◆ MmDeleteTeb()

VOID NTAPI MmDeleteTeb ( IN PEPROCESS  Process,
IN PTEB  Teb 
)

Definition at line 170 of file procsup.c.

172{
173 ULONG_PTR TebEnd;
175 PMMVAD Vad;
176 PMM_AVL_TABLE VadTree = &Process->VadRoot;
177 DPRINT("Deleting TEB: %p in %16s\n", Teb, Process->ImageFileName);
178
179 /* TEB is one page */
180 TebEnd = (ULONG_PTR)Teb + ROUND_TO_PAGES(sizeof(TEB)) - 1;
181
182#if defined(_WIN64) && defined(BUILD_WOW64_ENABLED)
183 /* If this is a WOW64 process, the TEB is followed by a TEB32 */
184 if (Process->Wow64Process)
185 {
186 TebEnd += ROUND_TO_PAGES(sizeof(TEB32));
187 }
188#endif
189
190 /* Attach to the process */
192
193 /* Lock the process address space */
194 KeAcquireGuardedMutex(&Process->AddressCreationLock);
195
196 /* Find the VAD, make sure it's a TEB VAD */
197 Vad = MiLocateAddress(Teb);
198 DPRINT("Removing node for VAD: %lx %lx\n", Vad->StartingVpn, Vad->EndingVpn);
199 ASSERT(Vad != NULL);
200 if (Vad->StartingVpn != ((ULONG_PTR)Teb >> PAGE_SHIFT))
201 {
202 /* Bug in the AVL code? */
203 DPRINT1("Corrupted VAD!\n");
204 }
205 else
206 {
207 /* Sanity checks for a valid TEB VAD */
208 ASSERT((Vad->StartingVpn == ((ULONG_PTR)Teb >> PAGE_SHIFT) &&
209 (Vad->EndingVpn == (TebEnd >> PAGE_SHIFT))));
210 ASSERT(Vad->u.VadFlags.NoChange == TRUE);
213
214 /* Lock the working set */
216
217 /* Remove this VAD from the tree */
218 ASSERT(VadTree->NumberGenericTableElements >= 1);
219 MiRemoveNode((PMMADDRESS_NODE)Vad, VadTree);
220
221 /* Delete the pages */
223
224 /* Release the working set */
226
227 /* Remove the VAD */
228 ExFreePool(Vad);
229
230 /* Return the quota the VAD used */
232 }
233
234 /* Release the address space lock */
235 KeReleaseGuardedMutex(&Process->AddressCreationLock);
236
237 /* Detach */
239}
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
PMMVAD NTAPI MiLocateAddress(IN PVOID VirtualAddress)
ULONG MultipleSecured
Definition: mmtypes.h:709
union _MMVAD::@2881 u2
MMVAD_FLAGS2 VadFlags2
Definition: mmtypes.h:742

◆ MmGrowKernelStack()

NTSTATUS NTAPI MmGrowKernelStack ( IN PVOID  StackPointer)

Definition at line 533 of file procsup.c.

534{
535 //
536 // Call the extended version
537 //
539}
NTSTATUS NTAPI MmGrowKernelStackEx(IN PVOID StackPointer, IN ULONG GrowSize)
Definition: procsup.c:445

Referenced by KiUserModeCallout().

◆ MmGrowKernelStackEx()

NTSTATUS NTAPI MmGrowKernelStackEx ( IN PVOID  StackPointer,
IN ULONG  GrowSize 
)

Definition at line 445 of file procsup.c.

447{
449 PMMPTE LimitPte, NewLimitPte, LastPte;
451 MMPTE TempPte, InvalidPte;
452 PFN_NUMBER PageFrameIndex;
453
454 //
455 // Make sure the stack did not overflow
456 //
457 ASSERT(((ULONG_PTR)Thread->StackBase - (ULONG_PTR)Thread->StackLimit) <=
459
460 //
461 // Get the current stack limit
462 //
463 LimitPte = MiAddressToPte(Thread->StackLimit);
464 ASSERT(LimitPte->u.Hard.Valid == 1);
465
466 //
467 // Get the new one and make sure this isn't a retarded request
468 //
469 NewLimitPte = MiAddressToPte((PVOID)((ULONG_PTR)StackPointer - GrowSize));
470 if (NewLimitPte == LimitPte) return STATUS_SUCCESS;
471
472 //
473 // Now make sure you're not going past the reserved space
474 //
475 LastPte = MiAddressToPte((PVOID)((ULONG_PTR)Thread->StackBase -
477 if (NewLimitPte < LastPte)
478 {
479 //
480 // Sorry!
481 //
483 }
484
485 //
486 // Calculate the number of new pages
487 //
488 LimitPte--;
489
490 /* Setup the temporary invalid PTE */
491 MI_MAKE_SOFTWARE_PTE(&InvalidPte, MM_NOACCESS);
492
493 //
494 // Acquire the PFN DB lock
495 //
496 OldIrql = MiAcquirePfnLock();
497
498 //
499 // Loop each stack page
500 //
501 while (LimitPte >= NewLimitPte)
502 {
503 /* Get a page and write the current invalid PTE */
505 MI_SET_PROCESS2(PsGetCurrentProcess()->ImageFileName);
506 PageFrameIndex = MiRemoveAnyPage(MI_GET_NEXT_COLOR());
507 MI_WRITE_INVALID_PTE(LimitPte, InvalidPte);
508
509 /* Initialize the PFN entry for this page */
510 MiInitializePfn(PageFrameIndex, LimitPte, 1);
511
512 /* Setup the template stack PTE */
513 MI_MAKE_HARDWARE_PTE_KERNEL(&TempPte, LimitPte, MM_READWRITE, PageFrameIndex);
514
515 /* Write the valid PTE */
516 MI_WRITE_VALID_PTE(LimitPte--, TempPte);
517 }
518
519 //
520 // Release the PFN lock
521 //
522 MiReleasePfnLock(OldIrql);
523
524 //
525 // Set the new limit
526 //
527 Thread->StackLimit = (ULONG_PTR)MiPteToAddress(NewLimitPte);
528 return STATUS_SUCCESS;
529}
#define KeGetCurrentThread
Definition: hal.h:55
@ MI_USAGE_KERNEL_STACK_EXPANSION
Definition: mm.h:339
#define STATUS_STACK_OVERFLOW
Definition: ntstatus.h:583

Referenced by MmGrowKernelStack().

◆ MmInitializeHandBuiltProcess()

NTSTATUS NTAPI MmInitializeHandBuiltProcess ( IN PEPROCESS  Process,
IN PULONG_PTR  DirectoryTableBase 
)

Definition at line 1183 of file procsup.c.

1185{
1186 /* Share the directory base with the idle process */
1187 DirectoryTableBase[0] = PsGetCurrentProcess()->Pcb.DirectoryTableBase[0];
1188 DirectoryTableBase[1] = PsGetCurrentProcess()->Pcb.DirectoryTableBase[1];
1189
1190 /* Initialize the Addresss Space */
1191 KeInitializeGuardedMutex(&Process->AddressCreationLock);
1192 KeInitializeSpinLock(&Process->HyperSpaceLock);
1193 Process->Vm.WorkingSetExpansionLinks.Flink = NULL;
1194 ASSERT(Process->VadRoot.NumberGenericTableElements == 0);
1195 Process->VadRoot.BalancedRoot.u1.Parent = &Process->VadRoot.BalancedRoot;
1196
1197 /* Use idle process Working set */
1198 Process->Vm.VmWorkingSetList = PsGetCurrentProcess()->Vm.VmWorkingSetList;
1199 Process->WorkingSetPage = PsGetCurrentProcess()->WorkingSetPage;
1200
1201 /* Done */
1202 Process->HasAddressSpace = TRUE;//??
1203 return STATUS_SUCCESS;
1204}
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31

Referenced by PspCreateProcess().

◆ MmInitializeHandBuiltProcess2()

NTSTATUS NTAPI MmInitializeHandBuiltProcess2 ( IN PEPROCESS  Process)

Definition at line 1209 of file procsup.c.

1210{
1211 /* Lock the VAD, ARM3-owned ranges away */
1212 return STATUS_SUCCESS;
1213}

Referenced by PspCreateProcess().

◆ MmInitializeProcessAddressSpace()

NTSTATUS NTAPI MmInitializeProcessAddressSpace ( IN PEPROCESS  Process,
IN PEPROCESS ProcessClone  OPTIONAL,
IN PVOID Section  OPTIONAL,
IN OUT PULONG  Flags,
IN POBJECT_NAME_INFORMATION *AuditName  OPTIONAL 
)

Definition at line 988 of file procsup.c.

993{
995 SIZE_T ViewSize = 0;
996 PVOID ImageBase = 0;
997 PMMPTE PointerPte;
999 PMMPDE PointerPde;
1000 PMMPFN Pfn;
1001 PFN_NUMBER PageFrameNumber;
1003 PWCHAR Source;
1005 USHORT Length = 0;
1006
1007#if (_MI_PAGING_LEVELS >= 3)
1008 PMMPPE PointerPpe;
1009#endif
1010#if (_MI_PAGING_LEVELS == 4)
1011 PMMPXE PointerPxe;
1012#endif
1013
1014 /* We should have a PDE */
1015 ASSERT(Process->Pcb.DirectoryTableBase[0] != 0);
1016 ASSERT(Process->PdeUpdateNeeded == FALSE);
1017
1018 /* Attach to the process */
1019 KeAttachProcess(&Process->Pcb);
1020
1021 /* The address space should now been in phase 1 or 0 */
1022 ASSERT(Process->AddressSpaceInitialized <= 1);
1023 Process->AddressSpaceInitialized = 2;
1024
1025 /* Initialize the Addresss Space lock */
1026 KeInitializeGuardedMutex(&Process->AddressCreationLock);
1027 Process->Vm.WorkingSetExpansionLinks.Flink = NULL;
1028
1029 /* Initialize AVL tree */
1030 ASSERT(Process->VadRoot.NumberGenericTableElements == 0);
1031 Process->VadRoot.BalancedRoot.u1.Parent = &Process->VadRoot.BalancedRoot;
1032
1033 /* Lock our working set */
1035
1036 /* Lock PFN database */
1037 OldIrql = MiAcquirePfnLock();
1038
1039 /* Setup the PFN for the PDE base of this process */
1040#if (_MI_PAGING_LEVELS == 4)
1041 PointerPte = MiAddressToPte(PXE_BASE);
1042#elif (_MI_PAGING_LEVELS == 3)
1043 PointerPte = MiAddressToPte(PPE_BASE);
1044#else
1045 PointerPte = MiAddressToPte(PDE_BASE);
1046#endif
1047 PageFrameNumber = PFN_FROM_PTE(PointerPte);
1048 ASSERT(Process->Pcb.DirectoryTableBase[0] == PageFrameNumber * PAGE_SIZE);
1049 MiInitializePfn(PageFrameNumber, PointerPte, TRUE);
1050
1051 /* Do the same for hyperspace */
1052 PointerPde = MiAddressToPde(HYPER_SPACE);
1053 PageFrameNumber = PFN_FROM_PTE(PointerPde);
1054 MiInitializePfn(PageFrameNumber, (PMMPTE)PointerPde, TRUE);
1055#if (_MI_PAGING_LEVELS == 2)
1056 ASSERT(Process->Pcb.DirectoryTableBase[1] == PageFrameNumber * PAGE_SIZE);
1057#endif
1058
1059#if (_MI_PAGING_LEVELS >= 3)
1060 PointerPpe = MiAddressToPpe((PVOID)HYPER_SPACE);
1061 PageFrameNumber = PFN_FROM_PTE(PointerPpe);
1062 MiInitializePfn(PageFrameNumber, PointerPpe, TRUE);
1063#if (_MI_PAGING_LEVELS == 3)
1064 ASSERT(Process->Pcb.DirectoryTableBase[1] == PageFrameNumber * PAGE_SIZE);
1065#endif
1066#endif
1067#if (_MI_PAGING_LEVELS == 4)
1068 PointerPxe = MiAddressToPxe((PVOID)HYPER_SPACE);
1069 PageFrameNumber = PFN_FROM_PTE(PointerPxe);
1070 MiInitializePfn(PageFrameNumber, PointerPxe, TRUE);
1071 ASSERT(Process->Pcb.DirectoryTableBase[1] == PageFrameNumber * PAGE_SIZE);
1072#endif
1073
1074 /* Do the same for the Working set list */
1075 PointerPte = MiAddressToPte(MmWorkingSetList);
1076 PageFrameNumber = PFN_FROM_PTE(PointerPte);
1077 MiInitializePfn(PageFrameNumber, PointerPte, TRUE);
1078
1079 /* All our pages are now active & valid. Release the lock. */
1080 MiReleasePfnLock(OldIrql);
1081
1082 /* This should be in hyper space, but not in the mapping range */
1083 Process->Vm.VmWorkingSetList = MmWorkingSetList;
1085
1086 /* Now initialize the working set list */
1088
1089 /* The rule is that the owner process is always in the FLINK of the PDE's PFN entry */
1090 Pfn = MiGetPfnEntry(Process->Pcb.DirectoryTableBase[0] >> PAGE_SHIFT);
1091 ASSERT(Pfn->u4.PteFrame == MiGetPfnEntryIndex(Pfn));
1092 ASSERT(Pfn->u1.WsIndex == 0);
1093 Pfn->u1.Event = (PKEVENT)Process;
1094
1095 /* Sanity check */
1096 ASSERT(Process->PhysicalVadRoot == NULL);
1097
1098 /* Release the process working set */
1100
1101#ifdef _M_AMD64
1102 /* On x64 we need a VAD for the shared user page */
1103 Status = MiInsertSharedUserPageVad(Process);
1104 if (!NT_SUCCESS(Status))
1105 {
1106 DPRINT1("MiCreateSharedUserPageVad() failed: 0x%lx\n", Status);
1107 return Status;
1108 }
1109#endif
1110
1111 /* Check if there's a Section Object */
1112 if (Section)
1113 {
1114 /* Determine the image file name and save it to EPROCESS */
1116 FileName = FileObject->FileName;
1117 Source = (PWCHAR)((PCHAR)FileName.Buffer + FileName.Length);
1118 if (FileName.Buffer)
1119 {
1120 /* Loop the file name*/
1121 while (Source > FileName.Buffer)
1122 {
1123 /* Make sure this isn't a backslash */
1125 {
1126 /* If so, stop it here */
1127 Source++;
1128 break;
1129 }
1130 else
1131 {
1132 /* Otherwise, keep going */
1133 Length++;
1134 }
1135 }
1136 }
1137
1138 /* Copy the to the process and truncate it to 15 characters if necessary */
1139 Destination = Process->ImageFileName;
1140 Length = min(Length, sizeof(Process->ImageFileName) - 1);
1141 while (Length--) *Destination++ = (UCHAR)*Source++;
1143
1144 /* Check if caller wants an audit name */
1145 if (AuditName)
1146 {
1147 /* Setup the audit name */
1149 if (!NT_SUCCESS(Status))
1150 {
1151 /* Fail */
1153 return Status;
1154 }
1155 }
1156
1157 /* Map the section */
1158 Status = MmMapViewOfSection(Section,
1159 Process,
1160 (PVOID*)&ImageBase,
1161 0,
1162 0,
1163 NULL,
1164 &ViewSize,
1165 ViewUnmap,
1166 MEM_COMMIT,
1168
1169 /* Save the pointer */
1170 Process->SectionBaseAddress = ImageBase;
1171 }
1172
1173 /* Be nice and detach */
1175
1176 /* Return status to caller */
1177 return Status;
1178}
#define PDE_BASE
Definition: winldr.c:21
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
#define PKEVENT
Definition: env_spec_w32.h:70
struct _FileName FileName
Definition: fatprocs.h:897
FORCEINLINE VOID MiUnlockProcessWorkingSet(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1201
FORCEINLINE VOID MiLockProcessWorkingSet(IN PEPROCESS Process, IN PETHREAD Thread)
Definition: miarm.h:1131
#define min(a, b)
Definition: monoChain.cc:55
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3051
#define PAGE_READWRITE
Definition: nt_native.h:1307
@ ViewUnmap
Definition: nt_native.h:1282
#define MEM_COMMIT
Definition: nt_native.h:1316
#define ANSI_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
PMMWSL MmWorkingSetList
Definition: wslist.cpp:19
#define HYPER_SPACE
Definition: mm.h:14
#define MI_MAPPING_RANGE_END
Definition: mm.h:48
#define HYPER_SPACE_END
Definition: mm.h:15
FORCEINLINE PMMPTE MiAddressToPpe(PVOID Address)
Definition: mm.h:161
FORCEINLINE PMMPTE MiAddressToPxe(PVOID Address)
Definition: mm.h:171
#define MiAddressToPde(x)
Definition: mm.h:156
PFILE_OBJECT NTAPI MmGetFileObjectForSection(IN PVOID Section)
Definition: section.c:1546
FORCEINLINE PFN_NUMBER MiGetPfnEntryIndex(IN PMMPFN Pfn1)
Definition: mm.h:1066
NTSTATUS NTAPI SeInitializeProcessAuditName(_In_ PFILE_OBJECT FileObject, _In_ BOOLEAN DoAudit, _Out_ POBJECT_NAME_INFORMATION *AuditInfo)
Initializes a process audit name and returns it to the caller.
Definition: audit.c:105
#define PXE_BASE
#define PPE_BASE
ULONG WsIndex
Definition: mm.h:394
union _MMPFN::@1978 u1
PKEVENT Event
Definition: mm.h:395
unsigned char UCHAR
Definition: typedefs.h:53
uint16_t * PWCHAR
Definition: typedefs.h:56
char * PCHAR
Definition: typedefs.h:51
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_Use_decl_annotations_ VOID NTAPI MiInitializeWorkingSetList(_Inout_ PMMSUPPORT WorkingSet)
Definition: wslist.cpp:369
* PFILE_OBJECT
Definition: iotypes.h:1998

◆ MmSetMemoryPriorityProcess()

NTSTATUS NTAPI MmSetMemoryPriorityProcess ( IN PEPROCESS  Process,
IN UCHAR  MemoryPriority 
)

Definition at line 543 of file procsup.c.

545{
546 UCHAR OldPriority;
547
548 //
549 // Check if we have less then 16MB of Physical Memory
550 //
551 if ((MmSystemSize == MmSmallSystem) &&
552 (MmNumberOfPhysicalPages < ((15 * 1024 * 1024) / PAGE_SIZE)))
553 {
554 //
555 // Always use background priority
556 //
557 MemoryPriority = MEMORY_PRIORITY_BACKGROUND;
558 }
559
560 //
561 // Save the old priority and update it
562 //
563 OldPriority = (UCHAR)Process->Vm.Flags.MemoryPriority;
564 Process->Vm.Flags.MemoryPriority = MemoryPriority;
565
566 //
567 // Return the old priority
568 //
569 return OldPriority;
570}
#define MEMORY_PRIORITY_BACKGROUND
Definition: pstypes.h:120
MM_SYSTEMSIZE MmSystemSize
Definition: mminit.c:327
PFN_COUNT MmNumberOfPhysicalPages
Definition: init.c:48
@ MmSmallSystem
Definition: mmtypes.h:145

Referenced by NtSetInformationProcess(), and PspComputeQuantumAndPriority().

◆ NtAllocateUserPhysicalPages()

NTSTATUS NTAPI NtAllocateUserPhysicalPages ( IN HANDLE  ProcessHandle,
IN OUT PULONG_PTR  NumberOfPages,
IN OUT PULONG_PTR  UserPfnArray 
)

Definition at line 1492 of file procsup.c.

1495{
1498}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42

Referenced by AllocateUserPhysicalPages().

◆ NtFreeUserPhysicalPages()

NTSTATUS NTAPI NtFreeUserPhysicalPages ( IN HANDLE  ProcessHandle,
IN OUT PULONG_PTR  NumberOfPages,
IN OUT PULONG_PTR  UserPfnArray 
)

Definition at line 1522 of file procsup.c.

1525{
1528}

Referenced by FreeUserPhysicalPages().

◆ NtMapUserPhysicalPages()

NTSTATUS NTAPI NtMapUserPhysicalPages ( IN PVOID  VirtualAddresses,
IN ULONG_PTR  NumberOfPages,
IN OUT PULONG_PTR  UserPfnArray 
)

Definition at line 1502 of file procsup.c.

1505{
1508}

Referenced by MapUserPhysicalPages().

◆ NtMapUserPhysicalPagesScatter()

NTSTATUS NTAPI NtMapUserPhysicalPagesScatter ( IN PVOID VirtualAddresses,
IN ULONG_PTR  NumberOfPages,
IN OUT PULONG_PTR  UserPfnArray 
)

Definition at line 1512 of file procsup.c.

1515{
1518}

Referenced by MapUserPhysicalPagesScatter().

Variable Documentation

◆ MmDeadStackSListHead

SLIST_HEADER MmDeadStackSListHead

Definition at line 22 of file procsup.c.

Referenced by MmArmInitSystem(), MmCreateKernelStack(), and MmDeleteKernelStack().

◆ MmMaximumDeadKernelStacks

ULONG MmMaximumDeadKernelStacks = 5

Definition at line 21 of file procsup.c.

Referenced by MmArmInitSystem(), and MmDeleteKernelStack().

◆ MmProcessColorSeed

ULONG MmProcessColorSeed = 0x12345678

Definition at line 20 of file procsup.c.

Referenced by MmCreateProcessAddressSpace().

◆ MmRotatingUniprocessorNumber

ULONG MmRotatingUniprocessorNumber = 0

Definition at line 23 of file procsup.c.

Referenced by MmCreatePeb().