+ {
+ return(STATUS_TOO_MANY_PAGING_FILES);
+ }
+
+ PreviousMode = ExGetPreviousMode();
+
+ if (PreviousMode != KernelMode)
+ {
+ _SEH_TRY
+ {
+ SafeInitialSize = ProbeForReadLargeInteger(InitialSize);
+ SafeMaximumSize = ProbeForReadLargeInteger(MaximumSize);
+ }
+ _SEH_HANDLE
+ {
+ Status = _SEH_GetExceptionCode();
+ }
+ _SEH_END;
+
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+ }
+ else
+ {
+ SafeInitialSize = *InitialSize;
+ SafeMaximumSize = *MaximumSize;
+ }
+
+ /* Pagefiles can't be larger than 4GB and ofcourse the minimum should be
+ smaller than the maximum */
+ if (0 != SafeInitialSize.u.HighPart)
+ {
+ return STATUS_INVALID_PARAMETER_2;
+ }
+ if (0 != SafeMaximumSize.u.HighPart)
+ {
+ return STATUS_INVALID_PARAMETER_3;
+ }
+ if (SafeMaximumSize.u.LowPart < SafeInitialSize.u.LowPart)
+ {
+ return STATUS_INVALID_PARAMETER_MIX;
+ }
+
+ Status = ProbeAndCaptureUnicodeString(&CapturedFileName,
+ PreviousMode,
+ FileName);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+