/// <summary> /// TRANS2_QUERY_FILE_INFORMATION Request handler. /// </summary> /// <param name="messageId">This is used to associate a response with a request.</param> /// <param name="sessionId"> /// Set this value to 0 to request a new session setup, or set this value to a previously established session /// identifier to request reauthenticate to an existing session. /// </param> /// <param name="treeId"> /// This field identifies the subdirectory (or tree) (also referred as a share in this document) on the /// server that the client is accessing. /// </param> /// <param name="isSigned"> /// Indicate whether the SUT has message signing enabled or required. /// </param> /// <param name="isUsePassthrough"> /// Indicate whether adding SMB_INFO_PASSTHROUGH in InformationLevel field of the request. /// </param> /// <param name="informationLevel">This can be used to query information from the server.</param> /// <param name="fid">The file identifier.</param> /// <param name="reserved">The reserved int value.</param> public void Trans2QueryFileInfoRequest( int messageId, int sessionId, int treeId, bool isSigned, bool isUsePassthrough, [Domain("InfoLevelQueriedByFid")] InformationLevel informationLevel, int fid, int reserved) { #region Create Packet SmbTrans2QueryFileInformationRequestPacket smbPacket = new SmbTrans2QueryFileInformationRequestPacket(); ushort uid = (ushort)this.uId[(uint)sessionId]; NamespaceCifs.Trans2SmbParametersFlags transactOptions = NamespaceCifs.Trans2SmbParametersFlags.NONE; ushort fileId = (ushort)this.fId[(uint)fid]; ushort level = this.informationLevelBytes[(ushort)informationLevel]; this.smbClientStack.Capability.IsUsePathThrough = isUsePassthrough; smbPacket = this.smbClientStack.CreateTrans2QueryFileInformationRequest( fileId, transactOptions, this.maxDataCount, (NamespaceCifs.QueryInformationLevel)level, null); if (isSigned) { NamespaceCifs.CifsClientPerConnection connection = this.smbClientStack.Context.GetConnection(ConnectionId); NamespaceCifs.CifsClientPerSession session = this.smbClientStack.Context.GetSession(ConnectionId, uid); smbPacket.Sign(connection.ClientNextSendSequenceNumber, session.SessionKey); } #endregion #region Send and Receive ExpectPacket this.smbClientStack.SendPacket(smbPacket); StackPacket response = this.smbClientStack.ExpectPacket(this.timeout); NamespaceCifs.SmbPacket smbPacketResponse = (NamespaceCifs.SmbPacket)response; this.QueryUidTable(smbPacketResponse); this.QueryTidTable(smbPacketResponse); VerifyTransport(smbPacketResponse); VerifyCommonMessageSyntax(smbPacketResponse); if (response.GetType() == typeof(SmbErrorResponsePacket)) { SmbErrorResponsePacket smbErrorResponsePacket = response as SmbErrorResponsePacket; NamespaceCifs.SmbHeader smbErrorHeader = smbErrorResponsePacket.SmbHeader; if (smbErrorHeader.Status == (uint)MessageStatus.StatusInvalidInfoClass) { smbErrorHeader.Status = (uint)MessageStatus.NotSupported; } this.ErrorTrans2QueryFileInfoResponse( smbErrorHeader.Mid + this.addMidMark, (MessageStatus)smbErrorHeader.Status, Boolean.Parse(this.Site.Properties["SHOULDMAYR2073Implementation"])); } else { SmbTrans2QueryFileInformationResponsePacket smbTrans2QueryFileInformationPacket = response as SmbTrans2QueryFileInformationResponsePacket; NamespaceCifs.SmbHeader trans2QueryFileInformationResponseHeader = smbTrans2QueryFileInformationPacket.SmbHeader; this.Trans2QueryFileInfoResponse( trans2QueryFileInformationResponseHeader.Mid + this.addMidMark, this.QueryUidTable(smbPacketResponse), this.QueryTidTable(smbPacketResponse), (smbPacketResponse).IsSignRequired, (MessageStatus)trans2QueryFileInformationResponseHeader.Status); } #endregion }
/// <summary> /// find the transaction2 packet. /// </summary> /// <param name="command">the command of transaction2 packet.</param> /// <returns>the target transaction2 packet</returns> private static SmbPacket FindTheTrans2Packet(Trans2SubCommand command) { SmbPacket smbPacket = null; switch ((Trans2SubCommand)command) { case Trans2SubCommand.TRANS2_FIND_FIRST2: smbPacket = new SmbTrans2FindFirst2RequestPacket(); break; case Trans2SubCommand.TRANS2_FIND_NEXT2: smbPacket = new SmbTrans2FindNext2RequestPacket(); break; case Trans2SubCommand.TRANS2_QUERY_FS_INFORMATION: smbPacket = new SmbTrans2QueryFsInformationRequestPacket(); break; case Trans2SubCommand.TRANS2_SET_FS_INFORMATION: smbPacket = new SmbTrans2SetFsInformationRequestPacket(); break; case Trans2SubCommand.TRANS2_QUERY_PATH_INFORMATION: smbPacket = new SmbTrans2QueryPathInformationRequestPacket(); break; case Trans2SubCommand.TRANS2_SET_PATH_INFORMATION: smbPacket = new SmbTrans2SetPathInformationRequestPacket(); break; case Trans2SubCommand.TRANS2_QUERY_FILE_INFORMATION: smbPacket = new SmbTrans2QueryFileInformationRequestPacket(); break; case Trans2SubCommand.TRANS2_SET_FILE_INFORMATION: smbPacket = new SmbTrans2SetFileInformationRequestPacket(); break; case Trans2SubCommand.TRANS2_GET_DFS_REFERRAL: smbPacket = new SmbTrans2GetDfsReferralRequestPacket(); break; default: break; } return smbPacket; }