From 459e14f224ad4cff9aade471bbbc2345e91f1e2e Mon Sep 17 00:00:00 2001 From: dahall Date: Sun, 27 Feb 2022 14:46:01 -0700 Subject: [PATCH] Fixed WINHTTP_CURRENT_USER_IE_PROXY_CONFIG so it exposed pointers which can be freed. --- PInvoke/WinHTTP/WinHTTP.Structs.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/PInvoke/WinHTTP/WinHTTP.Structs.cs b/PInvoke/WinHTTP/WinHTTP.Structs.cs index 9e5767b1..7c45a2ee 100644 --- a/PInvoke/WinHTTP/WinHTTP.Structs.cs +++ b/PInvoke/WinHTTP/WinHTTP.Structs.cs @@ -536,25 +536,32 @@ namespace Vanara.PInvoke /// /// If TRUE, indicates that the Internet Explorer proxy configuration for the current user specifies "automatically detect settings". /// - [MarshalAs(UnmanagedType.Bool)] public bool fAutoDetect; + [MarshalAs(UnmanagedType.Bool)] + public bool fAutoDetect; /// /// Pointer to a null-terminated Unicode string that contains the auto-configuration URL if the Internet Explorer proxy /// configuration for the current user specifies "Use automatic proxy configuration". /// - [MarshalAs(UnmanagedType.LPWStr)] - public string lpszAutoConfigUrl; + public StrPtrUni lpszAutoConfigUrl; /// /// Pointer to a null-terminated Unicode string that contains the proxy URL if the Internet Explorer proxy configuration for the /// current user specifies "use a proxy server". /// - [MarshalAs(UnmanagedType.LPWStr)] - public string lpszProxy; + public StrPtrUni lpszProxy; /// Pointer to a null-terminated Unicode string that contains the optional proxy by-pass server list. - [MarshalAs(UnmanagedType.LPWStr)] - public string lpszProxyBypass; + public StrPtrUni lpszProxyBypass; + + /// Frees the memory tied to the strings in this structure. + public void FreeMemory() + { + Marshal.FreeHGlobal((IntPtr)lpszAutoConfigUrl); + Marshal.FreeHGlobal((IntPtr)lpszProxy); + Marshal.FreeHGlobal((IntPtr)lpszProxyBypass); + lpszAutoConfigUrl = lpszProxy = lpszProxyBypass = default; + } } /// Represents an HTTP request header as a name/value string pair.