ReactOS  0.4.15-dev-2964-ge2a8585
session.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: BSD - See COPYING.ARM in the top level directory
4  * FILE: ntoskrnl/mm/ARM3/session.c
5  * PURPOSE: Session support routines
6  * PROGRAMMERS: ReactOS Portable Systems Group
7  * Timo Kreuzer (timo.kreuzer@reactos.org)
8  */
9 
10 /* INCLUDES *******************************************************************/
11 
12 #include <ntoskrnl.h>
13 #define NDEBUG
14 #include <debug.h>
15 
16 #define MODULE_INVOLVED_IN_ARM3
17 #include <mm/ARM3/miarm.h>
18 
19 /* GLOBALS ********************************************************************/
20 
28 
31 
34 
35 
36 /* PRIVATE FUNCTIONS **********************************************************/
37 
38 VOID
39 NTAPI
41 {
42  /* Initialize the list heads */
44 }
45 
46 BOOLEAN
47 NTAPI
49 {
50  /* Check if it is in range */
52 }
53 
54 LCID
55 NTAPI
57 {
59  PAGED_CODE();
60 
61  //
62  // Get the current process
63  //
65 
66  //
67  // Check if it's NOT the Session Leader
68  //
69  if (!Process->Vm.Flags.SessionLeader)
70  {
71  //
72  // Make sure it has a valid Session
73  //
74  if (Process->Session)
75  {
76  //
77  // Get the Locale ID
78  //
79  return ((PMM_SESSION_SPACE)Process->Session)->LocaleId;
80  }
81  }
82 
83  //
84  // Not a session leader, return the default
85  //
87 }
88 
90 VOID
91 NTAPI
92 MmSetSessionLocaleId(
94 {
96  PAGED_CODE();
97 
98  /* Get the current process and check if it is in a session */
100  if ((CurrentProcess->Vm.Flags.SessionLeader == 0) &&
101  (CurrentProcess->Session != NULL))
102  {
103  /* Set the session locale Id */
104  ((PMM_SESSION_SPACE)CurrentProcess->Session)->LocaleId = LocaleId;
105  }
106  else
107  {
108  /* Set the default locale */
110  }
111 }
112 
113 
114 VOID
115 NTAPI
117 {
118  ULONG Size, BitmapSize;
119  PFN_NUMBER TotalPages;
120 
121  /* Setup the total number of data pages needed for the structure */
122  TotalPages = MI_SESSION_DATA_PAGES_MAXIMUM;
125  TotalPages -= MiSessionDataPages;
126 
127  /* Setup the number of pages needed for session pool tags */
131  ASSERT(MiSessionTagPages <= TotalPages);
133 
134  /* Total pages needed for a session (FIXME: Probably different on PAE/x64) */
136 
137  /* Initialize the lock */
139 
140  /* Allocate the bitmap */
142  BitmapSize = ((Size + 31) / 32) * sizeof(ULONG);
144  sizeof(RTL_BITMAP) + BitmapSize,
145  TAG_MM);
146  if (MiSessionIdBitmap)
147  {
148  /* Free all the bits */
150  (PVOID)(MiSessionIdBitmap + 1),
151  Size);
153  }
154  else
155  {
156  /* Die if we couldn't allocate the bitmap */
157  KeBugCheckEx(INSTALL_MORE_MEMORY,
161  0x200);
162  }
163 }
164 
165 VOID
166 NTAPI
168 {
169  KIRQL OldIrql;
170 
171  /* Set the flag while under the expansion lock */
173  Process->Vm.Flags.SessionLeader = TRUE;
175 }
176 
177 ULONG
178 NTAPI
180 {
181  PMM_SESSION_SPACE SessionGlobal;
182 
183  /* The session leader is always session zero */
184  if (Process->Vm.Flags.SessionLeader == 1) return 0;
185 
186  /* Otherwise, get the session global, and read the session ID from it */
187  SessionGlobal = (PMM_SESSION_SPACE)Process->Session;
188  if (!SessionGlobal) return 0;
189  return SessionGlobal->SessionId;
190 }
191 
192 ULONG
193 NTAPI
195 {
196  PMM_SESSION_SPACE SessionGlobal;
197 
198  /* The session leader is always session zero */
199  if (Process->Vm.Flags.SessionLeader == 1) return 0;
200 
201  /* Otherwise, get the session global, and read the session ID from it */
202  SessionGlobal = (PMM_SESSION_SPACE)Process->Session;
203  if (!SessionGlobal) return -1;
204  return SessionGlobal->SessionId;
205 }
206 
207 VOID
208 NTAPI
210 {
211  ULONG i, SessionId;
212  PMMPTE PointerPte;
214  PMMPFN Pfn1;
215  KIRQL OldIrql;
216 
217  /* Is there more than just this reference? If so, bail out */
218  if (InterlockedDecrement(&SessionGlobal->ProcessReferenceToSession)) return;
219 
220  /* Get the session ID */
221  SessionId = SessionGlobal->SessionId;
222  DPRINT1("Last process in session %lu going down!!!\n", SessionId);
223 
224  /* Free the session page tables */
225 #ifndef _M_AMD64
226  ExFreePoolWithTag(SessionGlobal->PageTables, 'tHmM');
227 #endif
228  ASSERT(!MI_IS_PHYSICAL_ADDRESS(SessionGlobal));
229 
230  /* Capture the data page PFNs */
231  PointerPte = MiAddressToPte(SessionGlobal);
232  for (i = 0; i < MiSessionDataPages; i++)
233  {
234  PageFrameIndex[i] = PFN_FROM_PTE(PointerPte + i);
235  }
236 
237  /* Release them */
239 
240  /* Mark them as deleted */
241  for (i = 0; i < MiSessionDataPages; i++)
242  {
243  Pfn1 = MI_PFN_ELEMENT(PageFrameIndex[i]);
244  MI_SET_PFN_DELETED(Pfn1);
245  }
246 
247  /* Loop every data page and drop a reference count */
249  for (i = 0; i < MiSessionDataPages; i++)
250  {
251  /* Sanity check that the page is correct, then decrement it */
252  Pfn1 = MI_PFN_ELEMENT(PageFrameIndex[i]);
253  ASSERT(Pfn1->u2.ShareCount == 1);
254  ASSERT(Pfn1->u3.e2.ReferenceCount == 1);
255  MiDecrementShareCount(Pfn1, PageFrameIndex[i]);
256  }
257 
258  /* Done playing with pages, release the lock */
260 
261  /* Decrement the number of data pages */
263 
264  /* Free this session ID from the session bitmap */
269 }
270 
271 VOID
272 NTAPI
274 {
275  PMM_SESSION_SPACE SessionGlobal;
276  KIRQL OldIrql;
277 
278  /* Get the pointer to the global session address */
279  SessionGlobal = MmSessionSpace->GlobalVirtualAddress;
280 
281  /* Acquire the expansion lock */
283 
284  /* Set delete pending flag, so that processes can no longer attach to this
285  session and the last process that detaches sets the AttachEvent */
286  ASSERT(SessionGlobal->u.Flags.DeletePending == 0);
287  SessionGlobal->u.Flags.DeletePending = 1;
288 
289  /* Check if we have any attached processes */
290  if (SessionGlobal->AttachCount)
291  {
292  /* Initialize the event (it's not in use yet!) */
294 
295  /* Release the expansion lock for the wait */
297 
298  /* Wait for the event to be set due to the last process detach */
299  KeWaitForSingleObject(&SessionGlobal->AttachEvent, WrVirtualMemory, 0, 0, 0);
300 
301  /* Reacquire the expansion lock */
303 
304  /* Makes sure we still have the delete flag and no attached processes */
307  }
308 
309  /* Check if the session is in the workingset expansion list */
310  if (SessionGlobal->Vm.WorkingSetExpansionLinks.Flink != NULL)
311  {
312  /* Remove the session from the list and zero the list entry */
314  SessionGlobal->Vm.WorkingSetExpansionLinks.Flink = 0;
315  }
316 
317  /* Check if the session is in the workingset list */
318  if (SessionGlobal->WsListEntry.Flink)
319  {
320  /* Remove the session from the list and zero the list entry */
321  RemoveEntryList(&SessionGlobal->WsListEntry);
322  SessionGlobal->WsListEntry.Flink = NULL;
323  }
324 
325  /* Release the expansion lock */
327 
328  /* Check for a win32k unload routine */
329  if (SessionGlobal->Win32KDriverUnload)
330  {
331  /* Call it */
332  SessionGlobal->Win32KDriverUnload(NULL);
333  }
334 }
335 
336 
337 VOID
338 NTAPI
340 {
341  PMM_SESSION_SPACE SessionGlobal;
343  ULONG ReferenceCount, SessionId;
344 
345  /* Sanity checks */
346  ASSERT(PsGetCurrentProcess()->ProcessInSession ||
347  ((MmSessionSpace->u.Flags.Initialized == 0) &&
348  (PsGetCurrentProcess()->Vm.Flags.SessionLeader == 1) &&
349  (MmSessionSpace->ReferenceCount == 1)));
350 
351  /* The session bit must be set */
354 
355  /* Get the current process */
357 
358  /* Decrement the process count */
360 
361  /* Decrement the reference count and check if was the last reference */
363  if (ReferenceCount == 0)
364  {
365  /* No more references left, kill the session completely */
367  return;
368  }
369 
370  /* Check if this is the session leader */
371  if (Process->Vm.Flags.SessionLeader)
372  {
373  /* Get the global session address before we kill the session mapping */
374  SessionGlobal = MmSessionSpace->GlobalVirtualAddress;
375 
376  /* Delete all session PDEs and flush the TB */
377  //RtlZeroMemory(MiAddressToPde(MmSessionBase),
378  // BYTES_TO_PAGES(MmSessionSize) * sizeof(MMPDE));
380 
381  /* Clean up the references here. */
382  ASSERT(Process->Session == NULL);
384  }
385 
386  /* Reset the current process' session flag */
388 }
389 
390 VOID
391 NTAPI
393 {
395  KIRQL OldIrql;
396 
397  /* If the process isn't already in a session, or if it's the leader... */
398  if (!(CurrentProcess->Flags & PSF_PROCESS_IN_SESSION_BIT) ||
399  (CurrentProcess->Vm.Flags.SessionLeader))
400  {
401  /* Then there's nothing to do */
402  return;
403  }
404 
405  /* Sanity check */
407 
408  /* Acquire the expansion lock while touching the session */
410 
411  /* Remove the process from the list */
412  RemoveEntryList(&CurrentProcess->SessionProcessLinks);
413 
414  /* Release the lock again */
416 
417  /* Dereference the session */
419 }
420 
421 VOID
422 NTAPI
424 {
425  PMM_SESSION_SPACE SessionGlobal;
426  KIRQL OldIrql;
427 
428  /* The current process must already be in a session */
430 
431  /* Sanity check */
433 
434  /* Get the global session */
435  SessionGlobal = MmSessionSpace->GlobalVirtualAddress;
436 
437  /* Increment counters */
438  InterlockedIncrement((PLONG)&SessionGlobal->ReferenceCount);
441 
442  /* Set the session pointer */
443  ASSERT(NewProcess->Session == NULL);
444  NewProcess->Session = SessionGlobal;
445 
446  /* Acquire the expansion lock while touching the session */
448 
449  /* Insert it into the process list */
450  InsertTailList(&SessionGlobal->ProcessList, &NewProcess->SessionProcessLinks);
451 
452  /* Release the lock again */
454 
455  /* Set the flag */
457 }
458 
459 NTSTATUS
460 NTAPI
462 {
463  KIRQL OldIrql;
464  PMMPTE PointerPte;
465  PMMPDE PointerPde;
466  MMPTE TempPte;
467  MMPDE TempPde;
468  ULONG Color, Index;
469  PFN_NUMBER PageFrameIndex;
470  PMM_SESSION_SPACE SessionGlobal;
471  BOOLEAN AllocatedPageTable;
472  PMMWSL WorkingSetList;
473 
474  /* Get pointers to session global and the session working set list */
475  SessionGlobal = MmSessionSpace->GlobalVirtualAddress;
476  WorkingSetList = (PMMWSL)MiSessionSpaceWs;
477 
478  /* Fill out the two pointers */
479  MmSessionSpace->Vm.VmWorkingSetList = WorkingSetList;
480  MmSessionSpace->Wsle = (PMMWSLE)((&WorkingSetList->VadBitMapHint) + 1);
481 
482  /* Get the PDE for the working set, and check if it's already allocated */
483  PointerPde = MiAddressToPde(WorkingSetList);
484  if (PointerPde->u.Hard.Valid == 1)
485  {
486  /* Nope, we'll have to do it */
487 #ifndef _M_ARM
488  ASSERT(PointerPde->u.Hard.Global == 0);
489 #endif
490  AllocatedPageTable = FALSE;
491  }
492  else
493  {
494  /* Yep, that makes our job easier */
495  AllocatedPageTable = TRUE;
496  }
497 
498  /* Get the PTE for the working set */
499  PointerPte = MiAddressToPte(WorkingSetList);
500 
501  /* Initialize the working set lock, and lock the PFN database */
502  ExInitializePushLock(&SessionGlobal->Vm.WorkingSetMutex);
503  //MmLockPageableSectionByHandle(ExPageLockHandle);
505 
506  /* Check if we need a page table */
507  if (AllocatedPageTable != FALSE)
508  {
509  /* Get a zeroed colored zero page */
512  PageFrameIndex = MiRemoveZeroPageSafe(Color);
513  if (!PageFrameIndex)
514  {
515  /* No zero pages, grab a free one */
516  PageFrameIndex = MiRemoveAnyPage(Color);
517 
518  /* Zero it outside the PFN lock */
520  MiZeroPhysicalPage(PageFrameIndex);
522  }
523 
524  /* Write a valid PDE for it */
526  TempPde.u.Hard.PageFrameNumber = PageFrameIndex;
527  MI_WRITE_VALID_PDE(PointerPde, TempPde);
528 
529  /* Add this into the list */
530  Index = ((ULONG_PTR)WorkingSetList - (ULONG_PTR)MmSessionBase) >> 22;
531 #ifndef _M_AMD64
533 #endif
534  /* Initialize the page directory page, and now zero the working set list itself */
535  MiInitializePfnForOtherProcess(PageFrameIndex,
536  PointerPde,
538  KeZeroPages(PointerPte, PAGE_SIZE);
539  }
540 
541  /* Get a zeroed colored zero page */
544  PageFrameIndex = MiRemoveZeroPageSafe(Color);
545  if (!PageFrameIndex)
546  {
547  /* No zero pages, grab a free one */
548  PageFrameIndex = MiRemoveAnyPage(Color);
549 
550  /* Zero it outside the PFN lock */
552  MiZeroPhysicalPage(PageFrameIndex);
554  }
555 
556  /* Write a valid PTE for it */
559  TempPte.u.Hard.PageFrameNumber = PageFrameIndex;
560 
561  /* Initialize the working set list page */
562  MiInitializePfnAndMakePteValid(PageFrameIndex, PointerPte, TempPte);
563 
564  /* Now we can release the PFN database lock */
566 
567  /* Fill out the working set structure */
571  WorkingSetList->LastEntry = 20;
572  WorkingSetList->HashTable = NULL;
573  WorkingSetList->HashTableSize = 0;
574  WorkingSetList->Wsle = MmSessionSpace->Wsle;
575 
576  /* Acquire the expansion lock while touching the session */
578 
579  /* Handle list insertions */
580  ASSERT(SessionGlobal->WsListEntry.Flink == NULL);
581  ASSERT(SessionGlobal->WsListEntry.Blink == NULL);
582  InsertTailList(&MiSessionWsList, &SessionGlobal->WsListEntry);
583 
584  ASSERT(SessionGlobal->Vm.WorkingSetExpansionLinks.Flink == NULL);
585  ASSERT(SessionGlobal->Vm.WorkingSetExpansionLinks.Blink == NULL);
587  &SessionGlobal->Vm.WorkingSetExpansionLinks);
588 
589  /* Release the lock again */
591 
592  /* All done, return */
593  //MmUnlockPageableImageSection(ExPageLockHandle);
594  return STATUS_SUCCESS;
595 }
596 
597 NTSTATUS
598 NTAPI
600 {
602  ULONG NewFlags, Flags, i, Color;
603 #if (_MI_PAGING_LEVELS < 3)
604  ULONG Size;
605 #endif // (_MI_PAGING_LEVELS < 3)
606  PMMPDE PageTables = NULL;
607  KIRQL OldIrql;
608  PMMPTE PointerPte, SessionPte;
609  PMMPDE PointerPde;
610  PMM_SESSION_SPACE SessionGlobal;
611  MMPTE TempPte;
612  MMPDE TempPde;
614  BOOLEAN Result;
615  PFN_NUMBER SessionPageDirIndex;
618 
619  /* This should not exist yet */
621 
622  /* Loop so we can set the session-is-creating flag */
623  Flags = Process->Flags;
624  while (TRUE)
625  {
626  /* Check if it's already set */
628  {
629  /* Bail out */
630  DPRINT1("Lost session race\n");
632  }
633 
634  /* Now try to set it */
635  NewFlags = InterlockedCompareExchange((PLONG)&Process->Flags,
637  Flags);
638  if (NewFlags == Flags) break;
639 
640  /* It changed, try again */
641  Flags = NewFlags;
642  }
643 
644  /* Now we should own the flag */
646 
647 #if (_MI_PAGING_LEVELS < 3)
648  /*
649  * Session space covers everything from 0xA0000000 to 0xC0000000.
650  * Allocate enough page tables to describe the entire region
651  */
652  Size = (0x20000000 / PDE_MAPPED_VA) * sizeof(MMPTE);
653  PageTables = ExAllocatePoolWithTag(NonPagedPool, Size, 'tHmM');
654  ASSERT(PageTables != NULL);
655  RtlZeroMemory(PageTables, Size);
656 #endif // (_MI_PAGING_LEVELS < 3)
657 
658  /* Lock the session ID creation mutex */
660 
661  /* Allocate a new Session ID */
663  if (*SessionId == 0xFFFFFFFF)
664  {
665  /* We ran out of session IDs, we should expand */
666  DPRINT1("Too many sessions created. Expansion not yet supported\n");
667 #if (_MI_PAGING_LEVELS < 3)
668  ExFreePoolWithTag(PageTables, 'tHmM');
669 #endif // (_MI_PAGING_LEVELS < 3)
670  return STATUS_NO_MEMORY;
671  }
672 
673  /* Unlock the session ID creation mutex */
675 
676  /* Reserve the global PTEs */
678  ASSERT(SessionPte != NULL);
679 
680  /* Acquire the PFN lock while we set everything up */
682 
683  /* Loop the global PTEs */
685  for (i = 0; i < MiSessionDataPages; i++)
686  {
687  /* Get a zeroed colored zero page */
690  DataPage[i] = MiRemoveZeroPageSafe(Color);
691  if (!DataPage[i])
692  {
693  /* No zero pages, grab a free one */
694  DataPage[i] = MiRemoveAnyPage(Color);
695 
696  /* Zero it outside the PFN lock */
698  MiZeroPhysicalPage(DataPage[i]);
700  }
701 
702  /* Fill the PTE out */
703  TempPte.u.Hard.PageFrameNumber = DataPage[i];
704  MI_WRITE_VALID_PTE(SessionPte + i, TempPte);
705  }
706 
707  /* Set the pointer to global space */
708  SessionGlobal = MiPteToAddress(SessionPte);
709 
710  /* Get a zeroed colored zero page */
713  SessionPageDirIndex = MiRemoveZeroPageSafe(Color);
714  if (!SessionPageDirIndex)
715  {
716  /* No zero pages, grab a free one */
717  SessionPageDirIndex = MiRemoveAnyPage(Color);
718 
719  /* Zero it outside the PFN lock */
721  MiZeroPhysicalPage(SessionPageDirIndex);
723  }
724 
725  /* Fill the PTE out */
727  TempPde.u.Hard.PageFrameNumber = SessionPageDirIndex;
728 
729  /* Setup, allocate, fill out the MmSessionSpace PTE */
730  PointerPde = MiAddressToPde(MmSessionSpace);
731  ASSERT(PointerPde->u.Long == 0);
732  MI_WRITE_VALID_PDE(PointerPde, TempPde);
733  MiInitializePfnForOtherProcess(SessionPageDirIndex,
734  PointerPde,
735  SessionPageDirIndex);
736  ASSERT(MI_PFN_ELEMENT(SessionPageDirIndex)->u1.WsIndex == 0);
737 
738  /* Loop all the local PTEs for it */
740  PointerPte = MiAddressToPte(MmSessionSpace);
741  for (i = 0; i < MiSessionDataPages; i++)
742  {
743  /* And fill them out */
744  TempPte.u.Hard.PageFrameNumber = DataPage[i];
745  MiInitializePfnAndMakePteValid(DataPage[i], PointerPte + i, TempPte);
746  ASSERT(MI_PFN_ELEMENT(DataPage[i])->u1.WsIndex == 0);
747  }
748 
749  /* Finally loop all of the session pool tag pages */
750  for (i = 0; i < MiSessionTagPages; i++)
751  {
752  /* Grab a zeroed colored page */
755  TagPage[i] = MiRemoveZeroPageSafe(Color);
756  if (!TagPage[i])
757  {
758  /* No zero pages, grab a free one */
759  TagPage[i] = MiRemoveAnyPage(Color);
760 
761  /* Zero it outside the PFN lock */
763  MiZeroPhysicalPage(TagPage[i]);
765  }
766 
767  /* Fill the PTE out */
768  TempPte.u.Hard.PageFrameNumber = TagPage[i];
770  PointerPte + MiSessionDataPages + i,
771  TempPte);
772  }
773 
774  /* PTEs have been setup, release the PFN lock */
776 
777  /* Fill out the session space structure now */
778  MmSessionSpace->GlobalVirtualAddress = SessionGlobal;
784  MmSessionSpace->SessionPageDirectoryIndex = SessionPageDirIndex;
788 #ifndef _M_AMD64
789  MmSessionSpace->PageTables = PageTables;
790  MmSessionSpace->PageTables[PointerPde - MiAddressToPde(MmSessionBase)] = *PointerPde;
791 #endif
793 
794  DPRINT1("Session %lu is ready to go: 0x%p 0x%p, %lx 0x%p\n",
795  *SessionId, MmSessionSpace, SessionGlobal, SessionPageDirIndex, PageTables);
796 
797  /* Initialize session pool */
798  //Status = MiInitializeSessionPool();
801 
802  /* Initialize system space */
803  Result = MiInitializeSystemSpaceMap(&SessionGlobal->Session);
804  ASSERT(Result == TRUE);
805 
806  /* Initialize the process list, make sure the workign set list is empty */
807  ASSERT(SessionGlobal->WsListEntry.Flink == NULL);
808  ASSERT(SessionGlobal->WsListEntry.Blink == NULL);
809  InitializeListHead(&SessionGlobal->ProcessList);
810 
811  /* We're done, clear the flag */
814 
815  /* Insert the process into the session */
816  ASSERT(Process->Session == NULL);
817  ASSERT(SessionGlobal->ProcessReferenceToSession == 0);
818  SessionGlobal->ProcessReferenceToSession = 1;
819 
820  /* We're done */
822  return STATUS_SUCCESS;
823 }
824 
825 NTSTATUS
826 NTAPI
828 {
830  ULONG SessionLeaderExists;
832 
833  /* Fail if the process is already in a session */
834  if (Process->Flags & PSF_PROCESS_IN_SESSION_BIT)
835  {
836  DPRINT1("Process already in session\n");
838  }
839 
840  /* Check if the process is already the session leader */
841  if (!Process->Vm.Flags.SessionLeader)
842  {
843  /* Atomically set it as the leader */
844  SessionLeaderExists = InterlockedCompareExchange(&MiSessionLeaderExists, 1, 0);
845  if (SessionLeaderExists)
846  {
847  DPRINT1("Session leader race\n");
849  }
850 
851  /* Do the work required to upgrade him */
853  }
854 
855  /* Create the session */
858  if (!NT_SUCCESS(Status))
859  {
861  return Status;
862  }
863 
864  /* Set up the session working set */
866  if (!NT_SUCCESS(Status))
867  {
868  /* Fail */
869  //MiDereferenceSession();
870  ASSERT(FALSE);
872  return Status;
873  }
874 
875  /* All done */
877 
878  /* Set and assert the flags, and return */
882  return Status;
883 }
884 
885 NTSTATUS
886 NTAPI
888 {
890 
891  /* Process must be in a session */
892  if (!(Process->Flags & PSF_PROCESS_IN_SESSION_BIT))
893  {
894  DPRINT1("Not in a session!\n");
896  }
897 
898  /* It must be the session leader */
899  if (!Process->Vm.Flags.SessionLeader)
900  {
901  DPRINT1("Not a session leader!\n");
903  }
904 
905  /* Remove one reference count */
909 
910  /* All done */
911  return STATUS_SUCCESS;
912 }
913 
915 NTSTATUS
916 NTAPI
917 MmAttachSession(
918  _Inout_ PVOID SessionEntry,
920 {
921  PEPROCESS EntryProcess;
922  PMM_SESSION_SPACE EntrySession, CurrentSession;
924  KIRQL OldIrql;
925 
926  /* The parameter is the actual process! */
927  EntryProcess = SessionEntry;
928  ASSERT(EntryProcess != NULL);
929 
930  /* Sanity checks */
932  ASSERT(EntryProcess->Vm.Flags.SessionLeader == 0);
933 
934  /* Get the session from the process that was passed in */
935  EntrySession = EntryProcess->Session;
936  ASSERT(EntrySession != NULL);
937 
938  /* Get the current process and it's session */
940  CurrentSession = CurrentProcess->Session;
941 
942  /* Acquire the expansion lock while touching the session */
944 
945  /* Check if the session is about to be deleted */
946  if (EntrySession->u.Flags.DeletePending)
947  {
948  /* We cannot attach to it, so unlock and fail */
951  }
952 
953  /* Count the number of attaches */
954  EntrySession->AttachCount++;
955 
956  /* we can release the lock again */
958 
959  /* Check if we are not the session leader and we are in a session */
960  if (!CurrentProcess->Vm.Flags.SessionLeader && (CurrentSession != NULL))
961  {
962  /* Are we already in the right session? */
963  if (CurrentSession == EntrySession)
964  {
965  /* We are, so "attach" to the current process */
966  EntryProcess = CurrentProcess;
967  }
968  else
969  {
970  /* We are not, the session id should better not match! */
971  ASSERT(CurrentSession->SessionId != EntrySession->SessionId);
972  }
973  }
974 
975  /* Now attach to the process that we have */
976  KeStackAttachProcess(&EntryProcess->Pcb, ApcState);
977 
978  /* Success! */
979  return STATUS_SUCCESS;
980 }
981 
983 VOID
984 NTAPI
985 MmDetachSession(
986  _Inout_ PVOID SessionEntry,
988 {
989  PEPROCESS EntryProcess;
990  PMM_SESSION_SPACE EntrySession;
991  KIRQL OldIrql;
992  BOOLEAN DeletePending;
993 
994  /* The parameter is the actual process! */
995  EntryProcess = SessionEntry;
996  ASSERT(EntryProcess != NULL);
997 
998  /* Sanity checks */
1000  ASSERT(EntryProcess->Vm.Flags.SessionLeader == 0);
1001 
1002  /* Get the session from the process that was passed in */
1003  EntrySession = EntryProcess->Session;
1004  ASSERT(EntrySession != NULL);
1005 
1006  /* Acquire the expansion lock while touching the session */
1008 
1009  /* Make sure we have at least one attach and decrement the count */
1010  ASSERT(EntrySession->AttachCount >= 1);
1011  EntrySession->AttachCount--;
1012 
1013  /* Remember if a delete is pending and we were the last one attached */
1014  DeletePending = EntrySession->u.Flags.DeletePending &&
1015  (EntrySession->AttachCount == 0);
1016 
1017  /* Release the lock again */
1019 
1020  /* Detach from the process */
1022 
1023  /* Check if we need to set the attach event */
1024  if (DeletePending)
1025  KeSetEvent(&EntrySession->AttachEvent, IO_NO_INCREMENT, FALSE);
1026 }
1027 
1028 VOID
1029 NTAPI
1031  _Inout_ PVOID SessionEntry)
1032 {
1033  PEPROCESS EntryProcess;
1034 
1035  /* The parameter is the actual process! */
1036  EntryProcess = SessionEntry;
1037  ASSERT(EntryProcess != NULL);
1038 
1039  /* Sanity checks */
1041  ASSERT(EntryProcess->Vm.Flags.SessionLeader == 0);
1042  ASSERT(EntryProcess->Session != NULL);
1043 
1044  /* Get rid of the reference we took */
1045  ObDereferenceObject(EntryProcess);
1046 }
1047 
1048 PVOID
1049 NTAPI
1052 {
1053  PLIST_ENTRY ListEntry;
1054  PMM_SESSION_SPACE Session;
1056  KIRQL OldIrql;
1057 
1058  /* Acquire the expansion lock while touching the session */
1060 
1061  /* Loop all entries in the session ws list */
1062  ListEntry = MiSessionWsList.Flink;
1063  while (ListEntry != &MiSessionWsList)
1064  {
1065  Session = CONTAINING_RECORD(ListEntry, MM_SESSION_SPACE, WsListEntry);
1066  ListEntry = ListEntry->Flink;
1067 
1068  /* Check if this is the session we are looking for */
1069  if (Session->SessionId == SessionId)
1070  {
1071  /* Check if we also have a process in the process list */
1072  if (!IsListEmpty(&Session->ProcessList))
1073  {
1075  EPROCESS,
1076  SessionProcessLinks);
1077 
1078  /* Reference the process */
1080  break;
1081  }
1082  }
1083  }
1084 
1085  /* Release the lock again */
1087 
1088  return Process;
1089 }
PFN_NUMBER MiSessionTagSizePages
Definition: session.c:22
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
VOID NTAPI MiDereferenceSessionFinal(VOID)
Definition: session.c:273
MMSUPPORT Vm
Definition: miarm.h:505
ULONG SessionId
Definition: miarm.h:482
LIST_ENTRY ProcessList
Definition: miarm.h:483
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define IN
Definition: typedefs.h:39
#define PspClearProcessFlag(Process, Flag)
Definition: ps_x.h:35
SIZE_T NonPageablePages
Definition: miarm.h:486
#define MI_SESSION_TAG_PAGES_MAXIMUM
Definition: miarm.h:253
LONG ReferenceCount
Definition: miarm.h:476
#define _Inout_
Definition: ms_sal.h:378
#define MiAddressToPde(x)
Definition: mmx86.c:20
FORCEINLINE KIRQL MiAcquireExpansionLock(VOID)
Definition: miarm.h:1536
#define PSF_SESSION_CREATION_UNDERWAY_BIT
Definition: pstypes.h:286
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
#define _Out_
Definition: ms_sal.h:345
PMMPDE PageTables
Definition: miarm.h:512
KSPIN_LOCK MmExpansionLock
Definition: session.c:32
LONG ProcessReferenceToSession
Definition: miarm.h:499
#define TRUE
Definition: types.h:120
PMMPTE NTAPI MiReserveSystemPtes(IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
Definition: syspte.c:246
#define MI_IS_SESSION_ADDRESS(Address)
Definition: miarm.h:171
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
union _MMPFN::@1778 u2
ULONG SessionId
Definition: dllmain.c:28
PMMWSL VmWorkingSetList
Definition: mmtypes.h:940
PFN_NUMBER MiSessionCreateCharge
Definition: session.c:23
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
VOID NTAPI MiSessionAddProcess(IN PEPROCESS NewProcess)
Definition: session.c:423
PMM_SESSION_SPACE MmSessionSpace
Definition: session.c:21
#define MI_GET_NEXT_COLOR()
Definition: miarm.h:237
LCID NTAPI MmGetSessionLocaleId(VOID)
Definition: session.c:56
LCID PsDefaultSystemLocaleId
Definition: locale.c:20
HARDWARE_PDE_ARMV6 TempPde
Definition: winldr.c:78
FORCEINLINE KIRQL MiAcquirePfnLock(VOID)
Definition: mm.h:946
#define InterlockedCompareExchange
Definition: interlocked.h:104
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
PFN_NUMBER MmLowestPhysicalPage
Definition: meminit.c:30
BOOLEAN NTAPI MmIsSessionAddress(IN PVOID Address)
Definition: session.c:48
ULONG SessionLeader
Definition: mmtypes.h:904
union _MMPTE::@2305 u
#define RtlCheckBit(BMH, BP)
Definition: rtlfuncs.h:3152
VOID NTAPI MiInitializePfnForOtherProcess(IN PFN_NUMBER PageFrameIndex, IN PVOID PteAddress, IN PFN_NUMBER PteFrame)
Definition: pfnlist.c:1292
PVOID MiSessionSpaceWs
Definition: mminit.c:130
KGUARDED_MUTEX MiSessionIdMutex
Definition: session.c:24
DWORD LCID
Definition: nls.h:13
VOID NTAPI MiZeroPhysicalPage(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:122
ULONG MinimumWorkingSetSize
Definition: mmtypes.h:938
GLdouble u1
Definition: glext.h:8308
#define PSF_PROCESS_IN_SESSION_BIT
Definition: pstypes.h:288
#define InsertTailList(ListHead, Entry)
if(dx==0 &&dy==0)
Definition: linetemp.h:174
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
LCID PsDefaultThreadLocaleId
Definition: locale.c:25
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
LIST_ENTRY MmWorkingSetExpansionHead
Definition: session.c:30
VOID NTAPI MiSessionRemoveProcess(VOID)
Definition: session.c:392
ULONG64 Global
Definition: mmtypes.h:166
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
ULONG NTAPI MmGetSessionId(IN PEPROCESS Process)
Definition: session.c:179
FORCEINLINE VOID MiReleasePfnLock(_In_ KIRQL OldIrql)
Definition: mm.h:953
NTSTATUS NTAPI MmSessionDelete(IN ULONG SessionId)
Definition: session.c:887
struct Color Color
PFN_NUMBER MiSessionTagPages
Definition: session.c:22
LONG MmSessionDataPages
Definition: session.c:25
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_ALREADY_COMMITTED
Definition: ntstatus.h:270
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
struct _MMPFN::@1779::@1785 e2
#define MI_MAKE_DIRTY_PAGE(x)
Definition: mm.h:98
PDRIVER_UNLOAD Win32KDriverUnload
Definition: miarm.h:507
PVOID MmSessionBase
Definition: init.c:33
VOID NTAPI MiSessionLeader(IN PEPROCESS Process)
Definition: session.c:167
#define MiAddressToPte(x)
Definition: mmx86.c:19
ULONG PFN_NUMBER
Definition: ke.h:9
volatile LONG MiSessionLeaderExists
Definition: session.c:27
LIST_ENTRY WsListEntry
Definition: miarm.h:500
#define TAG_MM
Definition: tag.h:136
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:964
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:704
ULONG_PTR ShareCount
Definition: mm.h:377
long LONG
Definition: pedump.c:60
ULONG SessionSpace
Definition: mmtypes.h:902
_IRQL_requires_max_(APC_LEVEL)
Definition: session.c:89
#define RtlInterlockedClearBits(Flags, Flag)
Definition: rtlfuncs.h:3440
NTSTATUS NTAPI MiSessionInitializeWorkingSetList(VOID)
Definition: session.c:461
#define PsGetCurrentProcess
Definition: psfuncs.h:17
FORCEINLINE PFN_NUMBER MiRemoveZeroPageSafe(IN ULONG Color)
Definition: miarm.h:2420
unsigned char BOOLEAN
PETHREAD MiExpansionLockOwner
Definition: session.c:33
static WCHAR Address[46]
Definition: ping.c:68
VOID NTAPI MiInitializeSessionIds(VOID)
Definition: session.c:116
_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
#define _In_
Definition: ms_sal.h:308
NTSYSAPI ULONG WINAPI RtlFindClearBitsAndSet(PRTL_BITMAP, ULONG, ULONG)
#define ExInitializePushLock
Definition: ex.h:1011
VOID NTAPI MiDecrementShareCount(IN PMMPFN Pfn1, IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:1143
FORCEINLINE VOID MI_WRITE_VALID_PDE(IN PMMPDE PointerPde, IN MMPDE TempPde)
Definition: miarm.h:1023
#define MI_SET_USAGE(x)
Definition: mm.h:304
VOID NTAPI MiReleaseSystemPtes(IN PMMPTE StartingPte, IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
Definition: syspte.c:264
NTSTATUS NTAPI MiSessionCreateInternal(OUT PULONG SessionId)
Definition: session.c:599
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
VOID NTAPI KeFlushEntireTb(IN BOOLEAN Invalid, IN BOOLEAN AllProcessors)
Definition: cpu.c:403
ULONG LongFlags
Definition: miarm.h:479
PVOID Session
Definition: pstypes.h:1325
Status
Definition: gdiplustypes.h:24
#define STATUS_UNABLE_TO_FREE_VM
Definition: ntstatus.h:263
ULONG PageFrameNumber
Definition: mmtypes.h:74
MMSUPPORT_FLAGS Flags
Definition: mmtypes.h:930
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
EX_PUSH_LOCK WorkingSetMutex
Definition: mmtypes.h:958
VOID NTAPI MiDereferenceSession(VOID)
Definition: session.c:339
MM_SESSION_SPACE_FLAGS Flags
Definition: miarm.h:480
struct _MM_SESSION_SPACE * GlobalVirtualAddress
Definition: miarm.h:475
ULONG CurrentProcess
Definition: shell.c:125
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
LIST_ENTRY WorkingSetExpansionLinks
Definition: mmtypes.h:922
VOID FASTCALL KeZeroPages(IN PVOID Address, IN ULONG Size)
Definition: stubs.c:94
#define ASSERT(a)
Definition: mode.c:44
SIZE_T CommittedPages
Definition: miarm.h:487
PRTL_BITMAP MiSessionIdBitmap
Definition: session.c:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFCOLLECTION _In_ ULONG Index
MMSESSION Session
Definition: miarm.h:502
BOOLEAN NTAPI MiInitializeSystemSpaceMap(IN PMMSESSION InputSession OPTIONAL)
Definition: section.c:240
MMPTE ValidKernelPteLocal
Definition: init.c:33
ULONG64 Valid
Definition: mmtypes.h:150
PFN_NUMBER MiSessionDataPages
Definition: session.c:22
#define STATUS_PROCESS_IS_TERMINATING
Definition: ntstatus.h:502
#define ObDereferenceObject
Definition: obfuncs.h:203
#define MI_SESSION_DATA_PAGES_MAXIMUM
Definition: miarm.h:252
VOID NTAPI RtlClearBit(_In_ PRTL_BITMAP BitMapHeader, _In_ BITMAP_INDEX BitNumber)
Definition: bitmap.c:294
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:76
MMPTE ValidKernelPte
Definition: init.c:29
BOOLEAN NTAPI MmIsAddressValid(IN PVOID VirtualAddress)
Definition: mmsup.c:174
struct _MMWSL * PMMWSL
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING _In_ PCUNICODE_STRING _In_ LCID LocaleId
Definition: wdfpdo.h:430
FORCEINLINE PMMPFN MI_PFN_ELEMENT(IN PFN_NUMBER Pfn)
Definition: miarm.h:1579
PMMWSLE Wsle
Definition: mmtypes.h:872
#define InterlockedDecrement
Definition: armddk.h:52
PMMWSLE_HASH HashTable
Definition: mmtypes.h:875
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define MI_INITIAL_SESSION_IDS
Definition: miarm.h:212
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
Definition: mm.h:360
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:119
KPROCESS Pcb
Definition: pstypes.h:1262
PVOID NTAPI MmGetSessionById(_In_ ULONG SessionId)
Definition: session.c:1050
union _MMPFN::@1779 u3
LIST_ENTRY ImageList
Definition: miarm.h:494
LIST_ENTRY MiSessionWsList
Definition: session.c:29
MMPTE ValidKernelPdeLocal
Definition: init.c:32
MMSUPPORT Vm
Definition: pstypes.h:1356
ULONG_PTR Long
Definition: mmtypes.h:215
PFN_NUMBER NTAPI MiRemoveAnyPage(IN ULONG Color)
Definition: pfnlist.c:477
VOID NTAPI MiReleaseProcessReferenceToSessionDataPage(IN PMM_SESSION_SPACE SessionGlobal)
Definition: session.c:209
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define MI_SET_PFN_DELETED(x)
Definition: miarm.h:194
PFN_COUNT MmNumberOfPhysicalPages
Definition: init.c:48
KEVENT AttachEvent
Definition: miarm.h:497
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InterlockedIncrement
Definition: armddk.h:53
ULONG NTAPI MmGetSessionIdEx(IN PEPROCESS Process)
Definition: session.c:194
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ROUND_TO_PAGES(Size)
ULONG HashTableSize
Definition: mmtypes.h:876
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PMMWSLE Wsle
Definition: miarm.h:506
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1656
LONG ResidentProcessCount
Definition: miarm.h:492
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
FORCEINLINE VOID MiReleaseExpansionLock(KIRQL OldIrql)
Definition: miarm.h:1549
NTSYSAPI void WINAPI RtlClearAllBits(PRTL_BITMAP)
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
union _MM_SESSION_SPACE::@1808 u
#define DPRINT1
Definition: precomp.h:8
ULONG WsIndex
Definition: mm.h:365
struct _MM_SESSION_SPACE * PMM_SESSION_SPACE
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define OUT
Definition: typedefs.h:40
#define ObReferenceObject
Definition: obfuncs.h:204
#define PspSetProcessFlag(Process, Flag)
Definition: ps_x.h:33
VOID NTAPI MiInitializePfnAndMakePteValid(IN PFN_NUMBER PageFrameIndex, IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: pfnlist.c:1043
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define PDE_MAPPED_VA
Definition: mm.h:39
#define STATUS_INVALID_SYSTEM_SERVICE
Definition: ntstatus.h:265
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
NTSTATUS NTAPI MmSessionCreate(OUT PULONG SessionId)
Definition: session.c:827
#define ULONG_PTR
Definition: config.h:101
VOID NTAPI MiInitializeSessionWsSupport(VOID)
Definition: session.c:40
ULONG AttachCount
Definition: miarm.h:496
PFN_NUMBER MmHighestPhysicalPage
Definition: meminit.c:31
#define STATUS_SUCCESS
Definition: shellext.h:65
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
FORCEINLINE PVOID MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:201
ULONG MaximumWorkingSetSize
Definition: mmtypes.h:939
FORCEINLINE BOOLEAN MI_IS_PHYSICAL_ADDRESS(IN PVOID Address)
Definition: miarm.h:950
PFN_NUMBER MiSessionBigPoolPages
Definition: session.c:23
signed int * PLONG
Definition: retypes.h:5
ULONG LastEntry
Definition: mmtypes.h:870
VOID NTAPI MmQuitNextSession(_Inout_ PVOID SessionEntry)
Definition: session.c:1030
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define PFN_FROM_PTE(v)
Definition: mm.h:92
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
* PKAPC_STATE
Definition: ketypes.h:1280
struct _MMWSLE * PMMWSLE
ULONG PageFrameNumber
Definition: mmtypes.h:109
PFN_NUMBER SessionPageDirectoryIndex
Definition: miarm.h:485
#define PAGED_CODE()
ULONG VadBitMapHint
Definition: mmtypes.h:881