From 8477625472faddbf15a5b1b853d2ec295812d295 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Wed, 18 May 2016 16:32:19 -0400 Subject: [PATCH 01/13] Changed some default settings to avoid hangs Multiple users reported that having "Cahse Bitmaps" and/or "Use CredSSP" set to yes (which was the previous default) would cause problems with mRemoteNG - especially when opening multiple RDP connections. Also increased update check to 14 days. --- mRemoteV1/Properties/Settings.Designer.cs | 6 +++--- mRemoteV1/Properties/Settings.settings | 6 +++--- mRemoteV1/app.config | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mRemoteV1/Properties/Settings.Designer.cs b/mRemoteV1/Properties/Settings.Designer.cs index 288a17e2..7ee6004e 100644 --- a/mRemoteV1/Properties/Settings.Designer.cs +++ b/mRemoteV1/Properties/Settings.Designer.cs @@ -553,7 +553,7 @@ namespace mRemoteNG { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] + [global::System.Configuration.DefaultSettingValueAttribute("False")] public bool ConDefaultCacheBitmaps { get { return ((bool)(this["ConDefaultCacheBitmaps"])); @@ -1717,7 +1717,7 @@ namespace mRemoteNG { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("7")] + [global::System.Configuration.DefaultSettingValueAttribute("14")] public int CheckForUpdatesFrequencyDays { get { return ((int)(this["CheckForUpdatesFrequencyDays"])); @@ -2074,7 +2074,7 @@ namespace mRemoteNG { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] + [global::System.Configuration.DefaultSettingValueAttribute("False")] public bool ConDefaultUseCredSsp { get { return ((bool)(this["ConDefaultUseCredSsp"])); diff --git a/mRemoteV1/Properties/Settings.settings b/mRemoteV1/Properties/Settings.settings index a8a479ab..e0bf6145 100644 --- a/mRemoteV1/Properties/Settings.settings +++ b/mRemoteV1/Properties/Settings.settings @@ -135,7 +135,7 @@ Colors16Bit - True + False False @@ -426,7 +426,7 @@ False - 7 + 14 1980-01-01 @@ -516,7 +516,7 @@ False - True + False False diff --git a/mRemoteV1/app.config b/mRemoteV1/app.config index edcfa5ac..3d467657 100644 --- a/mRemoteV1/app.config +++ b/mRemoteV1/app.config @@ -169,7 +169,7 @@ Colors16Bit - True + False False @@ -460,7 +460,7 @@ False - 7 + 14 1980-01-01 @@ -541,7 +541,7 @@ False - True + False False From 8abe2bffb8ebd38fd32acedd2cf54a25cdfcb428 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Wed, 18 May 2016 16:36:54 -0400 Subject: [PATCH 02/13] Use CredSSP needs to be true for modern targets Just about all modern versions of Windows require CredSSP by default. Set that one back to "Yes". --- mRemoteV1/Properties/Settings.Designer.cs | 2 +- mRemoteV1/Properties/Settings.settings | 2 +- mRemoteV1/app.config | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mRemoteV1/Properties/Settings.Designer.cs b/mRemoteV1/Properties/Settings.Designer.cs index 7ee6004e..bea2a49c 100644 --- a/mRemoteV1/Properties/Settings.Designer.cs +++ b/mRemoteV1/Properties/Settings.Designer.cs @@ -2074,7 +2074,7 @@ namespace mRemoteNG { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("False")] + [global::System.Configuration.DefaultSettingValueAttribute("True")] public bool ConDefaultUseCredSsp { get { return ((bool)(this["ConDefaultUseCredSsp"])); diff --git a/mRemoteV1/Properties/Settings.settings b/mRemoteV1/Properties/Settings.settings index e0bf6145..a85dde8a 100644 --- a/mRemoteV1/Properties/Settings.settings +++ b/mRemoteV1/Properties/Settings.settings @@ -516,7 +516,7 @@ False - False + True False diff --git a/mRemoteV1/app.config b/mRemoteV1/app.config index 3d467657..c6191a2b 100644 --- a/mRemoteV1/app.config +++ b/mRemoteV1/app.config @@ -541,7 +541,7 @@ False - False + True False From 0501d73e7bd08e8ad6ae1e7d21e92b51e899f8d2 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Wed, 18 May 2016 17:02:09 -0400 Subject: [PATCH 03/13] Set largeaddressaware during build --- mRemoteV1/mRemoteV1.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mRemoteV1/mRemoteV1.csproj b/mRemoteV1/mRemoteV1.csproj index dbaad0f2..63fc12e6 100644 --- a/mRemoteV1/mRemoteV1.csproj +++ b/mRemoteV1/mRemoteV1.csproj @@ -1213,8 +1213,8 @@ - - + call "$(DevEnvDir)..\tools\vsvars32.bat" +editbin /largeaddressaware $(TargetPath) @@ -109,7 +109,7 @@ - False + True False From 7ed00bb42dc634b6039fe37dd327d0a58a8ed538 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Wed, 18 May 2016 17:26:22 -0400 Subject: [PATCH 05/13] Port from 3G - avoid crash and default icon https://github.com/kmscode/mRemote3G/commit/c917f353526701438f4ab66463778f287db8bf6b --- mRemoteV1/Tools/MiscTools.cs | 85 ++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/mRemoteV1/Tools/MiscTools.cs b/mRemoteV1/Tools/MiscTools.cs index 428e0c3d..c48088e7 100644 --- a/mRemoteV1/Tools/MiscTools.cs +++ b/mRemoteV1/Tools/MiscTools.cs @@ -3,24 +3,18 @@ using mRemoteNG.App; using mRemoteNG.Forms; using mRemoteNG.UI.Window; using System; -using System.Collections.Specialized; using System.ComponentModel; -using System.Data; -using System.Data.SqlClient; using System.Drawing; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.InteropServices; -using System.Text.RegularExpressions; using System.Windows.Forms; -using mRemoteNG.My; -using mRemoteNG.UI.Forms; namespace mRemoteNG.Tools { - public class MiscTools + public class MiscTools { private struct SHFILEINFO { @@ -42,34 +36,41 @@ namespace mRemoteNG.Tools public static Icon GetIconFromFile(string FileName) { - try - { - if (File.Exists(FileName) == false) - { - return null; - } - - IntPtr hImgSmall; //The handle to the system image list. - //Dim hImgLarge As IntPtr 'The handle to the system image list. - SHFILEINFO shinfo = new SHFILEINFO(); - shinfo = new SHFILEINFO(); - - shinfo.szDisplayName = new string('\0', 260); - shinfo.szTypeName = new string('\0', 80); - - //Use this to get the small icon. - hImgSmall = SHGetFileInfo(FileName, 0, ref shinfo, Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_SMALLICON); - - //Use this to get the large icon. - //hImgLarge = SHGetFileInfo(fName, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_LARGEICON); - - //The icon is returned in the hIcon member of the - //shinfo struct. - System.Drawing.Icon myIcon = default(System.Drawing.Icon); - myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon); - - return myIcon; - } + try + { + if (File.Exists(FileName) == false) + { + return null; + } + + IntPtr hImgSmall; //The handle to the system image list. + //Dim hImgLarge As IntPtr 'The handle to the system image list. + SHFILEINFO shinfo = new SHFILEINFO(); + shinfo = new SHFILEINFO(); + + shinfo.szDisplayName = new string('\0', 260); + shinfo.szTypeName = new string('\0', 80); + + //Use this to get the small icon. + hImgSmall = SHGetFileInfo(FileName, 0, ref shinfo, Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_SMALLICON); + + //Use this to get the large icon. + //hImgLarge = SHGetFileInfo(fName, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_LARGEICON); + + //The icon is returned in the hIcon member of the + //shinfo struct. + Icon myIcon = default(Icon); + myIcon = Icon.FromHandle(shinfo.hIcon); + + return myIcon; + } + catch (ArgumentException AEx) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, + "GetIconFromFile failed (Tools.Misc) - using default icon" + Environment.NewLine + AEx.Message, true); + return Resources.mRemote_Icon; + + } catch (Exception ex) { Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "GetIconFromFile failed (Tools.Misc)" + Environment.NewLine + ex.Message, true); @@ -117,11 +118,11 @@ namespace mRemoteNG.Tools public static string DBDate(DateTime Dt) { - string strDate = ""; - strDate = Dt.Year + LeadingZero(Convert.ToString(Dt.Month)) + LeadingZero(Convert.ToString(Dt.Day)) + " " + LeadingZero(Convert.ToString(Dt.Hour)) + ":" + LeadingZero(Convert.ToString(Dt.Minute)) + ":" + LeadingZero(Convert.ToString(Dt.Second)); - return strDate; + var strDate = Dt.Year + LeadingZero(Convert.ToString(Dt.Month)) + LeadingZero(Convert.ToString(Dt.Day)) + " " + LeadingZero(Convert.ToString(Dt.Hour)) + ":" + LeadingZero(Convert.ToString(Dt.Minute)) + ":" + LeadingZero(Convert.ToString(Dt.Second)); + return strDate; } - public static string PrepareForDB(string Text) + + public static string PrepareForDB(string Text) { return ReplaceBooleanStringsWithNumbers(Text); } @@ -179,7 +180,7 @@ namespace mRemoteNG.Tools Size currentFormSize = new Size(LeftWidth, TopHeight); Bitmap ScreenToBitmap = new Bitmap(LeftWidth, TopHeight); - System.Drawing.Graphics gGraphics = System.Drawing.Graphics.FromImage(ScreenToBitmap); + Graphics gGraphics = Graphics.FromImage(ScreenToBitmap); gGraphics.CopyFromScreen(new Point(LeftStart, TopStart), new Point(0, 0), currentFormSize); @@ -301,11 +302,11 @@ namespace mRemoteNG.Tools return true; } - public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) + public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { bool[] bools = new bool[] {true, false}; - TypeConverter.StandardValuesCollection svc = new TypeConverter.StandardValuesCollection(bools); + StandardValuesCollection svc = new StandardValuesCollection(bools); return svc; } From 77cf6202fe5a17a80a03b34129a466c431bd802c Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Wed, 18 May 2016 17:31:30 -0400 Subject: [PATCH 06/13] Port from 3G - Attempt to avoid crash https://github.com/kmscode/mRemote3G/commit/2f99c57eb6fccf32d850a3b7d38bd0a33c7d30bf --- mRemoteV1/UI/Window/ConnectionTreeWindow.cs | 11 +++++++++-- mRemoteV1/UI/Window/ConnectionWindow.cs | 12 ++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs index e0e59ea6..ace1ca3a 100644 --- a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs +++ b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs @@ -798,8 +798,15 @@ namespace mRemoteNG.UI.Window { try { - //clean up - cMenTreeToolsExternalApps.DropDownItems.Clear(); + //clean up + //since new items are added below, we have to dispose of any previous items first + if (cMenTreeToolsExternalApps.DropDownItems.Count > 0) + { + foreach (ToolStripMenuItem mitem in cMenTreeToolsExternalApps.DropDownItems) + mitem.Dispose(); + + cMenTreeToolsExternalApps.DropDownItems.Clear(); + } //add ext apps foreach (Tools.ExternalTool extA in Runtime.ExternalTools) diff --git a/mRemoteV1/UI/Window/ConnectionWindow.cs b/mRemoteV1/UI/Window/ConnectionWindow.cs index 8bc2ef28..09598aa8 100644 --- a/mRemoteV1/UI/Window/ConnectionWindow.cs +++ b/mRemoteV1/UI/Window/ConnectionWindow.cs @@ -969,8 +969,16 @@ namespace mRemoteNG.UI.Window { try { - //clean up - cmenTabExternalApps.DropDownItems.Clear(); + //clean up + //since new items are added below, we have to dispose of any previous items first + if (cmenTabExternalApps.DropDownItems.Count > 0) + { + foreach (ToolStripMenuItem mitem in cmenTabExternalApps.DropDownItems) + mitem.Dispose(); + + cmenTabExternalApps.DropDownItems.Clear(); + } + //add ext apps foreach (Tools.ExternalTool extA in Runtime.ExternalTools) From 00dbbdf453b8d96224322188505be6c6dfa9c3ff Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Wed, 18 May 2016 17:36:41 -0400 Subject: [PATCH 07/13] Port from 3G - Attempt to set a default icon https://github.com/kmscode/mRemote3G/commit/11fdc4fc2813cdad930b2ab2f45d35d0bae00985 --- mRemoteV1/Tools/ExternalTool.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mRemoteV1/Tools/ExternalTool.cs b/mRemoteV1/Tools/ExternalTool.cs index 7db8b3b0..a3f10d72 100644 --- a/mRemoteV1/Tools/ExternalTool.cs +++ b/mRemoteV1/Tools/ExternalTool.cs @@ -40,7 +40,7 @@ namespace mRemoteNG.Tools if (Icon != null) return Icon.ToBitmap(); else - return null; + return Resources.mRemote_Icon.ToBitmap(); } } #endregion From 395741a502d5d17b3f22d32561d1f8552e484471 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Wed, 18 May 2016 21:08:32 -0400 Subject: [PATCH 08/13] Disable optimizations to allow LARGEADDRESSAWARE Reference: https://msdn.microsoft.com/en-us/library/0zza0de8.aspx .obj files produced with /GL will not be available to such linker utilities as EDITBIN and DUMPBIN. --- mRemoteV1/mRemoteV1.csproj | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mRemoteV1/mRemoteV1.csproj b/mRemoteV1/mRemoteV1.csproj index 63fc12e6..c8d91658 100644 --- a/mRemoteV1/mRemoteV1.csproj +++ b/mRemoteV1/mRemoteV1.csproj @@ -54,12 +54,13 @@ 1591,660,661 x86 MinimumRecommendedRules.ruleset + DEBUG pdbonly false true - true + false bin\Release\ @@ -71,7 +72,7 @@ true bin\Release Portable\ - true + false 1591,660,661 pdbonly x86 @@ -89,7 +90,7 @@ x86 DEBUG;PORTABLE MinimumRecommendedRules.ruleset - true + false From 0a88ae6a5274b2d8413a435fcda2f1a1e6956575 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Wed, 18 May 2016 21:15:34 -0400 Subject: [PATCH 09/13] 3G Port - Don't display items in the ToolStripMenu Set disabled items to invisible when they aren't needed. https://github.com/kmscode/mRemote3G/commit/97d82f2b86dd3256bd4c2854e9c6d7ac517b432c --- mRemoteV1/UI/Window/ConnectionWindow.cs | 51 ++++++++++++------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/mRemoteV1/UI/Window/ConnectionWindow.cs b/mRemoteV1/UI/Window/ConnectionWindow.cs index 09598aa8..2f7f3208 100644 --- a/mRemoteV1/UI/Window/ConnectionWindow.cs +++ b/mRemoteV1/UI/Window/ConnectionWindow.cs @@ -9,13 +9,12 @@ using mRemoteNG.Config; using mRemoteNG.Connection.Protocol.VNC; using mRemoteNG.Connection.Protocol.RDP; using mRemoteNG.Connection.Protocol; -using mRemoteNG.My; using mRemoteNG.UI.Forms; using mRemoteNG.UI.TaskDialog; namespace mRemoteNG.UI.Window { - public class ConnectionWindow : BaseWindow + public class ConnectionWindow : BaseWindow { #region Form Init internal ContextMenuStrip cmenTab; @@ -98,9 +97,9 @@ namespace mRemoteNG.UI.Window // //TabController // - TabController.Anchor = (AnchorStyles) (((AnchorStyles.Top | AnchorStyles.Bottom) - | AnchorStyles.Left) - | AnchorStyles.Right); + TabController.Anchor = ((AnchorStyles.Top | AnchorStyles.Bottom) + | AnchorStyles.Left) + | AnchorStyles.Right; TabController.Appearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiDocument; TabController.Cursor = Cursors.Hand; TabController.DragFromControl = false; @@ -241,7 +240,7 @@ namespace mRemoteNG.UI.Window // ClientSize = new Size(632, 453); Controls.Add(TabController); - Font = new Font("Microsoft Sans Serif", (float) (8.25F), FontStyle.Regular, GraphicsUnit.Point, Convert.ToByte(0)); + Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, Convert.ToByte(0)); Icon = Resources.mRemote_Icon; Name = "Connection"; TabText = "UI.Window.Connection"; @@ -272,7 +271,7 @@ namespace mRemoteNG.UI.Window try { Crownwood.Magic.Controls.TabPage nTab = new Crownwood.Magic.Controls.TabPage(); - nTab.Anchor = (AnchorStyles) (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top); + nTab.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; if (Settings.Default.ShowProtocolOnTabs) { @@ -590,27 +589,27 @@ namespace mRemoteNG.UI.Window { ProtocolRDP rdp = (ProtocolRDP)IC.Protocol; - cmenTabFullscreen.Enabled = true; + cmenTabFullscreen.Visible = true; cmenTabFullscreen.Checked = rdp.Fullscreen; - cmenTabSmartSize.Enabled = true; + cmenTabSmartSize.Visible = true; cmenTabSmartSize.Checked = rdp.SmartSize; } else { - cmenTabFullscreen.Enabled = false; - cmenTabSmartSize.Enabled = false; + cmenTabFullscreen.Visible = false; + cmenTabSmartSize.Visible = false; } if (IC.Info.Protocol == ProtocolType.VNC) { - cmenTabSendSpecialKeys.Enabled = true; - cmenTabViewOnly.Enabled = true; + cmenTabSendSpecialKeys.Visible = true; + cmenTabViewOnly.Visible = true; - cmenTabSmartSize.Enabled = true; - cmenTabStartChat.Enabled = true; - cmenTabRefreshScreen.Enabled = true; - cmenTabTransferFile.Enabled = false; + cmenTabSmartSize.Visible = true; + cmenTabStartChat.Visible = true; + cmenTabRefreshScreen.Visible = true; + cmenTabTransferFile.Visible = false; ProtocolVNC vnc = (ProtocolVNC)IC.Protocol; cmenTabSmartSize.Checked = vnc.SmartSize; @@ -618,25 +617,25 @@ namespace mRemoteNG.UI.Window } else { - cmenTabSendSpecialKeys.Enabled = false; - cmenTabViewOnly.Enabled = false; - cmenTabStartChat.Enabled = false; - cmenTabRefreshScreen.Enabled = false; - cmenTabTransferFile.Enabled = false; + cmenTabSendSpecialKeys.Visible = false; + cmenTabViewOnly.Visible = false; + cmenTabStartChat.Visible = false; + cmenTabRefreshScreen.Visible = false; + cmenTabTransferFile.Visible = false; } if (IC.Info.Protocol == ProtocolType.SSH1 | IC.Info.Protocol == ProtocolType.SSH2) { - cmenTabTransferFile.Enabled = true; + cmenTabTransferFile.Visible = true; } if (IC.Protocol is PuttyBase) { - cmenTabPuttySettings.Enabled = true; + cmenTabPuttySettings.Visible = true; } else { - cmenTabPuttySettings.Enabled = false; + cmenTabPuttySettings.Visible = false; } AddExternalApps(); @@ -1225,7 +1224,7 @@ namespace mRemoteNG.UI.Window if (IC.Info.Protocol == ProtocolType.VNC) { - (IC.Protocol as ProtocolVNC).RefreshScreen(); + ((ProtocolVNC)IC.Protocol).RefreshScreen(); } } } From 9d6423e7d7812c1203e2b16a5b1caa7f6c9a7b01 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Wed, 18 May 2016 21:37:05 -0400 Subject: [PATCH 10/13] 3G port (and fix) - Make Smart Size Work Allow the Smart Size selection for RDP resolution to work properly (for reals this time). https://github.com/kmscode/mRemote3G/commit/3f54842cc186a000151575665fd2e87213ec6617 & code clean up. --- .../Protocol/RDP/Connection.Protocol.RDP.cs | 75 +++++++++---------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs b/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs index d5974f0a..f3ff2500 100644 --- a/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs +++ b/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs @@ -9,7 +9,6 @@ using System.Threading; using System.ComponentModel; using mRemoteNG.Messages; using mRemoteNG.App; -using mRemoteNG.My; using MSTSCLib; using mRemoteNG.Tools; using mRemoteNG.UI.Forms; @@ -133,7 +132,7 @@ namespace mRemoteNG.Connection.Protocol.RDP //not user changeable _rdpClient.AdvancedSettings2.GrabFocusOnConnect = true; _rdpClient.AdvancedSettings3.EnableAutoReconnect = true; - _rdpClient.AdvancedSettings3.MaxReconnectAttempts = Convert.ToInt32(mRemoteNG.Settings.Default.RdpReconnectionCount); + _rdpClient.AdvancedSettings3.MaxReconnectAttempts = Convert.ToInt32(Settings.Default.RdpReconnectionCount); _rdpClient.AdvancedSettings2.keepAliveInterval = 60000; //in milliseconds (10.000 = 10 seconds) _rdpClient.AdvancedSettings5.AuthenticationLevel = 0; _rdpClient.AdvancedSettings2.EncryptionEnabled = 1; @@ -199,7 +198,7 @@ namespace mRemoteNG.Connection.Protocol.RDP catch (Exception ex) { Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strRdpDisconnectFailed + Environment.NewLine + ex.Message, true); - base.Close(); + Close(); } } @@ -309,16 +308,8 @@ namespace mRemoteNG.Connection.Protocol.RDP { return ; } - - Size size = new Size(); - if (!Fullscreen) - { - size = Control.Size; - } - else - { - size = Screen.FromControl(Control).Bounds.Size; - } + + var size = !Fullscreen ? Control.Size : Screen.FromControl(Control).Bounds.Size; IMsRdpClient8 msRdpClient8 = _rdpClient; msRdpClient8.Reconnect((uint)size.Width, (uint)size.Height); @@ -426,13 +417,13 @@ namespace mRemoteNG.Connection.Protocol.RDP if (string.IsNullOrEmpty(userName)) { - if (mRemoteNG.Settings.Default.EmptyCredentials == "windows") + if (Settings.Default.EmptyCredentials == "windows") { _rdpClient.UserName = Environment.UserName; } - else if (mRemoteNG.Settings.Default.EmptyCredentials == "custom") + else if (Settings.Default.EmptyCredentials == "custom") { - _rdpClient.UserName = Convert.ToString(mRemoteNG.Settings.Default.DefaultUsername); + _rdpClient.UserName = Convert.ToString(Settings.Default.DefaultUsername); } } else @@ -442,11 +433,11 @@ namespace mRemoteNG.Connection.Protocol.RDP if (string.IsNullOrEmpty(password)) { - if (mRemoteNG.Settings.Default.EmptyCredentials == "custom") + if (Settings.Default.EmptyCredentials == "custom") { - if (mRemoteNG.Settings.Default.DefaultPassword != "") + if (Settings.Default.DefaultPassword != "") { - _rdpClient.AdvancedSettings2.ClearTextPassword = Security.Crypt.Decrypt(Convert.ToString(mRemoteNG.Settings.Default.DefaultPassword), App.Info.GeneralAppInfo.EncryptionKey); + _rdpClient.AdvancedSettings2.ClearTextPassword = Security.Crypt.Decrypt(Convert.ToString(Settings.Default.DefaultPassword), App.Info.GeneralAppInfo.EncryptionKey); } } } @@ -457,13 +448,13 @@ namespace mRemoteNG.Connection.Protocol.RDP if (string.IsNullOrEmpty(domain)) { - if (mRemoteNG.Settings.Default.EmptyCredentials == "windows") + if (Settings.Default.EmptyCredentials == "windows") { _rdpClient.Domain = Environment.UserDomainName; } - else if (mRemoteNG.Settings.Default.EmptyCredentials == "custom") + else if (Settings.Default.EmptyCredentials == "custom") { - _rdpClient.Domain = Convert.ToString(mRemoteNG.Settings.Default.DefaultDomain); + _rdpClient.Domain = Convert.ToString(Settings.Default.DefaultDomain); } } else @@ -494,6 +485,13 @@ namespace mRemoteNG.Connection.Protocol.RDP { _rdpClient.DesktopWidth = InterfaceControl.Size.Width; _rdpClient.DesktopHeight = InterfaceControl.Size.Height; + + if (InterfaceControl.Info.Resolution == RDPResolutions.SmartSize) + { + _rdpClient.AdvancedSettings2.SmartSizing = true; + } + + } else if (InterfaceControl.Info.Resolution == RDPResolutions.Fullscreen) { @@ -639,7 +637,7 @@ namespace mRemoteNG.Connection.Protocol.RDP Event_Disconnected(this, discReason + "\r\n" + reason); } - if (mRemoteNG.Settings.Default.ReconnectOnDisconnect) + if (Settings.Default.ReconnectOnDisconnect) { ReconnectGroup = new ReconnectGroup(); ReconnectGroup.CloseClicked += Event_ReconnectGroupCloseClicked; @@ -833,27 +831,28 @@ namespace mRemoteNG.Connection.Protocol.RDP protected static Hashtable _description; protected static void InitDescription() { - _description = new Hashtable(); - _description.Add("0", "Language.strRdpErrorUnknown"); - _description.Add("1", "Language.strRdpErrorCode1"); - _description.Add("2", "Language.strRdpErrorOutOfMemory"); - _description.Add("3", "Language.strRdpErrorWindowCreation"); - _description.Add("4", "Language.strRdpErrorCode2"); - _description.Add("5", "Language.strRdpErrorCode3"); - _description.Add("6", "Language.strRdpErrorCode4"); - _description.Add("7", "Language.strRdpErrorConnection"); - _description.Add("100", "Language.strRdpErrorWinsock"); + _description = new Hashtable + { + {"0", "Language.strRdpErrorUnknown"}, + {"1", "Language.strRdpErrorCode1"}, + {"2", "Language.strRdpErrorOutOfMemory"}, + {"3", "Language.strRdpErrorWindowCreation"}, + {"4", "Language.strRdpErrorCode2"}, + {"5", "Language.strRdpErrorCode3"}, + {"6", "Language.strRdpErrorCode4"}, + {"7", "Language.strRdpErrorConnection"}, + {"100", "Language.strRdpErrorWinsock"} + }; } public static string GetError(string id) { - if (_description == null) - { - InitDescription(); - } try { - return ((string)_description[id]); + if (_description == null) + InitDescription(); + + return ((string)_description?[id]); } catch (Exception ex) { From 28d882af7f5110de83a2da8f61e441bc20dee969 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Wed, 18 May 2016 21:40:17 -0400 Subject: [PATCH 11/13] 3G port - Added 1920x1080 resolution. https://github.com/kmscode/mRemote3G/commit/5a5c0c1e6b51ae82d6efbad2165de67304903306 --- mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs b/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs index f3ff2500..cf4cd449 100644 --- a/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs +++ b/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs @@ -759,7 +759,8 @@ namespace mRemoteNG.Connection.Protocol.RDP [Description("1600x1280")]Res1600x1280, [Description("1680x1050")]Res1680x1050, [Description("1900x1200")]Res1900x1200, - [Description("1920x1200")]Res1920x1200, + [Description("1920x1080")]Res1920x1080, + [Description("1920x1200")]Res1920x1200, [Description("2048x1536")]Res2048x1536, [Description("2560x2048")]Res2560x2048, [Description("3200x2400")]Res3200x2400, From 46985ab39d0e795824f281100938bba316ccf42f Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Wed, 18 May 2016 21:51:04 -0400 Subject: [PATCH 12/13] code clean up and set RDP admin session properly console is deprecated, admin is not. --- .../Protocol/RDP/Connection.Protocol.RDP.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs b/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs index cf4cd449..251cd9d6 100644 --- a/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs +++ b/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs @@ -388,14 +388,16 @@ namespace mRemoteNG.Connection.Protocol.RDP if (_rdpVersion >= Versions.RDC61) { Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strRdpSetConsoleSwitch, _rdpVersion), true); - //_rdpClient.AdvancedSettings7.ConnectToAdministerServer = value; + _rdpClient.AdvancedSettings7.ConnectToAdministerServer = value; } else { - Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strRdpSetConsoleSwitch, _rdpVersion), true); - _rdpClient.AdvancedSettings2.ConnectToServerConsole = value; - } - } + Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strRdpSetConsoleSwitch, _rdpVersion) + Environment.NewLine + "No longer supported in this RDP version. Reference: https://msdn.microsoft.com/en-us/library/aa380863(v=vs.85).aspx", true); + // ConnectToServerConsole is deprecated + //https://msdn.microsoft.com/en-us/library/aa380863(v=vs.85).aspx + //_rdpClient.AdvancedSettings2.ConnectToServerConsole = value; + } + } catch (Exception ex) { Runtime.MessageCollector.AddExceptionMessage(Language.strRdpSetConsoleSessionFailed, ex, MessageClass.ErrorMsg, true); From a792c98630328fa2d1c06815323acddd612841d5 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Wed, 18 May 2016 21:56:39 -0400 Subject: [PATCH 13/13] 3G port-Avoid exceptions starting an empty ExtApp Reference: https://github.com/kmscode/mRemote3G/issues/10 In my testing the crash was semi-random. The exception was thrown, logged and put into Notifications (all as expected). But every now and then, would crash (with no further info available). Could not reproduce in a debug build. https://github.com/kmscode/mRemote3G/commit/b2488494281e2da466c623750c766ad7712f5326 --- mRemoteV1/Tools/ExternalTool.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mRemoteV1/Tools/ExternalTool.cs b/mRemoteV1/Tools/ExternalTool.cs index a3f10d72..aab38af9 100644 --- a/mRemoteV1/Tools/ExternalTool.cs +++ b/mRemoteV1/Tools/ExternalTool.cs @@ -56,8 +56,11 @@ namespace mRemoteNG.Tools { try { - if (string.IsNullOrEmpty(FileName)) - throw (new InvalidOperationException("FileName cannot be blank.")); + if (string.IsNullOrEmpty(FileName)) + { + Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "ExternalApp.Start() failed: FileName cannot be blank.", false); + return; + } ConnectionInfo = startConnectionInfo;