From aad04bc9d7d13149874ce06fdc61d2e346f74cec Mon Sep 17 00:00:00 2001 From: RKrom Date: Fri, 20 Jun 2014 17:29:27 +0200 Subject: [PATCH] Fixes for CharSet marshaling, this caused problems with the IE Capturing. --- Greenshot/Helpers/CopyData.cs | 2 +- GreenshotPlugin/Controls/HotkeyControl.cs | 2 +- GreenshotPlugin/Core/CredentialsHelper.cs | 4 ++-- GreenshotPlugin/UnmanagedHelpers/GDIplus.cs | 10 +++++----- GreenshotPlugin/UnmanagedHelpers/Kernel32.cs | 2 +- GreenshotPlugin/UnmanagedHelpers/PsAPI.cs | 2 +- GreenshotPlugin/UnmanagedHelpers/User32.cs | 10 +++++----- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Greenshot/Helpers/CopyData.cs b/Greenshot/Helpers/CopyData.cs index d1d00e805..7a2243daf 100644 --- a/Greenshot/Helpers/CopyData.cs +++ b/Greenshot/Helpers/CopyData.cs @@ -362,7 +362,7 @@ namespace Greenshot.Helpers { /// public class CopyDataChannel : IDisposable { #region Unmanaged Code - [DllImport("user32", CharSet=CharSet.Unicode, SetLastError = true)] + [DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)] private extern static IntPtr GetProp(IntPtr hwnd, string lpString); [DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)] private extern static bool SetProp(IntPtr hwnd, string lpString, IntPtr hData); diff --git a/GreenshotPlugin/Controls/HotkeyControl.cs b/GreenshotPlugin/Controls/HotkeyControl.cs index 122f58c29..624c896b3 100644 --- a/GreenshotPlugin/Controls/HotkeyControl.cs +++ b/GreenshotPlugin/Controls/HotkeyControl.cs @@ -84,7 +84,7 @@ namespace GreenshotPlugin.Controls { [DllImport("user32.dll", SetLastError = true)] private static extern uint MapVirtualKey(uint uCode, uint uMapType); - [DllImport("user32.dll", EntryPoint = "GetKeyNameTextW", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] private static extern int GetKeyNameText(uint lParam, [Out] StringBuilder lpString, int nSize); // These variables store the current hotkey and modifier(s) diff --git a/GreenshotPlugin/Core/CredentialsHelper.cs b/GreenshotPlugin/Core/CredentialsHelper.cs index 2bf6e8c15..6a4fc7195 100644 --- a/GreenshotPlugin/Core/CredentialsHelper.cs +++ b/GreenshotPlugin/Core/CredentialsHelper.cs @@ -583,7 +583,7 @@ namespace GreenshotPlugin.Core { /// http://www.pinvoke.net/default.aspx/credui.CredUIPromptForCredentialsW /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/creduipromptforcredentials.asp /// - [DllImport("credui", EntryPoint="CredUIPromptForCredentialsW", CharSet=CharSet.Unicode)] + [DllImport("credui", CharSet=CharSet.Unicode)] public static extern ReturnCodes PromptForCredentials( ref INFO creditUR, string targetName, @@ -601,7 +601,7 @@ namespace GreenshotPlugin.Core { /// http://www.pinvoke.net/default.aspx/credui.CredUIConfirmCredentials /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/creduiconfirmcredentials.asp /// - [DllImport("credui.dll", EntryPoint="CredUIConfirmCredentialsW", CharSet=CharSet.Unicode)] + [DllImport("credui.dll", CharSet=CharSet.Unicode)] public static extern ReturnCodes ConfirmCredentials(string targetName, bool confirm); } } \ No newline at end of file diff --git a/GreenshotPlugin/UnmanagedHelpers/GDIplus.cs b/GreenshotPlugin/UnmanagedHelpers/GDIplus.cs index a3beafc08..664f19d6a 100644 --- a/GreenshotPlugin/UnmanagedHelpers/GDIplus.cs +++ b/GreenshotPlugin/UnmanagedHelpers/GDIplus.cs @@ -96,16 +96,16 @@ namespace GreenshotPlugin.UnmanagedHelpers { public static class GDIplus { private static ILog LOG = LogManager.GetLogger(typeof(GDIplus)); - [DllImport("gdiplus.dll", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + [DllImport("gdiplus.dll", SetLastError = true, ExactSpelling = true)] private static extern int GdipBitmapApplyEffect(IntPtr bitmap, IntPtr effect, ref RECT rectOfInterest, bool useAuxData, IntPtr auxData, int auxDataSize); - [DllImport("gdiplus.dll", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + [DllImport("gdiplus.dll", SetLastError = true, ExactSpelling = true)] private static extern int GdipDrawImageFX(IntPtr graphics, IntPtr bitmap, ref RECTF source, IntPtr matrix, IntPtr effect, IntPtr imageAttributes, GpUnit srcUnit); - [DllImport("gdiplus.dll", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + [DllImport("gdiplus.dll", SetLastError = true, ExactSpelling = true)] private static extern int GdipSetEffectParameters(IntPtr effect, IntPtr parameters, uint size); - [DllImport("gdiplus.dll", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + [DllImport("gdiplus.dll", SetLastError = true, ExactSpelling = true)] private static extern int GdipCreateEffect(Guid guid, out IntPtr effect); - [DllImport("gdiplus.dll", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] + [DllImport("gdiplus.dll", SetLastError = true, ExactSpelling = true)] private static extern int GdipDeleteEffect(IntPtr effect); private static Guid BlurEffectGuid = new Guid("{633C80A4-1843-482B-9EF2-BE2834C5FDD4}"); diff --git a/GreenshotPlugin/UnmanagedHelpers/Kernel32.cs b/GreenshotPlugin/UnmanagedHelpers/Kernel32.cs index 37a20ced1..19fd64f8b 100644 --- a/GreenshotPlugin/UnmanagedHelpers/Kernel32.cs +++ b/GreenshotPlugin/UnmanagedHelpers/Kernel32.cs @@ -57,7 +57,7 @@ namespace GreenshotPlugin.UnmanagedHelpers { public static extern int ResumeThread(IntPtr hThread); [DllImport("kernel32", SetLastError = true)] public static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, bool bInheritHandle, int dwProcessId); - [DllImport("kernel32", SetLastError = true, CharSet=CharSet.Unicode)] + [DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)] public static extern bool QueryFullProcessImageName(IntPtr hProcess, uint dwFlags, StringBuilder lpExeName, ref uint lpdwSize); [DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)] public static extern uint QueryDosDevice(string lpDeviceName, StringBuilder lpTargetPath, uint uuchMax); diff --git a/GreenshotPlugin/UnmanagedHelpers/PsAPI.cs b/GreenshotPlugin/UnmanagedHelpers/PsAPI.cs index 9ffc8db3f..054af61dd 100644 --- a/GreenshotPlugin/UnmanagedHelpers/PsAPI.cs +++ b/GreenshotPlugin/UnmanagedHelpers/PsAPI.cs @@ -30,7 +30,7 @@ namespace GreenshotPlugin.UnmanagedHelpers { /// public class PsAPI { private static readonly ILog LOG = LogManager.GetLogger(typeof(PsAPI)); - [DllImport("psapi", SetLastError = true, CharSet=CharSet.Unicode)] + [DllImport("psapi", SetLastError = true, CharSet = CharSet.Unicode)] public static extern uint GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, StringBuilder lpFilename, uint nSize); [DllImport("psapi", SetLastError = true, CharSet = CharSet.Unicode)] public static extern uint GetProcessImageFileName(IntPtr hProcess, StringBuilder lpImageFileName, uint nSize); diff --git a/GreenshotPlugin/UnmanagedHelpers/User32.cs b/GreenshotPlugin/UnmanagedHelpers/User32.cs index 5730b9db9..e378ff1ec 100644 --- a/GreenshotPlugin/UnmanagedHelpers/User32.cs +++ b/GreenshotPlugin/UnmanagedHelpers/User32.cs @@ -71,7 +71,7 @@ namespace GreenshotPlugin.UnmanagedHelpers { public static extern int ShowWindow(IntPtr hWnd, ShowWindowCommand nCmdShow); [DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)] public extern static int GetWindowText(IntPtr hWnd, StringBuilder lpString, int cch); - [DllImport("user32", CharSet = CharSet.Auto, SetLastError = true)] + [DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)] public extern static int GetWindowTextLength(IntPtr hWnd); [DllImport("user32", SetLastError = true)] public static extern uint GetSysColor(int nIndex); @@ -137,7 +137,7 @@ namespace GreenshotPlugin.UnmanagedHelpers { public static extern bool ShowScrollBar(IntPtr hwnd, ScrollBarDirection scrollBar, bool show); [DllImport("user32", SetLastError = true)] public static extern int SetScrollPos(IntPtr hWnd, Orientation nBar, int nPos, bool bRedraw); - [DllImport("user32", SetLastError=true, EntryPoint = "PostMessageA")] + [DllImport("user32", SetLastError=true)] public static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam); [DllImport("user32", SetLastError = true)] public static extern RegionResult GetWindowRgn(IntPtr hWnd, SafeHandle hRgn); @@ -157,7 +157,7 @@ namespace GreenshotPlugin.UnmanagedHelpers { public static extern IntPtr GetClipboardOwner(); [DllImport("user32", SetLastError = true)] public static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer); - [DllImport("user32", SetLastError = true, CharSet = CharSet.Auto)] + [DllImport("user32", SetLastError = true)] public static extern bool ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext); // Added for WinEventHook logic, Greenshot 1.2 @@ -181,9 +181,9 @@ namespace GreenshotPlugin.UnmanagedHelpers { /// [DllImport("user32", SetLastError = true)] public static extern uint GetGuiResources(IntPtr hProcess, uint uiFlags); - [DllImport("user32", EntryPoint = "RegisterWindowMessageA", SetLastError = true, CharSet = CharSet.Unicode)] + [DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)] public static extern uint RegisterWindowMessage(string lpString); - [DllImport("user32", SetLastError=true, CharSet=CharSet.Auto)] + [DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)] public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam, SendMessageTimeoutFlags fuFlags, uint uTimeout, out UIntPtr lpdwResult); [DllImport("user32", SetLastError = true)] public static extern bool GetPhysicalCursorPos(out POINT cursorLocation);