/// <summary> /// Deep copy constructor. /// </summary> public SmbOpenPrintFileRequestPacket(SmbOpenPrintFileRequestPacket packet) : base(packet) { this.InitDefaultValue(); this.smbParameters.WordCount = packet.SmbParameters.WordCount; this.smbParameters.SetupLength = packet.SmbParameters.SetupLength; this.smbParameters.Mode = packet.SmbParameters.Mode; this.smbData.ByteCount = packet.SmbData.ByteCount; this.smbData.BufferFormat = packet.SmbData.BufferFormat; if (packet.smbData.Identifier != null) { this.smbData.Identifier = new byte[packet.smbData.Identifier.Length]; Array.Copy(packet.smbData.Identifier, this.smbData.Identifier, packet.smbData.Identifier.Length); } else { this.smbData.Identifier = new byte[0]; } }
/// <summary> /// to create a OpenPrintFile 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="mode">A 16-bit field that contains a flag which specifies the print file mode.</param> /// <param name="identifier">STRING A null-terminated string containing a suggested name for the spool file. /// </param> /// <param name="setupLength">Length, in bytes, of the printer-specific control data that is to be included as /// the first part of the spool file</param> /// <returns>a OpenPrintFile request packet</returns> public SmbOpenPrintFileRequestPacket CreateOpenPrintFileRequest( ushort messageId, ushort uid, ushort treeId, SmbFlags flags, SmbFlags2 flags2, OpenPrintFileMode mode, string identifier, ushort setupLength) { if (identifier == null) { identifier = string.Empty; } SmbOpenPrintFileRequestPacket packet = new SmbOpenPrintFileRequestPacket(); packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_OPEN_PRINT_FILE, messageId, uid, treeId, flags, flags2); SMB_COM_OPEN_PRINT_FILE_Request_SMB_Parameters smbParameters = new SMB_COM_OPEN_PRINT_FILE_Request_SMB_Parameters(); smbParameters.Mode = (ushort)mode; smbParameters.SetupLength = setupLength; smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord); SMB_COM_OPEN_PRINT_FILE_Request_SMB_Data smbData = new SMB_COM_OPEN_PRINT_FILE_Request_SMB_Data(); smbData.BufferFormat = (byte)DataBufferFormat.SmbString; smbData.Identifier = CifsMessageUtils.ToSmbStringBytes(identifier, (flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE); smbData.ByteCount = (ushort)(Marshal.SizeOf(smbData.BufferFormat) + smbData.Identifier.Length); packet.SmbParameters = smbParameters; packet.SmbData = smbData; return packet; }
public SmbOpenPrintFileResponsePacket CreateOpenPrintFileResponse( CifsServerPerConnection connection, SmbOpenPrintFileRequestPacket request) { SmbOpenPrintFileResponsePacket response = new SmbOpenPrintFileResponsePacket(); response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request); SMB_COM_OPEN_PRINT_FILE_Response_SMB_Parameters smbParameters = response.SmbParameters; smbParameters.FID = (ushort)connection.GenerateFID(); smbParameters.WordCount = (byte)(TypeMarshal.GetBlockMemorySize(smbParameters) / 2); response.SmbParameters = smbParameters; return response; }