コード例 #1
0
 /// <summary>
 /// to create a WriteAndx 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="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="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>
 /// <exception cref="System.NullReferenceException">There is no connection in context. </exception>
 public SmbWriteAndxRequestPacket CreateWriteAndxRequest(
     ushort uid,
     ushort treeId,
     ushort fid,
     uint offset,
     WriteAndxWriteMode writeMode,
     uint offsetHigh,
     byte[] data,
     SmbPacket andxPacket)
 {
     return this.CreateWriteAndxRequest(this.Context.GetMessageId(this.connectionId),
         uid, treeId, this.defaultParameters.Flag, this.defaultParameters.Flag2, fid, offset, this.defaultParameters.Timeout, writeMode,
         offsetHigh, data, andxPacket);
 }
コード例 #2
0
        /// <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;
        }