コード例 #1
0
        public async Task <(NTStatus status, FileSystemInformation result)> GetFileSystemInformationAsync(object handle, FileSystemInformationClass informationClass, CancellationToken cancellationToken)
        {
            QueryInfoRequest request = new QueryInfoRequest();

            request.InfoType = InfoType.FileSystem;
            request.FileSystemInformationClass = informationClass;
            request.OutputBufferLength         = 4096;
            request.FileId = (FileID)handle;

            await TrySendCommandAsync(request, cancellationToken);

            SMB2Command response = m_client.WaitForCommand(SMB2CommandName.QueryInfo);

            if (response != null)
            {
                FileSystemInformation result = null;
                if (response.Header.Status == NTStatus.STATUS_SUCCESS && response is QueryInfoResponse)
                {
                    result = ((QueryInfoResponse)response).GetFileSystemInformation(informationClass);
                }
                return(response.Header.Status, result);
            }

            return(NTStatus.STATUS_INVALID_SMB, null);
        }
コード例 #2
0
        public NTStatus GetFileSystemInformation(out FileSystemInformation result, FileSystemInformationClass informationClass)
        {
            IO_STATUS_BLOCK ioStatusBlock;

            byte[]     buffer = new byte[4096];
            IntPtr     volumeHandle;
            FileStatus fileStatus;
            string     nativePath = @"\??\" + m_directory.FullName.Substring(0, 3);
            NTStatus   status     = CreateFile(out volumeHandle, out fileStatus, nativePath, AccessMask.GENERIC_READ, 0, (FileAttributes)0, ShareAccess.Read, CreateDisposition.FILE_OPEN, (CreateOptions)0);

            result = null;
            if (status != NTStatus.STATUS_SUCCESS)
            {
                return(status);
            }
            status = NtQueryVolumeInformationFile((IntPtr)volumeHandle, out ioStatusBlock, buffer, (uint)buffer.Length, (uint)informationClass);
            CloseFile(volumeHandle);
            if (status == NTStatus.STATUS_SUCCESS)
            {
                int numberOfBytesWritten = (int)ioStatusBlock.Information;
                buffer = ByteReader.ReadBytes(buffer, 0, numberOfBytesWritten);
                result = FileSystemInformation.GetFileSystemInformation(buffer, 0, informationClass);
            }
            return(status);
        }
コード例 #3
0
        public void Test_FileExtensions()
        {
            // arrange
            FileSystemInformation fileinfo = new FileSystemInformation();

            string sourcepath = @"D:\FirstFile\MyTest";

            FileInfo[] fiels = fileinfo.GetFilesFromFolder(sourcepath);
        }
コード例 #4
0
        internal static Transaction2SetFSInformationResponse GetSubcommandResponse(SMB1Header header, Transaction2SetFSInformationRequest subcommand, ISMBShare share, SMB1ConnectionState state)
        {
            SMB1Session session = state.GetSession(header.UID);

            if (share is FileSystemShare)
            {
                if (!((FileSystemShare)share).HasWriteAccess(session.SecurityContext, @"\"))
                {
                    state.LogToServer(Severity.Verbose, "SetFileSystemInformation on '{0}' failed. User '{1}' was denied access.", share.Name, session.UserName);
                    header.Status = NTStatus.STATUS_ACCESS_DENIED;
                    return(null);
                }
            }

            if (!subcommand.IsPassthroughInformationLevel)
            {
                state.LogToServer(Severity.Verbose, "SetFileSystemInformation on '{0}' failed. Not a pass-through information level.", share.Name);
                header.Status = NTStatus.STATUS_NOT_SUPPORTED;
                return(null);
            }

            FileSystemInformation fileSystemInfo;

            try
            {
                fileSystemInfo = FileSystemInformation.GetFileSystemInformation(subcommand.InformationBytes, 0, subcommand.FileSystemInformationClass);
            }
            catch (UnsupportedInformationLevelException)
            {
                state.LogToServer(Severity.Verbose, "SetFileSystemInformation on '{0}' failed. Information class: {1}, NTStatus: STATUS_OS2_INVALID_LEVEL.", share.Name, subcommand.FileSystemInformationClass);
                header.Status = NTStatus.STATUS_OS2_INVALID_LEVEL;
                return(null);
            }
            catch (Exception)
            {
                state.LogToServer(Severity.Verbose, "SetFileSystemInformation on '{0}' failed. Information class: {1}, NTStatus: STATUS_INVALID_PARAMETER.", share.Name, subcommand.FileSystemInformationClass);
                header.Status = NTStatus.STATUS_INVALID_PARAMETER;
                return(null);
            }

            NTStatus status = share.FileStore.SetFileSystemInformation(fileSystemInfo);

            if (status != NTStatus.STATUS_SUCCESS)
            {
                state.LogToServer(Severity.Verbose, "SetFileSystemInformation on '{0}' failed. Information class: {1}, NTStatus: {2}.", share.Name, subcommand.FileSystemInformationClass, status);
                header.Status = status;
                return(null);
            }

            state.LogToServer(Severity.Verbose, "SetFileSystemInformation on '{0}' succeeded. Information class: {1}.", share.Name, subcommand.FileSystemInformationClass);
            return(new Transaction2SetFSInformationResponse());
        }
コード例 #5
0
        public async Task <(NTStatus status, FileSystemInformation result)> GetFileSystemInformationAsync(FileSystemInformationClass informationClass, CancellationToken cancellationToken)
        {
            FileSystemInformation result = null;

            var(status, fileHandle, _) = await CreateFile(String.Empty, (AccessMask)DirectoryAccessMask.FILE_LIST_DIRECTORY | (AccessMask)DirectoryAccessMask.FILE_READ_ATTRIBUTES | AccessMask.SYNCHRONIZE, 0, ShareAccess.Read | ShareAccess.Write | ShareAccess.Delete, CreateDisposition.FILE_OPEN, CreateOptions.FILE_SYNCHRONOUS_IO_NONALERT | CreateOptions.FILE_DIRECTORY_FILE, null, cancellationToken);

            if (status != NTStatus.STATUS_SUCCESS)
            {
                return(status, result);
            }

            var(aStatus, aResult) = await GetFileSystemInformationAsync(fileHandle, informationClass, cancellationToken);
            await CloseFileAsync(fileHandle, cancellationToken);

            return(aStatus, aResult);
        }
コード例 #6
0
        public NTStatus GetFileSystemInformation(out FileSystemInformation result, FileSystemInformationClass informationClass)
        {
            result = null;
            object     fileHandle;
            FileStatus fileStatus;
            NTStatus   status = CreateFile(out fileHandle, out fileStatus, String.Empty, (AccessMask)DirectoryAccessMask.FILE_LIST_DIRECTORY | (AccessMask)DirectoryAccessMask.FILE_READ_ATTRIBUTES | AccessMask.SYNCHRONIZE, 0, ShareAccess.Read | ShareAccess.Write | ShareAccess.Delete, CreateDisposition.FILE_OPEN, CreateOptions.FILE_SYNCHRONOUS_IO_NONALERT | CreateOptions.FILE_DIRECTORY_FILE, null);

            if (status != NTStatus.STATUS_SUCCESS)
            {
                return(status);
            }

            status = GetFileSystemInformation(out result, fileHandle, informationClass);
            CloseFile(fileHandle);
            return(status);
        }
コード例 #7
0
        public void GetFileSystemInformation(out FileSystemInformation result, NtHandle handle, FileSystemInformationClass informationClass)
        {
            QueryInfoRequest request = new QueryInfoRequest
            {
                InfoType = InfoType.FileSystem,
                FileSystemInformationClass = informationClass,
                OutputBufferLength         = 4096,
                FileId = (FileID)handle
            };

            SendCommand(request);
            QueryInfoResponse queryInfoResponse = (QueryInfoResponse)WaitForCommand(request.MessageID);

            queryInfoResponse.IsSuccessElseThrow();
            result = queryInfoResponse.GetFileSystemInformation(informationClass);
        }
コード例 #8
0
 public static QueryFSInformation FromFileSystemInformation(FileSystemInformation fsInfo)
 {
     if (fsInfo is FileFsVolumeInformation)
     {
         FileFsVolumeInformation volumeInfo = (FileFsVolumeInformation)fsInfo;
         QueryFSVolumeInfo       result     = new QueryFSVolumeInfo();
         result.VolumeCreationTime = volumeInfo.VolumeCreationTime;
         result.SerialNumber       = volumeInfo.VolumeSerialNumber;
         result.VolumeLabel        = volumeInfo.VolumeLabel;
         return(result);
     }
     else if (fsInfo is FileFsSizeInformation)
     {
         FileFsSizeInformation fsSizeInfo = (FileFsSizeInformation)fsInfo;
         QueryFSSizeInfo       result     = new QueryFSSizeInfo();
         result.TotalAllocationUnits     = fsSizeInfo.TotalAllocationUnits;
         result.TotalFreeAllocationUnits = fsSizeInfo.AvailableAllocationUnits;
         result.BytesPerSector           = fsSizeInfo.BytesPerSector;
         result.SectorsPerAllocationUnit = fsSizeInfo.SectorsPerAllocationUnit;
         return(result);
     }
     else if (fsInfo is FileFsDeviceInformation)
     {
         FileFsDeviceInformation fsDeviceInfo = (FileFsDeviceInformation)fsInfo;
         QueryFSDeviceInfo       result       = new QueryFSDeviceInfo();
         result.DeviceType            = fsDeviceInfo.DeviceType;
         result.DeviceCharacteristics = fsDeviceInfo.Characteristics;
         return(result);
     }
     else if (fsInfo is FileFsAttributeInformation)
     {
         FileFsAttributeInformation fsAttributeInfo = (FileFsAttributeInformation)fsInfo;
         QueryFSAttibuteInfo        result          = new QueryFSAttibuteInfo();
         result.FileSystemAttributes     = fsAttributeInfo.FileSystemAttributes;
         result.MaxFileNameLengthInBytes = fsAttributeInfo.MaximumComponentNameLength;
         result.FileSystemName           = fsAttributeInfo.FileSystemName;
         return(result);
     }
     else
     {
         throw new NotImplementedException();
     }
 }
コード例 #9
0
        public NTStatus GetFileSystemInformation(out FileSystemInformation result, FileSystemInformationClass informationClass)
        {
            if (m_client.InfoLevelPassthrough)
            {
                result = null;
                int maxOutputLength = 4096;
                Transaction2QueryFSInformationRequest subcommand = new Transaction2QueryFSInformationRequest();
                subcommand.FileSystemInformationClass = informationClass;

                Transaction2Request request = new Transaction2Request();
                request.Setup               = subcommand.GetSetup();
                request.TransParameters     = subcommand.GetParameters(m_client.Unicode);
                request.TransData           = subcommand.GetData(m_client.Unicode);
                request.TotalDataCount      = (ushort)request.TransData.Length;
                request.TotalParameterCount = (ushort)request.TransParameters.Length;
                request.MaxParameterCount   = Transaction2QueryFSInformationResponse.ParametersLength;
                request.MaxDataCount        = (ushort)maxOutputLength;

                TrySendMessage(request);
                SMB1Message reply = m_client.WaitForMessage(CommandName.SMB_COM_TRANSACTION2);
                if (reply != null)
                {
                    if (reply.Header.Status == NTStatus.STATUS_SUCCESS && reply.Commands[0] is Transaction2Response)
                    {
                        Transaction2Response response = (Transaction2Response)reply.Commands[0];
                        Transaction2QueryFSInformationResponse subcommandResponse = new Transaction2QueryFSInformationResponse(response.TransParameters, response.TransData, reply.Header.UnicodeFlag);
                        result = subcommandResponse.GetFileSystemInformation(informationClass);
                    }
                    return(reply.Header.Status);
                }
                return(NTStatus.STATUS_INVALID_SMB);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
コード例 #10
0
        public NTStatus GetFileSystemInformation(out FileSystemInformation result, object handle, FileSystemInformationClass informationClass)
        {
            result = null;
            QueryInfoRequest request = new QueryInfoRequest();

            request.InfoType = InfoType.FileSystem;
            request.FileSystemInformationClass = informationClass;
            request.OutputBufferLength         = 4096;
            request.FileId = (FileID)handle;

            ulong       messageId = TrySendCommand(request);
            SMB2Command response  = m_client.WaitForCommand(SMB2CommandName.QueryInfo, messageId);

            if (response != null)
            {
                if (response.Header.Status == NTStatus.STATUS_SUCCESS && response is QueryInfoResponse)
                {
                    result = ((QueryInfoResponse)response).GetFileSystemInformation(informationClass);
                }
                return(response.Header.Status);
            }

            return(NTStatus.STATUS_INVALID_SMB);
        }
コード例 #11
0
 public void GetFileSystemInformation(out FileSystemInformation result, FileSystemInformationClass informationClass)
 {
     CreateFile(out NtHandle fileHandle, out _, string.Empty, (AccessMask)DirectoryAccessMask.FILE_LIST_DIRECTORY | (AccessMask)DirectoryAccessMask.FILE_READ_ATTRIBUTES | AccessMask.SYNCHRONIZE, 0, ShareAccess.Read | ShareAccess.Write | ShareAccess.Delete, CreateDisposition.FILE_OPEN, CreateOptions.FILE_SYNCHRONOUS_IO_NONALERT | CreateOptions.FILE_DIRECTORY_FILE, null);
     GetFileSystemInformation(out result, fileHandle, informationClass);
     CloseFile(fileHandle);
 }
コード例 #12
0
ファイル: SetInfoRequest.cs プロジェクト: gonsovsky/dnSvc
 public void SetFileSystemInformation(FileSystemInformation fileSystemInformation)
 {
     Buffer = fileSystemInformation.GetBytes();
 }
コード例 #13
0
 public static IEnumerator <FileHandleInfo> GetOpenFilesEnumerator(int processId, SmartPtr systemHandleInformationPointer, int handleCount)
 {
     return(FileSystemInformation.GetOpenFileHandleEnumerator(processId, systemHandleInformationPointer, handleCount));
 }
コード例 #14
0
 /// <remarks>
 /// Support for pass-through Information Levels must be enabled.
 /// </remarks>
 public void SetFileSystemInformation(FileSystemInformation information)
 {
     InformationBytes = information.GetBytes();
 }
コード例 #15
0
 /// <remarks>
 /// Support for pass-through Information Levels must be enabled.
 /// </remarks>
 public FileSystemInformation GetFileSystemInformation(FileSystemInformationClass informationClass)
 {
     return(FileSystemInformation.GetFileSystemInformation(InformationBytes, 0, informationClass));
 }
コード例 #16
0
ファイル: SetInfoHelper.cs プロジェクト: Ozytis/SMBLibrary
        internal static SMB2Command GetSetInfoResponse(SetInfoRequest request, ISMBShare share, SMB2ConnectionState state)
        {
            SMB2Session    session  = state.GetSession(request.Header.SessionID);
            OpenFileObject openFile = null;

            if (request.InfoType == InfoType.File || request.InfoType == InfoType.Security)
            {
                openFile = session.GetOpenFileObject(request.FileId);
                if (openFile == null)
                {
                    state.LogToServer(Severity.Verbose, "SetFileInformation failed. Invalid FileId. (SessionID: {0}, TreeID: {1}, FileId: {2})", request.Header.SessionID, request.Header.TreeID, request.FileId.Volatile);
                    return(new ErrorResponse(request.CommandName, NTStatus.STATUS_FILE_CLOSED));
                }

                if (share is FileSystemShare)
                {
                    if (!((FileSystemShare)share).HasWriteAccess(session.SecurityContext, openFile.Path))
                    {
                        state.LogToServer(Severity.Verbose, "SetFileInformation on '{0}{1}' failed. User '{2}' was denied access.", share.Name, openFile.Path, session.UserName);
                        return(new ErrorResponse(request.CommandName, NTStatus.STATUS_ACCESS_DENIED));
                    }
                }
            }
            else if (request.InfoType == InfoType.FileSystem)
            {
                if (share is FileSystemShare)
                {
                    if (!((FileSystemShare)share).HasWriteAccess(session.SecurityContext, @"\"))
                    {
                        state.LogToServer(Severity.Verbose, "SetFileSystemInformation on '{0}' failed. User '{1}' was denied access.", share.Name, session.UserName);
                        return(new ErrorResponse(request.CommandName, NTStatus.STATUS_ACCESS_DENIED));
                    }
                }
            }

            if (request.InfoType == InfoType.File)
            {
                FileInformation information;
                try
                {
                    information = FileInformation.GetFileInformation(request.Buffer, 0, request.FileInformationClass);
                }
                catch (UnsupportedInformationLevelException)
                {
                    state.LogToServer(Severity.Verbose, "SetFileInformation on '{0}{1}' failed. Information class: {2}, NTStatus: STATUS_INVALID_INFO_CLASS.", share.Name, openFile.Path, request.FileInformationClass);
                    return(new ErrorResponse(request.CommandName, NTStatus.STATUS_INVALID_INFO_CLASS));
                }
                catch (NotImplementedException)
                {
                    state.LogToServer(Severity.Verbose, "SetFileInformation on '{0}{1}' failed. Information class: {2}, NTStatus: STATUS_NOT_SUPPORTED.", share.Name, openFile.Path, request.FileInformationClass);
                    return(new ErrorResponse(request.CommandName, NTStatus.STATUS_NOT_SUPPORTED));
                }
                catch (Exception)
                {
                    state.LogToServer(Severity.Verbose, "SetFileInformation on '{0}{1}' failed. Information class: {2}, NTStatus: STATUS_INVALID_PARAMETER.", share.Name, openFile.Path, request.FileInformationClass);
                    return(new ErrorResponse(request.CommandName, NTStatus.STATUS_INVALID_PARAMETER));
                }

                if ((share is FileSystemShare) && (information is FileRenameInformationType2))
                {
                    string newFileName = ((FileRenameInformationType2)information).FileName;
                    if (!newFileName.StartsWith(@"\"))
                    {
                        newFileName = @"\" + newFileName;
                    }
                    if (!((FileSystemShare)share).HasWriteAccess(session.SecurityContext, newFileName))
                    {
                        state.LogToServer(Severity.Verbose, "SetFileInformation: Rename '{0}{1}' to '{0}{2}' failed. User '{3}' was denied access.", share.Name, openFile.Path, newFileName, session.UserName);
                        return(new ErrorResponse(request.CommandName, NTStatus.STATUS_ACCESS_DENIED));
                    }
                }

                NTStatus status = share.FileStore.SetFileInformation(openFile.Handle, information);
                if (status != NTStatus.STATUS_SUCCESS)
                {
                    state.LogToServer(Severity.Verbose, "SetFileInformation on '{0}{1}' failed. Information class: {2}, NTStatus: {3}. (FileId: {4})", share.Name, openFile.Path, request.FileInformationClass, status, request.FileId.Volatile);
                    return(new ErrorResponse(request.CommandName, status));
                }

                if (information is FileRenameInformationType2)
                {
                    string newFileName = ((FileRenameInformationType2)information).FileName;
                    if (!newFileName.StartsWith(@"\"))
                    {
                        newFileName = @"\" + newFileName;
                    }
                    state.LogToServer(Severity.Verbose, "SetFileInformation: Rename '{0}{1}' to '{0}{2}' succeeded. (FileId: {3})", share.Name, openFile.Path, newFileName, request.FileId.Volatile);
                    openFile.Path = newFileName;
                }
                else
                {
                    state.LogToServer(Severity.Information, "SetFileInformation on '{0}{1}' succeeded. Information class: {2}. (FileId: {3})", share.Name, openFile.Path, request.FileInformationClass, request.FileId.Volatile);
                }
                return(new SetInfoResponse());
            }
            else if (request.InfoType == InfoType.FileSystem)
            {
                FileSystemInformation fileSystemInformation;
                try
                {
                    fileSystemInformation = FileSystemInformation.GetFileSystemInformation(request.Buffer, 0, request.FileSystemInformationClass);
                }
                catch (UnsupportedInformationLevelException)
                {
                    state.LogToServer(Severity.Verbose, "SetFileSystemInformation on '{0}' failed. Information class: {1}, NTStatus: STATUS_INVALID_INFO_CLASS.", share.Name, request.FileSystemInformationClass);
                    return(new ErrorResponse(request.CommandName, NTStatus.STATUS_INVALID_INFO_CLASS));
                }
                catch (Exception)
                {
                    state.LogToServer(Severity.Verbose, "SetFileSystemInformation on '{0}' failed. Information class: {1}, NTStatus: STATUS_INVALID_PARAMETER.", share.Name, request.FileSystemInformationClass);
                    return(new ErrorResponse(request.CommandName, NTStatus.STATUS_INVALID_PARAMETER));
                }

                NTStatus status = share.FileStore.SetFileSystemInformation(fileSystemInformation);
                if (status != NTStatus.STATUS_SUCCESS)
                {
                    state.LogToServer(Severity.Verbose, "SetFileSystemInformation on '{0}' failed. Information class: {1}, NTStatus: {2}.", share.Name, request.FileSystemInformationClass, status);
                    return(new ErrorResponse(request.CommandName, status));
                }

                state.LogToServer(Severity.Verbose, "SetFileSystemInformation on '{0}' succeeded. Information class: {1}.", share.Name, request.FileSystemInformationClass);
                return(new SetInfoResponse());
            }
            else if (request.InfoType == InfoType.Security)
            {
                SecurityDescriptor securityDescriptor;
                try
                {
                    securityDescriptor = new SecurityDescriptor(request.Buffer, 0);
                }
                catch
                {
                    state.LogToServer(Severity.Verbose, "SetSecurityInformation on '{0}{1}' failed. NTStatus: STATUS_INVALID_PARAMETER.", share.Name, openFile.Path);
                    return(new ErrorResponse(request.CommandName, NTStatus.STATUS_INVALID_PARAMETER));
                }

                NTStatus status = share.FileStore.SetSecurityInformation(openFile, request.SecurityInformation, securityDescriptor);
                if (status != NTStatus.STATUS_SUCCESS)
                {
                    state.LogToServer(Severity.Verbose, "SetSecurityInformation on '{0}{1}' failed. Security information: 0x{2}, NTStatus: {3}. (FileId: {4})", share.Name, openFile.Path, request.SecurityInformation.ToString("X"), status, request.FileId.Volatile);
                    return(new ErrorResponse(request.CommandName, status));
                }

                state.LogToServer(Severity.Information, "SetSecurityInformation on '{0}{1}' succeeded. Security information: 0x{2}. (FileId: {3})", share.Name, openFile.Path, request.SecurityInformation.ToString("X"), request.FileId.Volatile);
                return(new SetInfoResponse());
            }
            return(new ErrorResponse(request.CommandName, NTStatus.STATUS_NOT_SUPPORTED));
        }
コード例 #17
0
 /// <remarks>
 /// Support for pass-through Information Levels must be enabled.
 /// </remarks>
 public void SetFileSystemInformation(FileSystemInformation information)
 {
     FileSystemInformationClass = information.FileSystemInformationClass;
     InformationBytes           = information.GetBytes();
 }
コード例 #18
0
 public void SetFileSystemInformation(FileSystemInformation information)
 {
     throw new NotImplementedException();
 }
コード例 #19
0
 public FileSystemInformation GetFileSystemInformation(FileSystemInformationClass informationClass)
 {
     return(FileSystemInformation.GetFileSystemInformation(OutputBuffer, 0, informationClass));
 }
コード例 #20
0
 public NTStatus SetFileSystemInformation(FileSystemInformation information)
 {
     return(NTStatus.STATUS_NOT_SUPPORTED);
 }
コード例 #21
0
        public NTStatus GetFileSystemInformation(out FileSystemInformation result, FileSystemInformationClass informationClass)
        {
            switch (informationClass)
            {
            case FileSystemInformationClass.FileFsVolumeInformation:
            {
                FileFsVolumeInformation information = new FileFsVolumeInformation();
                information.SupportsObjects = false;
                result = information;
                return(NTStatus.STATUS_SUCCESS);
            }

            case FileSystemInformationClass.FileFsSizeInformation:
            {
                FileFsSizeInformation information = new FileFsSizeInformation();
                information.TotalAllocationUnits     = m_fileSystem.Size / ClusterSize;
                information.AvailableAllocationUnits = m_fileSystem.FreeSpace / ClusterSize;
                information.SectorsPerAllocationUnit = ClusterSize / BytesPerSector;
                information.BytesPerSector           = BytesPerSector;
                result = information;
                return(NTStatus.STATUS_SUCCESS);
            }

            case FileSystemInformationClass.FileFsDeviceInformation:
            {
                FileFsDeviceInformation information = new FileFsDeviceInformation();
                information.DeviceType      = DeviceType.Disk;
                information.Characteristics = DeviceCharacteristics.IsMounted;
                result = information;
                return(NTStatus.STATUS_SUCCESS);
            }

            case FileSystemInformationClass.FileFsAttributeInformation:
            {
                FileFsAttributeInformation information = new FileFsAttributeInformation();
                information.FileSystemAttributes       = FileSystemAttributes.CasePreservedNamed | FileSystemAttributes.UnicodeOnDisk;
                information.MaximumComponentNameLength = 255;
                information.FileSystemName             = m_fileSystem.Name;
                result = information;
                return(NTStatus.STATUS_SUCCESS);
            }

            case FileSystemInformationClass.FileFsControlInformation:
            {
                FileFsControlInformation information = new FileFsControlInformation();
                information.FileSystemControlFlags = FileSystemControlFlags.ContentIndexingDisabled;
                information.DefaultQuotaThreshold  = UInt64.MaxValue;
                information.DefaultQuotaLimit      = UInt64.MaxValue;
                result = information;
                return(NTStatus.STATUS_SUCCESS);
            }

            case FileSystemInformationClass.FileFsFullSizeInformation:
            {
                FileFsFullSizeInformation information = new FileFsFullSizeInformation();
                information.TotalAllocationUnits           = m_fileSystem.Size / ClusterSize;
                information.CallerAvailableAllocationUnits = m_fileSystem.FreeSpace / ClusterSize;
                information.ActualAvailableAllocationUnits = m_fileSystem.FreeSpace / ClusterSize;
                information.SectorsPerAllocationUnit       = ClusterSize / BytesPerSector;
                information.BytesPerSector = BytesPerSector;
                result = information;
                return(NTStatus.STATUS_SUCCESS);
            }

            case FileSystemInformationClass.FileFsObjectIdInformation:
            {
                result = null;
                // STATUS_INVALID_PARAMETER is returned when the file system does not implement object IDs
                // See: https://msdn.microsoft.com/en-us/library/cc232106.aspx
                return(NTStatus.STATUS_INVALID_PARAMETER);
            }

            case FileSystemInformationClass.FileFsSectorSizeInformation:
            {
                FileFsSectorSizeInformation information = new FileFsSectorSizeInformation();
                information.LogicalBytesPerSector = BytesPerSector;
                information.PhysicalBytesPerSectorForAtomicity   = BytesPerSector;
                information.PhysicalBytesPerSectorForPerformance = BytesPerSector;
                information.FileSystemEffectivePhysicalBytesPerSectorForAtomicity = BytesPerSector;
                information.ByteOffsetForSectorAlignment    = 0;
                information.ByteOffsetForPartitionAlignment = 0;
                result = information;
                return(NTStatus.STATUS_SUCCESS);
            }

            default:
            {
                result = null;
                return(NTStatus.STATUS_INVALID_INFO_CLASS);
            }
            }
        }