diff --git a/PInvoke/ComCtl32/CommCtrl.ImageList.cs b/PInvoke/ComCtl32/CommCtrl.ImageList.cs index 5b06eeff..c710c734 100644 --- a/PInvoke/ComCtl32/CommCtrl.ImageList.cs +++ b/PInvoke/ComCtl32/CommCtrl.ImageList.cs @@ -1557,7 +1557,7 @@ namespace Vanara.PInvoke /// /// Safe image list handle. Be aware that if this is instantiated with ownership of the handle, it will be destroyed on disposal. /// - public class SafeHIMAGELIST : HANDLE + public class SafeHIMAGELIST : SafeHANDLE { private IImageList iImageList; diff --git a/PInvoke/ComCtl32/CommCtrl.PropSheet.cs b/PInvoke/ComCtl32/CommCtrl.PropSheet.cs index 4892d9bc..5673976c 100644 --- a/PInvoke/ComCtl32/CommCtrl.PropSheet.cs +++ b/PInvoke/ComCtl32/CommCtrl.PropSheet.cs @@ -920,7 +920,7 @@ namespace Vanara.PInvoke } /// Provides a to a that releases a created HPROPSHEETPAGE instance at disposal using DestroyPropertySheetPage. - public class SafeHPROPSHEETPAGE : HANDLE + public class SafeHPROPSHEETPAGE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/ComCtl32/dpa_dsa.cs b/PInvoke/ComCtl32/dpa_dsa.cs index 4fd7f8aa..68c65294 100644 --- a/PInvoke/ComCtl32/dpa_dsa.cs +++ b/PInvoke/ComCtl32/dpa_dsa.cs @@ -1404,7 +1404,7 @@ namespace Vanara.PInvoke } /// Provides a to a that releases a created HDPA instance at disposal using DPA_Destroy. - public class SafeHDPA : HANDLE + public class SafeHDPA : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -1425,7 +1425,7 @@ namespace Vanara.PInvoke } /// Provides a to a that releases a created HDSA instance at disposal using DSA_Destroy. - public class SafeHDSA : HANDLE + public class SafeHDSA : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/Cryptography/BCrypt/BCrypt.cs b/PInvoke/Cryptography/BCrypt/BCrypt.cs index 293f4b93..b9324a1d 100644 --- a/PInvoke/Cryptography/BCrypt/BCrypt.cs +++ b/PInvoke/Cryptography/BCrypt/BCrypt.cs @@ -9818,7 +9818,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeBCRYPT_ALG_HANDLE : HANDLE + public class SafeBCRYPT_ALG_HANDLE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -9845,7 +9845,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeBCRYPT_HASH_HANDLE : HANDLE + public class SafeBCRYPT_HASH_HANDLE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -9867,7 +9867,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeBCRYPT_KEY_HANDLE : HANDLE + public class SafeBCRYPT_KEY_HANDLE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -9889,7 +9889,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeBCRYPT_SECRET_HANDLE : HANDLE + public class SafeBCRYPT_SECRET_HANDLE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -9911,7 +9911,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeBCryptBuffer : HANDLE + public class SafeBCryptBuffer : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/Cryptography/NCrypt/NCrypt.cs b/PInvoke/Cryptography/NCrypt/NCrypt.cs index 757190bc..5bf7a031 100644 --- a/PInvoke/Cryptography/NCrypt/NCrypt.cs +++ b/PInvoke/Cryptography/NCrypt/NCrypt.cs @@ -3182,7 +3182,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeNCRYPT_KEY_HANDLE : HANDLE + public class SafeNCRYPT_KEY_HANDLE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -3209,7 +3209,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeNCRYPT_PROV_HANDLE : HANDLE + public class SafeNCRYPT_PROV_HANDLE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -3236,7 +3236,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeNCRYPT_SECRET_HANDLE : HANDLE + public class SafeNCRYPT_SECRET_HANDLE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/Cryptography/NCrypt/NCryptProtect.cs b/PInvoke/Cryptography/NCrypt/NCryptProtect.cs index f3a65744..46c03c15 100644 --- a/PInvoke/Cryptography/NCrypt/NCryptProtect.cs +++ b/PInvoke/Cryptography/NCrypt/NCryptProtect.cs @@ -1444,7 +1444,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeNCRYPT_DESCRIPTOR_HANDLE : HANDLE + public class SafeNCRYPT_DESCRIPTOR_HANDLE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -1466,7 +1466,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeNCRYPT_STREAM_HANDLE : HANDLE + public class SafeNCRYPT_STREAM_HANDLE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/Gdi32/WinGdi.Metafile.cs b/PInvoke/Gdi32/WinGdi.Metafile.cs index 70ea7ca3..f4227e7e 100644 --- a/PInvoke/Gdi32/WinGdi.Metafile.cs +++ b/PInvoke/Gdi32/WinGdi.Metafile.cs @@ -136,7 +136,7 @@ namespace Vanara.PInvoke public static extern SafeHENHMETAFILE GetEnhMetaFile(string lpName); /// Provides a for that is disposed using . - public class SafeHENHMETAFILE : HANDLE + public class SafeHENHMETAFILE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/Gdi32/WinGdi.SafeDCHandles.cs b/PInvoke/Gdi32/WinGdi.SafeDCHandles.cs index bfa79e76..9cd9417a 100644 --- a/PInvoke/Gdi32/WinGdi.SafeDCHandles.cs +++ b/PInvoke/Gdi32/WinGdi.SafeDCHandles.cs @@ -56,7 +56,7 @@ namespace Vanara.PInvoke /// /// Provides a to a graphics bitmap object that releases a created HBITMAP instance at disposal using DeleteObject. /// - public class SafeHBITMAP : HANDLE + public class SafeHBITMAP : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -84,7 +84,7 @@ namespace Vanara.PInvoke /// /// Provides a to a graphics bitmap object that releases a created HBRUSH instance at disposal using DeleteObject. /// - public class SafeHBRUSH : HANDLE + public class SafeHBRUSH : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -110,7 +110,7 @@ namespace Vanara.PInvoke } /// A SafeHandle to track DC handles. - public class SafeHDC : HANDLE + public class SafeHDC : SafeHANDLE { private readonly IDeviceContext idc; @@ -173,7 +173,7 @@ namespace Vanara.PInvoke /// /// Provides a to a graphics bitmap object that releases a created HFONT instance at disposal using DeleteObject. /// - public class SafeHFONT : HANDLE + public class SafeHFONT : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -202,7 +202,7 @@ namespace Vanara.PInvoke /// Provides a to a graphics color palette object that releases a created HPALETTE instance at disposal /// using DeleteObject. /// - public class SafeHPALETTE : HANDLE + public class SafeHPALETTE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -230,7 +230,7 @@ namespace Vanara.PInvoke /// /// Provides a to a graphics bitmap object that releases a created HPEN instance at disposal using DeleteObject. /// - public class SafeHPEN : HANDLE + public class SafeHPEN : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -258,7 +258,7 @@ namespace Vanara.PInvoke /// /// Provides a to a graphics bitmap object that releases a created HRGN instance at disposal using DeleteObject. /// - public class SafeHRGN : HANDLE + public class SafeHRGN : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/Kernel32/FileApi.cs b/PInvoke/Kernel32/FileApi.cs index 8f7a8faf..3de0e541 100644 --- a/PInvoke/Kernel32/FileApi.cs +++ b/PInvoke/Kernel32/FileApi.cs @@ -3963,7 +3963,7 @@ namespace Vanara.PInvoke /// FindFirstFileNameTransactedW, FindFirstFileTransacted, FindFirstStreamTransactedW, or FindFirstStreamW functions. /// /// - public class SafeSearchHandle : HANDLE + public class SafeSearchHandle : SafeHANDLE { /// Initializes a new instance of the class. /// The handle. @@ -3977,7 +3977,7 @@ namespace Vanara.PInvoke /// Represents a self-closing volume search handle opened by the FindFirstVolume. /// - public class SafeVolumeSearchHandle : HANDLE + public class SafeVolumeSearchHandle : SafeHANDLE { /// Initializes a new instance of the class. /// The handle. diff --git a/PInvoke/Kernel32/HandleApi.cs b/PInvoke/Kernel32/HandleApi.cs index 96b3852d..95fa00b3 100644 --- a/PInvoke/Kernel32/HandleApi.cs +++ b/PInvoke/Kernel32/HandleApi.cs @@ -246,12 +246,12 @@ namespace Vanara.PInvoke public static extern bool SetHandleInformation([In] IntPtr hObject, HANDLE_FLAG dwMask, HANDLE_FLAG dwFlags); /// Provides a to a handle that releases a created HANDLE instance at disposal using CloseHandle. - public abstract class SafeKernelHandle : HANDLE, IKernelHandle + public abstract class SafeKernelHandle : SafeHANDLE, IKernelHandle { /// Initializes a new instance of the class. protected SafeKernelHandle() : base() { } - /// Initializes a new instance of the class and assigns an existing handle. + /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. /// to reliably release the handle during the finalization phase; otherwise, (not recommended). protected SafeKernelHandle(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } diff --git a/PInvoke/Kernel32/HeapApi.cs b/PInvoke/Kernel32/HeapApi.cs index 675342b9..a75cce67 100644 --- a/PInvoke/Kernel32/HeapApi.cs +++ b/PInvoke/Kernel32/HeapApi.cs @@ -1078,7 +1078,7 @@ namespace Vanara.PInvoke } /// Provides a handle to a heap. - public class HHEAP : HANDLE + public class HHEAP : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/Kernel32/LibLoaderApi.cs b/PInvoke/Kernel32/LibLoaderApi.cs index d2a343ff..72d25129 100644 --- a/PInvoke/Kernel32/LibLoaderApi.cs +++ b/PInvoke/Kernel32/LibLoaderApi.cs @@ -1910,7 +1910,7 @@ namespace Vanara.PInvoke /// Provides a to a that releases a created HINSTANCE instance at disposal using FreeLibrary. [PInvokeData("LibLoaderAPI.h")] - public class SafeHINSTANCE : HANDLE + public class SafeHINSTANCE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -1948,7 +1948,7 @@ namespace Vanara.PInvoke /// Represents a loaded resource handle. /// - public class SafeResourceDataHandle : HANDLE + public class SafeResourceDataHandle : SafeHANDLE { private IntPtr bptr; @@ -1965,7 +1965,7 @@ namespace Vanara.PInvoke /// Represents a resource data block handle. /// - public class SafeResourceHandle : HANDLE + public class SafeResourceHandle : SafeHANDLE { /// Initializes a new instance of the class. public SafeResourceHandle() : base() { } diff --git a/PInvoke/Kernel32/MemoryApi.cs b/PInvoke/Kernel32/MemoryApi.cs index 821b623b..26563773 100644 --- a/PInvoke/Kernel32/MemoryApi.cs +++ b/PInvoke/Kernel32/MemoryApi.cs @@ -2711,7 +2711,7 @@ namespace Vanara.PInvoke // ParameterCount ); [DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)] [PInvokeData("memoryapi.h", MSDNShortId = "5021062F-E414-49A1-8B70-BE2A57A90E54")] - public static extern IntPtr VirtualAlloc2(HANDLE Process, IntPtr BaseAddress, SizeT Size, MEM_ALLOCATION_TYPE AllocationType, MEM_PROTECTION PageProtection, MEM_EXTENDED_PARAMETER[] ExtendedParameters, uint ParameterCount); + public static extern IntPtr VirtualAlloc2(SafeHANDLE Process, IntPtr BaseAddress, SizeT Size, MEM_ALLOCATION_TYPE AllocationType, MEM_PROTECTION PageProtection, MEM_EXTENDED_PARAMETER[] ExtendedParameters, uint ParameterCount); /// /// @@ -2952,7 +2952,7 @@ namespace Vanara.PInvoke // *ExtendedParameters, ULONG ParameterCount ); [DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)] [PInvokeData("memoryapi.h", MSDNShortId = "84896A75-A917-4CA1-A417-650428E1FBFD")] - public static extern IntPtr VirtualAlloc2FromApp(HANDLE Process, IntPtr BaseAddress, SizeT Size, MEM_ALLOCATION_TYPE AllocationType, MEM_PROTECTION PageProtection, MEM_EXTENDED_PARAMETER[] ExtendedParameters, uint ParameterCount); + public static extern IntPtr VirtualAlloc2FromApp(SafeHANDLE Process, IntPtr BaseAddress, SizeT Size, MEM_ALLOCATION_TYPE AllocationType, MEM_PROTECTION PageProtection, MEM_EXTENDED_PARAMETER[] ExtendedParameters, uint ParameterCount); /// /// diff --git a/PInvoke/Kernel32/NameSpaceApi.cs b/PInvoke/Kernel32/NameSpaceApi.cs index af2337ad..7ce928c9 100644 --- a/PInvoke/Kernel32/NameSpaceApi.cs +++ b/PInvoke/Kernel32/NameSpaceApi.cs @@ -234,7 +234,7 @@ namespace Vanara.PInvoke /// Provides a to a boundary descriptor that releases a created BoundaryDescriptorHandle instance at /// disposal using DeleteBoundaryDescriptor. /// - public class SafeBoundaryDescriptorHandle : HANDLE + public class SafeBoundaryDescriptorHandle : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -256,7 +256,7 @@ namespace Vanara.PInvoke } /// Provides a to a that releases a created NamespaceHandle instance at disposal using CloseHandle. - public class SafeNamespaceHandle : HANDLE + public class SafeNamespaceHandle : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/Kernel32/SynchApi.cs b/PInvoke/Kernel32/SynchApi.cs index 374493a4..8e0a98da 100644 --- a/PInvoke/Kernel32/SynchApi.cs +++ b/PInvoke/Kernel32/SynchApi.cs @@ -2239,7 +2239,7 @@ namespace Vanara.PInvoke /// /// Provides a to a wait handle created by RegisterWaitForSingleObject and closed on disposal by UnregisterWaitEx. /// - public class SafeRegisteredWaitHandle : HANDLE + public class SafeRegisteredWaitHandle : SafeHANDLE { private static readonly SafeEventHandle invalidEvent = new SafeEventHandle(new IntPtr(-1), false); diff --git a/PInvoke/Kernel32/ThreadPoolLegacyApiSet.cs b/PInvoke/Kernel32/ThreadPoolLegacyApiSet.cs index 161b6da5..9fc39d5e 100644 --- a/PInvoke/Kernel32/ThreadPoolLegacyApiSet.cs +++ b/PInvoke/Kernel32/ThreadPoolLegacyApiSet.cs @@ -559,7 +559,7 @@ namespace Vanara.PInvoke /// /// Provides a to a timer queue that releases a created TimerQueueHandle instance at disposal using CloseHandle. /// - public class SafeTimerQueueHandle : HANDLE + public class SafeTimerQueueHandle : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -583,7 +583,7 @@ namespace Vanara.PInvoke /// Provides a to a timer queue timer that releases a created TimerQueueTimerHandle instance at disposal /// using DeleteTimerQueueTimer. /// - public class SafeTimerQueueTimerHandle : HANDLE + public class SafeTimerQueueTimerHandle : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/Kernel32/WinBase.App.cs b/PInvoke/Kernel32/WinBase.App.cs index f659ab0b..60312008 100644 --- a/PInvoke/Kernel32/WinBase.App.cs +++ b/PInvoke/Kernel32/WinBase.App.cs @@ -1078,7 +1078,7 @@ namespace Vanara.PInvoke } /// Provides a to an account context that releases a created HACTCTX instance at disposal using ReleaseActCtx. - public class SafeHACTCTX : HANDLE + public class SafeHACTCTX : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/Kernel32/WinBase.File.cs b/PInvoke/Kernel32/WinBase.File.cs index 5de7ba1f..68552396 100644 --- a/PInvoke/Kernel32/WinBase.File.cs +++ b/PInvoke/Kernel32/WinBase.File.cs @@ -3799,7 +3799,7 @@ namespace Vanara.PInvoke } /// Represents a search handle used in a subsequent call to the FindNextVolumeMountPoint and retrieved by FindFirstVolumeMountPoint. - public class SafeVolumeMountPointHandle : HANDLE + public class SafeVolumeMountPointHandle : SafeHANDLE { /// Initializes a new instance of the class. /// The handle. diff --git a/PInvoke/Kernel32/WinBase.cs b/PInvoke/Kernel32/WinBase.cs index f275a32d..ec58c6d0 100644 --- a/PInvoke/Kernel32/WinBase.cs +++ b/PInvoke/Kernel32/WinBase.cs @@ -7648,7 +7648,7 @@ namespace Vanara.PInvoke /// /// Provides a to a UMS completion list that releases a created UmsCompletionList instance at disposal using DeleteUmsCompletionList. /// - public class SafePUMS_COMPLETION_LIST : HANDLE + public class SafePUMS_COMPLETION_LIST : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -7667,7 +7667,7 @@ namespace Vanara.PInvoke /// /// Provides a to a UMS thread context that releases a created UmsThreadContext instance at disposal using DeleteUmsThreadContext. /// - public class SafePUMS_CONTEXT : HANDLE + public class SafePUMS_CONTEXT : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/Mpr/Winnetwk.cs b/PInvoke/Mpr/Winnetwk.cs index 19c20870..5db21ea5 100644 --- a/PInvoke/Mpr/Winnetwk.cs +++ b/PInvoke/Mpr/Winnetwk.cs @@ -3256,7 +3256,7 @@ namespace Vanara.PInvoke } /// Provides a to a WNet enumeration that releases a created WNetEnumHandle instance at disposal using WNetCloseEnum. - public class SafeWNetEnumHandle : HANDLE + public class SafeWNetEnumHandle : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/NTDSApi/NTDSAPI.cs b/PInvoke/NTDSApi/NTDSAPI.cs index 5088a30d..ce08f976 100644 --- a/PInvoke/NTDSApi/NTDSAPI.cs +++ b/PInvoke/NTDSApi/NTDSAPI.cs @@ -5144,7 +5144,7 @@ namespace Vanara.PInvoke } /// Provides a to an authentication identity that releases its handle at disposal using DsFreePasswordCredentials. - public class SafeAuthIdentityHandle : HANDLE + public class SafeAuthIdentityHandle : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -5191,7 +5191,7 @@ namespace Vanara.PInvoke /// [SuppressUnmanagedCodeSecurity, ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] [PInvokeData("NTDSApi.h")] - public class SafeDsHandle : HANDLE + public class SafeDsHandle : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -5248,7 +5248,7 @@ namespace Vanara.PInvoke /// A for the results from . [PInvokeData("NTDSApi.h")] - public class SafeDsReplicaInfo : HANDLE + public class SafeDsReplicaInfo : SafeHANDLE { internal SafeDsReplicaInfo() { diff --git a/PInvoke/NTDll/NTDll.cs b/PInvoke/NTDll/NTDll.cs index c53464ef..be4d146b 100644 --- a/PInvoke/NTDll/NTDll.cs +++ b/PInvoke/NTDll/NTDll.cs @@ -4135,7 +4135,7 @@ namespace Vanara.PInvoke } /// Provides a to an object that releases a created handle at disposal using NtClose. - public abstract class SafeNtHandle : HANDLE + public abstract class SafeNtHandle : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/NetApi32/DsGetDC.cs b/PInvoke/NetApi32/DsGetDC.cs index 04f963dc..3f3b45d3 100644 --- a/PInvoke/NetApi32/DsGetDC.cs +++ b/PInvoke/NetApi32/DsGetDC.cs @@ -1277,7 +1277,7 @@ namespace Vanara.PInvoke /// /// Provides a to a domain controller enumeration handle that is released at disposal using DsGetDcClose. /// - public class SafeDCEnumHandle : HANDLE + public class SafeDCEnumHandle : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/NetApi32/DsRole.cs b/PInvoke/NetApi32/DsRole.cs index 068674eb..8b398912 100644 --- a/PInvoke/NetApi32/DsRole.cs +++ b/PInvoke/NetApi32/DsRole.cs @@ -296,7 +296,7 @@ namespace Vanara.PInvoke } /// Provides a to a buffer that releases a created handle at disposal using DsRoleFreeMemory. - public class SafeDcRoleBuffer : HANDLE + public class SafeDcRoleBuffer : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/NetApi32/Lm.cs b/PInvoke/NetApi32/Lm.cs index 3dbf3429..521c73c2 100644 --- a/PInvoke/NetApi32/Lm.cs +++ b/PInvoke/NetApi32/Lm.cs @@ -2317,7 +2317,7 @@ namespace Vanara.PInvoke } /// Provides a to a buffer that releases a created handle at disposal using NetApiBufferFree. - public class SafeNetApiBuffer : HANDLE + public class SafeNetApiBuffer : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/Ole/OleAut32/OleAuto.SAFEARRAY.cs b/PInvoke/Ole/OleAut32/OleAuto.SAFEARRAY.cs index 9488c457..4444efd2 100644 --- a/PInvoke/Ole/OleAut32/OleAuto.SAFEARRAY.cs +++ b/PInvoke/Ole/OleAut32/OleAuto.SAFEARRAY.cs @@ -1445,7 +1445,7 @@ namespace Vanara.PInvoke } /// Provides a to a safe array that releases a created SAFEARRAY instance at disposal using SafeArrayDestroy. - public class SafeSAFEARRAY : HANDLE + public class SafeSAFEARRAY : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/Security/AdvApi32/NTSecApi.cs b/PInvoke/Security/AdvApi32/NTSecApi.cs index f46dc97a..cf7e7c58 100644 --- a/PInvoke/Security/AdvApi32/NTSecApi.cs +++ b/PInvoke/Security/AdvApi32/NTSecApi.cs @@ -1852,7 +1852,7 @@ namespace Vanara.PInvoke /// /// Provides a to a LSA handle that releases a created LSA_HANDLE instance at disposal using LsaClose. /// - public class SafeLSA_HANDLE : HANDLE + public class SafeLSA_HANDLE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -1876,7 +1876,7 @@ namespace Vanara.PInvoke /// /// Provides a to a LSA memory handle that releases a created LsaMemoryHandle instance at disposal using LsaFreeMemory. /// - public class SafeLsaMemoryHandle : HANDLE + public class SafeLsaMemoryHandle : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -1893,7 +1893,7 @@ namespace Vanara.PInvoke } /// A for values that must be freed using the function. - public sealed class SafeLsaReturnBufferHandle : HANDLE + public sealed class SafeLsaReturnBufferHandle : SafeHANDLE { /// Initializes a new instance of the class. /// The pointer to the memory allocated by an Lsa function. diff --git a/PInvoke/Security/AdvApi32/SecurityBaseApi.SID.cs b/PInvoke/Security/AdvApi32/SecurityBaseApi.SID.cs index a80b0565..49a823e6 100644 --- a/PInvoke/Security/AdvApi32/SecurityBaseApi.SID.cs +++ b/PInvoke/Security/AdvApi32/SecurityBaseApi.SID.cs @@ -187,7 +187,7 @@ namespace Vanara.PInvoke public static extern bool IsValidSid(PSID pSid); /// Provides a to an allocated SID that is released at disposal using FreeSid. - public class SafeAllocatedSID : HANDLE, ISecurityObject + public class SafeAllocatedSID : SafeHANDLE, ISecurityObject { /// Initializes a new instance of the class. private SafeAllocatedSID() : base() { } diff --git a/PInvoke/Security/AdvApi32/WinSvc.cs b/PInvoke/Security/AdvApi32/WinSvc.cs index aa0b8ec3..f590fb31 100644 --- a/PInvoke/Security/AdvApi32/WinSvc.cs +++ b/PInvoke/Security/AdvApi32/WinSvc.cs @@ -2880,7 +2880,7 @@ namespace Vanara.PInvoke } /// Provides a to a service that releases a created SC_HANDLE instance at disposal using CloseServiceHandle. - public class SafeSC_HANDLE : HANDLE + public class SafeSC_HANDLE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/Security/Authz/Authz.cs b/PInvoke/Security/Authz/Authz.cs index 8ea45f02..02954fda 100644 --- a/PInvoke/Security/Authz/Authz.cs +++ b/PInvoke/Security/Authz/Authz.cs @@ -1751,7 +1751,7 @@ namespace Vanara.PInvoke /// Provides a to a check results value that releases a created AUTHZ_ACCESS_CHECK_RESULTS_HANDLE instance /// at disposal using AuthzFreeHandle. /// - public class SafeAUTHZ_ACCESS_CHECK_RESULTS_HANDLE : HANDLE + public class SafeAUTHZ_ACCESS_CHECK_RESULTS_HANDLE : SafeHANDLE { /// /// Initializes a new instance of the class and assigns an existing handle. @@ -1777,7 +1777,7 @@ namespace Vanara.PInvoke /// /// Provides a to an audit event that releases a created AUTHZ_AUDIT_EVENT_HANDLE instance at disposal using AuthzFreeAuditEvent. /// - public class SafeAUTHZ_AUDIT_EVENT_HANDLE : HANDLE + public class SafeAUTHZ_AUDIT_EVENT_HANDLE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -1799,7 +1799,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeAUTHZ_CLIENT_CONTEXT_HANDLE : HANDLE + public class SafeAUTHZ_CLIENT_CONTEXT_HANDLE : SafeHANDLE { /// /// Initializes a new instance of the class and assigns an existing handle. @@ -1825,7 +1825,7 @@ namespace Vanara.PInvoke /// /// Provides a for that is disposed using . /// - public class SafeAUTHZ_RESOURCE_MANAGER_HANDLE : HANDLE + public class SafeAUTHZ_RESOURCE_MANAGER_HANDLE : SafeHANDLE { /// /// Initializes a new instance of the class and assigns an existing handle. diff --git a/PInvoke/Security/Secur32/NTSecApi.cs b/PInvoke/Security/Secur32/NTSecApi.cs index 095bca6c..4842cd0c 100644 --- a/PInvoke/Security/Secur32/NTSecApi.cs +++ b/PInvoke/Security/Secur32/NTSecApi.cs @@ -151,7 +151,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeLsaConnectionHandle : HANDLE + public class SafeLsaConnectionHandle : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/Security/Secur32/Sspi.cs b/PInvoke/Security/Secur32/Sspi.cs index 9c4d1410..69ff5dad 100644 --- a/PInvoke/Security/Secur32/Sspi.cs +++ b/PInvoke/Security/Secur32/Sspi.cs @@ -461,7 +461,7 @@ namespace Vanara.PInvoke /// /// Provides a for that is disposed using . /// - public class SafePSEC_WINNT_AUTH_IDENTITY_OPAQUE : HANDLE + public class SafePSEC_WINNT_AUTH_IDENTITY_OPAQUE : SafeHANDLE { /// /// Initializes a new instance of the class and assigns an existing handle. diff --git a/PInvoke/Shared/Handles.cs b/PInvoke/Shared/Handles.cs index 7ba73d71..b99dae81 100644 --- a/PInvoke/Shared/Handles.cs +++ b/PInvoke/Shared/Handles.cs @@ -1883,19 +1883,19 @@ namespace Vanara.PInvoke /// /// /// - public class HANDLE : SafeHandleZeroOrMinusOneIsInvalid, IEquatable, IHandle + public abstract class SafeHANDLE : SafeHandleZeroOrMinusOneIsInvalid, IEquatable, IHandle { - /// Initializes a new instance of the class. - public HANDLE() : base(true) + /// Initializes a new instance of the class. + public SafeHANDLE() : base(true) { } - /// Initializes a new instance of the class and assigns an existing handle. + /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. /// /// to reliably release the handle during the finalization phase; otherwise, (not recommended). /// - protected HANDLE(IntPtr preexistingHandle, bool ownsHandle = true) : base(ownsHandle) => SetHandle(preexistingHandle); + protected SafeHANDLE(IntPtr preexistingHandle, bool ownsHandle = true) : base(ownsHandle) => SetHandle(preexistingHandle); /// Gets a value indicating whether this instance is null. /// true if this instance is null; otherwise, false. @@ -1905,18 +1905,18 @@ namespace Vanara.PInvoke /// The first handle. /// The second handle. /// The result of the operator. - public static bool operator !=(HANDLE h1, HANDLE h2) => !(h1 == h2); + public static bool operator !=(SafeHANDLE h1, SafeHANDLE h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. - public static bool operator ==(HANDLE h1, HANDLE h2) => h1 is null || h2 is null ? false : h1.Equals(h2); + public static bool operator ==(SafeHANDLE h1, SafeHANDLE h2) => h1 is null || h2 is null ? false : h1.Equals(h2); - /// Determines whether the specified , is equal to this instance. - /// The to compare with this instance. - /// true if the specified is equal to this instance; otherwise, false. - public bool Equals(HANDLE other) + /// Determines whether the specified , is equal to this instance. + /// The to compare with this instance. + /// true if the specified is equal to this instance; otherwise, false. + public bool Equals(SafeHANDLE other) { if (other is null) return false; @@ -1928,7 +1928,7 @@ namespace Vanara.PInvoke /// Determines whether the specified , is equal to this instance. /// The to compare with this instance. /// true if the specified is equal to this instance; otherwise, false. - public override bool Equals(object obj) => obj is HANDLE h ? Equals(h) : base.Equals(obj); + public override bool Equals(object obj) => obj is SafeHANDLE h ? Equals(h) : base.Equals(obj); /// Returns a hash code for this instance. /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. @@ -1939,7 +1939,7 @@ namespace Vanara.PInvoke /// zeros the handle. /// /// true to indicate successful release of the handle; false otherwise. - protected virtual bool InternalReleaseHandle() => true; + protected abstract bool InternalReleaseHandle(); /// protected override bool ReleaseHandle() diff --git a/PInvoke/Shell32/ShlObj.cs b/PInvoke/Shell32/ShlObj.cs index 07c56558..909e169a 100644 --- a/PInvoke/Shell32/ShlObj.cs +++ b/PInvoke/Shell32/ShlObj.cs @@ -7639,7 +7639,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeHPIF : HANDLE + public class SafeHPIF : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -7661,7 +7661,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeHPSXA : HANDLE + public class SafeHPSXA : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/ShlwApi/Shlwapi.cs b/PInvoke/ShlwApi/Shlwapi.cs index 8be15899..b5af4803 100644 --- a/PInvoke/ShlwApi/Shlwapi.cs +++ b/PInvoke/ShlwApi/Shlwapi.cs @@ -5777,7 +5777,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeHUSKEY : HANDLE + public class SafeHUSKEY : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/User32.Gdi/WinUser.Cursor.cs b/PInvoke/User32.Gdi/WinUser.Cursor.cs index 0855c9ec..36db73f9 100644 --- a/PInvoke/User32.Gdi/WinUser.Cursor.cs +++ b/PInvoke/User32.Gdi/WinUser.Cursor.cs @@ -775,7 +775,7 @@ namespace Vanara.PInvoke } /// Provides a to a Windows that disposes a created HCURSOR instance at disposal using DestroyCursor. - public class SafeHCURSOR : HANDLE + public class SafeHCURSOR : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/User32.Gdi/WinUser.Desktop.cs b/PInvoke/User32.Gdi/WinUser.Desktop.cs index 3776d3a5..ae2d0a77 100644 --- a/PInvoke/User32.Gdi/WinUser.Desktop.cs +++ b/PInvoke/User32.Gdi/WinUser.Desktop.cs @@ -1105,7 +1105,7 @@ namespace Vanara.PInvoke } /// Provides a to a that releases a created HDESK instance at disposal using CloseDesktop. - public class SafeHDESK : HANDLE + public class SafeHDESK : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. @@ -1128,7 +1128,7 @@ namespace Vanara.PInvoke } /// Provides a to a that releases a created HWINSTA instance at disposal using CloseWindowStation. - public class SafeHWINSTA : HANDLE + public class SafeHWINSTA : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/User32.Gdi/WinUser.Icon.cs b/PInvoke/User32.Gdi/WinUser.Icon.cs index 26018450..f228e9ae 100644 --- a/PInvoke/User32.Gdi/WinUser.Icon.cs +++ b/PInvoke/User32.Gdi/WinUser.Icon.cs @@ -1140,7 +1140,7 @@ namespace Vanara.PInvoke } /// Provides a to a Windows that disposes a created HICON instance at disposal using DestroyIcon. - public class SafeHICON : HANDLE + public class SafeHICON : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/User32.Gdi/WinUser.Menu.cs b/PInvoke/User32.Gdi/WinUser.Menu.cs index 9ccaeb67..518d1867 100644 --- a/PInvoke/User32.Gdi/WinUser.Menu.cs +++ b/PInvoke/User32.Gdi/WinUser.Menu.cs @@ -4045,7 +4045,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeHMENU : HANDLE + public class SafeHMENU : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/User32.Gdi/WinUser.Window.cs b/PInvoke/User32.Gdi/WinUser.Window.cs index 7d216837..f3873b12 100644 --- a/PInvoke/User32.Gdi/WinUser.Window.cs +++ b/PInvoke/User32.Gdi/WinUser.Window.cs @@ -6011,7 +6011,7 @@ namespace Vanara.PInvoke /// /// Provides a to a window or dialog that releases a created HWND instance at disposal using DestroyWindow. /// - public class SafeHWND : HANDLE + public class SafeHWND : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/User32/WinUser.Hook.cs b/PInvoke/User32/WinUser.Hook.cs index 8a4451d2..60b14e0c 100644 --- a/PInvoke/User32/WinUser.Hook.cs +++ b/PInvoke/User32/WinUser.Hook.cs @@ -1072,7 +1072,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeHHOOK : HANDLE + public class SafeHHOOK : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. diff --git a/PInvoke/UxTheme/UXTHEME.cs b/PInvoke/UxTheme/UXTHEME.cs index 0c449f14..7d950f17 100644 --- a/PInvoke/UxTheme/UXTHEME.cs +++ b/PInvoke/UxTheme/UXTHEME.cs @@ -3647,7 +3647,7 @@ namespace Vanara.PInvoke } /// Represents a safe handle for a theme. Use in place of HTHEME. - public class SafeHTHEME : HANDLE + public class SafeHTHEME : SafeHANDLE { /// Initializes a new instance of the class. /// The h theme. diff --git a/PInvoke/UxTheme/UXTHEME_BufferedPaint.cs b/PInvoke/UxTheme/UXTHEME_BufferedPaint.cs index 4ec76c9d..a6ea3ef6 100644 --- a/PInvoke/UxTheme/UXTHEME_BufferedPaint.cs +++ b/PInvoke/UxTheme/UXTHEME_BufferedPaint.cs @@ -607,7 +607,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeHANIMATIONBUFFER : HANDLE + public class SafeHANIMATIONBUFFER : SafeHANDLE { private readonly bool fUpdateTarget = true; @@ -632,7 +632,7 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeHPAINTBUFFER : HANDLE + public class SafeHPAINTBUFFER : SafeHANDLE { private readonly bool fUpdateTarget = true; diff --git a/PInvoke/WinINet/WinINet.cs b/PInvoke/WinINet/WinINet.cs index beea1be1..62c8ef4d 100644 --- a/PInvoke/WinINet/WinINet.cs +++ b/PInvoke/WinINet/WinINet.cs @@ -1774,7 +1774,7 @@ namespace Vanara.PInvoke } /// Provides a that is disposed using . - public class SafeInternetHandle : HANDLE + public class SafeInternetHandle : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use.