diff --git a/Greenshot/Helpers/EnvironmentInfo.cs b/Greenshot/Helpers/EnvironmentInfo.cs
index 443fe3321..4aa2e9bf7 100644
--- a/Greenshot/Helpers/EnvironmentInfo.cs
+++ b/Greenshot/Helpers/EnvironmentInfo.cs
@@ -645,6 +645,7 @@ namespace Greenshot.Helpers
#region GET
#region PRODUCT INFO
[DllImport("Kernel32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool GetProductInfo(
int osMajorVersion,
int osMinorVersion,
@@ -654,7 +655,8 @@ namespace Greenshot.Helpers
#endregion PRODUCT INFO
#region VERSION
- [DllImport("kernel32.dll")]
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ [return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetVersionEx(ref OSVERSIONINFOEX osVersionInfo);
#endregion VERSION
#endregion GET
diff --git a/GreenshotPlugin/Core/CredentialsHelper.cs b/GreenshotPlugin/Core/CredentialsHelper.cs
index 539ab244a..5c9474b55 100644
--- a/GreenshotPlugin/Core/CredentialsHelper.cs
+++ b/GreenshotPlugin/Core/CredentialsHelper.cs
@@ -59,6 +59,7 @@ namespace GreenshotPlugin.Core {
/// Encapsulates dialog functionality from the Credential Management API.
public sealed class CredentialsDialog {
[DllImport("gdi32.dll", SetLastError=true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
private static extern bool DeleteObject(IntPtr hObject);
/// The only valid bitmap height (in pixels) of a user-defined banner.
@@ -602,6 +603,6 @@ namespace GreenshotPlugin.Core {
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/creduiconfirmcredentials.asp
///
[DllImport("credui.dll", CharSet=CharSet.Unicode)]
- public static extern ReturnCodes CredUIConfirmCredentials(string targetName, bool confirm);
+ public static extern ReturnCodes CredUIConfirmCredentials(string targetName, [MarshalAs(UnmanagedType.Bool)] bool confirm);
}
}
\ No newline at end of file
diff --git a/GreenshotPlugin/Core/WindowCapture.cs b/GreenshotPlugin/Core/WindowCapture.cs
index 733aa12f0..a85792162 100644
--- a/GreenshotPlugin/Core/WindowCapture.cs
+++ b/GreenshotPlugin/Core/WindowCapture.cs
@@ -423,6 +423,7 @@ namespace GreenshotPlugin.Core {
///
///
[DllImport("gdi32", SetLastError = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
private static extern bool DeleteObject(IntPtr hObject);
private WindowCapture() {
diff --git a/GreenshotPlugin/UnmanagedHelpers/GDI32.cs b/GreenshotPlugin/UnmanagedHelpers/GDI32.cs
index 2d12a4a81..f3e2aff3e 100644
--- a/GreenshotPlugin/UnmanagedHelpers/GDI32.cs
+++ b/GreenshotPlugin/UnmanagedHelpers/GDI32.cs
@@ -62,6 +62,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
///
public abstract class SafeObjectHandle : SafeHandleZeroOrMinusOneIsInvalid {
[DllImport("gdi32", SetLastError = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
private static extern bool DeleteObject(IntPtr hObject);
protected SafeObjectHandle(bool ownsHandle) : base(ownsHandle) {
@@ -149,7 +150,8 @@ namespace GreenshotPlugin.UnmanagedHelpers {
///
public class SafeCompatibleDCHandle : SafeDCHandle {
[DllImport("gdi32", SetLastError = true)]
- private static extern bool DeleteDC(IntPtr hDC);
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool DeleteDC(IntPtr hDC);
[SecurityCritical]
private SafeCompatibleDCHandle() : base(true) {
diff --git a/GreenshotPlugin/UnmanagedHelpers/Kernel32.cs b/GreenshotPlugin/UnmanagedHelpers/Kernel32.cs
index 677e1a0f4..c2b347b06 100644
--- a/GreenshotPlugin/UnmanagedHelpers/Kernel32.cs
+++ b/GreenshotPlugin/UnmanagedHelpers/Kernel32.cs
@@ -58,12 +58,14 @@ namespace GreenshotPlugin.UnmanagedHelpers {
[DllImport("kernel32", SetLastError = true)]
public static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, bool bInheritHandle, int dwProcessId);
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)]
+ [return: MarshalAs(UnmanagedType.Bool)]
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);
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern IntPtr GetModuleHandle(string lpModuleName);
[DllImport("kernel32", SetLastError = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CloseHandle(IntPtr hObject);
///
diff --git a/GreenshotPlugin/UnmanagedHelpers/Shell32.cs b/GreenshotPlugin/UnmanagedHelpers/Shell32.cs
index 945c3b292..e74d38310 100644
--- a/GreenshotPlugin/UnmanagedHelpers/Shell32.cs
+++ b/GreenshotPlugin/UnmanagedHelpers/Shell32.cs
@@ -49,12 +49,12 @@ namespace GreenshotPlugin.UnmanagedHelpers {
public SHITEMID mkid;
}
- [StructLayout(LayoutKind.Sequential)]
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
private struct BROWSEINFO {
public IntPtr hwndOwner;
public IntPtr pidlRoot;
public IntPtr pszDisplayName;
- [MarshalAs(UnmanagedType.LPTStr)]
+ [MarshalAs(UnmanagedType.LPWStr)]
public string lpszTitle;
public uint ulFlags;
public IntPtr lpfn;
diff --git a/GreenshotPlugin/UnmanagedHelpers/User32.cs b/GreenshotPlugin/UnmanagedHelpers/User32.cs
index 416a38823..b3335a204 100644
--- a/GreenshotPlugin/UnmanagedHelpers/User32.cs
+++ b/GreenshotPlugin/UnmanagedHelpers/User32.cs
@@ -104,14 +104,14 @@ namespace GreenshotPlugin.UnmanagedHelpers {
public extern static bool IsZoomed(IntPtr hwnd);
[DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)]
public extern static int GetClassName (IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
- [DllImport("user32", SetLastError = true)]
+ [DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern uint GetClassLong(IntPtr hWnd, int nIndex);
[DllImport("user32", SetLastError = true, EntryPoint = "GetClassLongPtr")]
public static extern IntPtr GetClassLongPtr(IntPtr hWnd, int nIndex);
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool PrintWindow(IntPtr hwnd, IntPtr hDC, uint nFlags);
- [DllImport("user32", SetLastError=true)]
+ [DllImport("user32", CharSet=CharSet.Unicode, SetLastError=true)]
public extern static IntPtr SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, IntPtr lParam);
[DllImport("user32", SetLastError = true)]
public extern static IntPtr SendMessage(IntPtr hWnd, uint wMsg, IntPtr wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
@@ -119,7 +119,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
public extern static int GetWindowLong(IntPtr hwnd, int index);
[DllImport("user32", SetLastError = true, EntryPoint = "GetWindowLongPtr")]
public extern static IntPtr GetWindowLongPtr(IntPtr hwnd, int nIndex);
- [DllImport("user32", SetLastError = true)]
+ [DllImport("user32", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int SetWindowLong(IntPtr hWnd, int index, int styleFlags);
[DllImport("user32", SetLastError = true, EntryPoint = "SetWindowLongPtr")]
public static extern IntPtr SetWindowLongPtr(IntPtr hWnd, int index, IntPtr styleFlags);
@@ -139,9 +139,9 @@ namespace GreenshotPlugin.UnmanagedHelpers {
public static extern bool GetScrollInfo(IntPtr hwnd, int fnBar, ref SCROLLINFO lpsi);
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool ShowScrollBar(IntPtr hwnd, ScrollBarDirection scrollBar, bool show);
+ public static extern bool ShowScrollBar(IntPtr hwnd, ScrollBarDirection scrollBar, [MarshalAs(UnmanagedType.Bool)] bool show);
[DllImport("user32", SetLastError = true)]
- public static extern int SetScrollPos(IntPtr hWnd, Orientation nBar, int nPos, bool bRedraw);
+ public static extern int SetScrollPos(IntPtr hWnd, Orientation nBar, int nPos, [MarshalAs(UnmanagedType.Bool)] bool bRedraw);
[DllImport("user32", SetLastError = true)]
public static extern RegionResult GetWindowRgn(IntPtr hWnd, SafeHandle hRgn);
[DllImport("user32", SetLastError = true)]