mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 00:43:00 -05:00
sys: IRP_MJ_CREATE
This commit is contained in:
parent
8c3f912e05
commit
6bfb23e77d
@ -50,9 +50,14 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
|
|
||||||
NTSTATUS Result;
|
NTSTATUS Result;
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
FSP_FSVRT_DEVICE_EXTENSION *FsvrtDeviceExtension =
|
PDEVICE_OBJECT FsvrtDeviceObject = FsvolDeviceExtension->FsvrtDeviceObject;
|
||||||
FspFsvrtDeviceExtension(FsvolDeviceExtension->FsvrtDeviceObject);
|
|
||||||
|
|
||||||
|
if (!FspDeviceRetain(FsvrtDeviceObject))
|
||||||
|
return STATUS_CANCELLED;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FSP_FSVRT_DEVICE_EXTENSION *FsvrtDeviceExtension =
|
||||||
|
FspFsvrtDeviceExtension(FsvrtDeviceObject);
|
||||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
PFILE_OBJECT RelatedFileObject = FileObject->RelatedFileObject;
|
PFILE_OBJECT RelatedFileObject = FileObject->RelatedFileObject;
|
||||||
UNICODE_STRING FileName = FileObject->FileName;
|
UNICODE_STRING FileName = FileObject->FileName;
|
||||||
@ -69,8 +74,10 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
PFILE_FULL_EA_INFORMATION EaBuffer = Irp->AssociatedIrp.SystemBuffer;
|
PFILE_FULL_EA_INFORMATION EaBuffer = Irp->AssociatedIrp.SystemBuffer;
|
||||||
//ULONG EaLength = IrpSp->Parameters.Create.EaLength;
|
//ULONG EaLength = IrpSp->Parameters.Create.EaLength;
|
||||||
ULONG Flags = IrpSp->Flags;
|
ULONG Flags = IrpSp->Flags;
|
||||||
KPROCESSOR_MODE RequestorMode = FlagOn(Flags, SL_FORCE_ACCESS_CHECK) ? UserMode : Irp->RequestorMode;
|
KPROCESSOR_MODE RequestorMode =
|
||||||
BOOLEAN HasTraversePrivilege = BooleanFlagOn(AccessState->Flags, TOKEN_HAS_TRAVERSE_PRIVILEGE);
|
FlagOn(Flags, SL_FORCE_ACCESS_CHECK) ? UserMode : Irp->RequestorMode;
|
||||||
|
BOOLEAN HasTraversePrivilege =
|
||||||
|
BooleanFlagOn(AccessState->Flags, TOKEN_HAS_TRAVERSE_PRIVILEGE);
|
||||||
BOOLEAN IsAbsoluteSecurityDescriptor = FALSE;
|
BOOLEAN IsAbsoluteSecurityDescriptor = FALSE;
|
||||||
BOOLEAN IsSelfRelativeSecurityDescriptor = FALSE;
|
BOOLEAN IsSelfRelativeSecurityDescriptor = FALSE;
|
||||||
BOOLEAN HasTrailingBackslash = FALSE;
|
BOOLEAN HasTrailingBackslash = FALSE;
|
||||||
@ -79,19 +86,31 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
|
|
||||||
/* cannot open the volume object */
|
/* cannot open the volume object */
|
||||||
if (0 == RelatedFileObject && 0 == FileName.Length)
|
if (0 == RelatedFileObject && 0 == FileName.Length)
|
||||||
return STATUS_ACCESS_DENIED; /* need error code like POSIX EPERM (STATUS_NOT_SUPPORTED?) */
|
{
|
||||||
|
Result = STATUS_ACCESS_DENIED; /* need error code like POSIX EPERM (STATUS_NOT_SUPPORTED?) */
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* cannot open a paging file */
|
/* cannot open a paging file */
|
||||||
if (FlagOn(Flags, SL_OPEN_PAGING_FILE))
|
if (FlagOn(Flags, SL_OPEN_PAGING_FILE))
|
||||||
return STATUS_ACCESS_DENIED;
|
{
|
||||||
|
Result = STATUS_ACCESS_DENIED;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* cannot open files by fileid */
|
/* cannot open files by fileid */
|
||||||
if (FlagOn(CreateOptions, FILE_OPEN_BY_FILE_ID))
|
if (FlagOn(CreateOptions, FILE_OPEN_BY_FILE_ID))
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
{
|
||||||
|
Result = STATUS_NOT_IMPLEMENTED;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* do we support EA? */
|
/* do we support EA? */
|
||||||
if (0 != EaBuffer && !FsvrtDeviceExtension->VolumeParams.EaSupported)
|
if (0 != EaBuffer && !FsvrtDeviceExtension->VolumeParams.EaSupported)
|
||||||
return STATUS_EAS_NOT_SUPPORTED;
|
{
|
||||||
|
Result = STATUS_EAS_NOT_SUPPORTED;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* check security descriptor validity */
|
/* check security descriptor validity */
|
||||||
if (0 != SecurityDescriptor)
|
if (0 != SecurityDescriptor)
|
||||||
@ -101,7 +120,10 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
{
|
{
|
||||||
Result = RtlAbsoluteToSelfRelativeSD(SecurityDescriptor, 0, &SecurityDescriptorSize);
|
Result = RtlAbsoluteToSelfRelativeSD(SecurityDescriptor, 0, &SecurityDescriptorSize);
|
||||||
if (STATUS_BUFFER_TOO_SMALL != Result)
|
if (STATUS_BUFFER_TOO_SMALL != Result)
|
||||||
return STATUS_INVALID_PARAMETER;
|
{
|
||||||
|
Result = STATUS_INVALID_PARAMETER;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -109,7 +131,10 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
IsSelfRelativeSecurityDescriptor = RtlValidRelativeSecurityDescriptor(
|
IsSelfRelativeSecurityDescriptor = RtlValidRelativeSecurityDescriptor(
|
||||||
SecurityDescriptor, SecurityDescriptorSize, 0);
|
SecurityDescriptor, SecurityDescriptorSize, 0);
|
||||||
if (!IsSelfRelativeSecurityDescriptor)
|
if (!IsSelfRelativeSecurityDescriptor)
|
||||||
return STATUS_INVALID_PARAMETER;
|
{
|
||||||
|
Result = STATUS_INVALID_PARAMETER;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +148,10 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
|
|
||||||
if (sizeof(WCHAR) * 2 <= FileName.Length &&
|
if (sizeof(WCHAR) * 2 <= FileName.Length &&
|
||||||
L'\\' == FileName.Buffer[1] && L'\\' == FileName.Buffer[0])
|
L'\\' == FileName.Buffer[1] && L'\\' == FileName.Buffer[0])
|
||||||
return STATUS_OBJECT_NAME_INVALID;
|
{
|
||||||
|
Result = STATUS_OBJECT_NAME_INVALID;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for trailing backslash */
|
/* check for trailing backslash */
|
||||||
@ -134,7 +162,10 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
HasTrailingBackslash = TRUE;
|
HasTrailingBackslash = TRUE;
|
||||||
|
|
||||||
if (sizeof(WCHAR) * 2 <= FileName.Length && L'\\' == FileName.Buffer[FileName.Length / 2 - 1])
|
if (sizeof(WCHAR) * 2 <= FileName.Length && L'\\' == FileName.Buffer[FileName.Length / 2 - 1])
|
||||||
return STATUS_OBJECT_NAME_INVALID;
|
{
|
||||||
|
Result = STATUS_OBJECT_NAME_INVALID;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* is this a relative or absolute open? */
|
/* is this a relative or absolute open? */
|
||||||
@ -142,7 +173,10 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
{
|
{
|
||||||
/* must be a relative path */
|
/* must be a relative path */
|
||||||
if (sizeof(WCHAR) <= FileName.Length && L'\\' == FileName.Buffer[0])
|
if (sizeof(WCHAR) <= FileName.Length && L'\\' == FileName.Buffer[0])
|
||||||
return STATUS_OBJECT_NAME_INVALID;
|
{
|
||||||
|
Result = STATUS_OBJECT_NAME_INVALID;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
FSP_FILE_CONTEXT *RelatedFsContext = RelatedFileObject->FsContext;
|
FSP_FILE_CONTEXT *RelatedFsContext = RelatedFileObject->FsContext;
|
||||||
ASSERT(0 != RelatedFsContext);
|
ASSERT(0 != RelatedFsContext);
|
||||||
@ -160,7 +194,7 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
RelatedFsContext->FileName.Length + AppendBackslash * sizeof(WCHAR) + FileName.Length,
|
RelatedFsContext->FileName.Length + AppendBackslash * sizeof(WCHAR) + FileName.Length,
|
||||||
&FsContext);
|
&FsContext);
|
||||||
if (!NT_SUCCESS(Result))
|
if (!NT_SUCCESS(Result))
|
||||||
return Result;
|
goto exit;
|
||||||
|
|
||||||
Result = RtlAppendUnicodeStringToString(&FsContext->FileName, &RelatedFsContext->FileName);
|
Result = RtlAppendUnicodeStringToString(&FsContext->FileName, &RelatedFsContext->FileName);
|
||||||
ASSERT(NT_SUCCESS(Result));
|
ASSERT(NT_SUCCESS(Result));
|
||||||
@ -174,13 +208,16 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
{
|
{
|
||||||
/* must be an absolute path */
|
/* must be an absolute path */
|
||||||
if (sizeof(WCHAR) <= FileName.Length && L'\\' != FileName.Buffer[0])
|
if (sizeof(WCHAR) <= FileName.Length && L'\\' != FileName.Buffer[0])
|
||||||
return STATUS_OBJECT_NAME_INVALID;
|
{
|
||||||
|
Result = STATUS_OBJECT_NAME_INVALID;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
Result = FspFileContextCreate(
|
Result = FspFileContextCreate(
|
||||||
FileName.Length,
|
FileName.Length,
|
||||||
&FsContext);
|
&FsContext);
|
||||||
if (!NT_SUCCESS(Result))
|
if (!NT_SUCCESS(Result))
|
||||||
return Result;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result = RtlAppendUnicodeStringToString(&FsContext->FileName, &FileName);
|
Result = RtlAppendUnicodeStringToString(&FsContext->FileName, &FileName);
|
||||||
@ -195,7 +232,7 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
if (!NT_SUCCESS(Result))
|
if (!NT_SUCCESS(Result))
|
||||||
{
|
{
|
||||||
FspFileContextDelete(FsContext);
|
FspFileContextDelete(FsContext);
|
||||||
return Result;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* populate the Create request */
|
/* populate the Create request */
|
||||||
@ -226,7 +263,7 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
FspFileContextDelete(FsContext);
|
FspFileContextDelete(FsContext);
|
||||||
if (STATUS_BAD_DESCRIPTOR_FORMAT == Result || STATUS_BUFFER_TOO_SMALL == Result)
|
if (STATUS_BAD_DESCRIPTOR_FORMAT == Result || STATUS_BUFFER_TOO_SMALL == Result)
|
||||||
return STATUS_INVALID_PARAMETER; /* should not happen */
|
return STATUS_INVALID_PARAMETER; /* should not happen */
|
||||||
return Result;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -242,7 +279,7 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
if (!NT_SUCCESS(Result))
|
if (!NT_SUCCESS(Result))
|
||||||
{
|
{
|
||||||
FspFileContextDelete(FsContext);
|
FspFileContextDelete(FsContext);
|
||||||
return Result;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* send the kernel handle and change it into a process handle at prepare time */
|
/* send the kernel handle and change it into a process handle at prepare time */
|
||||||
@ -258,7 +295,15 @@ static NTSTATUS FspFsvolCreate(
|
|||||||
/* this can only happen if the Ioq was stopped */
|
/* this can only happen if the Ioq was stopped */
|
||||||
ASSERT(FspIoqStopped(&FsvrtDeviceExtension->Ioq));
|
ASSERT(FspIoqStopped(&FsvrtDeviceExtension->Ioq));
|
||||||
FspFileContextDelete(FsContext);
|
FspFileContextDelete(FsContext);
|
||||||
return STATUS_CANCELLED;
|
Result = STATUS_CANCELLED;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
exit:;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
FspDeviceRelease(FsvrtDeviceObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
return STATUS_PENDING;
|
return STATUS_PENDING;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user