/*
* PROJECT: ReactOS Windows-Compatible Session Manager
* LICENSE: BSD 2-Clause License
- * FILE: base/system/smss/smss.c
+ * FILE: base/system/smss/pagefile.c
* PURPOSE: Main SMSS Code
* PROGRAMMERS: Alex Ionescu
*/
/* INCLUDES *******************************************************************/
#include "smss.h"
+
#define NDEBUG
-#include "debug.h"
+#include <debug.h>
/* GLOBALS ********************************************************************/
/* Make sure we don't have too many */
if (SmpNumberOfPagingFiles >= 16)
{
- DPRINT1("SMSS:PFILE: Too many paging files specified - %d\n",
+ DPRINT1("SMSS:PFILE: Too many paging files specified - %lu\n",
SmpNumberOfPagingFiles);
return STATUS_TOO_MANY_PAGING_FILES;
}
/* Parse the specified and get the name and arguments out of it */
- DPRINT("SMSS:PFILE: Paging file specifier `%wZ' \n", PageFileToken);
+ DPRINT("SMSS:PFILE: Paging file specifier `%wZ'\n", PageFileToken);
Status = SmpParseCommandLine(PageFileToken,
NULL,
&PageFileName,
if (!NT_SUCCESS(Status))
{
/* Fail */
- DPRINT1("SMSS:PFILE: SmpParseCommandLine(%wZ) failed with status %X \n",
+ DPRINT1("SMSS:PFILE: SmpParseCommandLine( %wZ ) failed - Status == %lx\n",
PageFileToken, Status);
return Status;
}
{
/* Use the rest of the arguments as a maximum size */
SecondArgument.Buffer = &Arguments.Buffer[i];
- SecondArgument.Length = Arguments.Length -
- i * sizeof(WCHAR);
- SecondArgument.MaximumLength = Arguments.MaximumLength -
- i * sizeof(WCHAR);
+ SecondArgument.Length = (USHORT)(Arguments.Length -
+ i * sizeof(WCHAR));
+ SecondArgument.MaximumLength = (USHORT)(Arguments.MaximumLength -
+ i * sizeof(WCHAR));
Status = RtlUnicodeStringToInteger(&SecondArgument, 0, &MaxSize);
if (!NT_SUCCESS(Status))
{
/* This means no duplicates exist, so insert our descriptor! */
InsertTailList(&SmpPagingFileDescriptorList, &Descriptor->Entry);
SmpNumberOfPagingFiles++;
- DPRINT("SMSS:PFILE: Created descriptor for `%wZ' (`%wZ') \n",
+ DPRINT("SMSS:PFILE: Created descriptor for `%wZ' (`%wZ')\n",
PageFileToken, &Descriptor->Name);
return STATUS_SUCCESS;
}
!(Descriptor->Flags & SMP_PAGEFILE_ON_ANY_DRIVE));
/* We found a duplicate, so skip this descriptor/pagefile and fail */
- DPRINT1("SMSS:PFILE: Skipping duplicate specifier `%wZ' \n", PageFileToken);
+ DPRINT1("SMSS:PFILE: Skipping duplicate specifier `%wZ'\n", PageFileToken);
RtlFreeUnicodeString(&PageFileName);
RtlFreeHeap(RtlGetProcessHeap(), 0, Descriptor);
return STATUS_INVALID_PARAMETER;
FileStandardInformation);
if (!NT_SUCCESS(Status))
{
- DPRINT1("SMSS:PFILE: Failed query for size potential pagefile `%wZ' with status %X \n",
+ DPRINT1("SMSS:PFILE: Failed query for size potential pagefile `%wZ' with status %X\n",
FileName, Status);
NtClose(FileHandle);
return Status;
}
else
{
- DPRINT1("SMSS:PFILE: Deleted stale paging file - %wZ\n", FileName);
+ DPRINT("SMSS:PFILE: Deleted stale paging file - %wZ\n", FileName);
}
/* Close the handle */
wcscpy(PathString, L"\\??\\A:\\");
RtlInitUnicodeString(&VolumeName, PathString);
VolumeName.Buffer[STANDARD_DRIVE_LETTER_OFFSET] = Volume->DriveLetter;
- DPRINT("SMSS:PFILE: Querying volume `%wZ' for free space \n", &VolumeName);
+ DPRINT("SMSS:PFILE: Querying volume `%wZ' for free space\n", &VolumeName);
/* Open the volume */
InitializeObjectAttributes(&ObjectAttributes,
FILE_SYNCHRONOUS_IO_NONALERT | FILE_DIRECTORY_FILE);
if (!NT_SUCCESS(Status))
{
- DPRINT1("SMSS:PFILE: Open volume `%wZ' failed with status %X \n", &VolumeName, Status);
+ DPRINT1("SMSS:PFILE: Open volume `%wZ' failed with status %X\n", &VolumeName, Status);
return Status;
}
{
/* We failed */
DPRINT1("SMSS:PFILE: Query volume `%wZ' (handle %p) for size failed"
- " with status %X \n",
+ " with status %X\n",
&VolumeName,
VolumeHandle,
Status);
Status = NtCreatePagingFile(Name, MinSize, MaxSize, Priority);
if (NT_SUCCESS(Status))
{
- DPRINT("SMSS:PFILE: NtCreatePagingFile (%wZ, %I64X, %I64X) succeeded. \n",
+ DPRINT("SMSS:PFILE: NtCreatePagingFile (%wZ, %I64X, %I64X) succeeded.\n",
Name,
MinSize->QuadPart,
MaxSize->QuadPart);
}
else
{
- DPRINT1("SMSS:PFILE: NtCreatePagingFile (%wZ, %I64X, %I64X) failed with %X \n",
+ DPRINT1("SMSS:PFILE: NtCreatePagingFile (%wZ, %I64X, %I64X) failed with %X\n",
Name,
MinSize->QuadPart,
MaxSize->QuadPart,
if (!Volume)
{
/* Couldn't find it, fail */
- DPRINT1("SMSS:PFILE: No volume descriptor for `%wZ' \n",
+ DPRINT1("SMSS:PFILE: No volume descriptor for `%wZ'\n",
&Descriptor->Name);
return STATUS_INVALID_PARAMETER;
}
if (!(Descriptor->Flags & SMP_PAGEFILE_DUMP_PROCESSED))
{
/* Try to find a crash dump and extract it */
- DPRINT("SMSS:PFILE: Checking for crash dump in `%wZ' on boot volume \n",
+ DPRINT("SMSS:PFILE: Checking for crash dump in `%wZ' on boot volume\n",
&Descriptor->Name);
SmpCheckForCrashDump(&Descriptor->Name);
{
/* Crashdumps can only be on the boot volume */
DPRINT("SMSS:PFILE: Skipping crash dump checking for `%wZ' on non boot"
- "volume `%wC' \n",
+ "volume `%wC'\n",
&Descriptor->Name,
Volume->DriveLetter);
}
DPRINT("SMSS:PFILE: Detected size %I64X for future paging file `%wZ'\n",
PageFileSize,
&Descriptor->Name);
- DPRINT("SMSS:PFILE: Free space on volume `%wC' is %I64X \n",
+ DPRINT("SMSS:PFILE: Free space on volume `%wC' is %I64X\n",
Volume->DriveLetter,
Volume->FreeSpace.QuadPart);
{
Descriptor->ActualMaxSize = PageFileSize;
}
- DPRINT("SMSS:PFILE: min %I64X, max %I64X, real min %I64X \n",
+ DPRINT("SMSS:PFILE: min %I64X, max %I64X, real min %I64X\n",
Descriptor->ActualMinSize.QuadPart,
Descriptor->ActualMaxSize.QuadPart,
MinimumSize->QuadPart);
break;
}
- /* We failed, try a slighly smaller pagefile */
+ /* We failed, try a slightly smaller pagefile */
Descriptor->ActualMinSize.QuadPart -= FuzzFactor->QuadPart;
}
/* FIXFIX: Windows Vista does this, and it seems like we should too, so try to see if this fixes KVM */
Volume->FreeSpace.QuadPart = PageFileSize.QuadPart;
}
- DPRINT1("SMSS:PFILE: Failing for min %I64X, max %I64X, real min %I64X \n",
+ DPRINT1("SMSS:PFILE: Failing for min %I64X, max %I64X, real min %I64X\n",
Descriptor->ActualMinSize.QuadPart,
Descriptor->ActualMaxSize.QuadPart,
MinimumSize->QuadPart);
if (!NT_SUCCESS(Status))
{
/* If we failed, use defaults since we have no idea otherwise */
- DPRINT1("SMSS:PFILE: NtQuerySystemInformation failed with %x \n", Status);
+ DPRINT1("SMSS:PFILE: NtQuerySystemInformation failed with %x\n", Status);
SmpMakeDefaultPagingFileDescriptor(Descriptor);
return;
}
if (WasTooBig)
{
/* Notify debugger output and write a flag in the descriptor */
- DPRINT("SMSS:PFILE: Trimmed size of `%wZ' to maximum allowed \n",
+ DPRINT("SMSS:PFILE: Trimmed size of `%wZ' to maximum allowed\n",
&Descriptor->Name);
Descriptor->Flags |= SMP_PAGEFILE_WAS_TOO_BIG;
}
NULL);
if (!NT_SUCCESS(Status))
{
- DPRINT1("SMSS:PFILE: Query(ProcessDeviceMap) failed with status %X \n",
+ DPRINT1("SMSS:PFILE: Query(ProcessDeviceMap) failed with status %X\n",
Status);
return Status;
}
if (!NT_SUCCESS(Status))
{
/* Skip the volume if we failed */
- DPRINT1("SMSS:PFILE: Open volume `%wZ' failed with status %X \n",
+ DPRINT1("SMSS:PFILE: Open volume `%wZ' failed with status %X\n",
&VolumePath, Status);
continue;
}
{
/* Move to the next volume if we failed */
DPRINT1("SMSS:PFILE: Query volume `%wZ' (handle %p) for device info"
- " failed with status %X \n",
+ " failed with status %X\n",
&VolumePath,
VolumeHandle,
Status);
FILE_REMOVABLE_MEDIA))
{
/* It isn't, so skip it */
- DPRINT1("SMSS:PFILE: Volume `%wZ' (%X) cannot store a paging file \n",
+ DPRINT1("SMSS:PFILE: Volume `%wZ' (%X) cannot store a paging file\n",
&VolumePath,
DeviceInfo.Characteristics);
NtClose(VolumeHandle);
if (!Volume)
{
/* Failed to allocate memory, try the next disk */
- DPRINT1("SMSS:PFILE: Failed to allocate a volume descriptor (%u bytes) \n",
+ DPRINT1("SMSS:PFILE: Failed to allocate a volume descriptor (%u bytes)\n",
sizeof(SMP_VOLUME_DESCRIPTOR));
NtClose(VolumeHandle);
continue;
{
/* We failed -- keep going */
DPRINT1("SMSS:PFILE: Query volume `%wZ' (handle %p) for size failed"
- " with status %X \n",
+ " with status %X\n",
&VolumePath,
VolumeHandle,
Status);
/* All done, add this volume to our descriptor list */
InsertTailList(&SmpVolumeDescriptorList, &Volume->Entry);
Volume->Flags |= SMP_VOLUME_INSERTED;
- DPRINT("SMSS:PFILE: Created volume descriptor for`%wZ' \n", &VolumePath);
+ DPRINT("SMSS:PFILE: Created volume descriptor for`%wZ'\n", &VolumePath);
}
/* We must've found at least the boot volume */
/* Check if no paging files were requested */
if (!(SmpNumberOfPagingFiles) && !(SmpRegistrySpecifierPresent))
{
- /* The list should be empty -- nothign to do */
+ /* The list should be empty -- nothing to do */
ASSERT(IsListEmpty(&SmpPagingFileDescriptorList));
- DPRINT1("SMSS:PFILE: No paging file was requested \n");
+ DPRINT1("SMSS:PFILE: No paging file was requested\n");
return STATUS_SUCCESS;
}
if (!NT_SUCCESS(Status))
{
/* We failed -- try again, with size minimization this time */
- DPRINT1("SMSS:PFILE: Trying lower sizes for (`%wZ') \n",
+ DPRINT("SMSS:PFILE: Trying lower sizes for (`%wZ')\n",
&Descriptor->Name);
Status = SmpCreateSystemManagedPagingFile(Descriptor, TRUE);
}
SmpValidatePagingFileSizes(Descriptor);
/* Check if this is an ANY pagefile or a FIXED pagefile */
- DPRINT("SMSS:PFILE: Creating a normal paging file (`%wZ') \n",
+ DPRINT("SMSS:PFILE: Creating a normal paging file (`%wZ')\n",
&Descriptor->Name);
if (Descriptor->Name.Buffer[STANDARD_DRIVE_LETTER_OFFSET] == L'?')
{
if (!NT_SUCCESS(Status))
{
/* We failed to create it. Try again with a smaller size */
- DPRINT1("SMSS:PFILE: Trying lower sizes for (`%wZ') \n",
+ DPRINT("SMSS:PFILE: Trying lower sizes for (`%wZ')\n",
&Descriptor->Name);
Size.QuadPart = 16 * MEGABYTE;
Status = SmpCreatePagingFileOnAnyDrive(Descriptor,
if (!Created)
{
/* Build an emergency pagefile ourselves */
- DPRINT1("SMSS:PFILE: Creating emergency paging file. \n");
+ DPRINT1("SMSS:PFILE: Creating emergency paging file.\n");
Status = SmpCreateEmergencyPagingFile();
}