public static NTStatus GetFileSystemInformation(out QueryFSInformation result, INTFileStore fileStore, QueryFSInformationLevel informationLevel) { result = null; FileSystemInformationClass informationClass; try { informationClass = QueryFSInformationHelper.ToFileSystemInformationClass(informationLevel); } catch (UnsupportedInformationLevelException) { return(NTStatus.STATUS_OS2_INVALID_LEVEL); } FileSystemInformation fsInfo; NTStatus status = fileStore.GetFileSystemInformation(out fsInfo, informationClass); if (status != NTStatus.STATUS_SUCCESS) { return(status); } result = QueryFSInformationHelper.FromFileSystemInformation(fsInfo); return(NTStatus.STATUS_SUCCESS); }
public NTStatus GetFileSystemInformation(out QueryFSInformation result, QueryFSInformationLevel informationLevel) { result = null; int maxOutputLength = 4096; Transaction2QueryFSInformationRequest subcommand = new Transaction2QueryFSInformationRequest(); subcommand.QueryFSInformationLevel = informationLevel; 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.GetQueryFSInformation(informationLevel, reply.Header.UnicodeFlag); } return(reply.Header.Status); } return(NTStatus.STATUS_INVALID_SMB); }
public void GetFileSystemInformation(out QueryFSInformation result, QueryFSInformationLevel informationLevel) { int maxOutputLength = 4096; Transaction2QueryFSInformationRequest subcommand = new Transaction2QueryFSInformationRequest { QueryFSInformationLevel = informationLevel }; Transaction2Request request = new Transaction2Request { Setup = subcommand.GetSetup(), TransParameters = subcommand.GetParameters(m_client.Unicode), 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.Header.Status != NTStatus.STATUS_SUCCESS || !(reply.Commands[0] is Transaction2Response)) { throw new NtStatusException(reply.Header.Status); } Transaction2Response response = (Transaction2Response)reply.Commands[0]; Transaction2QueryFSInformationResponse subcommandResponse = new Transaction2QueryFSInformationResponse(response.TransData); result = subcommandResponse.GetQueryFSInformation(informationLevel); }
public static NTStatus GetFileSystemInformation(out QueryFSInformation result, INTFileStore fileStore, QueryFSInformationLevel informationLevel) { result = null; FileSystemInformation fsInfo; switch (informationLevel) { case QueryFSInformationLevel.SMB_QUERY_FS_VOLUME_INFO: { NTStatus status = fileStore.GetFileSystemInformation(out fsInfo, FileSystemInformationClass.FileFsVolumeInformation); if (status != NTStatus.STATUS_SUCCESS) { return(status); } FileFsVolumeInformation volumeInfo = (FileFsVolumeInformation)fsInfo; QueryFSVolumeInfo information = new QueryFSVolumeInfo(); information.VolumeCreationTime = volumeInfo.VolumeCreationTime; information.SerialNumber = volumeInfo.VolumeSerialNumber; information.VolumeLabel = volumeInfo.VolumeLabel; result = information; return(NTStatus.STATUS_SUCCESS); } case QueryFSInformationLevel.SMB_QUERY_FS_SIZE_INFO: { NTStatus status = fileStore.GetFileSystemInformation(out fsInfo, FileSystemInformationClass.FileFsSizeInformation); if (status != NTStatus.STATUS_SUCCESS) { return(status); } FileFsSizeInformation fsSizeInfo = (FileFsSizeInformation)fsInfo; QueryFSSizeInfo information = new QueryFSSizeInfo(); information.TotalAllocationUnits = fsSizeInfo.TotalAllocationUnits; information.TotalFreeAllocationUnits = fsSizeInfo.AvailableAllocationUnits; information.BytesPerSector = fsSizeInfo.BytesPerSector; information.SectorsPerAllocationUnit = fsSizeInfo.SectorsPerAllocationUnit; result = information; return(NTStatus.STATUS_SUCCESS); } case QueryFSInformationLevel.SMB_QUERY_FS_DEVICE_INFO: { NTStatus status = fileStore.GetFileSystemInformation(out fsInfo, FileSystemInformationClass.FileFsDeviceInformation); if (status != NTStatus.STATUS_SUCCESS) { return(status); } FileFsDeviceInformation fsDeviceInfo = (FileFsDeviceInformation)fsInfo; QueryFSDeviceInfo information = new QueryFSDeviceInfo(); information.DeviceType = fsDeviceInfo.DeviceType; information.DeviceCharacteristics = fsDeviceInfo.Characteristics; result = information; return(NTStatus.STATUS_SUCCESS); } case QueryFSInformationLevel.SMB_QUERY_FS_ATTRIBUTE_INFO: { NTStatus status = fileStore.GetFileSystemInformation(out fsInfo, FileSystemInformationClass.FileFsAttributeInformation); if (status != NTStatus.STATUS_SUCCESS) { return(status); } FileFsAttributeInformation fsAttributeInfo = (FileFsAttributeInformation)fsInfo; QueryFSAttibuteInfo information = new QueryFSAttibuteInfo(); information.FileSystemAttributes = fsAttributeInfo.FileSystemAttributes; information.MaxFileNameLengthInBytes = fsAttributeInfo.MaximumComponentNameLength; information.FileSystemName = fsAttributeInfo.FileSystemName; result = information; return(NTStatus.STATUS_SUCCESS); } default: { return(NTStatus.STATUS_OS2_INVALID_LEVEL); } } }
public void SetQueryFSInformation(QueryFSInformation queryFSInformation, bool isUnicode) { InformationBytes = queryFSInformation.GetBytes(isUnicode); }
public QueryFSInformation GetQueryFSInformation(QueryFSInformationLevel informationLevel) { return(QueryFSInformation.GetQueryFSInformation(InformationBytes, informationLevel)); }