sys: IRP_MJ_CREATE

This commit is contained in:
Bill Zissimopoulos 2015-12-02 15:55:28 -08:00
parent 10a9c6b8e2
commit 7d22bec54b
3 changed files with 52 additions and 3 deletions

View File

@ -52,6 +52,7 @@ typedef struct
UINT16 Version; UINT16 Version;
UINT16 SectorSize; UINT16 SectorSize;
UINT32 SerialNumber; UINT32 SerialNumber;
BOOLEAN EaSupported;
} FSP_FSCTL_VOLUME_PARAMS; } FSP_FSCTL_VOLUME_PARAMS;
typedef struct typedef struct
{ {

View File

@ -48,8 +48,56 @@ static NTSTATUS FspFsvolCreate(
{ {
PAGED_CODE(); PAGED_CODE();
/* !!!: DEVELOPMENT HACK! */ FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
return STATUS_CANCELLED; FSP_FSVRT_DEVICE_EXTENSION *FsvrtDeviceExtension =
FspFsvrtDeviceExtension(FsvolDeviceExtension->FsvrtDeviceObject);
PFILE_OBJECT FileObject = IrpSp->FileObject;
PFILE_OBJECT RelatedFileObject = FileObject->RelatedFileObject;
UNICODE_STRING FileName = FileObject->FileName;
ULONG Flags = IrpSp->Flags;
KPROCESSOR_MODE RequestorMode = FlagOn(Flags, SL_FORCE_ACCESS_CHECK) ? UserMode : Irp->RequestorMode;
PACCESS_STATE AccessState = IrpSp->Parameters.Create.SecurityContext->AccessState;
ACCESS_MASK DesiredAccess = IrpSp->Parameters.Create.SecurityContext->DesiredAccess;
USHORT ShareAccess = IrpSp->Parameters.Create.ShareAccess;
ULONG CreateDisposition = IrpSp->Parameters.Create.Options >> 24;
ULONG CreateOptions = IrpSp->Parameters.Create.Options & 0xffffff;
USHORT FileAttributes = IrpSp->Parameters.Create.FileAttributes;
LARGE_INTEGER AllocationSize = Irp->Overlay.AllocationSize;
PFILE_FULL_EA_INFORMATION EaBuffer = Irp->AssociatedIrp.SystemBuffer;
ULONG EaLength = IrpSp->Parameters.Create.EaLength;
BOOLEAN HasTraversePrivilege = BooleanFlagOn(AccessState->Flags, TOKEN_HAS_TRAVERSE_PRIVILEGE);
/* cannot open the volume object */
if (0 == RelatedFileObject && 0 == FileName.Length)
return STATUS_ACCESS_DENIED; // need error code like UNIX EPERM (STATUS_NOT_SUPPORTED?)
/* cannot open paging file */
if (FlagOn(Flags, SL_OPEN_PAGING_FILE))
return STATUS_ACCESS_DENIED;
/* cannot open files by fileid */
if (FlagOn(CreateOptions, FILE_OPEN_BY_FILE_ID))
return STATUS_NOT_IMPLEMENTED;
/* do we support EA? */
if (0 != EaBuffer && !FsvrtDeviceExtension->VolumeParams.EaSupported)
return STATUS_EAS_NOT_SUPPORTED;
/* according to fastfat, filenames that begin with two backslashes are ok */
if (sizeof(WCHAR) * 2 <= FileName.Length &&
L'\\' == FileName.Buffer[1] && L'\\' == FileName.Buffer[0])
{
FileName.Length -= sizeof(WCHAR);
FileName.MaximumLength -= sizeof(WCHAR);
FileName.Buffer++;
if (sizeof(WCHAR) * 2 <= FileName.Length &&
L'\\' == FileName.Buffer[1] && L'\\' == FileName.Buffer[0])
return STATUS_OBJECT_NAME_INVALID;
}
return STATUS_PENDING;
} }
NTSTATUS FspCreate( NTSTATUS FspCreate(

View File

@ -117,7 +117,7 @@
{ \ { \
/* 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));\
FspIopCompleteRequest(Irp, STATUS_ACCESS_DENIED);\ FspIopCompleteRequest(Irp, Result = STATUS_CANCELLED);\
} \ } \
} \ } \
} \ } \