ReactOS  0.4.15-dev-2504-g2b52f3b
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  }
368 
369  /* Check if tis is the session leader or the last process in the session */
370  if ((Process->Vm.Flags.SessionLeader) || (ReferenceCount == 0))
371  {
372  /* Get the global session address before we kill the session mapping */
373  SessionGlobal = MmSessionSpace->GlobalVirtualAddress;
374 
375  /* Delete all session PDEs and flush the TB */
377  BYTES_TO_PAGES(MmSessionSize) * sizeof(MMPDE));
379 
380  /* Is this the session leader? */
381  if (Process->Vm.Flags.SessionLeader)
382  {
383  /* Clean up the references here. */
384  ASSERT(Process->Session == NULL);
386  }
387  }
388 
389  /* Reset the current process' session flag */
391 }
392 
393 VOID
394 NTAPI
396 {
398  KIRQL OldIrql;
399 
400  /* If the process isn't already in a session, or if it's the leader... */
401  if (!(CurrentProcess->Flags & PSF_PROCESS_IN_SESSION_BIT) ||
402  (CurrentProcess->Vm.Flags.SessionLeader))
403  {
404  /* Then there's nothing to do */
405  return;
406  }
407 
408  /* Sanity check */
410 
411  /* Acquire the expansion lock while touching the session */
413 
414  /* Remove the process from the list */
415  RemoveEntryList(&CurrentProcess->SessionProcessLinks);
416 
417  /* Release the lock again */
419 
420  /* Dereference the session */
422 }
423 
424 VOID
425 NTAPI
427 {
428  PMM_SESSION_SPACE SessionGlobal;
429  KIRQL OldIrql;
430 
431  /* The current process must already be in a session */
433 
434  /* Sanity check */
436 
437  /* Get the global session */
438  SessionGlobal = MmSessionSpace->GlobalVirtualAddress;
439 
440  /* Increment counters */
441  InterlockedIncrement((PLONG)&SessionGlobal->ReferenceCount);
444 
445  /* Set the session pointer */
446  ASSERT(NewProcess->Session == NULL);
447  NewProcess->Session = SessionGlobal;
448 
449  /* Acquire the expansion lock while touching the session */
451 
452  /* Insert it into the process list */
453  InsertTailList(&SessionGlobal->ProcessList, &NewProcess->SessionProcessLinks);
454 
455  /* Release the lock again */
457 
458  /* Set the flag */
460 }
461 
462 NTSTATUS
463 NTAPI
465 {
466  KIRQL OldIrql;
467  PMMPTE PointerPte;
468  PMMPDE PointerPde;
469  MMPTE TempPte;
470  MMPDE TempPde;
471  ULONG Color, Index;
472  PFN_NUMBER PageFrameIndex;
473  PMM_SESSION_SPACE SessionGlobal;
474  BOOLEAN AllocatedPageTable;
475  PMMWSL WorkingSetList;
476 
477  /* Get pointers to session global and the session working set list */
478  SessionGlobal = MmSessionSpace->GlobalVirtualAddress;
479  WorkingSetList = (PMMWSL)MiSessionSpaceWs;
480 
481  /* Fill out the two pointers */
482  MmSessionSpace->Vm.VmWorkingSetList = WorkingSetList;
483  MmSessionSpace->Wsle = (PMMWSLE)WorkingSetList->UsedPageTableEntries;
484 
485  /* Get the PDE for the working set, and check if it's already allocated */
486  PointerPde = MiAddressToPde(WorkingSetList);
487  if (PointerPde->u.Hard.Valid == 1)
488  {
489  /* Nope, we'll have to do it */
490 #ifndef _M_ARM
491  ASSERT(PointerPde->u.Hard.Global == 0);
492 #endif
493  AllocatedPageTable = FALSE;
494  }
495  else
496  {
497  /* Yep, that makes our job easier */
498  AllocatedPageTable = TRUE;
499  }
500 
501  /* Get the PTE for the working set */
502  PointerPte = MiAddressToPte(WorkingSetList);
503 
504  /* Initialize the working set lock, and lock the PFN database */
505  ExInitializePushLock(&SessionGlobal->Vm.WorkingSetMutex);
506  //MmLockPageableSectionByHandle(ExPageLockHandle);
508 
509  /* Check if we need a page table */
510  if (AllocatedPageTable != FALSE)
511  {
512  /* Get a zeroed colored zero page */
515  PageFrameIndex = MiRemoveZeroPageSafe(Color);
516  if (!PageFrameIndex)
517  {
518  /* No zero pages, grab a free one */
519  PageFrameIndex = MiRemoveAnyPage(Color);
520 
521  /* Zero it outside the PFN lock */
523  MiZeroPhysicalPage(PageFrameIndex);
525  }
526 
527  /* Write a valid PDE for it */
529  TempPde.u.Hard.PageFrameNumber = PageFrameIndex;
530  MI_WRITE_VALID_PDE(PointerPde, TempPde);
531 
532  /* Add this into the list */
533  Index = ((ULONG_PTR)WorkingSetList - (ULONG_PTR)MmSessionBase) >> 22;
534 #ifndef _M_AMD64
536 #endif
537  /* Initialize the page directory page, and now zero the working set list itself */
538  MiInitializePfnForOtherProcess(PageFrameIndex,
539  PointerPde,
541  KeZeroPages(PointerPte, PAGE_SIZE);
542  }
543 
544  /* Get a zeroed colored zero page */
547  PageFrameIndex = MiRemoveZeroPageSafe(Color);
548  if (!PageFrameIndex)
549  {
550  /* No zero pages, grab a free one */
551  PageFrameIndex = MiRemoveAnyPage(Color);
552 
553  /* Zero it outside the PFN lock */
555  MiZeroPhysicalPage(PageFrameIndex);
557  }
558 
559  /* Write a valid PTE for it */
562  TempPte.u.Hard.PageFrameNumber = PageFrameIndex;
563 
564  /* Initialize the working set list page */
565  MiInitializePfnAndMakePteValid(PageFrameIndex, PointerPte, TempPte);
566 
567  /* Now we can release the PFN database lock */
569 
570  /* Fill out the working set structure */
574  WorkingSetList->LastEntry = 20;
575  WorkingSetList->HashTable = NULL;
576  WorkingSetList->HashTableSize = 0;
577  WorkingSetList->Wsle = MmSessionSpace->Wsle;
578 
579  /* Acquire the expansion lock while touching the session */
581 
582  /* Handle list insertions */
583  ASSERT(SessionGlobal->WsListEntry.Flink == NULL);
584  ASSERT(SessionGlobal->WsListEntry.Blink == NULL);
585  InsertTailList(&MiSessionWsList, &SessionGlobal->WsListEntry);
586 
587  ASSERT(SessionGlobal->Vm.WorkingSetExpansionLinks.Flink == NULL);
588  ASSERT(SessionGlobal->Vm.WorkingSetExpansionLinks.Blink == NULL);
590  &SessionGlobal->Vm.WorkingSetExpansionLinks);
591 
592  /* Release the lock again */
594 
595  /* All done, return */
596  //MmUnlockPageableImageSection(ExPageLockHandle);
597  return STATUS_SUCCESS;
598 }
599 
600 NTSTATUS
601 NTAPI
603 {
605  ULONG NewFlags, Flags, i, Color;
606 #if (_MI_PAGING_LEVELS < 3)
607  ULONG Size;
608 #endif // (_MI_PAGING_LEVELS < 3)
609  PMMPDE PageTables = NULL;
610  KIRQL OldIrql;
611  PMMPTE PointerPte, SessionPte;
612  PMMPDE PointerPde;
613  PMM_SESSION_SPACE SessionGlobal;
614  MMPTE TempPte;
615  MMPDE TempPde;
617  BOOLEAN Result;
618  PFN_NUMBER SessionPageDirIndex;
621 
622  /* This should not exist yet */
624 
625  /* Loop so we can set the session-is-creating flag */
626  Flags = Process->Flags;
627  while (TRUE)
628  {
629  /* Check if it's already set */
631  {
632  /* Bail out */
633  DPRINT1("Lost session race\n");
635  }
636 
637  /* Now try to set it */
638  NewFlags = InterlockedCompareExchange((PLONG)&Process->Flags,
640  Flags);
641  if (NewFlags == Flags) break;
642 
643  /* It changed, try again */
644  Flags = NewFlags;
645  }
646 
647  /* Now we should own the flag */
649 
650 #if (_MI_PAGING_LEVELS < 3)
651  /*
652  * Session space covers everything from 0xA0000000 to 0xC0000000.
653  * Allocate enough page tables to describe the entire region
654  */
655  Size = (0x20000000 / PDE_MAPPED_VA) * sizeof(MMPTE);
656  PageTables = ExAllocatePoolWithTag(NonPagedPool, Size, 'tHmM');
657  ASSERT(PageTables != NULL);
658  RtlZeroMemory(PageTables, Size);
659 #endif // (_MI_PAGING_LEVELS < 3)
660 
661  /* Lock the session ID creation mutex */
663 
664  /* Allocate a new Session ID */
666  if (*SessionId == 0xFFFFFFFF)
667  {
668  /* We ran out of session IDs, we should expand */
669  DPRINT1("Too many sessions created. Expansion not yet supported\n");
670 #if (_MI_PAGING_LEVELS < 3)
671  ExFreePoolWithTag(PageTables, 'tHmM');
672 #endif // (_MI_PAGING_LEVELS < 3)
673  return STATUS_NO_MEMORY;
674  }
675 
676  /* Unlock the session ID creation mutex */
678 
679  /* Reserve the global PTEs */
681  ASSERT(SessionPte != NULL);
682 
683  /* Acquire the PFN lock while we set everything up */
685 
686  /* Loop the global PTEs */
688  for (i = 0; i < MiSessionDataPages; i++)
689  {
690  /* Get a zeroed colored zero page */
693  DataPage[i] = MiRemoveZeroPageSafe(Color);
694  if (!DataPage[i])
695  {
696  /* No zero pages, grab a free one */
697  DataPage[i] = MiRemoveAnyPage(Color);
698 
699  /* Zero it outside the PFN lock */
701  MiZeroPhysicalPage(DataPage[i]);
703  }
704 
705  /* Fill the PTE out */
706  TempPte.u.Hard.PageFrameNumber = DataPage[i];
707  MI_WRITE_VALID_PTE(SessionPte + i, TempPte);
708  }
709 
710  /* Set the pointer to global space */
711  SessionGlobal = MiPteToAddress(SessionPte);
712 
713  /* Get a zeroed colored zero page */
716  SessionPageDirIndex = MiRemoveZeroPageSafe(Color);
717  if (!SessionPageDirIndex)
718  {
719  /* No zero pages, grab a free one */
720  SessionPageDirIndex = MiRemoveAnyPage(Color);
721 
722  /* Zero it outside the PFN lock */
724  MiZeroPhysicalPage(SessionPageDirIndex);
726  }
727 
728  /* Fill the PTE out */
730  TempPde.u.Hard.PageFrameNumber = SessionPageDirIndex;
731 
732  /* Setup, allocate, fill out the MmSessionSpace PTE */
733  PointerPde = MiAddressToPde(MmSessionSpace);
734  ASSERT(PointerPde->u.Long == 0);
735  MI_WRITE_VALID_PDE(PointerPde, TempPde);
736  MiInitializePfnForOtherProcess(SessionPageDirIndex,
737  PointerPde,
738  SessionPageDirIndex);
739  ASSERT(MI_PFN_ELEMENT(SessionPageDirIndex)->u1.WsIndex == 0);
740 
741  /* Loop all the local PTEs for it */
743  PointerPte = MiAddressToPte(MmSessionSpace);
744  for (i = 0; i < MiSessionDataPages; i++)
745  {
746  /* And fill them out */
747  TempPte.u.Hard.PageFrameNumber = DataPage[i];
748  MiInitializePfnAndMakePteValid(DataPage[i], PointerPte + i, TempPte);
749  ASSERT(MI_PFN_ELEMENT(DataPage[i])->u1.WsIndex == 0);
750  }
751 
752  /* Finally loop all of the session pool tag pages */
753  for (i = 0; i < MiSessionTagPages; i++)
754  {
755  /* Grab a zeroed colored page */
758  TagPage[i] = MiRemoveZeroPageSafe(Color);
759  if (!TagPage[i])
760  {
761  /* No zero pages, grab a free one */
762  TagPage[i] = MiRemoveAnyPage(Color);
763 
764  /* Zero it outside the PFN lock */
766  MiZeroPhysicalPage(TagPage[i]);
768  }
769 
770  /* Fill the PTE out */
771  TempPte.u.Hard.PageFrameNumber = TagPage[i];
773  PointerPte + MiSessionDataPages + i,
774  TempPte);
775  }
776 
777  /* PTEs have been setup, release the PFN lock */
779 
780  /* Fill out the session space structure now */
781  MmSessionSpace->GlobalVirtualAddress = SessionGlobal;
787  MmSessionSpace->SessionPageDirectoryIndex = SessionPageDirIndex;
791 #ifndef _M_AMD64
792  MmSessionSpace->PageTables = PageTables;
793  MmSessionSpace->PageTables[PointerPde - MiAddressToPde(MmSessionBase)] = *PointerPde;
794 #endif
796 
797  DPRINT1("Session %lu is ready to go: 0x%p 0x%p, %lx 0x%p\n",
798  *SessionId, MmSessionSpace, SessionGlobal, SessionPageDirIndex, PageTables);
799 
800  /* Initialize session pool */
801  //Status = MiInitializeSessionPool();
804 
805  /* Initialize system space */
806  Result = MiInitializeSystemSpaceMap(&SessionGlobal->Session);
807  ASSERT(Result == TRUE);
808 
809  /* Initialize the process list, make sure the workign set list is empty */
810  ASSERT(SessionGlobal->WsListEntry.Flink == NULL);
811  ASSERT(SessionGlobal->WsListEntry.Blink == NULL);
812  InitializeListHead(&SessionGlobal->ProcessList);
813 
814  /* We're done, clear the flag */
817 
818  /* Insert the process into the session */
819  ASSERT(Process->Session == NULL);
820  ASSERT(SessionGlobal->ProcessReferenceToSession == 0);
821  SessionGlobal->ProcessReferenceToSession = 1;
822 
823  /* We're done */
825  return STATUS_SUCCESS;
826 }
827 
828 NTSTATUS
829 NTAPI
831 {
833  ULONG SessionLeaderExists;
835 
836  /* Fail if the process is already in a session */
837  if (Process->Flags & PSF_PROCESS_IN_SESSION_BIT)
838  {
839  DPRINT1("Process already in session\n");
841  }
842 
843  /* Check if the process is already the session leader */
844  if (!Process->Vm.Flags.SessionLeader)
845  {
846  /* Atomically set it as the leader */
847  SessionLeaderExists = InterlockedCompareExchange(&MiSessionLeaderExists, 1, 0);
848  if (SessionLeaderExists)
849  {
850  DPRINT1("Session leader race\n");
852  }
853 
854  /* Do the work required to upgrade him */
856  }
857 
858  /* Create the session */
861  if (!NT_SUCCESS(Status))
862  {
864  return Status;
865  }
866 
867  /* Set up the session working set */
869  if (!NT_SUCCESS(Status))
870  {
871  /* Fail */
872  //MiDereferenceSession();
873  ASSERT(FALSE);
875  return Status;
876  }
877 
878  /* All done */
880 
881  /* Set and assert the flags, and return */
885  return Status;
886 }
887 
888 NTSTATUS
889 NTAPI
891 {
893 
894  /* Process must be in a session */
895  if (!(Process->Flags & PSF_PROCESS_IN_SESSION_BIT))
896  {
897  DPRINT1("Not in a session!\n");
899  }
900 
901  /* It must be the session leader */
902  if (!Process->Vm.Flags.SessionLeader)
903  {
904  DPRINT1("Not a session leader!\n");
906  }
907 
908  /* Remove one reference count */
910  /* FIXME: Do it */
912 
913  /* All done */
914  return STATUS_SUCCESS;
915 }
916 
918 NTSTATUS
919 NTAPI
920 MmAttachSession(
921  _Inout_ PVOID SessionEntry,
923 {
924  PEPROCESS EntryProcess;
925  PMM_SESSION_SPACE EntrySession, CurrentSession;
927  KIRQL OldIrql;
928 
929  /* The parameter is the actual process! */
930  EntryProcess = SessionEntry;
931  ASSERT(EntryProcess != NULL);
932 
933  /* Sanity checks */
935  ASSERT(EntryProcess->Vm.Flags.SessionLeader == 0);
936 
937  /* Get the session from the process that was passed in */
938  EntrySession = EntryProcess->Session;
939  ASSERT(EntrySession != NULL);
940 
941  /* Get the current process and it's session */
943  CurrentSession = CurrentProcess->Session;
944 
945  /* Acquire the expansion lock while touching the session */
947 
948  /* Check if the session is about to be deleted */
949  if (EntrySession->u.Flags.DeletePending)
950  {
951  /* We cannot attach to it, so unlock and fail */
954  }
955 
956  /* Count the number of attaches */
957  EntrySession->AttachCount++;
958 
959  /* we can release the lock again */
961 
962  /* Check if we are not the session leader and we are in a session */
963  if (!CurrentProcess->Vm.Flags.SessionLeader && (CurrentSession != NULL))
964  {
965  /* Are we already in the right session? */
966  if (CurrentSession == EntrySession)
967  {
968  /* We are, so "attach" to the current process */
969  EntryProcess = CurrentProcess;
970  }
971  else
972  {
973  /* We are not, the session id should better not match! */
974  ASSERT(CurrentSession->SessionId != EntrySession->SessionId);
975  }
976  }
977 
978  /* Now attach to the process that we have */
979  KeStackAttachProcess(&EntryProcess->Pcb, ApcState);
980 
981  /* Success! */
982  return STATUS_SUCCESS;
983 }
984 
986 VOID
987 NTAPI
988 MmDetachSession(
989  _Inout_ PVOID SessionEntry,
991 {
992  PEPROCESS EntryProcess;
993  PMM_SESSION_SPACE EntrySession;
994  KIRQL OldIrql;
995  BOOLEAN DeletePending;
996 
997  /* The parameter is the actual process! */
998  EntryProcess = SessionEntry;
999  ASSERT(EntryProcess != NULL);
1000 
1001  /* Sanity checks */
1003  ASSERT(EntryProcess->Vm.Flags.SessionLeader == 0);
1004 
1005  /* Get the session from the process that was passed in */
1006  EntrySession = EntryProcess->Session;
1007  ASSERT(EntrySession != NULL);
1008 
1009  /* Acquire the expansion lock while touching the session */
1011 
1012  /* Make sure we have at least one attach and decrement the count */
1013  ASSERT(EntrySession->AttachCount >= 1);
1014  EntrySession->AttachCount--;
1015 
1016  /* Remember if a delete is pending and we were the last one attached */
1017  DeletePending = EntrySession->u.Flags.DeletePending &&
1018  (EntrySession->AttachCount == 0);
1019 
1020  /* Release the lock again */
1022 
1023  /* Detach from the process */
1025 
1026  /* Check if we need to set the attach event */
1027  if (DeletePending)
1028  KeSetEvent(&EntrySession->AttachEvent, IO_NO_INCREMENT, FALSE);
1029 }
1030 
1031 VOID
1032 NTAPI
1034  _Inout_ PVOID SessionEntry)
1035 {
1036  PEPROCESS EntryProcess;
1037 
1038  /* The parameter is the actual process! */
1039  EntryProcess = SessionEntry;
1040  ASSERT(EntryProcess != NULL);
1041 
1042  /* Sanity checks */
1044  ASSERT(EntryProcess->Vm.Flags.SessionLeader == 0);
1045  ASSERT(EntryProcess->Session != NULL);
1046 
1047  /* Get rid of the reference we took */
1048  ObDereferenceObject(EntryProcess);
1049 }
1050 
1051 PVOID
1052 NTAPI
1055 {
1056  PLIST_ENTRY ListEntry;
1057  PMM_SESSION_SPACE Session;
1059  KIRQL OldIrql;
1060 
1061  /* Acquire the expansion lock while touching the session */
1063 
1064  /* Loop all entries in the session ws list */
1065  ListEntry = MiSessionWsList.Flink;
1066  while (ListEntry != &MiSessionWsList)
1067  {
1068  Session = CONTAINING_RECORD(ListEntry, MM_SESSION_SPACE, WsListEntry);
1069  ListEntry = ListEntry->Flink;
1070 
1071  /* Check if this is the session we are looking for */
1072  if (Session->SessionId == SessionId)
1073  {
1074  /* Check if we also have a process in the process list */
1075  if (!IsListEmpty(&Session->ProcessList))
1076  {
1078  EPROCESS,
1079  SessionProcessLinks);
1080 
1081  /* Reference the process */
1083  break;
1084  }
1085  }
1086  }
1087 
1088  /* Release the lock again */
1090 
1091  return Process;
1092 }
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:510
ULONG SessionId
Definition: miarm.h:487
LIST_ENTRY ProcessList
Definition: miarm.h:488
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define IN
Definition: typedefs.h:39
#define PspClearProcessFlag(Process, Flag)
Definition: ps_x.h:35
union _MM_SESSION_SPACE::@1806 u
SIZE_T NonPageablePages
Definition: miarm.h:491
#define MI_SESSION_TAG_PAGES_MAXIMUM
Definition: miarm.h:258
LONG ReferenceCount
Definition: miarm.h:481
#define MiAddressToPde(x)
Definition: mmx86.c:20
FORCEINLINE KIRQL MiAcquireExpansionLock(VOID)
Definition: miarm.h:1514
ULONG MmSessionSize
Definition: init.c:34
union _MMPTE::@2304 u
USHORT UsedPageTableEntries[768]
Definition: mmtypes.h:882
#define PSF_SESSION_CREATION_UNDERWAY_BIT
Definition: pstypes.h:286
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
PMMPDE PageTables
Definition: miarm.h:517
KSPIN_LOCK MmExpansionLock
Definition: session.c:32
LONG ProcessReferenceToSession
Definition: miarm.h:504
#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
struct _MMPFN::@1778::@1784 e2
ULONG SessionId
Definition: dllmain.c:28
PMMWSL VmWorkingSetList
Definition: mmtypes.h:929
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:426
PMM_SESSION_SPACE MmSessionSpace
Definition: session.c:21
#define MI_GET_NEXT_COLOR()
Definition: miarm.h:242
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:923
#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:893
#define RtlCheckBit(BMH, BP)
Definition: rtlfuncs.h:3154
VOID NTAPI MiInitializePfnForOtherProcess(IN PFN_NUMBER PageFrameIndex, IN PVOID PteAddress, IN PFN_NUMBER PteFrame)
Definition: pfnlist.c:1279
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:927
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:395
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:930
union _MMPFN::@1778 u3
NTSTATUS NTAPI MmSessionDelete(IN ULONG SessionId)
Definition: session.c:890
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
#define MI_MAKE_DIRTY_PAGE(x)
Definition: mm.h:98
PDRIVER_UNLOAD Win32KDriverUnload
Definition: miarm.h:512
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:505
#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:951
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:701
ULONG_PTR ShareCount
Definition: mm.h:362
long LONG
Definition: pedump.c:60
ULONG SessionSpace
Definition: mmtypes.h:891
_IRQL_requires_max_(APC_LEVEL)
Definition: session.c:89
#define RtlInterlockedClearBits(Flags, Flag)
Definition: rtlfuncs.h:3442
NTSTATUS NTAPI MiSessionInitializeWorkingSetList(VOID)
Definition: session.c:464
#define PsGetCurrentProcess
Definition: psfuncs.h:17
FORCEINLINE PFN_NUMBER MiRemoveZeroPageSafe(IN ULONG Color)
Definition: miarm.h:2413
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 _Out_
Definition: no_sal2.h:160
NTSYSAPI ULONG WINAPI RtlFindClearBitsAndSet(PRTL_BITMAP, ULONG, ULONG)
#define ExInitializePushLock
Definition: ex.h:992
VOID NTAPI MiDecrementShareCount(IN PMMPFN Pfn1, IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:1132
FORCEINLINE VOID MI_WRITE_VALID_PDE(IN PMMPDE PointerPde, IN MMPDE TempPde)
Definition: miarm.h:1010
#define MI_SET_USAGE(x)
Definition: mm.h:289
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:602
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:416
ULONG LongFlags
Definition: miarm.h:484
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:919
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
EX_PUSH_LOCK WorkingSetMutex
Definition: mmtypes.h:947
VOID NTAPI MiDereferenceSession(VOID)
Definition: session.c:339
MM_SESSION_SPACE_FLAGS Flags
Definition: miarm.h:485
struct _MM_SESSION_SPACE * GlobalVirtualAddress
Definition: miarm.h:480
ULONG CurrentProcess
Definition: shell.c:125
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
LIST_ENTRY WorkingSetExpansionLinks
Definition: mmtypes.h:911
VOID FASTCALL KeZeroPages(IN PVOID Address, IN ULONG Size)
Definition: stubs.c:91
#define ASSERT(a)
Definition: mode.c:45
SIZE_T CommittedPages
Definition: miarm.h:492
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:507
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:257
VOID NTAPI RtlClearBit(_In_ PRTL_BITMAP BitMapHeader, _In_ BITMAP_INDEX BitNumber)
Definition: bitmap.c:294
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:76
#define _Inout_
Definition: no_sal2.h:162
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
#define BYTES_TO_PAGES(Size)
FORCEINLINE PMMPFN MI_PFN_ELEMENT(IN PFN_NUMBER Pfn)
Definition: miarm.h:1557
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:345
#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:1053
LIST_ENTRY ImageList
Definition: miarm.h:499
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
#define _In_
Definition: no_sal2.h:158
PFN_NUMBER NTAPI MiRemoveAnyPage(IN ULONG Color)
Definition: pfnlist.c:475
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:502
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:753
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PMMWSLE Wsle
Definition: miarm.h:511
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1606
LONG ResidentProcessCount
Definition: miarm.h:497
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
FORCEINLINE VOID MiReleaseExpansionLock(KIRQL OldIrql)
Definition: miarm.h:1527
NTSYSAPI void WINAPI RtlClearAllBits(PRTL_BITMAP)
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
#define DPRINT1
Definition: precomp.h:8
ULONG WsIndex
Definition: mm.h:350
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:1035
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
union _MMPFN::@1777 u2
NTSTATUS NTAPI MmSessionCreate(OUT PULONG SessionId)
Definition: session.c:830
#define ULONG_PTR
Definition: config.h:101
VOID NTAPI MiInitializeSessionWsSupport(VOID)
Definition: session.c:40
ULONG AttachCount
Definition: miarm.h:501
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:928
FORCEINLINE BOOLEAN MI_IS_PHYSICAL_ADDRESS(IN PVOID Address)
Definition: miarm.h:937
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:1033
#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:490
#define PAGED_CODE()