MmNumberOfPagingFiles = 0;
}
-static ULONG
-MiAllocPageFromPagingFile(PMMPAGING_FILE PagingFile)
-{
- KIRQL oldIrql;
- ULONG off;
-
- KeAcquireSpinLock(&PagingFile->AllocMapLock, &oldIrql);
- off = RtlFindClearBitsAndSet(PagingFile->AllocMap, 1, 0);
- KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql);
-
- return off;
-}
-
VOID
NTAPI
MmFreeSwapPage(SWAPENTRY Entry)
{
KeBugCheck(MEMORY_MANAGEMENT);
}
- KeAcquireSpinLockAtDpcLevel(&PagingFile->AllocMapLock);
RtlClearBit(PagingFile->AllocMap, off >> 5);
MiFreeSwapPages++;
MiUsedSwapPages--;
- KeReleaseSpinLockFromDpcLevel(&PagingFile->AllocMapLock);
KeReleaseSpinLock(&PagingFileListLock, oldIrql);
}
if (MmPagingFile[i] != NULL &&
MmPagingFile[i]->FreePages >= 1)
{
- off = MiAllocPageFromPagingFile(MmPagingFile[i]);
+ off = RtlFindClearBitsAndSet(MmPagingFile[i]->AllocMap, 1, 0);
if (off == 0xFFFFFFFF)
{
KeBugCheck(MEMORY_MANAGEMENT);
PagingFile->CurrentSize.QuadPart = SafeInitialSize.QuadPart;
PagingFile->FreePages = (ULONG)(SafeInitialSize.QuadPart / PAGE_SIZE);
PagingFile->UsedPages = 0;
- KeInitializeSpinLock(&PagingFile->AllocMapLock);
PagingFile->PageFileName = PageFileName;
AllocMapSize = sizeof(RTL_BITMAP) + (((PagingFile->FreePages + 31) / 32) * sizeof(ULONG));