• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SmbFlags类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SmbFlags的典型用法代码示例。如果您正苦于以下问题:C# SmbFlags类的具体用法?C# SmbFlags怎么用?C# SmbFlags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SmbFlags类属于命名空间,在下文中一共展示了SmbFlags类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateReadRawRequest

        /// <summary>
        /// to create a ReadRaw 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="fid">This field MUST be a valid 16-bit signed integer indicating the file from which the data
        /// MUST be read.</param>
        /// <param name="offset">The offset in bytes from the start of the file at which the read MUST begin. This is
        /// the lower 32 bits of a 64 bit value if the WordCount is 10</param>
        /// <param name="maxCountOfBytesToReturn">The requested maximum number of bytes to read from the file and
        /// return to the client. The value MAY exceed the negotiated buffer size</param>
        /// <param name="minCountOfBytesToReturn">The requested minimum number of bytes to read from the file and
        /// return to the client. This field is used only when reading from a named pipe or a device. It is ignored
        /// when reading from a standard file</param>
        /// <param name="timeout">Support for this field is optional and this field is used only when reading from a
        /// named pipe or i/o device.</param>
        /// <param name="offsetHigh">the upper 32 bits of the offset in bytes from the start of the file at which
        /// the read MUST start.</param>
        /// <returns>a ReadRaw request packet</returns>
        public SmbReadRawRequestPacket CreateReadRawRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            ushort fid,
            uint offset,
            ushort maxCountOfBytesToReturn,
            ushort minCountOfBytesToReturn,
            uint timeout,
            uint offsetHigh)
        {
            SmbReadRawRequestPacket packet = new SmbReadRawRequestPacket();

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

            SMB_COM_READ_RAW_Request_SMB_Parameters smbParameters = new SMB_COM_READ_RAW_Request_SMB_Parameters();
            smbParameters.FID = fid;
            smbParameters.Offset = offset;
            smbParameters.MaxCountOfBytesToReturn = maxCountOfBytesToReturn;
            smbParameters.MinCountOfBytesToReturn = minCountOfBytesToReturn;
            smbParameters.Timeout = timeout;
            smbParameters.Reserved = 0;
            smbParameters.OffsetHigh = offsetHigh;
            smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord);

            SMB_COM_READ_RAW_Request_SMB_Data smbData = new SMB_COM_READ_RAW_Request_SMB_Data();
            smbData.ByteCount = 0;

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;

            return packet;
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:62,代码来源:CifsClient.cs


示例2: CreateWriteAndCloseRequest

        /// <summary>
        /// to create a WriteAndClose 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="fid">This field MUST be a valid 16-bit signed integer indicating the file to which the data
        /// SHOULD be written.</param>
        /// <param name="writeOffsetInBytes">This field is a 16-bit unsigned integer indicating the number of bytes to
        /// be written to the file</param>
        /// <param name="lastWriteTime">This field is a 32-bit unsigned integer indicating  the number of seconds since
        /// Jan 1, 1970, 00:00:00.0. The server SHOULD set the last write time of the file represented by the FID to
        /// this value. If the value is zero (0), the server SHOULD use the current local time of the server to set the
        /// value. Failure to set the time MUST not result in an error response from the server.</param>
        /// <param name="data">The raw bytes to be written to the file</param>
        /// <returns>a WriteAndClose request packet</returns>
        public SmbWriteAndCloseRequestPacket CreateWriteAndCloseRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            ushort fid,
            uint writeOffsetInBytes,
            UTime lastWriteTime,
            byte[] data)
        {
            if (data == null)
            {
                data = new byte[0];
            }

            SmbWriteAndCloseRequestPacket packet = new SmbWriteAndCloseRequestPacket();

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

            SMB_COM_WRITE_AND_CLOSE_Request_SMB_Parameters smbParameters =
                new SMB_COM_WRITE_AND_CLOSE_Request_SMB_Parameters();
            smbParameters.FID = fid;
            smbParameters.CountOfBytesToWrite = (ushort)data.Length;
            smbParameters.WriteOffsetInBytes = writeOffsetInBytes;
            smbParameters.LastWriteTime = lastWriteTime;
            smbParameters.Reserved = new uint[3]; // the correct length of Reserved word is always 3.
            smbParameters.WordCount = (byte)(CifsMessageUtils.GetSize<SMB_COM_WRITE_AND_CLOSE_Request_SMB_Parameters>(
                smbParameters) / NumBytesOfWord);

            SMB_COM_WRITE_AND_CLOSE_Request_SMB_Data smbData = new SMB_COM_WRITE_AND_CLOSE_Request_SMB_Data();
            smbData.Pad = 0;
            smbData.Data = data;
            smbData.ByteCount = (ushort)(Marshal.SizeOf(smbData.Pad) + smbData.Data.Length);

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;

            return packet;
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:63,代码来源:CifsClient.cs


示例3: CreateWriteAndxRequest

        /// <summary>
        /// to create a WriteAndx 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="fid">This field MUST be a valid FID indicating the file from which the data MUST be
        /// read.</param>
        /// <param name="offset">If WordCount is 10 this field represents a 32-bit offset, measured in bytes, of where
        /// the read MUST start relative to the beginning of the file. If WordCount is 12 this field represents the
        /// lower 32 bits of a 64-bit offset</param>
        /// <param name="timeout">This field represents the amount of time, in milliseconds, that a server MUST wait
        /// before sending a response</param>
        /// <param name="writeMode">A 16-bit field containing flags </param>
        /// <param name="offsetHigh">This field is optional. If WordCount is 12 this field is not included in the
        /// request. If WordCount is 14 this field represents the upper 32 bits of a 64-bit offset, measured in bytes,
        /// of where the write SHOULD start relative to the beginning of the file</param>
        /// <param name="data">The bytes to be written to the file</param>
        /// <param name="andxPacket">the andx packet.</param>
        /// <returns>a WriteAndx request packet</returns>
        public SmbWriteAndxRequestPacket CreateWriteAndxRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            ushort fid,
            uint offset,
            uint timeout,
            WriteAndxWriteMode writeMode,
            uint offsetHigh,
            byte[] data,
            SmbPacket andxPacket)
        {
            if (data == null)
            {
                data = new byte[0];
            }

            SmbWriteAndxRequestPacket packet = new SmbWriteAndxRequestPacket();

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

            SMB_COM_WRITE_ANDX_Request_SMB_Parameters smbParameters = new SMB_COM_WRITE_ANDX_Request_SMB_Parameters();
            smbParameters.AndXReserved = 0;
            smbParameters.Remaining = 0;
            smbParameters.Reserved = 0;

            if (andxPacket == null)
            {
                smbParameters.AndXCommand = SmbCommand.SMB_COM_NO_ANDX_COMMAND;
            }
            else
            {
                smbParameters.AndXCommand = andxPacket.SmbHeader.Command;
            }
            smbParameters.FID = fid;
            smbParameters.Offset = offset;
            smbParameters.WriteMode = writeMode;
            smbParameters.Timeout = timeout;
            smbParameters.OffsetHigh = offsetHigh;
            smbParameters.Remaining = (ushort)data.Length;
            smbParameters.DataLength = (ushort)data.Length;
            smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord);

            SMB_COM_WRITE_ANDX_Request_SMB_Data smbData = new SMB_COM_WRITE_ANDX_Request_SMB_Data();
            smbData.Pad = 0;
            smbData.Data = data;
            smbData.ByteCount = (ushort)(Marshal.SizeOf(smbData.Pad) + smbData.Data.Length);

            smbParameters.DataOffset = (ushort)(Marshal.SizeOf(packet.SmbHeader) + Marshal.SizeOf(smbParameters)
                + Marshal.SizeOf(smbData.ByteCount) + Marshal.SizeOf(smbData.Pad));

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;
            packet.AndxPacket = andxPacket;

            return packet;
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:86,代码来源:CifsClient.cs


示例4: CreateTreeConnectRequest

        /// <summary>
        /// to create a TreeConnect 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="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="path">A null-terminated string that represents the server and share name of the resource to
        /// which the client is attempting to connect</param>
        /// <param name="password">A null-terminated string that represents a share password in plaintext form</param>
        /// <param name="service">A null-terminated string representing the type of resource the client intends to
        /// access</param>
        /// <returns>a TreeConnect request packet</returns>
        public SmbTreeConnectRequestPacket CreateTreeConnectRequest(
            ushort messageId,
            ushort uid,
            SmbFlags flags,
            SmbFlags2 flags2,
            string path,
            string password,
            string service)
        {
            if (path == null)
            {
                path = string.Empty;
            }
            if (password == null)
            {
                password = string.Empty;
            }
            if (service == null)
            {
                service = string.Empty;
            }

            SmbTreeConnectRequestPacket packet = new SmbTreeConnectRequestPacket();

            packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_TREE_CONNECT,
                messageId, uid, 0, flags, flags2);

            SMB_COM_TREE_CONNECT_Request_SMB_Parameters smbParameters =
                new SMB_COM_TREE_CONNECT_Request_SMB_Parameters();
            smbParameters.WordCount = 0;

            SMB_COM_TREE_CONNECT_Request_SMB_Data smbData = new SMB_COM_TREE_CONNECT_Request_SMB_Data();
            smbData.BufferFormat1 = (byte)DataBufferFormat.SmbString;
            smbData.BufferFormat2 = (byte)DataBufferFormat.SmbString;
            smbData.BufferFormat3 = (byte)DataBufferFormat.SmbString;
            smbData.Path = CifsMessageUtils.ToSmbStringBytes(path, false);
            smbData.Password = CifsMessageUtils.ToSmbStringBytes(password, false);
            smbData.Service = CifsMessageUtils.ToSmbStringBytes(service, false);

            smbData.ByteCount = (ushort)(Marshal.SizeOf(smbData.BufferFormat1) + smbData.Path.Length
                + Marshal.SizeOf(smbData.BufferFormat2) + smbData.Password.Length
                + Marshal.SizeOf(smbData.BufferFormat3) + smbData.Service.Length);

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;

            return packet;
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:64,代码来源:CifsClient.cs


示例5: CreateUnlockByteRangeRequest

        /// <summary>
        /// to create a UnlockByteRange 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="fid">This field MUST be a valid 16-bit signed integer indicating the file from which the data
        /// MUST be read</param>
        /// <param name="countOfBytesToUnlock">This field is a 32-bit unsigned integer indicating the number of
        /// contiguous bytes to be unlocked</param>
        /// <param name="unlockOffsetInBytes">ULONG This field is a 32-bit unsigned integer indicating the offset in
        /// number of bytes from which to begin the unlock. Because this field is limited to 32-bits this command is
        /// inappropriate for files having 64-bit offsets</param>
        /// <returns>a UnlockByteRange request packet</returns>
        public SmbUnlockByteRangeRequestPacket CreateUnlockByteRangeRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            ushort fid,
            uint countOfBytesToUnlock,
            uint unlockOffsetInBytes)
        {
            SmbUnlockByteRangeRequestPacket packet = new SmbUnlockByteRangeRequestPacket();

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

            SMB_COM_UNLOCK_BYTE_RANGE_Request_SMB_Parameters smbParameters =
                new SMB_COM_UNLOCK_BYTE_RANGE_Request_SMB_Parameters();
            smbParameters.FID = fid;
            smbParameters.CountOfBytesToUnlock = countOfBytesToUnlock;
            smbParameters.UnlockOffsetInBytes = unlockOffsetInBytes;
            smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord);

            SMB_COM_UNLOCK_BYTE_RANGE_Request_SMB_Data smbData = new SMB_COM_UNLOCK_BYTE_RANGE_Request_SMB_Data();
            smbData.ByteCount = 0;

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;

            return packet;
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:50,代码来源:CifsClient.cs


示例6: CreateCreateTemporaryRequest

        /// <summary>
        /// to create a CreateTemporary 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="creationTime">The time the file was created on the client represented as the number of seconds
        /// since Jan 1, 1970, 00:00:00.0. Server support of this field is OPTIONAL</param>
        /// <param name="directoryName">A null-terminated string that represents the fully qualified name of the
        /// directory relative to the supplied TID in which to create the temporary file.</param>
        /// <returns>a CreateTemporary request packet</returns>
        public SmbCreateTemporaryRequestPacket CreateCreateTemporaryRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            UTime creationTime,
            string directoryName)
        {
            if (directoryName == null)
            {
                directoryName = string.Empty;
            }

            SmbCreateTemporaryRequestPacket packet = new SmbCreateTemporaryRequestPacket();

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

            SMB_COM_CREATE_TEMPORARY_Request_SMB_Parameters smbParameters =
                new SMB_COM_CREATE_TEMPORARY_Request_SMB_Parameters();
            smbParameters.FileAttributes = SmbFileAttributes.SMB_FILE_ATTRIBUTE_NORMAL;
            smbParameters.CreationTime = creationTime;
            smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord);

            SMB_COM_CREATE_TEMPORARY_Request_SMB_Data smbData = new SMB_COM_CREATE_TEMPORARY_Request_SMB_Data();
            smbData.BufferFormat = (byte)DataBufferFormat.SmbString;
            smbData.DirectoryName = CifsMessageUtils.ToSmbStringBytes(directoryName,
                (flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE);
            smbData.ByteCount = (ushort)(Marshal.SizeOf(smbData.BufferFormat) + smbData.DirectoryName.Length);

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;

            return packet;
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:53,代码来源:CifsClient.cs


示例7: CreateTransWriteNmpipeRequest

        /// <summary>
        /// to create a TransWriteNmpipe 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</param>
        /// <param name="timeout">The value of this field MUST be the maximum number of milliseconds the server SHOULD
        /// wait for completion of the transaction before generating a timeout and returning a response to the
        /// client. </param>
        /// <param name="fid">MUST contain a valid FID obtained from a previously successful SMB open command.</param>
        /// <param name="writeData">This field MUST contain the bytes to be written to the named pipe as part of the
        /// transacted operation.</param>
        /// <param name="name">The pathname of the mailslot or named pipe to which the transaction subcommand applies
        /// or a client supplied identifier that provides a name for the transaction.</param>
        /// <returns>a TransWriteNmpipe request packet</returns>
        public SmbTransWriteNmpipeRequestPacket CreateTransWriteNmpipeRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            ushort maxParameterCount,
            ushort maxDataCount,
            byte maxSetupCount,
            TransSmbParametersFlags smbParametersflags,
            uint timeout,
            ushort fid,
            byte[] writeData,
            string name)
        {
            if (writeData == null)
            {
                writeData = new byte[0];
            }
            if (name == null)
            {
                name = string.Empty;
            }

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

            // Set Smb Parameters
            SMB_COM_TRANSACTION_Request_SMB_Parameters smbParameters =
                new SMB_COM_TRANSACTION_Request_SMB_Parameters();
            smbParameters.MaxParameterCount = maxParameterCount;
            smbParameters.MaxDataCount = maxDataCount;
            smbParameters.MaxSetupCount = maxSetupCount;
            smbParameters.Flags = smbParametersflags;
            smbParameters.Timeout = timeout;
            smbParameters.SetupCount = 2; // the correct count in word of the Setup is always 2.
            smbParameters.Setup = new ushort[2];
            smbParameters.Setup[0] = (ushort)TransSubCommand.TRANS_WRITE_NMPIPE;
            smbParameters.Setup[1] = fid;
            smbParameters.WordCount = (byte)(CifsMessageUtils.GetSize<SMB_COM_TRANSACTION_Request_SMB_Parameters>(
                smbParameters) / NumBytesOfWord);

            // Set Smb Data
            SMB_COM_TRANSACTION_Request_SMB_Data smbData = new SMB_COM_TRANSACTION_Request_SMB_Data();
            smbData.Name = CifsMessageUtils.ToSmbStringBytes(name,
                (flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE);

            // Set Trans_Data
            TRANS_WRITE_NMPIPE_Request_Trans_Data transData = new TRANS_WRITE_NMPIPE_Request_Trans_Data();
            transData.WriteData = writeData;

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;
            packet.TransData = transData;
            packet.UpdateCountAndOffset();

            return packet;
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:88,代码来源:CifsClient.cs


示例8: CreateSeekRequest

        /// <summary>
        /// to create a Seek 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="fid">The File ID of the open file within which to seek</param>
        /// <param name="mode">The seek mode. Possible values are 0,1,2</param>
        /// <param name="offset">A 32-bit signed long value indicating the file position, relative to the position
        /// indicated in Mode, to which to set the updated file pointer.</param>
        /// <returns>a Seek request packet</returns>
        public SmbSeekRequestPacket CreateSeekRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            ushort fid,
            SeekModeValues mode,
            int offset)
        {
            SmbSeekRequestPacket packet = new SmbSeekRequestPacket();

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

            SMB_COM_SEEK_Request_SMB_Parameters smbParameters = new SMB_COM_SEEK_Request_SMB_Parameters();
            smbParameters.FID = fid;
            smbParameters.Mode = (ushort)mode;
            smbParameters.Offset = offset;
            smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord);

            SMB_COM_SEEK_Request_SMB_Data smbData = new SMB_COM_SEEK_Request_SMB_Data();
            smbData.ByteCount = 0;

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;

            return packet;
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:46,代码来源:CifsClient.cs


示例9: CreateSessionSetupAndxRequest

        /// <summary>
        /// to create a SessionSetupAndx 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="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="maxBufferSize">The maximum size, in bytes, of the largest SMB message that the client can
        /// receive. This is the size of the largest SMB message that the server MAY send to the client. SMB message
        /// size includes the size of the SMB header, parameter, and data blocks. This size MUST not include any
        /// transport-layer framing or other transport-layer data</param>
        /// <param name="maxMpxCount">The maximum number of pending multiplexed requests supported by the client. This
        /// value MUST be less than or equal to the MaxMpxCount value provided by the server in the SMB_COM_NEGOTIATE
        /// response</param>
        /// <param name="vcNumber">The number of this VC (virtual circuit) between the client and the server. This
        /// field SHOULD be set to a value of 0 for the first virtual circuit between the client and the server and it
        /// SHOULD be set to a unique nonzero value for additional virtual circuit.</param>
        /// <param name="sessionKey">The client MUST set this to be equal to the SessionKey field in the
        /// SMB_COM_NEGOTIATE response for this SMB connection</param>
        /// <param name="capabilities">A 32-bit field providing a set of client capability indicators. The client uses
        /// this field to report its own set of capabilities to the server. The client capabilities are a subset of the
        /// server capabilities, specified in section </param>
        /// <param name="userInfo">the user account information with which the user authenticates.</param>     
        /// <param name="nativeOs">A string representing the native operating system of the CIFS client. </param>     
        /// <param name="nativeLanMan">A string that represents the native LAN manager type of the client.</param>     
        /// <param name="andxPacket">the andx packet.</param>
        /// <param name="ntlmAuthenticationPolicy">the NT LAN Manager challenge/response authentication mechanism
        /// to be used.</param>     
        /// <param name="lmAuthenticationPolicy">the LAN Manager challenge/response authentication mechanism
        /// to be used. </param>     
        /// <returns>a SessionSetupAndx request packet</returns>
        /// <exception cref="System.ArgumentNullException">the userInfo must not be null.</exception>
        public SmbSessionSetupAndxRequestPacket CreateSessionSetupAndxRequest(
            ushort messageId,
            SmbFlags flags,
            SmbFlags2 flags2,
            ushort maxBufferSize,
            ushort maxMpxCount,
            ushort vcNumber,
            uint sessionKey,
            Capabilities capabilities,
            CifsUserAccount userInfo,
            string nativeOs,
            string nativeLanMan,
            SmbPacket andxPacket,
            NTLMAuthenticationPolicyValues ntlmAuthenticationPolicy,
            LMAuthenticationPolicyValues lmAuthenticationPolicy)
        {
            #region Check parameters

            if (userInfo == null)
            {
                throw new ArgumentNullException("userInfo");
            }
            if (nativeOs == null)
            {
                nativeOs = string.Empty;
            }
            if (nativeLanMan == null)
            {
                nativeLanMan = string.Empty;
            }

            #endregion

            #region GetConnection and create SmbSessionSetupAndxRequestPacket

            CifsClientPerConnection connection = this.Context.GetConnection(this.connectionId);
            if (connection == null)
            {
                throw new InvalidOperationException("No connection set up."
                    + " Please call this method after receiving successful Negotiate response.");
            }

            this.context.NtlmAuthenticationPolicy = ntlmAuthenticationPolicy;
            this.context.LmAuthenticationPolicy = lmAuthenticationPolicy;
            this.context.PlaintextAuthenticationPolicy = PlaintextAuthenticationPolicyValues.Disabled;

            bool isUnicode = (flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE;

            SmbSessionSetupAndxRequestPacket packet = new SmbSessionSetupAndxRequestPacket();

            packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_SESSION_SETUP_ANDX,
                messageId, 0, 0, flags, flags2);

            SMB_COM_SESSION_SETUP_ANDX_Request_SMB_Parameters smbParameters =
                new SMB_COM_SESSION_SETUP_ANDX_Request_SMB_Parameters();
            smbParameters.AndXReserved = 0;
            smbParameters.MaxBufferSize = maxBufferSize;
            smbParameters.MaxMpxCount = maxMpxCount;
            smbParameters.VcNumber = vcNumber;
            smbParameters.SessionKey = sessionKey;
            smbParameters.OEMPasswordLen = 0;
            smbParameters.UnicodePasswordLen = 0;
            smbParameters.Capabilities = capabilities;
            smbParameters.Reserved = 0;
            smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord);
            if (andxPacket == null)
//.........这里部分代码省略.........
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:101,代码来源:CifsClient.cs


示例10: CreateSearchRequest

        /// <summary>
        /// to create a Search 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="maxCount">The maximum number of directory entries to return</param>
        /// <param name="searchAttributes">ATTRIBUTES  An attribute mask used to specify the standard attributes a file
        /// MUST have in order to match the search</param>
        /// <param name="fileName">null-terminated SMB_STRING. This is the full directory path (relative to the TID) of
        /// the file(s) being sought</param>
        /// <param name="resumeKey">The ResumeKey contains data used by both the client and the server to maintain the
        /// state of the search</param>
        /// <returns>a Search request packet</returns>
        public SmbSearchRequestPacket CreateSearchRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            ushort maxCount,
            SmbFileAttributes searchAttributes,
            string fileName,
            SMB_Resume_Key[] resumeKey)
        {
            if (fileName == null)
            {
                fileName = string.Empty;
            }
            if (resumeKey == null)
            {
                resumeKey = new SMB_Resume_Key[0];
            }

            SmbSearchRequestPacket packet = new SmbSearchRequestPacket();

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

            SMB_COM_SEARCH_Request_SMB_Parameters smbParameters = new SMB_COM_SEARCH_Request_SMB_Parameters();
            smbParameters.MaxCount = maxCount;
            smbParameters.SearchAttributes = searchAttributes;
            smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord);

            SMB_COM_SEARCH_Request_SMB_Data smbData = new SMB_COM_SEARCH_Request_SMB_Data();
            int resumeKeySize = 0;
            if (resumeKey.Length > 0)
            {
                resumeKeySize = CifsMessageUtils.GetSize<SMB_Resume_Key>(resumeKey[0]);
            }
            smbData.BufferFormat1 = (byte)DataBufferFormat.SmbString;
            smbData.BufferFormat2 = (byte)DataBufferFormat.VariableBlock;
            smbData.ResumeKey = resumeKey;
            smbData.ResumeKeyLength = (ushort)resumeKeySize;
            smbData.FileName = CifsMessageUtils.ToSmbStringBytes(fileName,
                (flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE);
            smbData.ByteCount = (ushort)(Marshal.SizeOf(smbData.BufferFormat1) + smbData.FileName.Length
                + Marshal.SizeOf(smbData.BufferFormat2) + Marshal.SizeOf(smbData.ResumeKeyLength)
                + smbData.ResumeKeyLength);

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;

            return packet;
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:71,代码来源:CifsClient.cs


示例11: CreateSecurityPackageAndxRequest

        /// <summary>
        /// to create a SecurityPackageAndx 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>
        /// <returns>a SecurityPackageAndx request packet</returns>
        public SmbSecurityPackageAndxRequestPacket CreateSecurityPackageAndxRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2)
        {
            SmbSecurityPackageAndxRequestPacket packet = new SmbSecurityPackageAndxRequestPacket();

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

            return packet;
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:27,代码来源:CifsClient.cs


示例12: CreateCloseRequest

        /// <summary>
        /// to create a Close 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="fid">The FID of the object to be closed</param>
        /// <param name="lastTimeModified">A time value encoded as the number of seconds since January 1, 
        /// 1970 00:00:00.0. The client MAY request that the last modification time for the file be updated to this
        /// time value. A value of 0 or 0xFFFFFF results in the server using the default value. The server is NOT 
        /// REQUIRED to support this request</param>
        /// <returns>a Close request packet</returns>
        public SmbCloseRequestPacket CreateCloseRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            ushort fid,
            UTime lastTimeModified)
        {
            SmbCloseRequestPacket packet = new SmbCloseRequestPacket();

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

            SMB_COM_CLOSE_Request_SMB_Parameters smbParameters = new SMB_COM_CLOSE_Request_SMB_Parameters();
            smbParameters.FID = fid;
            smbParameters.LastTimeModified = lastTimeModified;
            smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord);

            SMB_COM_CLOSE_Request_SMB_Data smbData = new SMB_COM_CLOSE_Request_SMB_Data();
            smbData.ByteCount = 0;

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;

            return packet;
        }
开发者ID:pyq881120,项目名称:WindowsProtocolTestSuites,代码行数:45,代码来源:CifsClient.cs


示例13: CreateRenameRequest

        /// <summary>
        /// to create a Rename 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="searchAttributes">The file attributes of the file(s) to be deleted. If the value of this
        /// field is zero, then only normal files MUST be matched for deletion.  If the System or Hidden attributes
        /// MUST be specified, then entries with those attributes are matched in addition to the normal files. 
        /// Read-only files MAY NOT be deleted. The read-only attribute of the file MUST be cleared before the file
        /// MAY be deleted.</param>
        /// <param name="oldFileName">A null-terminated string containing the name of the file or files to be renamed.
        /// Wildcards MAY be used in the filename component of the path</param>
        /// <param name="newFileName">A null-terminated string containing the new name(s) to be given to the file(s)
        /// that matches OldFileName or the name of the destination directory into which the files matching 
        /// OldFileName MUST be moved.</param>
        /// <returns>a Rename request packet</returns>
        public SmbRenameRequestPacket CreateRenameRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            SmbFileAttributes searchAttributes,
            string oldFileName,
            string newFileName)
        {
            if (oldFileName == null)
            {
                oldFil 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SmbFlags2类代码示例发布时间:2022-05-24
下一篇:
C# Smb2FunctionalClient类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap