/// <summary> /// to create a Create 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="fileAttributes">A 16-bit field of 1-bit flags that represent the file attributes to assign /// to the file if it is created successfully.</param> /// <param name="creationTime">UTIME 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="fileName">A null-terminated string that represents the fully qualified name of the file /// relative to the supplied TID to create or truncate on the server.</param> /// <returns>a Open request packet</returns> public SmbCreateRequestPacket CreateCreateRequest( ushort messageId, ushort uid, ushort treeId, SmbFlags flags, SmbFlags2 flags2, SmbFileAttributes fileAttributes, UTime creationTime, string fileName) { if (fileName == null) { fileName = string.Empty; } SmbCreateRequestPacket packet = new SmbCreateRequestPacket(); packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_CREATE, messageId, uid, treeId, flags, flags2); SMB_COM_CREATE_Request_SMB_Parameters smbParameters = new SMB_COM_CREATE_Request_SMB_Parameters(); smbParameters.FileAttributes = fileAttributes; smbParameters.CreationTime = creationTime; smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord); SMB_COM_CREATE_Request_SMB_Data smbData = new SMB_COM_CREATE_Request_SMB_Data(); smbData.BufferFormat = (byte)DataBufferFormat.SmbString; smbData.FileName = CifsMessageUtils.ToSmbStringBytes(fileName, (flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE); smbData.ByteCount = (ushort)(Marshal.SizeOf(smbData.BufferFormat) + smbData.FileName.Length); packet.SmbParameters = smbParameters; packet.SmbData = smbData; return packet; }
/// <summary> /// to decode the smb data: from the general SmbDada to the concrete Smb Data. /// </summary> protected override void DecodeData() { this.smbData = TypeMarshal.ToStruct<SMB_COM_CREATE_Request_SMB_Data>( TypeMarshal.ToBytes(this.smbDataBlock)); }