diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index 5e91d2147..2561b9691 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -270,6 +270,9 @@ namespace Greenshot { return; } + // BUG-1809: Add message filter, to filter out all the InputLangChanged messages which go to a target control with a handle > 32 bit. + Application.AddMessageFilter(new WmInputLangChangeRequestFilter()); + // From here on we continue starting Greenshot Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); diff --git a/Greenshot/Helpers/EnvironmentInfo.cs b/Greenshot/Helpers/EnvironmentInfo.cs index 941f1eba0..443fe3321 100644 --- a/Greenshot/Helpers/EnvironmentInfo.cs +++ b/Greenshot/Helpers/EnvironmentInfo.cs @@ -18,30 +18,33 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + using System; using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; - -using GreenshotPlugin.UnmanagedHelpers; -using GreenshotPlugin.Core; using Greenshot.IniFile; -using Greenshot.Drawing; +using GreenshotPlugin.UnmanagedHelpers; using log4net; -namespace Greenshot.Helpers { +namespace Greenshot.Helpers +{ /// /// Description of EnvironmentInfo. /// - public static class EnvironmentInfo { + public static class EnvironmentInfo + { private static readonly ILog LOG = LogManager.GetLogger(typeof(EnvironmentInfo)); private static bool? isWindows = null; - public static bool IsWindows { - get { - if (isWindows.HasValue) { + public static bool IsWindows + { + get + { + if (isWindows.HasValue) + { return isWindows.Value; } isWindows = Environment.OSVersion.Platform.ToString().StartsWith("Win"); @@ -49,75 +52,104 @@ namespace Greenshot.Helpers { } } - public static bool IsNet45OrNewer() { + public static bool IsNet45OrNewer() + { // Class "ReflectionContext" exists from .NET 4.5 onwards. return Type.GetType("System.Reflection.ReflectionContext", false) != null; } - public static string EnvironmentToString(bool newline) { + public static string EnvironmentToString(bool newline) + { StringBuilder environment = new StringBuilder(); environment.Append("Software version: " + Application.ProductVersion); if (IniConfig.IsPortable) { - environment.Append(" Portable"); + environment.Append(" Portable"); } environment.Append(" (" + OSInfo.Bits + " bit)"); - if (newline) { + if (newline) + { environment.AppendLine(); - } else { + } + else + { environment.Append(", "); } environment.Append(".NET runtime version: " + Environment.Version); - if (IsNet45OrNewer()) { + if (IsNet45OrNewer()) + { environment.Append("+"); } - if (newline) { + if (newline) + { environment.AppendLine(); - } else { + } + else + { environment.Append(", "); } environment.Append("Time: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss zzz")); - if (IsWindows) { - if (newline) { + if (IsWindows) + { + if (newline) + { environment.AppendLine(); - } else { + } + else + { environment.Append(", "); } environment.Append(String.Format("OS: {0} {1} {2} (x{3}) {4}", OSInfo.Name, OSInfo.Edition, OSInfo.ServicePack, OSInfo.Bits, OSInfo.VersionString)); - if (newline) { + if (newline) + { environment.AppendLine(); - } else { + } + else + { environment.Append(", "); } // Get some important information for fixing GDI related Problems - environment.Append("GDI object count: " + User32.GetGuiResourcesGDICount()); - if (newline) { + environment.AppendFormat("GDI object count: {0}", User32.GetGuiResourcesGDICount()); + if (newline) + { environment.AppendLine(); - } else { + } + else + { environment.Append(", "); } - environment.Append("User object count: " + User32.GetGuiResourcesUserCount()); - } else { - if (newline) { - environment.AppendLine(); - } else { - environment.Append(", "); - } - environment.Append("OS: " + Environment.OSVersion.Platform.ToString()); + environment.AppendFormat("User object count: {0}", User32.GetGuiResourcesUserCount()); } - if (newline) { + else + { + if (newline) + { + environment.AppendLine(); + } + else + { + environment.Append(", "); + } + environment.AppendFormat("OS: {0}", Environment.OSVersion.Platform); + } + if (newline) + { environment.AppendLine(); - } else { + } + else + { environment.Append(", "); } - environment.Append("Surface count: " + Surface.Count); + // TODO: Is this needed? + // environment.AppendFormat("Surface count: {0}", Surface.Count); return environment.ToString(); } - public static string ExceptionToString(Exception ex) { + public static string ExceptionToString(Exception ex) + { if (ex == null) return "null\r\n"; @@ -125,44 +157,54 @@ namespace Greenshot.Helpers { report.AppendLine("Exception: " + ex.GetType().ToString()); report.AppendLine("Message: " + ex.Message); - if (ex.Data != null && ex.Data.Count > 0) { + if (ex.Data != null && ex.Data.Count > 0) + { report.AppendLine(); report.AppendLine("Additional Information:"); - foreach (object key in ex.Data.Keys) { + foreach (object key in ex.Data.Keys) + { object data = ex.Data[key]; - if (data != null) { + if (data != null) + { report.AppendLine(key + " : " + data); } } } - if (ex is ExternalException) { + if (ex is ExternalException) + { // e.g. COMException report.AppendLine().AppendLine("ErrorCode: 0x" + (ex as ExternalException).ErrorCode.ToString("X")); } report.AppendLine().AppendLine("Stack:").AppendLine(ex.StackTrace); - if (ex is ReflectionTypeLoadException) { + if (ex is ReflectionTypeLoadException) + { report.AppendLine().AppendLine("LoaderExceptions: "); - foreach (Exception cbE in (ex as ReflectionTypeLoadException).LoaderExceptions) { + foreach (Exception cbE in (ex as ReflectionTypeLoadException).LoaderExceptions) + { report.AppendLine(cbE.Message); } } - if (ex.InnerException != null) { + if (ex.InnerException != null) + { report.AppendLine("--- InnerException: ---"); report.AppendLine(ExceptionToString(ex.InnerException)); } return report.ToString(); } - public static string BuildReport(Exception exception) { + public static string BuildReport(Exception exception) + { StringBuilder exceptionText = new StringBuilder(); exceptionText.AppendLine(EnvironmentToString(true)); exceptionText.AppendLine(ExceptionToString(exception)); exceptionText.AppendLine("Configuration dump:"); - using (TextWriter writer = new StringWriter(exceptionText)) { - IniConfig.GetIniSection().Write(writer, true); + using (TextWriter writer = new StringWriter(exceptionText)) + { + // TODO: Create summary of properties + //var iniConfig = IniConfig.Current.WriteToStreamAsync(); } return exceptionText.ToString(); @@ -173,13 +215,16 @@ namespace Greenshot.Helpers { /// Provides detailed information about the host operating system. /// Code is available at: http://www.csharp411.com/determine-windows-version-and-edition-with-c/ /// - static public class OSInfo { + static public class OSInfo + { #region BITS /// /// Determines if the current application is 32 or 64-bit. /// - static public int Bits { - get { + static public int Bits + { + get + { return IntPtr.Size * 8; } } @@ -190,9 +235,12 @@ namespace Greenshot.Helpers { /// /// Gets the edition of the operating system running on this computer. /// - static public string Edition { - get { - if (s_Edition != null) { + static public string Edition + { + get + { + if (s_Edition != null) + { return s_Edition; //***** RETURN *****// } @@ -202,22 +250,30 @@ namespace Greenshot.Helpers { OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX(); osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX)); - if (GetVersionEx(ref osVersionInfo)) { + if (GetVersionEx(ref osVersionInfo)) + { int majorVersion = osVersion.Version.Major; int minorVersion = osVersion.Version.Minor; byte productType = osVersionInfo.wProductType; short suiteMask = osVersionInfo.wSuiteMask; #region VERSION 4 - if (majorVersion == 4) { - if (productType == VER_NT_WORKSTATION) { + if (majorVersion == 4) + { + if (productType == VER_NT_WORKSTATION) + { // Windows NT 4.0 Workstation edition = "Workstation"; - } else if (productType == VER_NT_SERVER) { - if ((suiteMask & VER_SUITE_ENTERPRISE) != 0) { + } + else if (productType == VER_NT_SERVER) + { + if ((suiteMask & VER_SUITE_ENTERPRISE) != 0) + { // Windows NT 4.0 Server Enterprise edition = "Enterprise Server"; - } else { + } + else + { // Windows NT 4.0 Server edition = "Standard Server"; } @@ -226,38 +282,60 @@ namespace Greenshot.Helpers { #endregion VERSION 4 #region VERSION 5 - else if (majorVersion == 5) { - if (productType == VER_NT_WORKSTATION) { - if ((suiteMask & VER_SUITE_PERSONAL) != 0) { + else if (majorVersion == 5) + { + if (productType == VER_NT_WORKSTATION) + { + if ((suiteMask & VER_SUITE_PERSONAL) != 0) + { // Windows XP Home Edition edition = "Home"; - } else { + } + else + { // Windows XP / Windows 2000 Professional edition = "Professional"; } - } else if (productType == VER_NT_SERVER) { - if (minorVersion == 0) { - if ((suiteMask & VER_SUITE_DATACENTER) != 0) { + } + else if (productType == VER_NT_SERVER) + { + if (minorVersion == 0) + { + if ((suiteMask & VER_SUITE_DATACENTER) != 0) + { // Windows 2000 Datacenter Server edition = "Datacenter Server"; - } else if ((suiteMask & VER_SUITE_ENTERPRISE) != 0) { + } + else if ((suiteMask & VER_SUITE_ENTERPRISE) != 0) + { // Windows 2000 Advanced Server edition = "Advanced Server"; - } else { + } + else + { // Windows 2000 Server edition = "Server"; } - } else { - if ((suiteMask & VER_SUITE_DATACENTER) != 0) { + } + else + { + if ((suiteMask & VER_SUITE_DATACENTER) != 0) + { // Windows Server 2003 Datacenter Edition edition = "Datacenter"; - } else if ((suiteMask & VER_SUITE_ENTERPRISE) != 0) { + } + else if ((suiteMask & VER_SUITE_ENTERPRISE) != 0) + { // Windows Server 2003 Enterprise Edition edition = "Enterprise"; - } else if ((suiteMask & VER_SUITE_BLADE) != 0) { + } + else if ((suiteMask & VER_SUITE_BLADE) != 0) + { // Windows Server 2003 Web Edition edition = "Web Edition"; - } else { + } + else + { // Windows Server 2003 Standard Edition edition = "Standard"; } @@ -267,10 +345,13 @@ namespace Greenshot.Helpers { #endregion VERSION 5 #region VERSION 6 - else if (majorVersion == 6) { + else if (majorVersion == 6) + { int ed; - if (GetProductInfo(majorVersion, minorVersion, osVersionInfo.wServicePackMajor, osVersionInfo.wServicePackMinor, out ed)) { - switch (ed) { + if (GetProductInfo(majorVersion, minorVersion, osVersionInfo.wServicePackMajor, osVersionInfo.wServicePackMinor, out ed)) + { + switch (ed) + { case PRODUCT_BUSINESS: edition = "Business"; break; @@ -399,9 +480,12 @@ namespace Greenshot.Helpers { /// /// Gets the name of the operating system running on this computer. /// - static public string Name { - get { - if (s_Name != null) { + static public string Name + { + get + { + if (s_Name != null) + { return s_Name; //***** RETURN *****// } @@ -411,27 +495,37 @@ namespace Greenshot.Helpers { OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX(); osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX)); - if (GetVersionEx(ref osVersionInfo)) { + if (GetVersionEx(ref osVersionInfo)) + { int majorVersion = osVersion.Version.Major; int minorVersion = osVersion.Version.Minor; byte productType = osVersionInfo.wProductType; short suiteMask = osVersionInfo.wSuiteMask; - switch (osVersion.Platform) { + switch (osVersion.Platform) + { case PlatformID.Win32Windows: - if (majorVersion == 4) { + if (majorVersion == 4) + { string csdVersion = osVersionInfo.szCSDVersion; - switch (minorVersion) { + switch (minorVersion) + { case 0: - if (csdVersion == "B" || csdVersion == "C") { + if (csdVersion == "B" || csdVersion == "C") + { name = "Windows 95 OSR2"; - } else { + } + else + { name = "Windows 95"; } break; case 10: - if (csdVersion == "A") { + if (csdVersion == "A") + { name = "Windows 98 Second Edition"; - } else { + } + else + { name = "Windows 98"; } break; @@ -442,12 +536,14 @@ namespace Greenshot.Helpers { } break; case PlatformID.Win32NT: - switch (majorVersion) { + switch (majorVersion) + { case 3: name = "Windows NT 3.51"; break; case 4: - switch (productType) { + switch (productType) + { case 1: name = "Windows NT 4.0"; break; @@ -457,12 +553,14 @@ namespace Greenshot.Helpers { } break; case 5: - switch (minorVersion) { + switch (minorVersion) + { case 0: name = "Windows 2000"; break; case 1: - switch (suiteMask) { + switch (suiteMask) + { case 0x0200: name = "Windows XP Professional"; break; @@ -472,7 +570,8 @@ namespace Greenshot.Helpers { } break; case 2: - switch (suiteMask) { + switch (suiteMask) + { case 0x0200: name = "Windows XP Professional x64"; break; @@ -496,9 +595,11 @@ namespace Greenshot.Helpers { } break; case 6: - switch (minorVersion) { + switch (minorVersion) + { case 0: - switch (productType) { + switch (productType) + { case 3: name = "Windows Server 2008"; break; @@ -508,7 +609,8 @@ namespace Greenshot.Helpers { } break; case 1: - switch (productType) { + switch (productType) + { case 3: name = "Windows Server 2008 R2"; break; @@ -520,8 +622,14 @@ namespace Greenshot.Helpers { case 2: name = "Windows 8"; break; + case 3: + name = "Windows 8.1"; + break; } break; + case 10: + name = "Windows 10"; + break; } break; } @@ -553,7 +661,8 @@ namespace Greenshot.Helpers { #region OSVERSIONINFOEX [StructLayout(LayoutKind.Sequential)] - private struct OSVERSIONINFOEX { + private struct OSVERSIONINFOEX + { public int dwOSVersionInfoSize; public int dwMajorVersion; public int dwMinorVersion; @@ -629,14 +738,17 @@ namespace Greenshot.Helpers { /// /// Gets the service pack information of the operating system running on this computer. /// - static public string ServicePack { - get { + static public string ServicePack + { + get + { string servicePack = String.Empty; OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX(); osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX)); - if (GetVersionEx(ref osVersionInfo)) { + if (GetVersionEx(ref osVersionInfo)) + { servicePack = osVersionInfo.szCSDVersion; } @@ -650,8 +762,10 @@ namespace Greenshot.Helpers { /// /// Gets the build version number of the operating system running on this computer. /// - public static int BuildVersion { - get { + public static int BuildVersion + { + get + { return Environment.OSVersion.Version.Build; } } @@ -662,8 +776,10 @@ namespace Greenshot.Helpers { /// /// Gets the full version string of the operating system running on this computer. /// - static public string VersionString { - get { + static public string VersionString + { + get + { return string.Format("{0}.{1} build {3} revision {2:X}", Environment.OSVersion.Version.Major, Environment.OSVersion.Version.Minor, Environment.OSVersion.Version.Revision, Environment.OSVersion.Version.Build); } } @@ -673,8 +789,10 @@ namespace Greenshot.Helpers { /// /// Gets the full version of the operating system running on this computer. /// - static public Version Version { - get { + static public Version Version + { + get + { return Environment.OSVersion.Version; } } @@ -685,8 +803,10 @@ namespace Greenshot.Helpers { /// /// Gets the major version number of the operating system running on this computer. /// - static public int MajorVersion { - get { + static public int MajorVersion + { + get + { return Environment.OSVersion.Version.Major; } } @@ -696,8 +816,10 @@ namespace Greenshot.Helpers { /// /// Gets the minor version number of the operating system running on this computer. /// - static public int MinorVersion { - get { + static public int MinorVersion + { + get + { return Environment.OSVersion.Version.Minor; } } @@ -707,12 +829,14 @@ namespace Greenshot.Helpers { /// /// Gets the revision version number of the operating system running on this computer. /// - static public int RevisionVersion { - get { + static public int RevisionVersion + { + get + { return Environment.OSVersion.Version.Revision; } } #endregion REVISION #endregion VERSION } -} +} \ No newline at end of file diff --git a/Greenshot/greenshot.manifest b/Greenshot/greenshot.manifest index 58a12a1a1..919fcb895 100644 --- a/Greenshot/greenshot.manifest +++ b/Greenshot/greenshot.manifest @@ -9,14 +9,16 @@ - - - - - - - + + + + + + + + + diff --git a/Greenshot/releases/additional_files/readme.txt.template b/Greenshot/releases/additional_files/readme.txt.template index e0129e8b4..e99adfc57 100644 --- a/Greenshot/releases/additional_files/readme.txt.template +++ b/Greenshot/releases/additional_files/readme.txt.template @@ -9,6 +9,13 @@ All details to our tickets can be found here: https://greenshot.atlassian.net @DETAILVERSION@ +Bugs Resolved: +* BUG-1809: OverflowException when changing the windows input language +* BUG-1835: Imgur uploads were cancelled due to a timeout which was set too small + + +1.2.6.7-359dcf3 RELEASE + Bugs Resolved: * BUG-1769: Switched to OAuth 2 for Picasa Authentication, OAuth 1.x will be terminated as of 20th of April 2015. * BUG-1770: Fix problems when a font doesn't want to draw itself. diff --git a/GreenshotPlugin/Core/CoreConfiguration.cs b/GreenshotPlugin/Core/CoreConfiguration.cs index 60f2021ee..b5bff9abb 100644 --- a/GreenshotPlugin/Core/CoreConfiguration.cs +++ b/GreenshotPlugin/Core/CoreConfiguration.cs @@ -291,7 +291,7 @@ namespace GreenshotPlugin.Core { } } - [IniProperty("WebRequestTimeout", Description = "The connect timeout value for webrequets, these are seconds", DefaultValue = "10")] + [IniProperty("WebRequestTimeout", Description = "The connect timeout value for webrequets, these are seconds", DefaultValue = "100")] public int WebRequestTimeout; [IniProperty("WebRequestReadWriteTimeout", Description = "The read/write timeout value for webrequets, these are seconds", DefaultValue = "100")] public int WebRequestReadWriteTimeout; @@ -509,8 +509,8 @@ namespace GreenshotPlugin.Core { OutputFileReduceColorsTo = 256; } - if (WebRequestTimeout < 1) { - WebRequestTimeout = 10; + if (WebRequestTimeout <= 10) { + WebRequestTimeout = 100; } if (WebRequestReadWriteTimeout < 1) { WebRequestReadWriteTimeout = 100; diff --git a/GreenshotPlugin/Core/WmInputLangChangeRequestFilter.cs b/GreenshotPlugin/Core/WmInputLangChangeRequestFilter.cs new file mode 100644 index 000000000..74c48788e --- /dev/null +++ b/GreenshotPlugin/Core/WmInputLangChangeRequestFilter.cs @@ -0,0 +1,43 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +using GreenshotPlugin.UnmanagedHelpers; +using System.Windows.Forms; + +namespace GreenshotPlugin.Core +{ + /// + /// This IMessageFilter filters out all WM_INPUTLANGCHANGEREQUEST messages which go to a handle which is >32 bits. + /// The need for this is documented here: http://stackoverflow.com/a/32021586 + /// Unfortunately there is an error in the code example, should use HWnd instead of LParam for the handle. + /// + public class WmInputLangChangeRequestFilter : IMessageFilter + { + public bool PreFilterMessage(ref Message m) + { + if (m.Msg == (int)WindowsMessages.WM_INPUTLANGCHANGEREQUEST || m.Msg == (int)WindowsMessages.WM_INPUTLANGCHANGE) + { + return m.HWnd.ToInt64() > 0x7FFFFFFF; + } + return false; + } + } +} \ No newline at end of file diff --git a/GreenshotPlugin/GreenshotPlugin.csproj b/GreenshotPlugin/GreenshotPlugin.csproj index c7a6740af..e9c313f6f 100644 --- a/GreenshotPlugin/GreenshotPlugin.csproj +++ b/GreenshotPlugin/GreenshotPlugin.csproj @@ -37,6 +37,7 @@ +