ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

Definition at line 47 of file rmap.c.

Referenced by CcRosTrimCache(), and MmTrimUserMemory().

{
   PMM_RMAP_ENTRY entry;
   PMEMORY_AREA MemoryArea;
   PMMSUPPORT AddressSpace;
   ULONG Type;
   PVOID Address;
   PEPROCESS Process;
   ULONGLONG Offset;
   NTSTATUS Status = STATUS_SUCCESS;

   ExAcquireFastMutex(&RmapListLock);
   entry = MmGetRmapListHeadPage(Page);

#ifdef NEWCC
   // Special case for NEWCC: we can have a page that's only in a segment
   // page table
   if (entry && RMAP_IS_SEGMENT(entry->Address) && entry->Next == NULL)
   {
       /* NEWCC does locking itself */
       ExReleaseFastMutex(&RmapListLock);
       return MmpPageOutPhysicalAddress(Page);
   }
#endif

   while (entry && RMAP_IS_SEGMENT(entry->Address))
       entry = entry->Next;

   if (entry == NULL)
   {
      ExReleaseFastMutex(&RmapListLock);
      return(STATUS_UNSUCCESSFUL);
   }

   Process = entry->Process;

   Address = entry->Address;

   if ((((ULONG_PTR)Address) & 0xFFF) != 0)
   {
      KeBugCheck(MEMORY_MANAGEMENT);
   }

   if (Address < MmSystemRangeStart)
   {
       if (!ExAcquireRundownProtection(&Process->RundownProtect))
       {
          ExReleaseFastMutex(&RmapListLock);
          return STATUS_PROCESS_IS_TERMINATING;
       }

      Status = ObReferenceObjectByPointer(Process, PROCESS_ALL_ACCESS, NULL, KernelMode);
      ExReleaseFastMutex(&RmapListLock);
      if (!NT_SUCCESS(Status))
      {
         ExReleaseRundownProtection(&Process->RundownProtect);
         return Status;
      }
      AddressSpace = &Process->Vm;
   }
   else
   {
      ExReleaseFastMutex(&RmapListLock);
      AddressSpace = MmGetKernelAddressSpace();
   }

   MmLockAddressSpace(AddressSpace);
   MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, Address);
   if (MemoryArea == NULL || MemoryArea->DeleteInProgress)
   {
      MmUnlockAddressSpace(AddressSpace);
      if (Address < MmSystemRangeStart)
      {
         ExReleaseRundownProtection(&Process->RundownProtect);
         ObDereferenceObject(Process);
      }
      return(STATUS_UNSUCCESSFUL);
   }
   Type = MemoryArea->Type;
   if (Type == MEMORY_AREA_SECTION_VIEW)
   {
      ULONG_PTR Entry;
      Offset = MemoryArea->Data.SectionData.ViewOffset.QuadPart +
               ((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress);

      MmLockSectionSegment(MemoryArea->Data.SectionData.Segment);

      /*
       * Get or create a pageop
       */
      Entry = MmGetPageEntrySectionSegment(MemoryArea->Data.SectionData.Segment,
                                           (PLARGE_INTEGER)&Offset);
      if (Entry && IS_SWAP_FROM_SSE(Entry) && SWAPENTRY_FROM_SSE(Entry) == MM_WAIT_ENTRY)
      {
         MmUnlockSectionSegment(MemoryArea->Data.SectionData.Segment);
         MmUnlockAddressSpace(AddressSpace);
         if (Address < MmSystemRangeStart)
         {
            ExReleaseRundownProtection(&Process->RundownProtect);
            ObDereferenceObject(Process);
         }
         return(STATUS_UNSUCCESSFUL);
      }

      MmSetPageEntrySectionSegment(MemoryArea->Data.SectionData.Segment, (PLARGE_INTEGER)&Offset, MAKE_SWAP_SSE(MM_WAIT_ENTRY));

      /*
       * Release locks now we have a page op.
       */
      MmUnlockSectionSegment(MemoryArea->Data.SectionData.Segment);
      MmUnlockAddressSpace(AddressSpace);

      /*
       * Do the actual page out work.
       */
      Status = MmPageOutSectionView(AddressSpace, MemoryArea, Address, Entry);
   }
   else if (Type == MEMORY_AREA_CACHE)
   {
       /* NEWCC does locking itself */
       MmUnlockAddressSpace(AddressSpace);
       Status = MmpPageOutPhysicalAddress(Page);
   }
   else
   {
      KeBugCheck(MEMORY_MANAGEMENT);
   }

   if (Address < MmSystemRangeStart)
   {
      ExReleaseRundownProtection(&Process->RundownProtect);
      ObDereferenceObject(Process);
   }
   return(Status);
}

Generated on Sun May 27 2012 06:08:28 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.