<PackageReference Include="System.Text.Encoding.CodePages" Version="4.4.0" />

SafeAllocHHandle

sealed class SafeAllocHHandle : SafeBuffer
using System; using System.Runtime.InteropServices; using System.Security; namespace Microsoft.Win32.SafeHandles { [SecurityCritical] internal sealed class SafeAllocHHandle : SafeBuffer { internal static SafeAllocHHandle InvalidHandle => new SafeAllocHHandle(IntPtr.Zero); private SafeAllocHHandle() : base(true) { } internal SafeAllocHHandle(IntPtr handle) : base(true) { SetHandle(handle); } [SecurityCritical] protected override bool ReleaseHandle() { if (handle != IntPtr.Zero) Marshal.FreeHGlobal(handle); return true; } } }