コード例 #1
0
        /// <exception cref="SmbLibraryStd.UnsupportedInformationLevelException"></exception>
        public static FileInformationClass ToFileInformationClass(QueryInformationLevel informationLevel)
        {
            switch (informationLevel)
            {
            case QueryInformationLevel.SMB_QUERY_FILE_BASIC_INFO:
                return(FileInformationClass.FileBasicInformation);

            case QueryInformationLevel.SMB_QUERY_FILE_STANDARD_INFO:
                return(FileInformationClass.FileStandardInformation);

            case QueryInformationLevel.SMB_QUERY_FILE_EA_INFO:
                return(FileInformationClass.FileEaInformation);

            case QueryInformationLevel.SMB_QUERY_FILE_NAME_INFO:
                return(FileInformationClass.FileNameInformation);

            case QueryInformationLevel.SMB_QUERY_FILE_ALL_INFO:
                return(FileInformationClass.FileAllInformation);

            case QueryInformationLevel.SMB_QUERY_FILE_ALT_NAME_INFO:
                return(FileInformationClass.FileAlternateNameInformation);

            case QueryInformationLevel.SMB_QUERY_FILE_STREAM_INFO:
                return(FileInformationClass.FileStreamInformation);

            case QueryInformationLevel.SMB_QUERY_FILE_COMPRESSION_INFO:
                return(FileInformationClass.FileCompressionInformation);

            default:
                throw new UnsupportedInformationLevelException();
            }
        }
コード例 #2
0
ファイル: QueryInformation.cs プロジェクト: gonsovsky/dnSvc
        public static QueryInformation GetQueryInformation(byte[] buffer, QueryInformationLevel informationLevel)
        {
            switch (informationLevel)
            {
            case QueryInformationLevel.SMB_QUERY_FILE_BASIC_INFO:
                return(new QueryFileBasicInfo(buffer, 0));

            case QueryInformationLevel.SMB_QUERY_FILE_STANDARD_INFO:
                return(new QueryFileStandardInfo(buffer, 0));

            case QueryInformationLevel.SMB_QUERY_FILE_EA_INFO:
                return(new QueryFileEaInfo(buffer, 0));

            case QueryInformationLevel.SMB_QUERY_FILE_NAME_INFO:
                return(new QueryFileNameInfo(buffer, 0));

            case QueryInformationLevel.SMB_QUERY_FILE_ALL_INFO:
                return(new QueryFileAllInfo(buffer, 0));

            case QueryInformationLevel.SMB_QUERY_FILE_ALT_NAME_INFO:
                return(new QueryFileAltNameInfo(buffer, 0));

            case QueryInformationLevel.SMB_QUERY_FILE_STREAM_INFO:
                return(new QueryFileStreamInfo(buffer, 0));

            case QueryInformationLevel.SMB_QUERY_FILE_COMPRESSION_INFO:
                return(new QueryFileCompressionInfo(buffer, 0));

            default:
                throw new UnsupportedInformationLevelException();
            }
        }
 /// <summary>
 /// Deep copy constructor.
 /// </summary>
 public SmbTrans2QueryPathInformationFinalResponsePacket(
         SmbTrans2QueryPathInformationFinalResponsePacket packet)
     : base(packet)
 {
     this.InitDefaultValue();
     this.trans2Parameters.EaErrorOffset = packet.trans2Parameters.EaErrorOffset;
     this.trans2Data.Data = packet.trans2Data.Data;
     this.informationLevel = packet.informationLevel;
 }
 /// <summary>
 /// Deep copy constructor.
 /// </summary>
 public SmbTrans2QueryFileInformationFinalResponsePacket(
         SmbTrans2QueryFileInformationFinalResponsePacket packet)
     : base(packet)
 {
     this.InitDefaultValue();
     this.trans2Parameters = packet.trans2Parameters;
     this.trans2Data = packet.trans2Data;
     this.informationLevel = packet.informationLevel;
 }
コード例 #5
0
 /// <summary>
 /// Deep copy constructor.
 /// </summary>
 public SmbTrans2QueryPathInformationFinalResponsePacket(
     SmbTrans2QueryPathInformationFinalResponsePacket packet)
     : base(packet)
 {
     this.InitDefaultValue();
     this.trans2Parameters.EaErrorOffset = packet.trans2Parameters.EaErrorOffset;
     this.trans2Data.Data  = packet.trans2Data.Data;
     this.informationLevel = packet.informationLevel;
 }
 /// <summary>
 /// Deep copy constructor.
 /// </summary>
 public SmbTrans2QueryFileInformationFinalResponsePacket(
     SmbTrans2QueryFileInformationFinalResponsePacket packet)
     : base(packet)
 {
     this.InitDefaultValue();
     this.trans2Parameters = packet.trans2Parameters;
     this.trans2Data       = packet.trans2Data;
     this.informationLevel = packet.informationLevel;
 }
コード例 #7
0
        public Transaction2QueryFileInformationRequest(byte[] parameters, byte[] data, bool isUnicode) : base()
        {
            FID = LittleEndianConverter.ToUInt16(parameters, 0);
            InformationLevel = (QueryInformationLevel)LittleEndianConverter.ToUInt16(parameters, 2);

            if (InformationLevel == QueryInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST)
            {
                GetExtendedAttributeList = new FullExtendedAttributeList(data, 0);
            }
        }
コード例 #8
0
        public Transaction2QueryPathInformationRequest(byte[] parameters, byte[] data, bool isUnicode) : base()
        {
            InformationLevel = (QueryInformationLevel)LittleEndianConverter.ToUInt16(parameters, 0);
            Reserved         = LittleEndianConverter.ToUInt32(parameters, 4);
            FileName         = SMB1Helper.ReadSMBString(parameters, 6, isUnicode);

            if (InformationLevel == QueryInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST)
            {
                GetExtendedAttributeList = new FullExtendedAttributeList(data, 0);
            }
        }
コード例 #9
0
        public NTStatus GetFileInformation(out FileInformation result, object handle, FileInformationClass informationClass)
        {
            result = null;
            if (m_client.InfoLevelPassthrough)
            {
                int maxOutputLength = 4096;
                Transaction2QueryFileInformationRequest subcommand = new Transaction2QueryFileInformationRequest();
                subcommand.FID = (ushort)handle;
                subcommand.FileInformationClass = 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   = Transaction2QueryFileInformationResponse.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];
                        Transaction2QueryFileInformationResponse subcommandResponse = new Transaction2QueryFileInformationResponse(response.TransParameters, response.TransData, reply.Header.UnicodeFlag);
                        if (informationClass == FileInformationClass.FileAllInformation)
                        {
                            // Windows implementations return SMB_QUERY_FILE_ALL_INFO when a client specifies native NT passthrough level "FileAllInformation".
                            QueryInformation queryFileAllInfo = subcommandResponse.GetQueryInformation(QueryInformationLevel.SMB_QUERY_FILE_ALL_INFO);
                            result = QueryInformationHelper.ToFileInformation(queryFileAllInfo);
                        }
                        else
                        {
                            result = subcommandResponse.GetFileInformation(informationClass);
                        }
                    }
                    return(reply.Header.Status);
                }
                return(NTStatus.STATUS_INVALID_SMB);
            }
            else
            {
                QueryInformationLevel informationLevel = QueryInformationHelper.ToFileInformationLevel(informationClass);
                QueryInformation      queryInformation;
                NTStatus status = GetFileInformation(out queryInformation, handle, informationLevel);
                if (status == NTStatus.STATUS_SUCCESS)
                {
                    result = QueryInformationHelper.ToFileInformation(queryInformation);
                }
                return(status);
            }
        }
コード例 #10
0
        public void GetFileInformation(out FileInformation result, NtHandle handle, FileInformationClass informationClass)
        {
            if (m_client.InfoLevelPassthrough)
            {
                int maxOutputLength = 4096;
                Transaction2QueryFileInformationRequest subcommand = new Transaction2QueryFileInformationRequest
                {
                    FID = ((Smb1Handle)handle).FID,
                    FileInformationClass = informationClass
                };

                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   = Transaction2QueryFileInformationResponse.ParametersLength;
                request.MaxDataCount        = (ushort)maxOutputLength;

                TrySendMessage(request);
                SMB1Message reply = m_client.WaitForMessage(CommandName.SMB_COM_TRANSACTION2);
                reply.IsSuccessElseThrow();
                if (!(reply.Commands[0] is Transaction2Response transaction2Response))
                {
                    throw new NtStatusException(reply.Header.Status);
                }

                Transaction2QueryFileInformationResponse subcommandResponse = new Transaction2QueryFileInformationResponse(transaction2Response.TransParameters, transaction2Response.TransData);
                if (informationClass == FileInformationClass.FileAllInformation)
                {
                    // Windows implementations return SMB_QUERY_FILE_ALL_INFO when a client specifies native NT passthrough level "FileAllInformation".
                    QueryInformation queryFileAllInfo = subcommandResponse.GetQueryInformation(QueryInformationLevel.SMB_QUERY_FILE_ALL_INFO);
                    result = QueryInformationHelper.ToFileInformation(queryFileAllInfo);
                }
                else
                {
                    result = subcommandResponse.GetFileInformation(informationClass);
                }
                reply.IsSuccessElseThrow();
                return;
            }

            QueryInformationLevel informationLevel = QueryInformationHelper.ToFileInformationLevel(informationClass);

            GetFileInformation(out QueryInformation? queryInformation, handle, informationLevel);
            result = QueryInformationHelper.ToFileInformation(queryInformation);
        }
コード例 #11
0
        /// <summary>
        /// SMB_INFO_IS_NAME_VALID will return null
        /// </summary>
        public static QueryInformation GetQueryInformation(byte[] buffer, QueryInformationLevel informationLevel)
        {
            switch (informationLevel)
            {
            case QueryInformationLevel.SMB_INFO_STANDARD:
                return(new QueryInfoStandard(buffer, 0));

            case QueryInformationLevel.SMB_INFO_QUERY_EA_SIZE:
                return(new QueryEASize(buffer, 0));

            case QueryInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST:
                return(new QueryExtendedAttributesFromList(buffer, 0));

            case QueryInformationLevel.SMB_INFO_QUERY_ALL_EAS:
                return(new QueryAllExtendedAttributes(buffer, 0));

            case QueryInformationLevel.SMB_QUERY_FILE_BASIC_INFO:
                return(new QueryFileBasicInfo(buffer, 0));

            case QueryInformationLevel.SMB_QUERY_FILE_STANDARD_INFO:
                return(new QueryFileStandardInfo(buffer, 0));

            case QueryInformationLevel.SMB_QUERY_FILE_EA_INFO:
                return(new QueryFileExtendedAttributeInfo(buffer, 0));

            case QueryInformationLevel.SMB_QUERY_FILE_NAME_INFO:
                return(new QueryFileNameInfo(buffer, 0));

            case QueryInformationLevel.SMB_QUERY_FILE_ALL_INFO:
                return(new QueryFileAllInfo(buffer, 0));

            case QueryInformationLevel.SMB_QUERY_FILE_ALT_NAME_INFO:
                return(new QueryFileAltNameInfo(buffer, 0));

            case QueryInformationLevel.SMB_QUERY_FILE_STREAM_INFO:
                return(new QueryFileStreamInfo(buffer, 0));

            case QueryInformationLevel.SMB_QUERY_FILE_COMPRESSION_INFO:
                return(new QueryFileCompressionInfo(buffer, 0));

            default:
                throw new InvalidRequestException();
            }
        }
コード例 #12
0
        public static QueryInformation GetQueryInformation(byte[]?buffer, QueryInformationLevel informationLevel)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            return(informationLevel switch
            {
                QueryInformationLevel.SMB_QUERY_FILE_BASIC_INFO => new QueryFileBasicInfo(buffer, 0),
                QueryInformationLevel.SMB_QUERY_FILE_STANDARD_INFO => new QueryFileStandardInfo(buffer, 0),
                QueryInformationLevel.SMB_QUERY_FILE_EA_INFO => new QueryFileEaInfo(buffer, 0),
                QueryInformationLevel.SMB_QUERY_FILE_NAME_INFO => new QueryFileNameInfo(buffer),
                QueryInformationLevel.SMB_QUERY_FILE_ALL_INFO => new QueryFileAllInfo(buffer, 0),
                QueryInformationLevel.SMB_QUERY_FILE_ALT_NAME_INFO => new QueryFileAltNameInfo(buffer, 0),
                QueryInformationLevel.SMB_QUERY_FILE_STREAM_INFO => new QueryFileStreamInfo(buffer, 0),
                QueryInformationLevel.SMB_QUERY_FILE_COMPRESSION_INFO => new QueryFileCompressionInfo(buffer, 0),
                _ => throw new UnsupportedInformationLevelException()
            });
コード例 #13
0
        public void GetFileInformation(out QueryInformation result, NtHandle handle, QueryInformationLevel informationLevel)
        {
            int maxOutputLength = 4096;
            Transaction2QueryFileInformationRequest subcommand = new Transaction2QueryFileInformationRequest
            {
                FID = ((Smb1Handle)handle).FID,
                QueryInformationLevel = 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   = Transaction2QueryFileInformationResponse.ParametersLength;
            request.MaxDataCount        = (ushort)maxOutputLength;

            TrySendMessage(request);
            SMB1Message reply = m_client.WaitForMessage(CommandName.SMB_COM_TRANSACTION2);

            reply.IsSuccessElseThrow();
            if (!(reply.Commands[0] is Transaction2Response))
            {
                throw new NtStatusException(reply.Header.Status);
            }

            Transaction2Response response = (Transaction2Response)reply.Commands[0];
            Transaction2QueryFileInformationResponse subcommandResponse = new Transaction2QueryFileInformationResponse(response.TransParameters, response.TransData);

            result = subcommandResponse.GetQueryInformation(informationLevel);
            reply.IsSuccessElseThrow();
        }
コード例 #14
0
        public NTStatus GetFileInformation(out QueryInformation result, object handle, QueryInformationLevel informationLevel)
        {
            result = null;
            int maxOutputLength = 4096;
            Transaction2QueryFileInformationRequest subcommand = new Transaction2QueryFileInformationRequest();

            subcommand.FID = (ushort)handle;
            subcommand.QueryInformationLevel = 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   = Transaction2QueryFileInformationResponse.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];
                    Transaction2QueryFileInformationResponse subcommandResponse = new Transaction2QueryFileInformationResponse(response.TransParameters, response.TransData, reply.Header.UnicodeFlag);
                    result = subcommandResponse.GetQueryInformation(informationLevel);
                }
                return(reply.Header.Status);
            }
            return(NTStatus.STATUS_INVALID_SMB);
        }
コード例 #15
0
ファイル: QueryInformation.cs プロジェクト: henke37/debugHelp
 public QueryInformation(ulong batteryTag, QueryInformationLevel informationLevel) : this()
 {
     BatteryTag       = batteryTag;
     InformationLevel = informationLevel;
     AtRate           = 0;
 }
コード例 #16
0
 public Transaction2QueryFileInformationResponse(byte[] parameters, byte[] data, QueryInformationLevel informationLevel, bool isUnicode) : base()
 {
     if ((ushort)informationLevel > 0x0100)
     {
         EaErrorOffset = LittleEndianConverter.ToUInt16(parameters, 0);
     }
     QueryInfo = QueryInformation.GetQueryInformation(data, informationLevel);
 }
コード例 #17
0
        /// <summary>
        /// to create a Trans2QueryFileInformation request packet.
        /// </summary>
        /// <param name="messageId">This field SHOULD be the multiplex ID that is used to associate a response with a
        /// request.</param>
        /// <param name="uid">This field SHOULD identify the authenticated instance of the user.</param>
        /// <param name="treeId">This field identifies the subdirectory (or tree) on the server that the client is
        /// accessing.</param>
        /// <param name="flags">An 8-bit field of 1-bit flags describing various features in effect for the
        /// message</param>
        /// <param name="flags2">A 16-bit field of 1-bit flags that represent various features in effect for the
        /// message. Unspecified bits are reserved and MUST be zero.</param>
        /// <param name="maxParameterCount">The maximum number of parameter bytes that the client will accept in the
        /// transaction reply. The server MUST NOT return more than this number of parameter bytes.</param>
        /// <param name="maxDataCount">The maximum number of data bytes that the client will accept in the transaction
        /// reply. The server MUST NOT return more than this number of data bytes.</param>
        /// <param name="maxSetupCount">Maximum number of setup bytes that the client will accept in the transaction
        /// reply. The server MUST NOT return more than this number of setup bytes</param>
        /// <param name="smbParametersFlags">A set of bit flags that alter the behavior of the requested operation.
        /// Unused bit fields MUST be set to zero by the client sending the request, and MUST be ignored by the server
        /// receiving the request. The client MAY set either or both of the following bit flags</param>
        /// <param name="timeout">The number of milliseconds the server SHOULD wait for completion of the transaction
        /// before generating a timeout. A value of zero indicates that the operation MUST NOT block.</param>
        /// <param name="informationLevel">This field contains an information level code, which determines the
        /// information contained in the response.</param>
        /// <param name="fid">This field MUST contain a valid FID returned from a previously successful SMB open
        /// command</param>
        /// <param name="name">This field is present but not used in SMB_COM_TRANSACTION2 requests. If Unicode support
        /// has been negotiated, then this field MUST be aligned to a 16-bit boundary and MUST consist of two null bytes
        /// (a null-terminator). If Unicode support has not been negotiated this field will contain only one null
        /// byte.</param>
        /// <param name="extendedAttributeList">This field MUST contain an array of extended file attribute name value
        /// pairs.</param>
        /// <returns>a Trans2QueryFileInformation request packet</returns>
        public SmbTrans2QueryFileInformationRequestPacket CreateTrans2QueryFileInformationRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            ushort maxParameterCount,
            ushort maxDataCount,
            byte maxSetupCount,
            Trans2SmbParametersFlags smbParametersFlags,
            uint timeout,
            string name,
            ushort fid,
            QueryInformationLevel informationLevel,
            SMB_GEA[] extendedAttributeList)
        {
            if (name == null)
            {
                name = string.Empty;
            }
            if (extendedAttributeList == null)
            {
                extendedAttributeList = new SMB_GEA[0];
            }

            SmbTrans2QueryFileInformationRequestPacket packet = new SmbTrans2QueryFileInformationRequestPacket();
            packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_TRANSACTION2,
                messageId, uid, treeId, flags, flags2);

            // Set Smb_Parameters
            SMB_COM_TRANSACTION2_Request_SMB_Parameters smbParameters =
                new SMB_COM_TRANSACTION2_Request_SMB_Parameters();
            smbParameters.MaxParameterCount = maxParameterCount;
            smbParameters.MaxDataCount = maxDataCount;
            smbParameters.MaxSetupCount = maxSetupCount;
            smbParameters.Flags = (ushort)smbParametersFlags;
            smbParameters.Timeout = timeout;
            smbParameters.SetupCount = 1; // the correct count in word of the Setup is always 1.
            smbParameters.Setup = new ushort[] { (ushort)Trans2SubCommand.TRANS2_QUERY_FILE_INFORMATION };
            smbParameters.WordCount = (byte)(CifsMessageUtils.GetSize<SMB_COM_TRANSACTION2_Request_SMB_Parameters>(
                smbParameters) / NumBytesOfWord);

            // Set Smb_Data
            SMB_COM_TRANSACTION2_Request_SMB_Data smbData = new SMB_COM_TRANSACTION2_Request_SMB_Data();
            smbData.Name = CifsMessageUtils.ToSmbStringBytes(name,
                (flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE);

            // Set Trans2_Parameters
            TRANS2_QUERY_FILE_INFORMATION_Request_Trans2_Parameters trans2Parameters =
                new TRANS2_QUERY_FILE_INFORMATION_Request_Trans2_Parameters();
            trans2Parameters.FID = fid;
            trans2Parameters.InformationLevel = informationLevel;

            // Set Trans2_Data
            TRANS2_QUERY_PATH_INFORMATION_Request_Trans2_Data trans2Data =
                new TRANS2_QUERY_PATH_INFORMATION_Request_Trans2_Data();
            trans2Data.GetExtendedAttributeList.GEAList = extendedAttributeList;
            trans2Data.GetExtendedAttributeList.SizeOfListInBytes =
                (uint)CifsMessageUtils.GetSize<uint>(trans2Data.GetExtendedAttributeList.SizeOfListInBytes);
            trans2Data.GetExtendedAttributeList.SizeOfListInBytes +=
                CifsMessageUtils.GetSmbQueryEAListSize(extendedAttributeList);

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;
            packet.Trans2Parameters = trans2Parameters;
            packet.Trans2Data = trans2Data;
            packet.UpdateCountAndOffset();

            return packet;
        }
コード例 #18
0
        internal static QueryInformation FromFileSystemEntry(FileSystemEntry entry, QueryInformationLevel informationLevel)
        {
            switch (informationLevel)
            {
            case QueryInformationLevel.SMB_INFO_STANDARD:
            {
                QueryInfoStandard result = new QueryInfoStandard();
                result.CreationDateTime   = entry.CreationTime;
                result.LastAccessDateTime = entry.LastAccessTime;
                result.LastWriteDateTime  = entry.LastWriteTime;
                result.FileDataSize       = (uint)Math.Min(entry.Size, UInt32.MaxValue);
                result.AllocationSize     = (uint)Math.Min(GetAllocationSize(entry.Size), UInt32.MaxValue);
                return(result);
            }

            case QueryInformationLevel.SMB_INFO_QUERY_EA_SIZE:
            {
                QueryEASize result = new QueryEASize();
                result.CreationDateTime   = entry.CreationTime;
                result.LastAccessDateTime = entry.LastAccessTime;
                result.LastWriteDateTime  = entry.LastWriteTime;
                result.FileDataSize       = (uint)Math.Min(entry.Size, UInt32.MaxValue);
                result.AllocationSize     = (uint)Math.Min(GetAllocationSize(entry.Size), UInt32.MaxValue);
                result.Attributes         = GetFileAttributes(entry);
                result.EASize             = 0;
                return(result);
            }

            case QueryInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST:
            {
                throw new NotImplementedException();
            }

            case QueryInformationLevel.SMB_INFO_QUERY_ALL_EAS:
            {
                throw new NotImplementedException();
            }

            case QueryInformationLevel.SMB_INFO_IS_NAME_VALID:
            {
                throw new NotImplementedException();
            }

            case QueryInformationLevel.SMB_QUERY_FILE_BASIC_INFO:
            {
                QueryFileBasicInfo result = new QueryFileBasicInfo();
                result.CreationDateTime   = entry.CreationTime;
                result.LastAccessDateTime = entry.LastAccessTime;
                result.LastWriteDateTime  = entry.LastWriteTime;
                result.LastChangeTime     = entry.LastWriteTime;
                result.ExtFileAttributes  = GetExtendedFileAttributes(entry);
                return(result);
            }

            case QueryInformationLevel.SMB_QUERY_FILE_STANDARD_INFO:
            {
                QueryFileStandardInfo result = new QueryFileStandardInfo();
                result.AllocationSize = GetAllocationSize(entry.Size);
                result.EndOfFile      = entry.Size;
                result.Directory      = entry.IsDirectory;
                return(result);
            }

            case QueryInformationLevel.SMB_QUERY_FILE_EA_INFO:
            {
                QueryFileExtendedAttributeInfo result = new QueryFileExtendedAttributeInfo();
                result.EASize = 0;
                return(result);
            }

            case QueryInformationLevel.SMB_QUERY_FILE_NAME_INFO:
            {
                QueryFileNameInfo result = new QueryFileNameInfo();
                result.FileName = entry.Name;
                return(result);
            }

            case QueryInformationLevel.SMB_QUERY_FILE_ALL_INFO:
            {
                QueryFileAllInfo result = new QueryFileAllInfo();
                result.CreationDateTime   = entry.CreationTime;
                result.LastAccessDateTime = entry.LastAccessTime;
                result.LastWriteDateTime  = entry.LastWriteTime;
                result.ExtFileAttributes  = GetExtendedFileAttributes(entry);
                result.LastChangeTime     = entry.LastWriteTime;
                result.AllocationSize     = GetAllocationSize(entry.Size);
                result.EndOfFile          = entry.Size;
                result.DeletePending      = false;    // We delete immediately
                result.Directory          = entry.IsDirectory;
                result.EASize             = 0;
                result.FileName           = entry.Name;
                return(result);
            }

            case QueryInformationLevel.SMB_QUERY_FILE_ALT_NAME_INFO:
            {
                QueryFileAltNameInfo result = new QueryFileAltNameInfo();
                result.FileName = GetShortName(entry.Name);
                return(result);
            }

            case QueryInformationLevel.SMB_QUERY_FILE_STREAM_INFO:
            {
                QueryFileStreamInfo result = new QueryFileStreamInfo();
                result.StreamSize           = entry.Size;
                result.StreamAllocationSize = GetAllocationSize(entry.Size);
                result.StreamName           = "::$DATA";
                return(result);
            }

            case QueryInformationLevel.SMB_QUERY_FILE_COMPRESSION_INFO:
            {
                QueryFileCompressionInfo result = new QueryFileCompressionInfo();
                result.CompressionFormat = CompressionFormat.COMPRESSION_FORMAT_NONE;
                return(result);
            }

            default:
            {
                throw new UnsupportedInformationLevelException();
            }
            }
        }
コード例 #19
0
 public QueryInformation GetQueryInformation(QueryInformationLevel queryInformationLevel)
 {
     return(QueryInformation.GetQueryInformation(InformationBytes, queryInformationLevel));
 }
コード例 #20
0
        /// <summary>
        /// to create a Trans2QueryPathInformation request packet.
        /// </summary>
        /// <param name="messageId">This field SHOULD be the multiplex ID that is used to associate a response with a
        /// request.</param>
        /// <param name="uid">This field SHOULD identify the authenticated instance of the user.</param>
        /// <param name="treeId">This field identifies the subdirectory (or tree) on the server that the client is
        /// accessing.</param>
        /// <param name="flags">An 8-bit field of 1-bit flags describing various features in effect for the
        /// message</param>
        /// <param name="flags2">A 16-bit field of 1-bit flags that represent various features in effect for the
        /// message. Unspecified bits are reserved and MUST be zero.</param>
        /// <param name="maxParameterCount">The maximum number of parameter bytes that the client will accept in the
        /// transaction reply. The server MUST NOT return more than this number of parameter bytes.</param>
        /// <param name="maxDataCount">The maximum number of data bytes that the client will accept in the transaction
        /// reply. The server MUST NOT return more than this number of data bytes.</param>
        /// <param name="maxSetupCount">Maximum number of setup bytes that the client will accept in the transaction
        /// reply. The server MUST NOT return more than this number of setup bytes</param>
        /// <param name="smbParametersFlags">A set of bit flags that alter the behavior of the requested operation.
        /// Unused bit fields MUST be set to zero by the client sending the request, and MUST be ignored by the server
        /// receiving the request. The client MAY set either or both of the following bit flags</param>
        /// <param name="timeout">The number of milliseconds the server SHOULD wait for completion of the transaction
        /// before generating a timeout. A value of zero indicates that the operation MUST NOT block.</param>
        /// <param name="informationLevel">This field contains an information level code, which determines the
        /// information contained in the response.</param>
        /// <param name="name">A buffer containing the name of the file to be opened, created, or truncated. The
        /// string MUST be null terminated</param>
        /// <param name="extendedAttributeList">This field MUST contain an array of extended file attribute name value
        /// pairs. </param>
        /// <returns>a Trans2QueryPathInformation request packet</returns>
        public SmbTrans2QueryPathInformationRequestPacket CreateTrans2QueryPathInformationRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            ushort maxParameterCount,
            ushort maxDataCount,
            byte maxSetupCount,
            Trans2SmbParametersFlags smbParametersFlags,
            uint timeout,
            QueryInformationLevel informationLevel,
            string name,
            SMB_GEA[] extendedAttributeList)
        {
            if (name == null)
            {
                name = string.Empty;
            }
            if (extendedAttributeList == null)
            {
                extendedAttributeList = new SMB_GEA[0];
            }

            SmbTrans2QueryPathInformationRequestPacket packet = new SmbTrans2QueryPathInformationRequestPacket();
            packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_TRANSACTION2,
                messageId, uid, treeId, flags, flags2);

            // Set Smb_Parameters
            SMB_COM_TRANSACTION2_Request_SMB_Parameters smbParameters =
                new SMB_COM_TRANSACTION2_Request_SMB_Parameters();
            smbParameters.MaxParameterCount = maxParameterCount;
            smbParameters.MaxDataCount = maxDataCount;
            smbParameters.MaxSetupCount = maxSetupCount;
            smbParameters.Flags = (ushort)smbParametersFlags;
            smbParameters.Timeout = timeout;
            smbParameters.SetupCount = 1; // the correct count in word of the Setup is always 1.
            smbParameters.Setup = new ushort[] { (ushort)Trans2SubCommand.TRANS2_QUERY_PATH_INFORMATION };
            smbParameters.WordCount = (byte)(CifsMessageUtils.GetSize<SMB_COM_TRANSACTION2_Request_SMB_Parameters>(
                smbParameters) / NumBytesOfWord);

            // Set Smb_Data
            SMB_COM_TRANSACTION2_Request_SMB_Data smbData = new SMB_COM_TRANSACTION2_Request_SMB_Data();
            smbData.Name = CifsMessageUtils.ToSmbStringBytes(name,
                (flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE);

            // Set Trans2_Parameters
            TRANS2_QUERY_PATH_INFORMATION_Request_Trans2_Parameters trans2Parameters =
                new TRANS2_QUERY_PATH_INFORMATION_Request_Trans2_Parameters();
            trans2Parameters.InformationLevel = informationLevel;
            trans2Parameters.FileName = CifsMessageUtils.ToSmbStringBytes(name,
                (flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE);

            // The size of the preceding SmbParameters part plus Header part is an odd number for all cifs messages
            // Use Name field to judge whether needs to add one 16-bits align pad.
            if ((flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE && smbData.Name.Length
                % twoBytesAlign == 0)
            {
                // pad 1 byte for 16-bits align:
                smbData.Pad1 = new byte[1];
            }
            else
            {
                smbData.Pad1 = new byte[0];
            }

            // Set Trans2_Data
            TRANS2_QUERY_PATH_INFORMATION_Request_Trans2_Data trans2Data =
                new TRANS2_QUERY_PATH_INFORMATION_Request_Trans2_Data();
            trans2Data.GetExtendedAttributeList.GEAList = extendedAttributeList;
            trans2Data.GetExtendedAttributeList.SizeOfListInBytes =
                (uint)CifsMessageUtils.GetSize<uint>(trans2Data.GetExtendedAttributeList.SizeOfListInBytes);
            trans2Data.GetExtendedAttributeList.SizeOfListInBytes +=
                CifsMessageUtils.GetSmbQueryEAListSize(extendedAttributeList);

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;
            packet.Trans2Parameters = trans2Parameters;
            packet.Trans2Data = trans2Data;
            packet.UpdateCountAndOffset();

            return packet;
        }
コード例 #21
0
        public static NTStatus GetFileInformation(out QueryInformation result, INTFileStore fileStore, object handle, QueryInformationLevel informationLevel)
        {
            result = null;
            FileInformationClass informationClass;

            try
            {
                informationClass = QueryInformationHelper.ToFileInformationClass(informationLevel);
            }
            catch (UnsupportedInformationLevelException)
            {
                return(NTStatus.STATUS_OS2_INVALID_LEVEL);
            }

            FileInformation fileInformation;
            NTStatus        status = fileStore.GetFileInformation(out fileInformation, handle, informationClass);

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

            result = QueryInformationHelper.FromFileInformation(fileInformation);
            return(NTStatus.STATUS_SUCCESS);
        }
 /// <summary>
 /// Constructor: Create a request directly from a buffer.
 /// </summary>
 /// <param name="informationLevel">The response format is controlled by the value of the InformationLevel
 /// field provided in the request.</param>
 public SmbTrans2QueryPathInformationResponsePacket(QueryInformationLevel informationLevel)
     : base(informationLevel)
 {
 }
コード例 #23
0
        /// <summary>
        /// Create Trans2QueryPathInformation request for client to query path information from server. 
        /// </summary>
        /// <param name = "treeId">the valid tree connect id, must be response by server of the tree connect. </param>
        /// <param name = "fileName">The name of path to query information from. </param>
        /// <param name = "transactOptions">
        /// A set of bit flags that alter the behavior of the requested operation. Unused bit fields MUST be set to  
        /// zero by the client sending the request, and MUST be ignored by the server receiving the request. The 
        /// client MAY set either or both of the following bit flags 
        /// </param>
        /// <param name = "informationLevel">
        /// Indicates that client specifies the information it is requesting. Server return different data based on 
        /// the client's request. 
        /// </param>
        /// <param name = "maxDataCount">The max size to query path information. </param>
        /// <param name = "isReparsePath">If true, the path in the request MUST contain an @GMT token. </param>
        /// <returns>a query path information request packet </returns>
        public virtual SmbTrans2QueryPathInformationRequestPacket CreateTrans2QueryPathInformationRequest(
            ushort treeId,
            string fileName,
            Trans2SmbParametersFlags transactOptions,
            QueryInformationLevel informationLevel,
            ushort maxDataCount,
            bool isReparsePath)
        {
            SmbHeader_Flags2_Values flags2 = this.capability.Flags2;
            // update flags2 of header
            if (isReparsePath)
            {
                flags2 |= SmbHeader_Flags2_Values.SMB_FLAGS2_REPARSE_PATH;
            }

            return CreateTrans2QueryPathInformationRequest(this.MessageId,
                this.GetSessionIdByTreeId(treeId), treeId,
                this.capability.Flag, flags2, fileName,
                transactOptions, this.capability.Timeout, this.capability.IsUsePathThrough,
                informationLevel, maxDataCount);
        }
コード例 #24
0
 /// <summary>
 /// Check if the information level matches the information structure.
 /// </summary>
 /// <param name="level">information level</param>
 /// <param name="queryInformationLevel">information level structure</param>
 /// <returns>true if the level matches the structure, false if not.</returns>
 private bool CheckInformationLevel(QueryInformationLevel level, object queryInformationLevel)
 {
     bool ret = false;
     switch (level)
     {
         case QueryInformationLevel.SMB_INFO_STANDARD:
             ret = queryInformationLevel is SMB_INFO_STANDARD_OF_TRANS2_QUERY_PATH_INFORMATION;
             break;
         case QueryInformationLevel.SMB_INFO_QUERY_EA_SIZE:
             ret = queryInformationLevel is SMB_INFO_QUERY_EA_SIZE_OF_TRANS2_QUERY_PATH_INFORMATION;
             break;
         case QueryInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST:
             ret = queryInformationLevel is SMB_INFO_QUERY_EAS_FROM_LIST_OF_TRANS2_QUERY_PATH_INFORMATION;
             break;
         case QueryInformationLevel.SMB_INFO_QUERY_ALL_EAS:
             ret = queryInformationLevel is SMB_INFO_QUERY_ALL_EAS_OF_TRANS2_QUERY_PATH_INFORMATION;
             break;
         case QueryInformationLevel.SMB_INFO_IS_NAME_VALID:
             ret = queryInformationLevel == null;
             break;
         case QueryInformationLevel.SMB_QUERY_FILE_BASIC_INFO:
             ret = queryInformationLevel is SMB_QUERY_FILE_BASIC_INFO_OF_TRANS2_QUERY_PATH_INFORMATION;
             break;
         case QueryInformationLevel.SMB_QUERY_FILE_STANDARD_INFO:
             ret = queryInformationLevel is SMB_QUERY_FILE_STANDARD_INFO_OF_TRANS2_QUERY_PATH_INFORMATION;
             break;
         case QueryInformationLevel.SMB_QUERY_FILE_EA_INFO:
             ret = queryInformationLevel is SMB_QUERY_FILE_EA_INFO_OF_TRANS2_QUERY_PATH_INFORMATION;
             break;
         case QueryInformationLevel.SMB_QUERY_FILE_NAME_INFO:
             ret = queryInformationLevel is SMB_QUERY_FILE_NAME_INFO_OF_TRANS2_QUERY_PATH_INFORMATION;
             break;
         case QueryInformationLevel.SMB_QUERY_FILE_ALL_INFO:
             ret = queryInformationLevel is SMB_QUERY_FILE_ALL_INFO_OF_TRANS2_QUERY_PATH_INFORMATION;
             break;
         case QueryInformationLevel.SMB_QUERY_FILE_ALT_NAME_INFO:
             ret = queryInformationLevel is SMB_QUERY_FILE_ALT_NAME_INFO_OF_TRANS2_QUERY_PATH_INFORMATION;
             break;
         case QueryInformationLevel.SMB_QUERY_FILE_STREAM_INFO:
             ret = queryInformationLevel is SMB_QUERY_FILE_STREAM_INFO_OF_TRANS2_QUERY_PATH_INFORMATION;
             break;
         case QueryInformationLevel.SMB_QUERY_FILE_COMPRESSION_INFO:
             ret = queryInformationLevel is SMB_QUERY_FILE_COMPRESSION_INFO_OF_TRANS2_QUERY_PATH_INFORMATION;
             break;
         default:
             break;
     }
     return ret;
 }
コード例 #25
0
 /// <summary>
 /// to create a Trans2QueryPathInformation request packet.
 /// </summary>
 /// <param name="uid">This field SHOULD identify the authenticated instance of the user.</param>
 /// <param name="treeId">This field identifies the subdirectory (or tree) on the server that the client is
 /// accessing.</param>
 /// <param name="informationLevel">This field contains an information level code, which determines the
 /// information contained in the response.</param>
 /// <param name="name">A buffer containing the name of the file to be opened, created, or truncated. The
 /// string MUST be null terminated</param>
 /// <param name="extendedAttributeList">This field MUST contain an array of extended file attribute name value
 /// pairs. </param>
 /// <returns>a Trans2QueryPathInformation request packet</returns>
 /// <exception cref="System.NullReferenceException">There is no connection in context. </exception>
 public SmbTrans2QueryPathInformationRequestPacket CreateTrans2QueryPathInformationRequest(
     ushort uid,
     ushort treeId,
     QueryInformationLevel informationLevel,
     string name,
     SMB_GEA[] extendedAttributeList)
 {
     return this.CreateTrans2QueryPathInformationRequest(this.Context.GetMessageId(this.connectionId),
         uid, treeId, this.defaultParameters.Flag, this.defaultParameters.Flag2, this.defaultParameters.MaxParameterCount,
         this.defaultParameters.MaxDataCount, this.defaultParameters.MaxSetupCount, this.defaultParameters.Trans2SmbParametersFlags,
         this.defaultParameters.Timeout, informationLevel, name, extendedAttributeList);
 }
コード例 #26
0
        public static NTStatus GetFileInformation(out QueryInformation result, INTFileStore fileStore, string path, QueryInformationLevel informationLevel, SecurityContext securityContext)
        {
            object     handle;
            FileStatus fileStatus;
            NTStatus   openStatus = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)FileAccessMask.FILE_READ_ATTRIBUTES, 0, ShareAccess.Read | ShareAccess.Write, CreateDisposition.FILE_OPEN, 0, securityContext);

            if (openStatus != NTStatus.STATUS_SUCCESS)
            {
                result = null;
                return(openStatus);
            }
            NTStatus returnStatus = GetFileInformation(out result, fileStore, handle, informationLevel);

            fileStore.CloseFile(handle);
            return(returnStatus);
        }
 /// <summary>
 /// Constructor: Create a request directly from a buffer.
 /// </summary>
 public SmbTrans2QueryFileInformationFinalResponsePacket(QueryInformationLevel informationLevel)
 {
     this.InitDefaultValue();
     this.informationLevel = informationLevel;
 }
 /// <summary>
 /// Constructor: Create a request directly from a buffer.
 /// </summary>
 /// <param name="informationLevel">The response format is controlled by the value of the InformationLevel
 /// field provided in the request.</param>
 public SmbTrans2QueryPathInformationResponsePacket(QueryInformationLevel informationLevel)
     : base(informationLevel)
 {
 }
コード例 #29
0
        public static NTStatus GetFileInformation(out QueryInformation result, INTFileStore fileStore, object handle, QueryInformationLevel informationLevel)
        {
            result = null;
            FileInformation fileInfo;

            switch (informationLevel)
            {
            case QueryInformationLevel.SMB_INFO_QUERY_ALL_EAS:
            {
                result = null;
                return(NTStatus.STATUS_NOT_IMPLEMENTED);
            }

            case QueryInformationLevel.SMB_INFO_IS_NAME_VALID:
            {
                result = null;
                return(NTStatus.STATUS_NOT_IMPLEMENTED);
            }

            case QueryInformationLevel.SMB_QUERY_FILE_BASIC_INFO:
            {
                NTStatus status = fileStore.GetFileInformation(out fileInfo, handle, FileInformationClass.FileBasicInformation);
                if (status != NTStatus.STATUS_SUCCESS)
                {
                    return(status);
                }

                FileBasicInformation fileBasicInfo = (FileBasicInformation)fileInfo;

                QueryFileBasicInfo information = new QueryFileBasicInfo();
                information.CreationTime      = fileBasicInfo.CreationTime;
                information.LastAccessTime    = fileBasicInfo.LastAccessTime;
                information.LastWriteTime     = fileBasicInfo.LastWriteTime;
                information.LastChangeTime    = fileBasicInfo.LastWriteTime;
                information.ExtFileAttributes = (ExtendedFileAttributes)fileBasicInfo.FileAttributes;
                result = information;
                return(NTStatus.STATUS_SUCCESS);
            }

            case QueryInformationLevel.SMB_QUERY_FILE_STANDARD_INFO:
            {
                NTStatus status = fileStore.GetFileInformation(out fileInfo, handle, FileInformationClass.FileStandardInformation);
                if (status != NTStatus.STATUS_SUCCESS)
                {
                    return(status);
                }

                FileStandardInformation fileStandardInfo = (FileStandardInformation)fileInfo;

                QueryFileStandardInfo information = new QueryFileStandardInfo();
                information.AllocationSize = fileStandardInfo.AllocationSize;
                information.EndOfFile      = fileStandardInfo.EndOfFile;
                information.DeletePending  = fileStandardInfo.DeletePending;
                information.Directory      = fileStandardInfo.Directory;
                result = information;
                return(NTStatus.STATUS_SUCCESS);
            }

            case QueryInformationLevel.SMB_QUERY_FILE_EA_INFO:
            {
                NTStatus status = fileStore.GetFileInformation(out fileInfo, handle, FileInformationClass.FileEaInformation);
                if (status != NTStatus.STATUS_SUCCESS)
                {
                    return(status);
                }

                FileEaInformation fileEAInfo = (FileEaInformation)fileInfo;

                QueryFileExtendedAttributeInfo information = new QueryFileExtendedAttributeInfo();
                information.EASize = fileEAInfo.EaSize;
                result             = information;
                return(NTStatus.STATUS_SUCCESS);
            }

            case QueryInformationLevel.SMB_QUERY_FILE_NAME_INFO:
            {
                NTStatus status = fileStore.GetFileInformation(out fileInfo, handle, FileInformationClass.FileNameInformation);
                if (status != NTStatus.STATUS_SUCCESS)
                {
                    return(status);
                }

                FileNameInformation fileNameInfo = (FileNameInformation)fileInfo;

                QueryFileNameInfo information = new QueryFileNameInfo();
                information.FileName = fileNameInfo.FileName;
                result = information;
                return(NTStatus.STATUS_SUCCESS);
            }

            case QueryInformationLevel.SMB_QUERY_FILE_ALL_INFO:
            {
                NTStatus status = fileStore.GetFileInformation(out fileInfo, handle, FileInformationClass.FileAllInformation);
                if (status != NTStatus.STATUS_SUCCESS)
                {
                    return(status);
                }

                FileAllInformation fileAllInfo = (FileAllInformation)fileInfo;

                QueryFileAllInfo information = new QueryFileAllInfo();
                information.CreationDateTime   = fileAllInfo.BasicInformation.CreationTime;
                information.LastAccessDateTime = fileAllInfo.BasicInformation.LastAccessTime;
                information.LastWriteDateTime  = fileAllInfo.BasicInformation.LastWriteTime;
                information.LastChangeTime     = fileAllInfo.BasicInformation.LastWriteTime;
                information.ExtFileAttributes  = (ExtendedFileAttributes)fileAllInfo.BasicInformation.FileAttributes;
                information.AllocationSize     = fileAllInfo.StandardInformation.AllocationSize;
                information.EndOfFile          = fileAllInfo.StandardInformation.EndOfFile;
                information.DeletePending      = fileAllInfo.StandardInformation.DeletePending;
                information.Directory          = fileAllInfo.StandardInformation.Directory;
                information.EASize             = fileAllInfo.EaInformation.EaSize;
                information.FileName           = fileAllInfo.NameInformation.FileName;
                result = information;
                return(NTStatus.STATUS_SUCCESS);
            }

            case QueryInformationLevel.SMB_QUERY_FILE_ALT_NAME_INFO:
            {
                NTStatus status = fileStore.GetFileInformation(out fileInfo, handle, FileInformationClass.FileAlternateNameInformation);
                if (status != NTStatus.STATUS_SUCCESS)
                {
                    return(status);
                }

                FileAlternateNameInformation fileAltNameInfo = (FileAlternateNameInformation)fileInfo;

                QueryFileAltNameInfo information = new QueryFileAltNameInfo();
                information.FileName = fileAltNameInfo.FileName;
                result = information;
                return(NTStatus.STATUS_SUCCESS);
            }

            case QueryInformationLevel.SMB_QUERY_FILE_STREAM_INFO:
            {
                NTStatus status = fileStore.GetFileInformation(out fileInfo, handle, FileInformationClass.FileStreamInformation);
                if (status != NTStatus.STATUS_SUCCESS)
                {
                    return(status);
                }

                FileStreamInformation fileStreamInfo = (FileStreamInformation)fileInfo;

                QueryFileStreamInfo information = new QueryFileStreamInfo();
                information.StreamSize           = fileStreamInfo.StreamSize;
                information.StreamAllocationSize = fileStreamInfo.StreamAllocationSize;
                information.StreamName           = fileStreamInfo.StreamName;
                result = information;
                return(NTStatus.STATUS_SUCCESS);
            }

            case QueryInformationLevel.SMB_QUERY_FILE_COMPRESSION_INFO:
            {
                NTStatus status = fileStore.GetFileInformation(out fileInfo, handle, FileInformationClass.FileCompressionInformation);
                if (status != NTStatus.STATUS_SUCCESS)
                {
                    return(status);
                }

                FileCompressionInformation fileCompressionInfo = (FileCompressionInformation)fileInfo;

                QueryFileCompressionInfo information = new QueryFileCompressionInfo();
                information.CompressedFileSize   = fileCompressionInfo.CompressedFileSize;
                information.CompressionFormat    = fileCompressionInfo.CompressionFormat;
                information.CompressionUnitShift = fileCompressionInfo.CompressionUnitShift;
                information.ChunkShift           = fileCompressionInfo.ChunkShift;
                information.ClusterShift         = fileCompressionInfo.ClusterShift;
                information.Reserved             = fileCompressionInfo.Reserved;
                result = information;
                return(NTStatus.STATUS_SUCCESS);
            }

            default:
            {
                result = null;
                return(NTStatus.STATUS_OS2_INVALID_LEVEL);
            }
            }
        }
コード例 #30
0
 /// <summary>
 /// Create Trans2QueryFileInformation request for client to query information of file on server. 
 /// </summary>
 /// <param name = "fileId">the valid file id to operation on, response by server. </param>
 /// <param name = "transactOptions">
 /// A set of bit flags that alter the behavior of the requested operation. Unused bit fields MUST be set to  
 /// zero by the client sending the request, and MUST be ignored by the server receiving the request. The 
 /// client MAY set either or both of the following bit flags 
 /// </param>
 /// <param name = "maxDataCount">
 /// This value MUST be the number of bytes that the client requests  to read from the file on server. 
 /// </param>
 /// <param name = "informationLevel">
 /// Indicates that client specifies the information it is requesting. Server return different data based on 
 /// the client's request. 
 /// </param>
 /// <param name = "extendedAttributeList">
 /// This field MUST contain an array of extended file attribute name value pairs. 
 /// </param>
 /// <returns>a query file information request packet </returns>
 public virtual SmbTrans2QueryFileInformationRequestPacket CreateTrans2QueryFileInformationRequest(
     ushort fileId,
     Trans2SmbParametersFlags transactOptions,
     ushort maxDataCount,
     QueryInformationLevel informationLevel,
     params SMB_GEA[] extendedAttributeList)
 {
     return CreateTrans2QueryFileInformationRequest(
         this.MessageId,
         this.GetSessionIdByFileId(fileId), this.GetTreeIdByFileId(fileId),
         this.capability.Flag, this.capability.Flags2,
         fileId, transactOptions, this.capability.Timeout, this.capability.IsUsePathThrough,
         maxDataCount, informationLevel, extendedAttributeList);
 }
 /// <summary>
 /// Constructor: Create a request directly from a buffer.
 /// </summary>
 public SmbTrans2QueryFileInformationFinalResponsePacket(QueryInformationLevel informationLevel)
 {
     this.InitDefaultValue();
     this.informationLevel = informationLevel;
 }
コード例 #32
0
        /// <summary>
        /// Create Trans2QueryPathInformation request for client to query path information from server. 
        /// </summary>
        /// <param name = "messageId">the id of message, used to identity the request and the server response. </param>
        /// <param name = "sessionUid">the valid session id, must be response by server of the session setup request. </param>
        /// <param name = "treeId">the valid tree connect id, must be response by server of the tree connect. </param>
        /// <param name = "flags">
        /// The Flags field contains individual flags, as specified in [CIFS] sections 2.4.2 and 3.1.1. 
        /// </param>
        /// <param name = "flags2">
        /// The Flags2 field contains individual bit flags that, depending on the negotiated SMB dialect, indicate   
        /// various client and server capabilities. 
        /// </param>
        /// <param name = "fileName">The name of path to query information from. </param>
        /// <param name = "transactOptions">
        /// A set of bit flags that alter the behavior of the requested operation. Unused bit fields MUST be set to  
        /// zero by the client sending the request, and MUST be ignored by the server receiving the request. The 
        /// client MAY set either or both of the following bit flags 
        /// </param>
        /// <param name = "timeOut">
        /// The maximum amount of time in milliseconds to wait for the operation to complete. The client SHOULD set  
        /// this to 0 to indicate that no time-out is given. If the operation does not complete within the specified  
        /// time, the server MAY abort the request and send a failure response. 
        /// </param>
        /// <param name="isUsePathThrough">
        /// Indicates that the client is requesting a native Microsoft Windows庐 NT operating system information level, 
        /// as specified in section 3.2.4.7 and in [MS-FSCC] section 2.4. 
        /// </param>
        /// <param name = "informationLevel">
        /// Indicates that client specifies the information it is requesting. Server return different data based on 
        /// the client's request. 
        /// </param>
        /// <param name = "maxDataCount">The max size to query path information. </param>
        /// <returns>a query path information request packet </returns>
        private SmbTrans2QueryPathInformationRequestPacket CreateTrans2QueryPathInformationRequest(
            ushort messageId,
            ushort sessionUid,
            ushort treeId,
            SmbHeader_Flags_Values flags,
            SmbHeader_Flags2_Values flags2,
            string fileName,
            Trans2SmbParametersFlags transactOptions,
            uint timeOut,
            bool isUsePathThrough,
            QueryInformationLevel informationLevel,
            ushort maxDataCount)
        {
            // update information level
            if (isUsePathThrough)
            {
                informationLevel = (QueryInformationLevel)
                    (informationLevel + SmbCapability.CONST_SMB_INFO_PASSTHROUGH);
            }

            return new SmbTrans2QueryPathInformationRequestPacket(
                this.cifsClient.CreateTrans2QueryPathInformationRequest(
                messageId, sessionUid, treeId, (SmbFlags)flags, (SmbFlags2)flags2,
                this.capability.MaxParameterCount, maxDataCount, this.capability.MaxSetupCount,
                transactOptions, timeOut, informationLevel, fileName, null));
        }
コード例 #33
0
 public Transaction2SetFileInformationResponse(byte[] parameters, byte[] data, QueryInformationLevel informationLevel, bool isUnicode) : base()
 {
     EaErrorOffset = LittleEndianConverter.ToUInt16(parameters, 0);
 }