/// <summary> /// Start RDP connection using a parameter structure /// </summary> /// <param name="configureParameters"></param> /// <returns></returns> public static int Start_RDP_Connection(RDP_Connection_Configure_Parameters configureParameters) { string arguments = ""; if (configureParameters.port == 0) { arguments += string.Format(@" /v:{0}", configureParameters.address); } else { arguments += string.Format(@" /v:{0}:{1}", configureParameters.address, configureParameters.port); } if (configureParameters.screenType == RDP_Screen_Type.FULL_SCREEN) { arguments += @" /f"; } else { arguments += string.Format(@" /w:{0} /h:{1}", configureParameters.desktopWidth, configureParameters.desktopHeight); } //Start RDP connection Process rdpProcess = new Process(); rdpProcess.StartInfo.FileName = "mstsc.exe"; rdpProcess.StartInfo.Arguments = arguments; rdpProcess.Start(); rdpProcess.Close(); return(1); }
public bool Decode(byte[] rawData, int payloadLength, ref int index) { try { this.type = (RDP_Connect_Payload_Type)BitConverter.ToUInt32(Utility.GetNumericBytes(rawData, index, 4), 0); index += 4; if (type == RDP_Connect_Payload_Type.RDP_FILE) { this.rdpFileConfig = Encoding.UTF8.GetString(rawData, index, payloadLength - 4); index += (payloadLength - 4); } else { this.configureParameters = new RDP_Connection_Configure_Parameters(); if (!this.configureParameters.Decode(rawData, ref index)) { return(false); } } } catch (Exception) { return(false); } return(true); }
/// <summary> /// Start RDP connection using a parameter structure /// </summary> /// <param name="configureParameters"></param> /// <returns></returns> public static int Start_RDP_Connection(RDP_Connection_Configure_Parameters configureParameters) { string arguments; if (configureParameters.connectApproach == RDP_Connect_Approach.Negotiate && configureParameters.screenType == RDP_Screen_Type.NORMAL) { arguments = GetConfiguredValue("Negotiate"); } else if (configureParameters.connectApproach == RDP_Connect_Approach.Negotiate && configureParameters.screenType == RDP_Screen_Type.FULL_SCREEN) { arguments = GetConfiguredValue("NegotiateFullScreen"); } else if (configureParameters.connectApproach == RDP_Connect_Approach.Direct && configureParameters.screenType == RDP_Screen_Type.NORMAL) { arguments = GetConfiguredValue("DirectCredSSP"); } else if (configureParameters.connectApproach == RDP_Connect_Approach.Direct && configureParameters.screenType == RDP_Screen_Type.FULL_SCREEN) { arguments = GetConfiguredValue("DirectCredSSPFullScreen"); } else { arguments = GetConfiguredValue("Negotiate"); } try { arguments = arguments.Replace("{{address}}", configureParameters.address); if (configureParameters.port == 0) { arguments = arguments.Replace(":{{port}}", ""); } else { arguments = arguments.Replace("{{port}}", configureParameters.port.ToString()); } } catch (Exception e) { return(-1); } //Start RDP connection InvokeRemoteClientProcess(arguments); return(1); }