/// <summary> /// RDPEDYC Server /// </summary> /// <param name="rdpedycServer"></param> public RdpeusbServer(RdpedycServer rdpedycServer) { this.rdpedycServer = rdpedycServer; this.rdpeusbChannelDicbyId = new Dictionary <uint, DynamicVirtualChannel>(); this.receivedDvcData = new Dictionary <uint, QueueManager>(); this.pduParser = new RdpeusbClientPduParser(); }
/// <summary> /// Initialize this protocol with create control and data channels. /// </summary> /// <param name="rdpedycServer">RDPEDYC Server instance</param> /// <param name="transportType">selected transport type for created channels</param> /// <returns>true if client supports this protocol; otherwise, return false.</returns> public bool ProtocolInitialize(RdpedycServer rdpedycServer, DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_UDP_Reliable) { if (!rdpedycServer.IsMultipleTransportCreated(transportType)) { rdpedycServer.CreateMultipleTransport(transportType); } this.rdpefsServer = new RdpefsServer(rdpedycServer); bool success = false; // Create RDPEFS channel try { uint channelId = DynamicVirtualChannel.NewChannelId(); Dictionary <TunnelType_Value, List <uint> > channelListDic = new Dictionary <TunnelType_Value, List <uint> >(); List <uint> list = new List <uint>(); list.Add(channelId); channelListDic.Add(TunnelType_Value.TUNNELTYPE_UDPFECR, list); rdpedycServer.SoftSyncNegotiate(waitTime, channelListDic); success = rdpefsServer.CreateRdpefsDvc(waitTime, channelId); } catch (Exception e) { Site.Log.Add(LogEntryKind.Comment, "Exception occurred when creating RDPEFS channels: {1}", e.Message); } return(success); }
/// <summary> /// Establish EMT connection and soft sync. /// </summary> private void StartSoftSyncConnection(TransportMode mode) { StartRDPConnection(false, true); this.TestSite.Log.Add(LogEntryKind.Comment, "Create a {0} UDP connection.", mode); this.EstablishUDPConnection(mode, waitTime); this.TestSite.Log.Add(LogEntryKind.Comment, "Create a {0} RDPEMT connection.", mode); this.EstablishRdpemtConnection(mode, waitTime, true); this.TestSite.Log.Add(LogEntryKind.Comment, "Expect for Client Initiate Multitransport PDU to indicate that the client was able to successfully complete the multitransport initiation request."); this.rdpbcgrAdapter.WaitForPacket <Client_Initiate_Multitransport_Response_PDU>(waitTime); // This response code MUST only be sent to a server that advertises the SOFTSYNC_TCP_TO_UDP (0x200) flag in the Server Multitransport Channel Data. // Indicates that the client was able to successfully complete the multitransport initiation request. if (requestIdList.Count == 1) { VerifyClientInitiateMultitransportResponsePDU(rdpbcgrAdapter.SessionContext.ClientInitiateMultitransportResponsePDU, requestIdList[0], HrResponse_Value.S_OK); } #region Start EDYC soft sync if (rdpedycServer == null) { rdpedycServer = new Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpedyc.RdpedycServer(this.rdpbcgrAdapter.ServerStack, this.rdpbcgrAdapter.SessionContext); } this.TestSite.Log.Add(LogEntryKind.Comment, "Start Dynamic VC Version Negotiation"); rdpedycServer.ExchangeCapabilities(waitTime); this.TestSite.Log.Add(LogEntryKind.Comment, "Start Soft-Sync"); rdpedycServer.SoftSyncNegotiate(waitTime); #endregion }
//Start RDP connection. private void StartRDPConnection(bool createReliableUDPtransport = false, bool createLossyUDPtransport = false) { #region Trigger client to connect //Trigger client to connect. this.TestSite.Log.Add(LogEntryKind.Comment, "Triggering SUT to initiate a RDP connection to server."); triggerClientRDPConnect(transportProtocol); #endregion #region RDPBCGR Connection //Waiting for the transport level connection request. this.TestSite.Log.Add(LogEntryKind.Comment, "Expecting the transport layer connection request."); this.rdpbcgrAdapter.ExpectTransportConnection(RDPSessionType.Normal); //Set Server Capability with RomoteFX codec supported. this.TestSite.Log.Add(LogEntryKind.Comment, "Setting Server Capability."); setServerCapabilitiesWithRemoteFxSupported(); //Waiting for the RDP connection sequence. this.TestSite.Log.Add(LogEntryKind.Comment, "Establishing RDP connection."); this.rdpbcgrAdapter.EstablishRDPConnection(selectedProtocol, enMethod, enLevel, true, false, rdpServerVersion); this.TestSite.Log.Add(LogEntryKind.Comment, "Sending Server Save Session Info PDU to SUT to notify user has logged on."); this.rdpbcgrAdapter.ServerSaveSessionInfo(LogonNotificationType.UserLoggedOn, ErrorNotificationType_Values.LOGON_FAILED_OTHER); #endregion this.rdpedycServer = new RdpedycServer(this.rdpbcgrAdapter.ServerStack, this.rdpbcgrAdapter.SessionContext); rdpedycServer.ExchangeCapabilities(waitTime); bool initRdpegtChannel = this.rdpegtAdapter.ProtocolInitialize(this.rdpedycServer); Assert.IsTrue(initRdpegtChannel, "Creation of RDPEGT channel failed!"); }
/// <summary> /// Inherited from ManagedAdapterBase. /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { if (disposing) { rdpedycServer = null; } base.Dispose(disposing); }
/// <summary> /// Constructor. /// </summary> public RdpegfxServer(RdpedycServer rdpedycServer) { this.rdpedycServer = rdpedycServer; codecContextIdList = new List <uint>(); receivedList = new List <RdpegfxPdu>(); maxCodecContextId = 0; maxFId = 0; maxSeqNum = 0; }
/// <summary> /// Establish a RDP connection to detect RDP feature /// </summary> /// <returns></returns> public bool DetectRDPFeature() { // Establish a RDP connection with RDP client try { DetectorUtil.WriteLog("Establish RDP connection with SUT..."); StartRDPListening(); triggerClientRDPConnect(detectInfo.TriggerMethod); EstablishRDPConnection(); // Set RDP Version SetRdpVersion(); CheckSupportedFeatures(); CheckSupportedProtocols(); } catch (Exception e) { DetectorUtil.WriteLog("Exception occured when establishing RDP connection: " + e.Message); DetectorUtil.WriteLog("" + e.StackTrace); if (e.InnerException != null) { DetectorUtil.WriteLog("**" + e.InnerException.Message); DetectorUtil.WriteLog("**" + e.InnerException.StackTrace); } DetectorUtil.WriteLog("Failed", false, LogStyle.StepFailed); return(false); } finally { // Trigger client to close the RDP connection TriggerClientDisconnectAll(detectInfo.TriggerMethod); if (this.rdpedycServer != null) { this.rdpedycServer.Dispose(); this.rdpedycServer = null; } if (this.rdpbcgrServerStack != null) { this.rdpbcgrServerStack.Dispose(); this.rdpbcgrServerStack = null; } } // Notify the UI for establishing RDP connection successfully. DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); return(true); }
/// <summary> /// Dispose /// </summary> public void Dispose() { if (this.rdpedycServer != null) { this.rdpedycServer.Dispose(); this.rdpedycServer = null; } if (this.rdpbcgrServerStack != null) { this.rdpbcgrServerStack.Dispose(); this.rdpbcgrServerStack = null; } }
/// <summary> /// Start RDP connection /// </summary> private void StartRDPConnection() { #region Trigger client to connect //Trigger client to connect. this.TestSite.Log.Add(LogEntryKind.Comment, "Triggering SUT to initiate a RDP connection to server."); triggerClientRDPConnect(transportProtocol, true); #endregion #region RDPBCGR Connection // Waiting for the transport level connection request. this.TestSite.Log.Add(LogEntryKind.Comment, "Expecting the transport layer connection request."); this.rdpbcgrAdapter.ExpectTransportConnection(RDPSessionType.Normal); //Set Server Capability with RomoteFX codec supported. this.TestSite.Log.Add(LogEntryKind.Comment, "Setting Server RDPRFX Capability."); setServerCapabilitiesWithRemoteFxSupported(); // Waiting for the RDP connection sequence. this.TestSite.Log.Add(LogEntryKind.Comment, "Establishing RDP connection."); this.rdpbcgrAdapter.EstablishRDPConnection(selectedProtocol, enMethod, enLevel, true, false, rdpServerVersion); this.TestSite.Log.Add(LogEntryKind.Comment, "Sending Server Save Session Info PDU to SUT to notify user has logged on."); this.rdpbcgrAdapter.ServerSaveSessionInfo(LogonNotificationType.UserLoggedOn, ErrorNotificationType_Values.LOGON_FAILED_OTHER); #endregion rdpedycServer = new RdpedycServer(this.rdpbcgrAdapter.ServerStack, this.rdpbcgrAdapter.SessionContext); rdpedycServer.ExchangeCapabilities(waitTime); if (notificationType == NotificationType.SurfaceManagementCommand) { this.rdpegfxAdapter = this.TestSite.GetAdapter <IRdpegfxAdapter>(); this.rdpegfxAdapter.Reset(); this.rdprfxAdapter = null; // RDPEGFX capability exchange RDPEGFX_CapabilityExchange(); this.rdpedispAdapter.AttachRdpbcgrAdapter(this.rdpbcgrAdapter); this.rdpedispAdapter.AttachRdpegfxAdapter(rdpegfxAdapter); } else { this.rdprfxAdapter = this.TestSite.GetAdapter <IRdprfxAdapter>(); this.rdprfxAdapter.Reset(); //Initial the RDPRFX adapter context. rdprfxAdapter.Accept(this.rdpbcgrAdapter.ServerStack, this.rdpbcgrAdapter.SessionContext); receiveAndLogClientRfxCapabilites(); this.rdpedispAdapter.AttachRdpbcgrAdapter(this.rdpbcgrAdapter); this.rdpedispAdapter.AttachRdprfxAdapter(this.rdprfxAdapter); } }
/// <summary> /// Start RDP connection /// </summary> private void StartRDPConnection(bool isSoftSync = false) { #region Trigger client to connect //Trigger client to connect. this.TestSite.Log.Add(LogEntryKind.Comment, "Triggering SUT to initiate a RDP connection to server."); triggerClientRDPConnect(transportProtocol, true); #endregion #region RDPBCGR Connection // Waiting for the transport level connection request. this.TestSite.Log.Add(LogEntryKind.Comment, "Expecting the transport layer connection request."); this.rdpbcgrAdapter.ExpectTransportConnection(RDPSessionType.Normal); //Set Server Capability with RomoteFX codec supported. this.TestSite.Log.Add(LogEntryKind.Comment, "Setting Server Capability."); setServerCapabilitiesWithRemoteFxSupported(); // Waiting for the RDP connection sequence. this.TestSite.Log.Add(LogEntryKind.Comment, "Establishing RDP connection."); MULTITRANSPORT_TYPE_FLAGS flags = MULTITRANSPORT_TYPE_FLAGS.None; if (isSoftSync) { flags = MULTITRANSPORT_TYPE_FLAGS.SOFTSYNC_TCP_TO_UDP | MULTITRANSPORT_TYPE_FLAGS.TRANSPORTTYPE_UDPFECL; } this.rdpbcgrAdapter.EstablishRDPConnection(selectedProtocol, enMethod, enLevel, true, false, rdpServerVersion, flags, true, isSoftSync); if (isSoftSync) { Site.Assert.IsTrue(this.rdpbcgrAdapter.SessionContext.MultitransportTypeFlagsInMCSConnectIntialPdu.HasFlag(MULTITRANSPORT_TYPE_FLAGS.SOFTSYNC_TCP_TO_UDP), "Client Should support Soft-Sync, flags: {0}", this.rdpbcgrAdapter.SessionContext.MultitransportTypeFlagsInMCSConnectIntialPdu); } this.TestSite.Log.Add(LogEntryKind.Comment, "Sending Server Save Session Info PDU to SUT to notify user has logged on."); this.rdpbcgrAdapter.ServerSaveSessionInfo(LogonNotificationType.UserLoggedOn, ErrorNotificationType_Values.LOGON_FAILED_OTHER); #endregion this.rdpedycServer = new RdpedycServer(this.rdpbcgrAdapter.ServerStack, this.rdpbcgrAdapter.SessionContext); rdpegfxAdapter.AttachRdpbcgrAdapter(this.rdpbcgrAdapter); rdpedycServer.ExchangeCapabilities(waitTime); }
/// <summary> /// Initialize this protocol with create control and data channels. /// </summary> /// <param name="rdpedycserver">RDPEDYC Server instance</param> /// <param name="transportType">selected transport type for created channels</param> /// <returns>true if client supports this protocol; otherwise, return false.</returns> public bool ProtocolInitialize(RdpedycServer rdpedycServer, DynamicVC_TransportType transportType = DynamicVC_TransportType.RDP_TCP) { if (!rdpedycServer.IsMultipleTransportCreated(transportType)) { rdpedycServer.CreateMultipleTransport(transportType); } this.rdpedispServer = new RdpedispServer(rdpedycServer); bool success = false; try { success = rdpedispServer.CreateRdpedispDvc(waitTime, transportType); } catch (Exception e) { Site.Log.Add(LogEntryKind.Comment, "Exception occurred when creating RDPEDISP channels: {1}", e.Message); } return(success); }
// Default is using RDPEFS static virtual channel. Now is using DVC named "rdpdr". private void EstablishTunnelingStaticVCTrafficConnection(string staticChannelName = "RDPDR") { this.TestSite.Log.Add(LogEntryKind.Comment, "Start RDP connection, support soft sync and UDP perferred."); StartRDPConnection(false, true, true); // Check whether 'rdpdr' channel has been created if (this.rdpbcgrAdapter.GetStaticVirtualChannelId(staticChannelName) == 0) { this.TestSite.Assume.Fail("The necessary channel {0} has not been created, so stop running this test case.", staticChannelName); } if (rdpefsAdapter == null) { this.TestSite.Log.Add(LogEntryKind.Comment, "Create rdpefs adapter."); this.rdpefsAdapter = (IRdpefsAdapter)this.TestSite.GetAdapter(typeof(IRdpefsAdapter)); this.rdpefsAdapter.Reset(); this.rdpefsAdapter.AttachRdpbcgrAdapter(this.rdpbcgrAdapter); } if (rdpedycServer == null) { rdpedycServer = new RdpedycServer(this.rdpbcgrAdapter.ServerStack, this.rdpbcgrAdapter.SessionContext); } this.TestSite.Log.Add(LogEntryKind.Comment, "Start Dynamic VC Version Negotiation"); ushort version = rdpedycServer.ExchangeCapabilities(waitTime); if (version < 0x0003) { this.TestSite.Log.Add(LogEntryKind.TestError, "Client doesn's support Version 3 DYNVC."); } this.TestSite.Log.Add(LogEntryKind.Comment, "Create a dynamic virtual channel for MS-RDPEFS"); rdpefsAdapter.ProtocolInitialize(rdpedycServer); this.TestSite.Log.Add(LogEntryKind.Comment, "Send and receive efs data over DVC"); rdpefsAdapter.EfsInitializationSequenceOverDVC(); }
/// <summary> /// Reset the RdpeiServer instance. /// </summary> public void Reset() { rdpedycServer = null; rdpeiDVC = null; receivedList.Clear(); }
/// <summary> /// Establish RDP Connection /// </summary> private void EstablishRDPConnection() { sessionContext = rdpbcgrServerStack.ExpectConnect(timeout); #region Connection Initial x224ConnectionRequest = ExpectPacket <Client_X_224_Connection_Request_Pdu>(sessionContext, timeout); Server_X_224_Connection_Confirm_Pdu confirmPdu = rdpbcgrServerStack.CreateX224ConnectionConfirmPdu(sessionContext, selectedProtocols_Values.PROTOCOL_RDP_FLAG, RDP_NEG_RSP_flags_Values.DYNVC_GFX_PROTOCOL_SUPPORTED | RDP_NEG_RSP_flags_Values.EXTENDED_CLIENT_DATA_SUPPORTED); SendPdu(confirmPdu); if (bool.Parse(detectInfo.IsWindowsImplementation)) { RdpbcgrServerSessionContext orgSession = sessionContext; sessionContext = rdpbcgrServerStack.ExpectConnect(timeout); if (sessionContext.Identity == orgSession.Identity) { sessionContext = rdpbcgrServerStack.ExpectConnect(timeout); } x224ConnectionRequest = ExpectPacket <Client_X_224_Connection_Request_Pdu>(sessionContext, timeout); confirmPdu = rdpbcgrServerStack.CreateX224ConnectionConfirmPdu(sessionContext, selectedProtocols_Values.PROTOCOL_RDP_FLAG, RDP_NEG_RSP_flags_Values.DYNVC_GFX_PROTOCOL_SUPPORTED | RDP_NEG_RSP_flags_Values.EXTENDED_CLIENT_DATA_SUPPORTED); SendPdu(confirmPdu); } #endregion Connection Initial #region Basic Setting Exchange mscConnectionInitialPDU = ExpectPacket <Client_MCS_Connect_Initial_Pdu_with_GCC_Conference_Create_Request>(sessionContext, timeout); SERVER_CERTIFICATE cert = null; int certLen = 0; int dwKeysize = 2048; byte[] privateExp, publicExp, modulus; cert = rdpbcgrServerStack.GenerateCertificate(dwKeysize, out privateExp, out publicExp, out modulus); certLen = 120 + dwKeysize / 8; Server_MCS_Connect_Response_Pdu_with_GCC_Conference_Create_Response connectRespPdu = rdpbcgrServerStack.CreateMCSConnectResponsePduWithGCCConferenceCreateResponsePdu( sessionContext, EncryptionMethods.ENCRYPTION_METHOD_128BIT, EncryptionLevel.ENCRYPTION_LEVEL_LOW, cert, certLen, MULTITRANSPORT_TYPE_FLAGS.TRANSPORTTYPE_UDPFECL | MULTITRANSPORT_TYPE_FLAGS.TRANSPORTTYPE_UDPFECR); SendPdu(connectRespPdu); sessionContext.ServerPrivateExponent = new byte[privateExp.Length]; Array.Copy(privateExp, sessionContext.ServerPrivateExponent, privateExp.Length); #endregion Basic Setting Exchange #region Channel Connection ExpectPacket <Client_MCS_Erect_Domain_Request>(sessionContext, timeout); ExpectPacket <Client_MCS_Attach_User_Request>(sessionContext, timeout); Server_MCS_Attach_User_Confirm_Pdu attachUserConfirmPdu = rdpbcgrServerStack.CreateMCSAttachUserConfirmPdu(sessionContext); SendPdu(attachUserConfirmPdu); //Join Channel int channelNum = 2; if (sessionContext.VirtualChannelIdStore != null) { channelNum += sessionContext.VirtualChannelIdStore.Length; } if (sessionContext.IsServerMessageChannelDataSend) { channelNum++; } for (int i = 0; i < channelNum; i++) { Client_MCS_Channel_Join_Request channelJoinPdu = ExpectPacket <Client_MCS_Channel_Join_Request>(sessionContext, timeout); Server_MCS_Channel_Join_Confirm_Pdu channelJoinResponse = rdpbcgrServerStack.CreateMCSChannelJoinConfirmPdu( sessionContext, channelJoinPdu.mcsChannelId); SendPdu(channelJoinResponse); } #endregion Channel Connection #region RDP Security Commencement securityExchangePDU = ExpectPacket <Client_Security_Exchange_Pdu>(sessionContext, timeout); #endregion RDP Security Commencement #region Secure Setting Exchange clientInfoPDU = ExpectPacket <Client_Info_Pdu>(sessionContext, timeout); #endregion Secure Setting Exchange #region Licensing Server_License_Error_Pdu_Valid_Client licensePdu = rdpbcgrServerStack.CreateLicenseErrorMessage(sessionContext); SendPdu(licensePdu); #endregion Licensing #region Capabilities Exchange RdpbcgrCapSet capSet = new RdpbcgrCapSet(); capSet.GenerateCapabilitySets(); Server_Demand_Active_Pdu demandActivePdu = rdpbcgrServerStack.CreateDemandActivePdu(sessionContext, capSet.CapabilitySets); SendPdu(demandActivePdu); confirmActivePDU = ExpectPacket <Client_Confirm_Active_Pdu>(sessionContext, timeout); clientCapSet = new RdpbcgrCapSet(); clientCapSet.CapabilitySets = confirmActivePDU.confirmActivePduData.capabilitySets; #endregion Capabilities Exchange #region Connection Finalization ExpectPacket <Client_Synchronize_Pdu>(sessionContext, timeout); Server_Synchronize_Pdu synchronizePdu = rdpbcgrServerStack.CreateSynchronizePdu(sessionContext); SendPdu(synchronizePdu); Server_Control_Pdu controlCooperatePdu = rdpbcgrServerStack.CreateControlCooperatePdu(sessionContext); SendPdu(controlCooperatePdu); ExpectPacket <Client_Control_Pdu_Cooperate>(sessionContext, timeout); ExpectPacket <Client_Control_Pdu_Request_Control>(sessionContext, timeout); Server_Control_Pdu controlGrantedPdu = rdpbcgrServerStack.CreateControlGrantedPdu(sessionContext); SendPdu(controlGrantedPdu); ITsCapsSet cap = this.clientCapSet.FindCapSet(capabilitySetType_Values.CAPSTYPE_BITMAPCACHE_REV2); if (cap != null) { TS_BITMAPCACHE_CAPABILITYSET_REV2 bitmapCacheV2 = (TS_BITMAPCACHE_CAPABILITYSET_REV2)cap; if ((bitmapCacheV2.CacheFlags & CacheFlags_Values.PERSISTENT_KEYS_EXPECTED_FLAG) != 0) { ExpectPacket <Client_Persistent_Key_List_Pdu>(sessionContext, timeout); } } ExpectPacket <Client_Font_List_Pdu>(sessionContext, timeout); Server_Font_Map_Pdu fontMapPdu = rdpbcgrServerStack.CreateFontMapPdu(sessionContext); SendPdu(fontMapPdu); #endregion Connection Finalization // Init for RDPEDYC try { rdpedycServer = new RdpedycServer(rdpbcgrServerStack, sessionContext); rdpedycServer.ExchangeCapabilities(timeout); } catch (Exception) { rdpedycServer = null; } }
/// <summary> /// Constructor /// </summary> /// <param name="rdpedycserver"></param> public RdpedispServer(RdpedycServer rdpedycserver) { this.rdpedycServer = rdpedycserver; receivedList = new List <RdpedispPdu>(); }
public RdpefsServer(RdpedycServer rdpedycServer) { this.rdpedycServer = rdpedycServer; receivedList = new List <RdpefsPDU>(); }
/// <summary> /// Establish a RDP connection to detect RDP feature /// </summary> /// <returns></returns> public bool DetectRDPFeature() { // Establish a RDP connection with RDP client try { StartRDPListening(); triggerClientRDPConnect(detectInfo.TriggerMethod); EstablishRDPConnection(); } catch (Exception e) { DetectorUtil.WriteLog("Exception occured when establishing RDP connection: " + e.Message); DetectorUtil.WriteLog("" + e.StackTrace); if (e.InnerException != null) { DetectorUtil.WriteLog("**" + e.InnerException.Message); DetectorUtil.WriteLog("**" + e.InnerException.StackTrace); } DetectorUtil.WriteLog("Failed", false, LogStyle.StepFailed); return(false); } // Notify the UI for establishing RDP connection successfully. DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); // Set result according to messages during connection if (mscConnectionInitialPDU.mcsCi.gccPdu.clientCoreData != null && mscConnectionInitialPDU.mcsCi.gccPdu.clientCoreData.earlyCapabilityFlags != null) { detectInfo.IsSupportNetcharAutoDetect = ((mscConnectionInitialPDU.mcsCi.gccPdu.clientCoreData.earlyCapabilityFlags.actualData & (ushort)earlyCapabilityFlags_Values.RNS_UD_CS_SUPPORT_NETWORK_AUTODETECT) == (ushort)earlyCapabilityFlags_Values.RNS_UD_CS_SUPPORT_NETWORK_AUTODETECT); detectInfo.IsSupportHeartbeatPdu = ((mscConnectionInitialPDU.mcsCi.gccPdu.clientCoreData.earlyCapabilityFlags.actualData & (ushort)earlyCapabilityFlags_Values.RNS_UD_CS_SUPPORT_HEARTBEAT_PDU) == (ushort)earlyCapabilityFlags_Values.RNS_UD_CS_SUPPORT_HEARTBEAT_PDU); } else { detectInfo.IsSupportNetcharAutoDetect = false; detectInfo.IsSupportHeartbeatPdu = false; } // Trigger client to close the RDP connection TriggerClientDisconnectAll(detectInfo.TriggerMethod); if (detectInfo.IsSupportStaticVirtualChannel != null && detectInfo.IsSupportStaticVirtualChannel.Value) { detectInfo.IsSupportRDPEUDP = true; } else { detectInfo.IsSupportRDPEUDP = false; } // Notify the UI for detecting protocol supported finished DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); if (this.rdpedycServer != null) { this.rdpedycServer.Dispose(); this.rdpedycServer = null; } if (this.rdpbcgrServerStack != null) { this.rdpbcgrServerStack.Dispose(); this.rdpbcgrServerStack = null; } return(true); }
/// <summary> /// Inherited from ManagedAdapterBase. /// </summary> public override void Reset() { rdpedycServer = null; base.Reset(); }
/// <summary> /// Constructor of RdpeiServer /// </summary> public RdpeiServer(RdpedycServer edycServer) { receivedList = new List <RDPINPUT_PDU>(); rdpedycServer = edycServer; }
/// <summary> /// Initialize this protocol with create control and data channels. /// </summary> /// <param name="rdpedycServer">RDPEDYC Server instance</param> /// <param name="transportType">selected transport type for created channels</param> /// <returns>true if client supports this protocol; otherwise, return false.</returns> public bool ProtocolInitialize(RdpedycServer rdpedycServer) { this.rdpedycServer = rdpedycServer; this.rdpeusbServer = new RdpeusbServer(rdpedycServer); return(true); }
/// <summary> /// Establish a RDP connection to detect RDP feature /// </summary> /// <returns></returns> public bool DetectRDPFeature() { // Establish a RDP connection with RDP client try { StartRDPListening(); triggerClientRDPConnect(detectInfo.TriggerMethod); EstablishRDPConnection(); } catch (Exception e) { DetectorUtil.WriteLog("Exception occured when establishing RDP connection: " + e.Message); DetectorUtil.WriteLog("" + e.StackTrace); if (e.InnerException != null) { DetectorUtil.WriteLog("**" + e.InnerException.Message); DetectorUtil.WriteLog("**" + e.InnerException.StackTrace); } DetectorUtil.WriteLog("Failed", false, LogStyle.StepFailed); return(false); } // Notify the UI for establishing RDP connection successfully. DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); // Set result according to messages during connection if (mscConnectionInitialPDU.mcsCi.gccPdu.clientCoreData != null && mscConnectionInitialPDU.mcsCi.gccPdu.clientCoreData.earlyCapabilityFlags != null) { detectInfo.IsSupportNetcharAutoDetect = ((mscConnectionInitialPDU.mcsCi.gccPdu.clientCoreData.earlyCapabilityFlags.actualData & (ushort)earlyCapabilityFlags_Values.RNS_UD_CS_SUPPORT_NETWORK_AUTODETECT) == (ushort)earlyCapabilityFlags_Values.RNS_UD_CS_SUPPORT_NETWORK_AUTODETECT); detectInfo.IsSupportRDPEGFX = ((mscConnectionInitialPDU.mcsCi.gccPdu.clientCoreData.earlyCapabilityFlags.actualData & (ushort)earlyCapabilityFlags_Values.RNS_UD_CS_SUPPORT_DYNVC_GFX_PROTOCOL) == (ushort)earlyCapabilityFlags_Values.RNS_UD_CS_SUPPORT_DYNVC_GFX_PROTOCOL); detectInfo.IsSupportHeartbeatPdu = ((mscConnectionInitialPDU.mcsCi.gccPdu.clientCoreData.earlyCapabilityFlags.actualData & (ushort)earlyCapabilityFlags_Values.RNS_UD_CS_SUPPORT_HEARTBEAT_PDU) == (ushort)earlyCapabilityFlags_Values.RNS_UD_CS_SUPPORT_HEARTBEAT_PDU); } else { detectInfo.IsSupportNetcharAutoDetect = false; detectInfo.IsSupportRDPEGFX = false; detectInfo.IsSupportHeartbeatPdu = false; } if (mscConnectionInitialPDU.mcsCi.gccPdu.clientMultitransportChannelData != null) { detectInfo.IsSupportTransportTypeUdpFECR = (mscConnectionInitialPDU.mcsCi.gccPdu.clientMultitransportChannelData.flags.HasFlag(MULTITRANSPORT_TYPE_FLAGS.TRANSPORTTYPE_UDPFECR)); detectInfo.IsSupportTransportTypeUdpFECL = (mscConnectionInitialPDU.mcsCi.gccPdu.clientMultitransportChannelData.flags.HasFlag(MULTITRANSPORT_TYPE_FLAGS.TRANSPORTTYPE_UDPFECL)); } else { detectInfo.IsSupportTransportTypeUdpFECR = false; detectInfo.IsSupportTransportTypeUdpFECL = false; } if (mscConnectionInitialPDU.mcsCi.gccPdu.clientClusterData != null) { detectInfo.IsSupportServerRedirection = (mscConnectionInitialPDU.mcsCi.gccPdu.clientClusterData.Flags.HasFlag(Flags_Values.REDIRECTION_SUPPORTED)); } else { detectInfo.IsSupportServerRedirection = false; } if (mscConnectionInitialPDU.mcsCi.gccPdu.clientNetworkData != null && mscConnectionInitialPDU.mcsCi.gccPdu.clientNetworkData.channelCount > 0) { detectInfo.IsSupportStaticVirtualChannel = true; } else { detectInfo.IsSupportStaticVirtualChannel = false; } TS_GENERAL_CAPABILITYSET generalCapSet = (TS_GENERAL_CAPABILITYSET)this.clientCapSet.FindCapSet(capabilitySetType_Values.CAPSTYPE_GENERAL); if (generalCapSet.extraFlags.HasFlag(extraFlags_Values.AUTORECONNECT_SUPPORTED)) { detectInfo.IsSupportAutoReconnect = true; } else { detectInfo.IsSupportAutoReconnect = false; } detectInfo.IsSupportRDPRFX = false; ITsCapsSet codecCapSet = this.clientCapSet.FindCapSet(capabilitySetType_Values.CAPSETTYPE_BITMAP_CODECS); if (codecCapSet != null) { foreach (TS_BITMAPCODEC codec in ((TS_BITMAPCODECS_CAPABILITYSET)codecCapSet).supportedBitmapCodecs.bitmapCodecArray) { if (is_REMOTEFX_CODEC_GUID(codec.codecGUID)) { detectInfo.IsSupportRDPRFX = true; break; } } } if (detectInfo.IsSupportRDPRFX.Value) { ITsCapsSet surfcmdCapSet = this.clientCapSet.FindCapSet(capabilitySetType_Values.CAPSETTYPE_SURFACE_COMMANDS); if (!((TS_SURFCMDS_CAPABILITYSET)surfcmdCapSet).cmdFlags.HasFlag(CmdFlags_Values.SURFCMDS_STREAMSURFACEBITS)) { detectInfo.IsSupportRDPRFX = false; } } // Notify the UI for detecting feature finished DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); detectInfo.IsSupportRDPEFS = false; if (mscConnectionInitialPDU.mcsCi.gccPdu.clientNetworkData != null && mscConnectionInitialPDU.mcsCi.gccPdu.clientNetworkData.channelCount > 0) { List <CHANNEL_DEF> channels = mscConnectionInitialPDU.mcsCi.gccPdu.clientNetworkData.channelDefArray; foreach (CHANNEL_DEF channel in channels) { if (channel.name.ToUpper().Contains("RDPDR")) { detectInfo.IsSupportRDPEFS = true; break; } } } // Create Dynamic Virtual Channels to detect protocols supported detectInfo.IsSupportRDPEDISP = (CreateEDYCChannel(RDPDetector.RdpedispChannelName)); if (detectInfo.IsSupportRDPEGFX != null && detectInfo.IsSupportRDPEGFX.Value) { detectInfo.IsSupportRDPEGFX = CreateEDYCChannel(RDPDetector.RdpegfxChannelName); } detectInfo.IsSupportRDPEI = (CreateEDYCChannel(RDPDetector.rdpeiChannelName)); detectInfo.IsSupportRDPEUSB = (CreateEDYCChannel(RDPDetector.RdpeusbChannelName)); detectInfo.IsSupportRDPEVOR = (CreateEDYCChannel(RDPDetector.RdpegtChannelName) && CreateEDYCChannel(RDPDetector.RdpevorControlChannelName) && CreateEDYCChannel(RDPDetector.RdpevorDataChannelName)); // Trigger client to close the RDP connection TriggerClientDisconnectAll(detectInfo.TriggerMethod); if (detectInfo.IsSupportStaticVirtualChannel != null && detectInfo.IsSupportStaticVirtualChannel.Value && ((detectInfo.IsSupportTransportTypeUdpFECR != null && detectInfo.IsSupportTransportTypeUdpFECR.Value) || (detectInfo.IsSupportTransportTypeUdpFECL != null && detectInfo.IsSupportTransportTypeUdpFECL.Value))) { detectInfo.IsSupportRDPEMT = true; detectInfo.IsSupportRDPEUDP = true; } else { detectInfo.IsSupportRDPEMT = false; detectInfo.IsSupportRDPEUDP = false; } // Notify the UI for detecting protocol supported finished DetectorUtil.WriteLog("Passed", false, LogStyle.StepPassed); if (this.rdpedycServer != null) { this.rdpedycServer.Dispose(); this.rdpedycServer = null; } if (this.rdpbcgrServerStack != null) { this.rdpbcgrServerStack.Dispose(); this.rdpbcgrServerStack = null; } return(true); }
/// <summary> /// Constructor /// </summary> /// <param name="rdpedycServer"></param> public RdpevorServer(RdpedycServer rdpedycServer) { this.rdpedycServer = rdpedycServer; receivedList = new List <RdpevorPdu>(); }
/// <summary> /// Constructor /// </summary> /// <param name="rdpedycServer"></param> public RdpegtServer(RdpedycServer rdpedycServer) { this.rdpedycServer = rdpedycServer; }