From b3dfe07915dc37618881d348130a7b3c0cd5c59d Mon Sep 17 00:00:00 2001 From: ryanbodrug-microsoft <56318517+ryanbodrug-microsoft@users.noreply.github.com> Date: Mon, 31 Aug 2020 17:25:31 -0700 Subject: [PATCH] Fixes for CA2101 Specify marshaling for P/Invoke string arguments. --- .../Components/InteropAndHelpers.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/InteropAndHelpers.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/InteropAndHelpers.cs index 5005b8496..aee4461ca 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/InteropAndHelpers.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/InteropAndHelpers.cs @@ -853,10 +853,10 @@ namespace Microsoft.Plugin.WindowWalker.Components public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); [DllImport("psapi.dll")] - public static extern uint GetProcessImageFileName(IntPtr hProcess, [Out] StringBuilder lpImageFileName, [In][MarshalAs(UnmanagedType.U4)] int nSize); + public static extern uint GetProcessImageFileName(IntPtr hProcess, [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpImageFileName, [In][MarshalAs(UnmanagedType.U4)] int nSize); [DllImport("user32.dll", SetLastError = true)] - public static extern IntPtr GetProp(IntPtr hWnd, string lpString); + public static extern IntPtr GetProp(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] string lpString); [DllImport("kernel32.dll")] public static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId); @@ -871,7 +871,7 @@ namespace Microsoft.Plugin.WindowWalker.Components public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out int pvAttribute, int cbAttribute); [DllImport("user32.dll")] - public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount); + public static extern int GetClassName(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpClassName, int nMaxCount); [DllImport("user32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)]