[SMSS2/SMSS]: Put SMSS back in charge of the pagefile as yet another attempt to fix KVM.

[NTOSKRNL]: Stub-plement SystemSessionDetachInformation.

svn path=/trunk/; revision=55465
This commit is contained in:
Alex Ionescu 2012-02-06 18:14:36 +00:00
parent 5fb988c04d
commit 560ff3fed9
5 changed files with 59 additions and 14 deletions

View file

@ -32,7 +32,7 @@ struct {
// {TRUE, SmProcessFileRenameList, "process the file rename list"},
// {FALSE, SmUpdateEnvironment, "update environment variables"},
// {FALSE, SmLoadKnownDlls, "preload system DLLs"},
// {TRUE, SmCreatePagingFiles, "create paging files"},
{TRUE, SmCreatePagingFiles, "create paging files"},
// {TRUE, SmInitializeRegistry, "initialize the registry"},
{TRUE, SmInitializeClientManagement, "initialize client management"},
{TRUE, SmLoadSubsystems, "load subsystems"}

View file

@ -12,7 +12,7 @@
#define NDEBUG
#include <debug.h>
#if 0
#if 1
#define GIGABYTE (1024 * 1024 * 1024) /* One Gigabyte */
@ -220,7 +220,7 @@ SmpPagingFilesQueryRoutine(PWSTR ValueName,
0);
if (! NT_SUCCESS(Status))
{
PrintString("Creation of paging file %wZ with size %I64d KB failed (status 0x%x)\n",
DPRINT1("Creation of paging file %wZ with size %I64d KB failed (status 0x%x)\n",
&FileName, InitialSize.QuadPart / 1024, Status);
}

View file

@ -457,7 +457,8 @@ SmpCreatePagingFile(IN PUNICODE_STRING Name,
NTSTATUS Status;
/* Tell the kernel to create the pagefile */
Status = NtCreatePagingFile(Name, MinSize, MaxSize, Priority);
//Status = NtCreatePagingFile(Name, MinSize, MaxSize, Priority);
Status = STATUS_SUCCESS;
if (NT_SUCCESS(Status))
{
DPRINT1("SMSS:PFILE: NtCreatePagingFile (%wZ, %I64X, %I64X) succeeded. \n",
@ -592,13 +593,7 @@ SmpCreatePagingFileOnFixedDrive(IN PSMP_PAGEFILE_DESCRIPTOR Descriptor,
if (Descriptor->ActualMinSize.QuadPart < MinimumSize->QuadPart)
{
/* Delete the current page file and fail */
if (ShouldDelete)
{
SmpDeletePagingFile(&Descriptor->Name);
/* 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;
}
if (ShouldDelete) SmpDeletePagingFile(&Descriptor->Name);
DPRINT1("SMSS:PFILE: Failing for min %I64X, max %I64X, real min %I64X \n",
Descriptor->ActualMinSize.QuadPart,
Descriptor->ActualMaxSize.QuadPart,
@ -978,6 +973,10 @@ SmpCreateVolumeDescriptors(VOID)
SizeInfo.SectorsPerAllocationUnit;
FinalFreeSpace.QuadPart = FreeSpace.QuadPart * SizeInfo.BytesPerSector;
Volume->FreeSpace = FinalFreeSpace;
DPRINT1("AUs: %I64x Sectors: %lx Bytes Per Sector: %lx\n",
SizeInfo.AvailableAllocationUnits.QuadPart,
SizeInfo.SectorsPerAllocationUnit,
SizeInfo.BytesPerSector);
/* Check if there's less than 32MB free so we don't starve the disk */
if (FinalFreeSpace.QuadPart <= 0x2000000)

View file

@ -1759,6 +1759,10 @@ NTSTATUS
NTAPI
MmSessionCreate(OUT PULONG SessionId);
NTSTATUS
NTAPI
MmSessionDelete(IN ULONG SessionId);
/* Class 47 - Create a new session (TSE) */
SSI_DEF(SystemCreateSession)
{
@ -1786,9 +1790,22 @@ SSI_DEF(SystemCreateSession)
/* Class 48 - Delete an existing session (TSE) */
SSI_DEF(SystemDeleteSession)
{
/* FIXME */
DPRINT1("NtSetSystemInformation - SystemDeleteSession not implemented\n");
return STATUS_NOT_IMPLEMENTED;
ULONG SessionId;
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
if (Size != sizeof(ULONG)) return STATUS_INFO_LENGTH_MISMATCH;
if (PreviousMode != KernelMode)
{
if (!SeSinglePrivilegeCheck(SeLoadDriverPrivilege, PreviousMode))
{
return STATUS_PRIVILEGE_NOT_HELD;
}
}
SessionId = *(PULONG)Buffer;
return MmSessionDelete(SessionId);
}

View file

@ -1478,6 +1478,35 @@ MmSessionCreate(OUT PULONG SessionId)
return Status;
}
NTSTATUS
NTAPI
MmSessionDelete(IN ULONG SessionId)
{
PEPROCESS Process = PsGetCurrentProcess();
/* Process must be in a session */
if (!(Process->Flags & PSF_PROCESS_IN_SESSION_BIT))
{
DPRINT1("Not in a session!\n");
return STATUS_UNABLE_TO_FREE_VM;
}
/* It must be the session leader */
if (!Process->Vm.Flags.SessionLeader)
{
DPRINT1("Not a session leader!\n");
return STATUS_UNABLE_TO_FREE_VM;
}
/* Remove one reference count */
KeEnterCriticalRegion();
/* FIXME: Do it */
KeLeaveCriticalRegion();
/* All done */
return STATUS_SUCCESS;
}
/* SYSTEM CALLS ***************************************************************/
NTSTATUS