ULONG MmNumberOfPagingFiles;
/* Number of pages that are available for swapping */
-PFN_NUMBER MiFreeSwapPages;
+PFN_COUNT MiFreeSwapPages;
/* Number of pages that have been allocated for swapping */
-PFN_NUMBER MiUsedSwapPages;
+PFN_COUNT MiUsedSwapPages;
BOOLEAN MmZeroPageFile;
/*
* Number of pages that have been reserved for swapping but not yet allocated
*/
-static PFN_NUMBER MiReservedSwapPages;
+static PFN_COUNT MiReservedSwapPages;
/*
* Ratio between reserved and available swap pages, e.g. setting this to five
*/
#define FILE_FROM_ENTRY(i) ((i) & 0x0f)
#define OFFSET_FROM_ENTRY(i) ((i) >> 11)
-#define ENTRY_FROM_FILE_OFFSET(i, j) ((i) | (j) << 11 | 0x400)
+#define ENTRY_FROM_FILE_OFFSET(i, j) ((i) | ((j) << 11) | 0x400)
+
+/* Make sure there can be only 16 paging files */
+C_ASSERT(FILE_FROM_ENTRY(0xffffffff) < MAX_PAGING_FILES);
static BOOLEAN MmSwapSpaceMessage = FALSE;
MmBuildMdlFromPages(PMDL Mdl, PPFN_NUMBER Pages)
{
memcpy(Mdl + 1, Pages, sizeof(PFN_NUMBER) * (PAGE_ROUND_UP(Mdl->ByteOffset+Mdl->ByteCount)/PAGE_SIZE));
-
+
/* FIXME: this flag should be set by the caller perhaps? */
Mdl->MdlFlags |= MDL_IO_PAGE_READ;
}
BOOLEAN
NTAPI
-MmIsFileAPagingFile(PFILE_OBJECT FileObject)
+MmIsFileObjectAPagingFile(PFILE_OBJECT FileObject)
{
ULONG i;
NTAPI
MmWriteToSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page)
{
- ULONG i, offset;
+ ULONG i;
+ ULONG_PTR offset;
LARGE_INTEGER file_offset;
IO_STATUS_BLOCK Iosb;
NTSTATUS Status;
i = FILE_FROM_ENTRY(SwapEntry);
offset = OFFSET_FROM_ENTRY(SwapEntry);
- if (i >= MAX_PAGING_FILES)
- {
- DPRINT1("Bad swap entry 0x%.8X\n", SwapEntry);
- KeBugCheck(MEMORY_MANAGEMENT);
- }
if (PagingFileList[i]->FileObject == NULL ||
PagingFileList[i]->FileObject->DeviceObject == NULL)
{
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
Status = Iosb.Status;
}
-
+
if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
{
MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
NTAPI
MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_NUMBER Page)
{
- ULONG i, offset;
+ ULONG i;
+ ULONG_PTR offset;
LARGE_INTEGER file_offset;
IO_STATUS_BLOCK Iosb;
NTSTATUS Status;
i = FILE_FROM_ENTRY(SwapEntry);
offset = OFFSET_FROM_ENTRY(SwapEntry);
- if (i >= MAX_PAGING_FILES)
- {
- DPRINT1("Bad swap entry 0x%.8X\n", SwapEntry);
- KeBugCheck(MEMORY_MANAGEMENT);
- }
if (PagingFileList[i]->FileObject == NULL ||
PagingFileList[i]->FileObject->DeviceObject == NULL)
{
MmFreeSwapPage(SWAPENTRY Entry)
{
ULONG i;
- ULONG off;
+ ULONG_PTR off;
KIRQL oldIrql;
i = FILE_FROM_ENTRY(Entry);
off = OFFSET_FROM_ENTRY(Entry);
- if (i >= MAX_PAGING_FILES)
- {
- DPRINT1("Bad swap entry 0x%.8X\n", Entry);
- KeBugCheck(MEMORY_MANAGEMENT);
- }
-
KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
if (PagingFileList[i] == NULL)
{
* bytes) to the physical location of cluster 3042 then. */
if (BytesPerAllocationUnit % PAGE_SIZE)
{
- DPRINT1("BytesPerAllocationUnit %d is not a multiple of PAGE_SIZE %d\n",
+ DPRINT1("BytesPerAllocationUnit %lu is not a multiple of PAGE_SIZE %d\n",
BytesPerAllocationUnit, PAGE_SIZE);
ZwClose(FileHandle);
return STATUS_UNSUCCESSFUL;
ZwClose(FileHandle);
return(STATUS_NO_MEMORY);
}
- DPRINT("ExtentCount: %d\n", ExtentCount);
+ DPRINT("ExtentCount: %lu\n", ExtentCount);
Size = sizeof(RETRIEVAL_POINTERS_BUFFER) + ExtentCount * 2 * sizeof(LARGE_INTEGER);
PagingFile->RetrievalPointers = ExAllocatePool(NonPagedPool, Size);
if (PagingFile->RetrievalPointers == NULL)