Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / Security / SafeSecurityHandles.cs / 1 / SafeSecurityHandles.cs
namespace Microsoft.Win32.SafeHandles { using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.ConstrainedExecution; using System.Security; internal sealed class SafeLocalAllocHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeLocalAllocHandle () : base(true) {} // 0 is an Invalid Handle internal SafeLocalAllocHandle (IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeLocalAllocHandle InvalidHandle { get { return new SafeLocalAllocHandle(IntPtr.Zero); } } override protected bool ReleaseHandle() { return Win32Native.LocalFree(handle) == IntPtr.Zero; } } internal sealed class SafeLsaLogonProcessHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeLsaLogonProcessHandle() : base (true) {} // 0 is an Invalid Handle internal SafeLsaLogonProcessHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeLsaLogonProcessHandle InvalidHandle { get { return new SafeLsaLogonProcessHandle(IntPtr.Zero); } } override protected bool ReleaseHandle() { // LsaDeregisterLogonProcess returns an NTSTATUS return Win32Native.LsaDeregisterLogonProcess(handle) >= 0; } } internal sealed class SafeLsaMemoryHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeLsaMemoryHandle() : base(true) {} // 0 is an Invalid Handle internal SafeLsaMemoryHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeLsaMemoryHandle InvalidHandle { get { return new SafeLsaMemoryHandle( IntPtr.Zero ); } } override protected bool ReleaseHandle() { return Win32Native.LsaFreeMemory(handle) == 0; } } internal sealed class SafeLsaPolicyHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeLsaPolicyHandle() : base(true) {} // 0 is an Invalid Handle internal SafeLsaPolicyHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeLsaPolicyHandle InvalidHandle { get { return new SafeLsaPolicyHandle( IntPtr.Zero ); } } override protected bool ReleaseHandle() { return Win32Native.LsaClose(handle) == 0; } } internal sealed class SafeLsaReturnBufferHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeLsaReturnBufferHandle() : base (true) {} // 0 is an Invalid Handle internal SafeLsaReturnBufferHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeLsaReturnBufferHandle InvalidHandle { get { return new SafeLsaReturnBufferHandle(IntPtr.Zero); } } override protected bool ReleaseHandle() { // LsaFreeReturnBuffer returns an NTSTATUS return Win32Native.LsaFreeReturnBuffer(handle) >= 0; } } internal sealed class SafeProcessHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeProcessHandle() : base (true) {} // 0 is an Invalid Handle internal SafeProcessHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeProcessHandle InvalidHandle { get { return new SafeProcessHandle(IntPtr.Zero); } } override protected bool ReleaseHandle() { return Win32Native.CloseHandle(handle); } } internal sealed class SafeThreadHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeThreadHandle() : base (true) {} // 0 is an Invalid Handle internal SafeThreadHandle(IntPtr handle) : base (true) { SetHandle(handle); } override protected bool ReleaseHandle() { return Win32Native.CloseHandle(handle); } } internal sealed class SafeTokenHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeTokenHandle() : base (true) {} // 0 is an Invalid Handle internal SafeTokenHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeTokenHandle InvalidHandle { get { return new SafeTokenHandle(IntPtr.Zero); } } override protected bool ReleaseHandle() { return Win32Native.CloseHandle(handle); } } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- NameValueCollection.cs
- GreenMethods.cs
- TokenBasedSetEnumerator.cs
- XmlConverter.cs
- CancellationToken.cs
- SystemColors.cs
- RangeValidator.cs
- ResourceKey.cs
- SamlDoNotCacheCondition.cs
- Version.cs
- TableLayout.cs
- Normalization.cs
- ExeConfigurationFileMap.cs
- DataGridBeginningEditEventArgs.cs
- EmptyQuery.cs
- FixedSOMTableRow.cs
- SpecularMaterial.cs
- Helpers.cs
- WebConfigurationHostFileChange.cs
- BooleanConverter.cs
- DataGridViewLayoutData.cs
- CubicEase.cs
- SafeHandles.cs
- Int32AnimationUsingKeyFrames.cs
- PropertyStore.cs
- ConnectionsZone.cs
- Point.cs
- PolyLineSegment.cs
- ZoneIdentityPermission.cs
- SaveFileDialogDesigner.cs
- ProcessModelSection.cs
- PerformanceCounterManager.cs
- TextCharacters.cs
- DataGridItemEventArgs.cs
- SHA1Cng.cs
- RuntimeCompatibilityAttribute.cs
- SqlDataReaderSmi.cs
- QueryOutputWriter.cs
- MasterPageCodeDomTreeGenerator.cs
- TypeSemantics.cs
- CanonicalFormWriter.cs
- SafeNativeMethods.cs
- XmlSchemaAttribute.cs
- ContentFilePart.cs
- GradientStop.cs
- LinkLabelLinkClickedEvent.cs
- ButtonStandardAdapter.cs
- ServiceOperation.cs
- SelectionPatternIdentifiers.cs
- DataGridParentRows.cs
- InteropExecutor.cs
- TargetPerspective.cs
- SmiEventSink_Default.cs
- HttpCacheVaryByContentEncodings.cs
- RuntimeConfig.cs
- WorkflowValidationFailedException.cs
- ColorTransformHelper.cs
- SmuggledIUnknown.cs
- ServerIdentity.cs
- AddInActivator.cs
- PrintSchema.cs
- isolationinterop.cs
- ClientTargetSection.cs
- ListControlConvertEventArgs.cs
- XPathDocumentNavigator.cs
- TextBoxLine.cs
- DesignerAttributeInfo.cs
- TextFragmentEngine.cs
- MeasurementDCInfo.cs
- GlobalEventManager.cs
- SqlNamer.cs
- AngleUtil.cs
- MenuCommands.cs
- OdbcDataReader.cs
- XmlElementCollection.cs
- MexTcpBindingElement.cs
- PrtCap_Reader.cs
- AuthenticationService.cs
- MemberInfoSerializationHolder.cs
- TextEditor.cs
- FirstMatchCodeGroup.cs
- ScopelessEnumAttribute.cs
- DataGridViewColumnEventArgs.cs
- NumericUpDownAccelerationCollection.cs
- RadioButtonAutomationPeer.cs
- _NetworkingPerfCounters.cs
- TextProperties.cs
- ContentFileHelper.cs
- SystemIPv6InterfaceProperties.cs
- RoutingService.cs
- DrawingGroup.cs
- ProfileManager.cs
- SelectingProviderEventArgs.cs
- IgnoreFileBuildProvider.cs
- MetadataFile.cs
- CompatibleIComparer.cs
- SettingsPropertyValue.cs
- IEnumerable.cs
- MdbDataFileEditor.cs
- NativeMethods.cs