diff --git a/reactos/drivers/fs/vfat/iface.c b/reactos/drivers/fs/vfat/iface.c index 432167ebe0b..0be46bc5b03 100644 --- a/reactos/drivers/fs/vfat/iface.c +++ b/reactos/drivers/fs/vfat/iface.c @@ -1,4 +1,4 @@ -/* $Id: iface.c,v 1.52 2001/05/04 01:21:45 rex Exp $ +/* $Id: iface.c,v 1.53 2001/06/11 19:52:22 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -283,7 +283,8 @@ VfatFileSystemControl (PDEVICE_OBJECT DeviceObject, PIRP Irp) NTSTATUS STDCALL -DriverEntry (PDRIVER_OBJECT _DriverObject, PUNICODE_STRING RegistryPath) +DriverEntry(PDRIVER_OBJECT _DriverObject, + PUNICODE_STRING RegistryPath) /* * FUNCTION: Called by the system to initalize the driver * ARGUMENTS: @@ -329,6 +330,8 @@ DriverEntry (PDRIVER_OBJECT _DriverObject, PUNICODE_STRING RegistryPath) VfatDirectoryControl; VfatDriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] = VfatQueryVolumeInformation; + VfatDriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] = + VfatSetVolumeInformation; VfatDriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = VfatShutdown; VfatDriverObject->MajorFunction[IRP_MJ_CLEANUP] = VfatCleanup; diff --git a/reactos/drivers/fs/vfat/vfat.h b/reactos/drivers/fs/vfat/vfat.h index a64f0864e42..bcbc046d347 100644 --- a/reactos/drivers/fs/vfat/vfat.h +++ b/reactos/drivers/fs/vfat/vfat.h @@ -1,4 +1,4 @@ -/* $Id: vfat.h,v 1.29 2001/05/10 04:02:21 rex Exp $ */ +/* $Id: vfat.h,v 1.30 2001/06/11 19:52:22 ekohl Exp $ */ #include @@ -162,6 +162,8 @@ NTSTATUS STDCALL VfatShutdown(PDEVICE_OBJECT DeviceObject, PIRP Irp); NTSTATUS STDCALL VfatQueryVolumeInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp); +NTSTATUS STDCALL +VfatSetVolumeInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp); NTSTATUS diff --git a/reactos/drivers/fs/vfat/volume.c b/reactos/drivers/fs/vfat/volume.c index ba132b4e8cf..7cb3c63f583 100644 --- a/reactos/drivers/fs/vfat/volume.c +++ b/reactos/drivers/fs/vfat/volume.c @@ -1,4 +1,4 @@ -/* $Id: volume.c,v 1.7 2001/03/01 07:48:17 dwelch Exp $ +/* $Id: volume.c,v 1.8 2001/06/11 19:52:22 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -19,14 +19,14 @@ /* FUNCTIONS ****************************************************************/ -NTSTATUS -FsdGetFsVolumeInformation (PFILE_OBJECT FileObject, - PVFATFCB FCB, - PDEVICE_OBJECT DeviceObject, - PFILE_FS_VOLUME_INFORMATION FsVolumeInfo) +static NTSTATUS +FsdGetFsVolumeInformation(PFILE_OBJECT FileObject, + PVFATFCB FCB, + PDEVICE_OBJECT DeviceObject, + PFILE_FS_VOLUME_INFORMATION FsVolumeInfo) { - DPRINT ("FsdGetFsVolumeInformation()\n"); - DPRINT ("FsVolumeInfo = %p\n", FsVolumeInfo); + DPRINT("FsdGetFsVolumeInformation()\n"); + DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo); if (!FsVolumeInfo) return (STATUS_SUCCESS); @@ -35,48 +35,49 @@ FsdGetFsVolumeInformation (PFILE_OBJECT FileObject, /* valid entries */ FsVolumeInfo->VolumeSerialNumber = DeviceObject->Vpb->SerialNumber; FsVolumeInfo->VolumeLabelLength = DeviceObject->Vpb->VolumeLabelLength; - wcscpy (FsVolumeInfo->VolumeLabel, DeviceObject->Vpb->VolumeLabel); + wcscpy(FsVolumeInfo->VolumeLabel, DeviceObject->Vpb->VolumeLabel); /* dummy entries */ FsVolumeInfo->VolumeCreationTime.QuadPart = 0; FsVolumeInfo->SupportsObjects = FALSE; - DPRINT ("Finished FsdGetFsVolumeInformation()\n"); + DPRINT("Finished FsdGetFsVolumeInformation()\n"); - return (STATUS_SUCCESS); + return(STATUS_SUCCESS); } -NTSTATUS -FsdGetFsAttributeInformation (PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo) +static NTSTATUS +FsdGetFsAttributeInformation(PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo) { - DPRINT ("FsdGetFsAttributeInformation()\n"); - DPRINT ("FsAttributeInfo = %p\n", FsAttributeInfo); + DPRINT("FsdGetFsAttributeInformation()\n"); + DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo); if (!FsAttributeInfo) return (STATUS_SUCCESS); - FsAttributeInfo->FileSystemAttributes = FS_CASE_IS_PRESERVED; + FsAttributeInfo->FileSystemAttributes = + FILE_CASE_PRESERVED_NAMES || FILE_UNICODE_ON_DISK; FsAttributeInfo->MaximumComponentNameLength = 255; - FsAttributeInfo->FileSystemNameLength = 3; - wcscpy (FsAttributeInfo->FileSystemName, L"FAT"); + FsAttributeInfo->FileSystemNameLength = 6; + wcscpy(FsAttributeInfo->FileSystemName, L"FAT"); - DPRINT ("Finished FsdGetFsAttributeInformation()\n"); + DPRINT("Finished FsdGetFsAttributeInformation()\n"); - return (STATUS_SUCCESS); + return(STATUS_SUCCESS); } -NTSTATUS -FsdGetFsSizeInformation (PDEVICE_OBJECT DeviceObject, - PFILE_FS_SIZE_INFORMATION FsSizeInfo) +static NTSTATUS +FsdGetFsSizeInformation(PDEVICE_OBJECT DeviceObject, + PFILE_FS_SIZE_INFORMATION FsSizeInfo) { PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension; - DPRINT ("FsdGetFsSizeInformation()\n"); - DPRINT ("FsSizeInfo = %p\n", FsSizeInfo); + DPRINT("FsdGetFsSizeInformation()\n"); + DPRINT("FsSizeInfo = %p\n", FsSizeInfo); if (!FsSizeInfo) - return (STATUS_SUCCESS); + return(STATUS_SUCCESS); if (DeviceExt->FatType == FAT32) { @@ -112,62 +113,70 @@ FsdGetFsSizeInformation (PDEVICE_OBJECT DeviceObject, FsSizeInfo->BytesPerSector = BootSect->BytesPerSector; } - DPRINT ("Finished FsdGetFsSizeInformation()\n"); + DPRINT("Finished FsdGetFsSizeInformation()\n"); - return (STATUS_SUCCESS); + return(STATUS_SUCCESS); +} + + +static NTSTATUS +FsdSetFsLabelInformation(PDEVICE_OBJECT DeviceObject, + PFILE_FS_LABEL_INFORMATION FsLabelInfo) +{ + DPRINT1("FsdSetFsLabelInformation()\n"); + + return STATUS_NOT_IMPLEMENTED; } NTSTATUS STDCALL -VfatQueryVolumeInformation (PDEVICE_OBJECT DeviceObject, PIRP Irp) +VfatQueryVolumeInformation(PDEVICE_OBJECT DeviceObject, + PIRP Irp) /* - * FUNCTION: Retrieve the specified file information + * FUNCTION: Retrieve the specified volume information */ { - PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation (Irp); - FILE_INFORMATION_CLASS FileInformationClass = - Stack->Parameters.QueryVolume.FileInformationClass; + PIO_STACK_LOCATION Stack; + FS_INFORMATION_CLASS FsInformationClass; PFILE_OBJECT FileObject = NULL; PVFATFCB FCB = NULL; -// PVfatCCB CCB = NULL; NTSTATUS RC = STATUS_SUCCESS; - void *SystemBuffer; + PVOID SystemBuffer; + ULONG BufferLength; /* PRECONDITION */ - assert (DeviceObject != NULL); - assert (Irp != NULL); + assert(DeviceObject != NULL); + assert(Irp != NULL); - DPRINT ("FsdQueryVolumeInformation(DeviceObject %x, Irp %x)\n", - DeviceObject, Irp); + DPRINT("FsdQueryVolumeInformation(DeviceObject %x, Irp %x)\n", + DeviceObject, Irp); /* INITIALIZATION */ Stack = IoGetCurrentIrpStackLocation (Irp); - FileInformationClass = Stack->Parameters.QueryVolume.FileInformationClass; + FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass; + BufferLength = Stack->Parameters.QueryVolume.Length; + SystemBuffer = Irp->AssociatedIrp.SystemBuffer; FileObject = Stack->FileObject; // CCB = (PVfatCCB)(FileObject->FsContext2); // FCB = CCB->Buffer; // Should be CCB->FCB??? FCB = ((PVFATCCB) (FileObject->FsContext2))->pFcb; - // FIXME : determine Buffer for result : - if (Irp->MdlAddress) - SystemBuffer = MmGetSystemAddressForMdl (Irp->MdlAddress); - else - SystemBuffer = Irp->UserBuffer; -// SystemBuffer = Irp->AssociatedIrp.SystemBuffer; - DPRINT ("FileInformationClass %d\n", FileInformationClass); + DPRINT ("FsInformationClass %d\n", FsInformationClass); DPRINT ("SystemBuffer %x\n", SystemBuffer); - switch (FileInformationClass) + switch (FsInformationClass) { case FileFsVolumeInformation: - RC = FsdGetFsVolumeInformation (FileObject, - FCB, DeviceObject, SystemBuffer); + RC = FsdGetFsVolumeInformation(FileObject, + FCB, + DeviceObject, + SystemBuffer); break; case FileFsAttributeInformation: - RC = FsdGetFsAttributeInformation (SystemBuffer); + RC = FsdGetFsAttributeInformation(SystemBuffer); break; case FileFsSizeInformation: @@ -184,3 +193,60 @@ VfatQueryVolumeInformation (PDEVICE_OBJECT DeviceObject, PIRP Irp) return RC; } + + +NTSTATUS STDCALL +VfatSetVolumeInformation(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +/* + * FUNCTION: Set the specified volume information + */ +{ + PIO_STACK_LOCATION Stack; + FS_INFORMATION_CLASS FsInformationClass; +// PFILE_OBJECT FileObject = NULL; +// PVFATFCB FCB = NULL; + + NTSTATUS Status = STATUS_SUCCESS; + PVOID SystemBuffer; + ULONG BufferLength; + + /* PRECONDITION */ + assert(DeviceObject != NULL); + assert(Irp != NULL); + + DPRINT("FsdSetVolumeInformation(DeviceObject %x, Irp %x)\n", + DeviceObject, + Irp); + + Stack = IoGetCurrentIrpStackLocation (Irp); + FsInformationClass = Stack->Parameters.SetVolume.FsInformationClass; + BufferLength = Stack->Parameters.SetVolume.Length; + SystemBuffer = Irp->AssociatedIrp.SystemBuffer; +// FileObject = Stack->FileObject; +// FCB = ((PVFATCCB) (FileObject->FsContext2))->pFcb; + + DPRINT("FsInformationClass %d\n", FsInformationClass); + DPRINT("BufferLength %d\n", BufferLength); + DPRINT("SystemBuffer %x\n", SystemBuffer); + + switch (FsInformationClass) + { + case FileFsLabelInformation: + Status = FsdSetFsLabelInformation(DeviceObject, + SystemBuffer); + break; + + default: + Status = STATUS_NOT_SUPPORTED; + } + + Irp->IoStatus.Status = Status; + Irp->IoStatus.Information = 0; + IoCompleteRequest(Irp, + IO_NO_INCREMENT); + + return(Status); +} + +/* EOF */ diff --git a/reactos/include/ddk/iotypes.h b/reactos/include/ddk/iotypes.h index e7fdf6585d6..f0306bd5bb8 100644 --- a/reactos/include/ddk/iotypes.h +++ b/reactos/include/ddk/iotypes.h @@ -1,4 +1,4 @@ -/* $Id: iotypes.h,v 1.29 2001/05/24 22:18:16 ekohl Exp $ +/* $Id: iotypes.h,v 1.30 2001/06/11 19:45:29 ekohl Exp $ * */ @@ -308,12 +308,12 @@ typedef struct _IO_STACK_LOCATION struct { ULONG Length; - FS_INFORMATION_CLASS FileInformationClass; + FS_INFORMATION_CLASS FsInformationClass; } QueryVolume; struct { ULONG Length; - FS_INFORMATION_CLASS FileInformationClass; + FS_INFORMATION_CLASS FsInformationClass; } SetVolume; struct { @@ -338,21 +338,6 @@ typedef struct _IO_STACK_LOCATION FILE_INFORMATION_CLASS FileInformationClass; ULONG FileIndex; } QueryDirectory; -/* - struct - { - ULONG CreateDisposition; - ULONG CreateOptions; - ULONG ShareAccess; - BOOLEAN WriteModeMessage; - BOOLEAN ReadModeMessage; - BOOLEAN NonBlocking; - ULONG MaxInstances; - ULONG InBufferSize; - ULONG OutBufferSize; - LARGE_INTEGER TimeOut; - } CreateNamedPipe; -*/ // Parameters for IRP_MN_QUERY_DEVICE_RELATIONS struct { diff --git a/reactos/include/ddk/zw.h b/reactos/include/ddk/zw.h index 44c88b4db9b..acce6d20598 100644 --- a/reactos/include/ddk/zw.h +++ b/reactos/include/ddk/zw.h @@ -1,5 +1,5 @@ -/* $Id: zw.h,v 1.45 2001/05/27 11:09:35 ekohl Exp $ +/* $Id: zw.h,v 1.46 2001/06/11 19:45:29 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -3532,11 +3532,12 @@ ZwQueryVirtualMemory( /* * FUNCTION: Queries the volume information * ARGUMENTS: - * FileHandle = Handle to a file object on the target volume - ReturnLength = DataWritten - FsInformation = Caller should supply storage for the information structure. - Length = Size of the information structure - FsInformationClass = Index to a information structure + * FileHandle = Handle to a file object on the target volume + * IoStatusBlock = Caller should supply storage for additional status information + * ReturnLength = DataWritten + * FsInformation = Caller should supply storage for the information structure. + * Length = Size of the information structure + * FsInformationClass = Index to a information structure FileFsVolumeInformation FILE_FS_VOLUME_INFORMATION FileFsLabelInformation FILE_FS_LABEL_INFORMATION @@ -4625,30 +4626,33 @@ ZwSetValueKey( ); /* - * FUNCTION: Sets the volume information of a file. + * FUNCTION: Sets the volume information. * ARGUMENTS: - * FileHandle = Handle to the file - * VolumeInformationClass = specifies the particular volume information to set + * FileHandle = Handle to the file + * IoStatusBlock = Caller should supply storage for additional status information * VolumeInformation = pointer to a structure containing the new volume information * Length = size of the structure. + * VolumeInformationClass = specifies the particular volume information to set * RETURNS: Status */ NTSTATUS STDCALL NtSetVolumeInformationFile( IN HANDLE FileHandle, - IN CINT VolumeInformationClass, - PVOID VolumeInformation, - ULONG Length + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID FsInformation, + IN ULONG Length, + IN FS_INFORMATION_CLASS FsInformationClass ); NTSTATUS STDCALL ZwSetVolumeInformationFile( IN HANDLE FileHandle, - IN CINT VolumeInformationClass, - PVOID VolumeInformation, - ULONG Length + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID FsInformation, + IN ULONG Length, + IN FS_INFORMATION_CLASS FsInformationClass ); /* diff --git a/reactos/include/ntos/file.h b/reactos/include/ntos/file.h index 1e37739afd2..eed866d849d 100644 --- a/reactos/include/ntos/file.h +++ b/reactos/include/ntos/file.h @@ -104,5 +104,13 @@ #define FS_FILE_COMPRESSION (16) #define FS_VOL_IS_COMPRESSED (32768) +/* NtQueryVolumeInformationFile */ +#define FILE_CASE_SENSITIVE_SEARCH (0x00000001) +#define FILE_CASE_PRESERVED_NAMES (0x00000002) +#define FILE_UNICODE_ON_DISK (0x00000004) +#define FILE_PERSISTENT_ACLS (0x00000008) +#define FILE_FILE_COMPRESSION (0x00000010) +#define FILE_VOLUME_IS_COMPRESSED (0x00008000) + #endif /* __INCLUDE_FILE_H */ diff --git a/reactos/ntoskrnl/io/vpb.c b/reactos/ntoskrnl/io/vpb.c index 281d39b3727..5729665271d 100644 --- a/reactos/ntoskrnl/io/vpb.c +++ b/reactos/ntoskrnl/io/vpb.c @@ -1,4 +1,4 @@ -/* $Id: vpb.c,v 1.11 2001/03/07 16:48:42 dwelch Exp $ +/* $Id: vpb.c,v 1.12 2001/06/11 19:48:58 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -13,8 +13,10 @@ #include #include +#include #include + #define NDEBUG #include @@ -23,23 +25,25 @@ static KSPIN_LOCK IoVpbLock; #define TAG_VPB TAG('V', 'P', 'B', ' ') +#define TAG_SYSB TAG('S', 'Y', 'S', 'B') /* FUNCTIONS *****************************************************************/ VOID -IoInitVpbImplementation ( - VOID - ) +IoInitVpbImplementation(VOID) { - KeInitializeSpinLock(&IoVpbLock); + KeInitializeSpinLock(&IoVpbLock); } -NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject) +NTSTATUS +IoAttachVpb(PDEVICE_OBJECT DeviceObject) { PVPB Vpb; - Vpb = ExAllocatePoolWithTag(NonPagedPool, sizeof(VPB), TAG_VPB); - if (Vpb==NULL) + Vpb = ExAllocatePoolWithTag(NonPagedPool, + sizeof(VPB), + TAG_VPB); + if (Vpb == NULL) { return(STATUS_UNSUCCESSFUL); } @@ -48,86 +52,33 @@ NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject) Vpb->Size = sizeof(VPB) / sizeof(DWORD); Vpb->Flags = 0; Vpb->VolumeLabelLength = 0; - Vpb->DeviceObject = NULL; + Vpb->DeviceObject = NULL; Vpb->RealDevice = DeviceObject; Vpb->SerialNumber = 0; Vpb->ReferenceCount = 0; - RtlZeroMemory(Vpb->VolumeLabel,sizeof(WCHAR)*MAXIMUM_VOLUME_LABEL_LENGTH); + RtlZeroMemory(Vpb->VolumeLabel, + sizeof(WCHAR) * MAXIMUM_VOLUME_LABEL_LENGTH); DeviceObject->Vpb = Vpb; return(STATUS_SUCCESS); } -PIRP IoBuildVolumeInformationIrp(ULONG MajorFunction, - PFILE_OBJECT FileObject, - PVOID FSInformation, - ULONG Length, - CINT FSInformationClass, - PIO_STATUS_BLOCK IoStatusBlock, - PKEVENT Event) -{ - PIRP Irp; - PIO_STACK_LOCATION StackPtr; - PDEVICE_OBJECT DeviceObject; - - DeviceObject = FileObject->DeviceObject; - - Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE); - if (Irp==NULL) - { - return(NULL); - } - -// Irp->AssociatedIrp.SystemBuffer = FSInformation; - Irp->UserBuffer = FSInformation; - - StackPtr = IoGetNextIrpStackLocation(Irp); - StackPtr->MajorFunction = MajorFunction; - StackPtr->MinorFunction = 0; - StackPtr->Flags = 0; - StackPtr->Control = 0; - StackPtr->DeviceObject = DeviceObject; - StackPtr->FileObject = FileObject; - Irp->UserEvent = Event; - Irp->UserIosb = IoStatusBlock; - - switch (MajorFunction) - { - case IRP_MJ_SET_VOLUME_INFORMATION: - StackPtr->Parameters.SetVolume.Length = Length; - StackPtr->Parameters.SetVolume.FileInformationClass = - FSInformationClass; - break; - case IRP_MJ_QUERY_VOLUME_INFORMATION: - StackPtr->Parameters.QueryVolume.Length = Length; - StackPtr->Parameters.QueryVolume.FileInformationClass = - FSInformationClass; - break; - } - return(Irp); -} - - -NTSTATUS -STDCALL -NtQueryVolumeInformationFile ( - - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID FSInformation, - IN ULONG Length, - IN FS_INFORMATION_CLASS FSInformationClass - ) +NTSTATUS STDCALL +NtQueryVolumeInformationFile(IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FSInformation, + IN ULONG Length, + IN FS_INFORMATION_CLASS FSInformationClass) /* * FUNCTION: Queries the volume information * ARGUMENTS: - * FileHandle = Handle to a file object on the target volume + * FileHandle = Handle to a file object on the target volume * ReturnLength = DataWritten * FSInformation = Caller should supply storage for the information - * structure. + * structure. * Length = Size of the information structure * FSInformationClass = Index to a information structure * @@ -149,6 +100,8 @@ NtQueryVolumeInformationFile ( PIRP Irp; KEVENT Event; NTSTATUS Status; + PIO_STACK_LOCATION StackPtr; + PVOID SystemBuffer; DPRINT("FSInformation %p\n", FSInformation); @@ -157,125 +110,190 @@ NtQueryVolumeInformationFile ( NULL, UserMode, (PVOID*)&FileObject, - NULL); - if (Status != STATUS_SUCCESS) + NULL); + if (!NT_SUCCESS(Status)) { return(Status); } DeviceObject = FileObject->DeviceObject; - KeInitializeEvent(&Event,NotificationEvent,FALSE); + KeInitializeEvent(&Event, + NotificationEvent, + FALSE); - Irp = IoBuildVolumeInformationIrp(IRP_MJ_QUERY_VOLUME_INFORMATION, - FileObject, - FSInformation, - Length, - FSInformationClass, - IoStatusBlock, - &Event); - Status = IoCallDriver(DeviceObject,Irp); + Irp = IoAllocateIrp(DeviceObject->StackSize, + TRUE); + if (Irp == NULL) + { + ObDereferenceObject(FileObject); + return(STATUS_INSUFFICIENT_RESOURCES); + } + + SystemBuffer = ExAllocatePoolWithTag(NonPagedPool, + Length, + TAG_SYSB); + if (SystemBuffer == NULL) + { + IoFreeIrp(Irp); + ObDereferenceObject(FileObject); + return(STATUS_INSUFFICIENT_RESOURCES); + } + + Irp->AssociatedIrp.SystemBuffer = SystemBuffer; + Irp->UserEvent = &Event; + Irp->UserIosb = IoStatusBlock; + + StackPtr = IoGetNextIrpStackLocation(Irp); + StackPtr->MajorFunction = IRP_MJ_QUERY_VOLUME_INFORMATION; + StackPtr->MinorFunction = 0; + StackPtr->Flags = 0; + StackPtr->Control = 0; + StackPtr->DeviceObject = DeviceObject; + StackPtr->FileObject = FileObject; + StackPtr->Parameters.QueryVolume.Length = Length; + StackPtr->Parameters.QueryVolume.FsInformationClass = + FSInformationClass; + + Status = IoCallDriver(DeviceObject, + Irp); if (Status == STATUS_PENDING) { - KeWaitForSingleObject(&Event,UserRequest,KernelMode,FALSE,NULL); + KeWaitForSingleObject(&Event, + UserRequest, + KernelMode, + FALSE, + NULL); Status = IoStatusBlock->Status; } + + MmSafeCopyToUser(FSInformation, + SystemBuffer, + Length); + ExFreePool(SystemBuffer); + return(Status); } -NTSTATUS -STDCALL -IoQueryVolumeInformation ( - IN PFILE_OBJECT FileObject, - IN FS_INFORMATION_CLASS FsInformationClass, - IN ULONG Length, - OUT PVOID FsInformation, - OUT PULONG ReturnedLength - ) +NTSTATUS STDCALL +IoQueryVolumeInformation(IN PFILE_OBJECT FileObject, + IN FS_INFORMATION_CLASS FsInformationClass, + IN ULONG Length, + OUT PVOID FsInformation, + OUT PULONG ReturnedLength) { - UNIMPLEMENTED; - return (STATUS_NOT_IMPLEMENTED); + UNIMPLEMENTED; + return(STATUS_NOT_IMPLEMENTED); } -NTSTATUS -STDCALL -NtSetVolumeInformationFile ( - IN HANDLE FileHandle, - IN CINT VolumeInformationClass, - PVOID VolumeInformation, - ULONG Length - ) +NTSTATUS STDCALL +NtSetVolumeInformationFile(IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID FsInformation, + IN ULONG Length, + IN FS_INFORMATION_CLASS FsInformationClass) { PFILE_OBJECT FileObject; PDEVICE_OBJECT DeviceObject; PIRP Irp; KEVENT Event; NTSTATUS Status; - + PIO_STACK_LOCATION StackPtr; + PVOID SystemBuffer; + Status = ObReferenceObjectByHandle(FileHandle, FILE_WRITE_ATTRIBUTES, NULL, UserMode, (PVOID*)&FileObject, - NULL); + NULL); if (Status != STATUS_SUCCESS) { return(Status); } - + DeviceObject = FileObject->DeviceObject; - KeInitializeEvent(&Event,NotificationEvent,FALSE); - - Irp = IoBuildVolumeInformationIrp(IRP_MJ_SET_VOLUME_INFORMATION, - FileObject, - VolumeInformation, - Length, - VolumeInformationClass, - NULL, - &Event); + KeInitializeEvent(&Event, + NotificationEvent, + FALSE); + + Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE); + if (Irp == NULL) + { + ObDereferenceObject(FileObject); + return(STATUS_INSUFFICIENT_RESOURCES); + } + + SystemBuffer = ExAllocatePoolWithTag(NonPagedPool, + Length, + TAG_SYSB); + if (SystemBuffer == NULL) + { + IoFreeIrp(Irp); + ObDereferenceObject(FileObject); + return(STATUS_INSUFFICIENT_RESOURCES); + } + + MmSafeCopyFromUser(SystemBuffer, + FsInformation, + Length); + + Irp->AssociatedIrp.SystemBuffer = SystemBuffer; + Irp->UserEvent = &Event; + Irp->UserIosb = IoStatusBlock; + + StackPtr = IoGetNextIrpStackLocation(Irp); + StackPtr->MajorFunction = IRP_MJ_SET_VOLUME_INFORMATION; + StackPtr->MinorFunction = 0; + StackPtr->Flags = 0; + StackPtr->Control = 0; + StackPtr->DeviceObject = DeviceObject; + StackPtr->FileObject = FileObject; + StackPtr->Parameters.SetVolume.Length = Length; + StackPtr->Parameters.SetVolume.FsInformationClass = + FsInformationClass; + Status = IoCallDriver(DeviceObject,Irp); if (Status == STATUS_PENDING) { - KeWaitForSingleObject(&Event,UserRequest,KernelMode,FALSE,NULL); + KeWaitForSingleObject(&Event, + UserRequest, + KernelMode, + FALSE, + NULL); } + + ExFreePool(SystemBuffer); + return(Status); } -VOID -STDCALL -IoAcquireVpbSpinLock ( - OUT PKIRQL Irql - ) +VOID STDCALL +IoAcquireVpbSpinLock(OUT PKIRQL Irql) { - KeAcquireSpinLock (&IoVpbLock, - Irql); + KeAcquireSpinLock(&IoVpbLock, + Irql); } -VOID -STDCALL -IoReleaseVpbSpinLock ( - IN KIRQL Irql - ) +VOID STDCALL +IoReleaseVpbSpinLock(IN KIRQL Irql) { - KeReleaseSpinLock (&IoVpbLock, - Irql); + KeReleaseSpinLock(&IoVpbLock, + Irql); } -NTSTATUS -STDCALL -IoVerifyVolume ( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN AllowRawMount - ) +NTSTATUS STDCALL +IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN AllowRawMount) { - UNIMPLEMENTED; - return (STATUS_NOT_IMPLEMENTED); + UNIMPLEMENTED; + return(STATUS_NOT_IMPLEMENTED); }