Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / clr / src / BCL / Microsoft / Win32 / SafeHandles / Win32SafeHandles.cs / 1 / Win32SafeHandles.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // // Abstract derivations of SafeHandle designed to provide the common // functionality supporting Win32 handles. More specifically, they describe how // an invalid handle looks (for instance, some handles use -1 as an invalid // handle value, others use 0). // // Further derivations of these classes can specialise this even further (e.g. // file or registry handles). // // using System; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Security.Permissions; using System.Runtime.ConstrainedExecution; namespace Microsoft.Win32.SafeHandles { // Class of safe handle which uses 0 or -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected SafeHandleZeroOrMinusOneIsInvalid(bool ownsHandle) : base(IntPtr.Zero, ownsHandle) { } public override bool IsInvalid { get { return handle.IsNull() || handle == new IntPtr(-1); } } } // Class of safe handle which uses only -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class SafeHandleMinusOneIsInvalid : SafeHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected SafeHandleMinusOneIsInvalid(bool ownsHandle) : base(new IntPtr(-1), ownsHandle) { } public override bool IsInvalid { get { return handle == new IntPtr(-1); } } } // Class of critical handle which uses 0 or -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class CriticalHandleZeroOrMinusOneIsInvalid : CriticalHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected CriticalHandleZeroOrMinusOneIsInvalid() : base(IntPtr.Zero) { } public override bool IsInvalid { get { return handle.IsNull() || handle == new IntPtr(-1); } } } // Class of critical handle which uses only -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class CriticalHandleMinusOneIsInvalid : CriticalHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected CriticalHandleMinusOneIsInvalid() : base(new IntPtr(-1)) { } public override bool IsInvalid { get { return handle == new IntPtr(-1); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // // Abstract derivations of SafeHandle designed to provide the common // functionality supporting Win32 handles. More specifically, they describe how // an invalid handle looks (for instance, some handles use -1 as an invalid // handle value, others use 0). // // Further derivations of these classes can specialise this even further (e.g. // file or registry handles). // // using System; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Security.Permissions; using System.Runtime.ConstrainedExecution; namespace Microsoft.Win32.SafeHandles { // Class of safe handle which uses 0 or -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected SafeHandleZeroOrMinusOneIsInvalid(bool ownsHandle) : base(IntPtr.Zero, ownsHandle) { } public override bool IsInvalid { get { return handle.IsNull() || handle == new IntPtr(-1); } } } // Class of safe handle which uses only -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class SafeHandleMinusOneIsInvalid : SafeHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected SafeHandleMinusOneIsInvalid(bool ownsHandle) : base(new IntPtr(-1), ownsHandle) { } public override bool IsInvalid { get { return handle == new IntPtr(-1); } } } // Class of critical handle which uses 0 or -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class CriticalHandleZeroOrMinusOneIsInvalid : CriticalHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected CriticalHandleZeroOrMinusOneIsInvalid() : base(IntPtr.Zero) { } public override bool IsInvalid { get { return handle.IsNull() || handle == new IntPtr(-1); } } } // Class of critical handle which uses only -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class CriticalHandleMinusOneIsInvalid : CriticalHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected CriticalHandleMinusOneIsInvalid() : base(new IntPtr(-1)) { } public override bool IsInvalid { get { return handle == new IntPtr(-1); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PathData.cs
- SmiContext.cs
- DataGridViewCellCollection.cs
- RoleGroupCollection.cs
- SelectorItemAutomationPeer.cs
- ApplicationServiceHelper.cs
- GuidConverter.cs
- smtppermission.cs
- SignedPkcs7.cs
- WindowCollection.cs
- FrameworkElementFactory.cs
- XmlSerializationReader.cs
- DomainUpDown.cs
- ValueConversionAttribute.cs
- SqlRemoveConstantOrderBy.cs
- VScrollProperties.cs
- XsltContext.cs
- FactoryId.cs
- XmlSchemaObject.cs
- LiteralDesigner.cs
- CriticalHandle.cs
- TextLineBreak.cs
- BitmapEffectOutputConnector.cs
- ItemsPresenter.cs
- ITreeGenerator.cs
- DataGridViewComboBoxCell.cs
- NameSpaceExtractor.cs
- DependencyProperty.cs
- IInstanceTable.cs
- returneventsaver.cs
- TraceUtils.cs
- VisualStyleElement.cs
- AmbientLight.cs
- FilterElement.cs
- RTTypeWrapper.cs
- ClickablePoint.cs
- HMACRIPEMD160.cs
- XDeferredAxisSource.cs
- ColorMap.cs
- MailAddressCollection.cs
- DesigntimeLicenseContextSerializer.cs
- InfoCardProofToken.cs
- Misc.cs
- _OverlappedAsyncResult.cs
- WebColorConverter.cs
- XhtmlBasicPhoneCallAdapter.cs
- TypeSystemHelpers.cs
- BoundField.cs
- Interlocked.cs
- MetadataArtifactLoaderCompositeResource.cs
- CallTemplateAction.cs
- ActivityTypeDesigner.xaml.cs
- DocobjHost.cs
- SoapSchemaImporter.cs
- XmlDocumentFragment.cs
- Parsers.cs
- documentsequencetextpointer.cs
- cookie.cs
- base64Transforms.cs
- MethodImplAttribute.cs
- WindowsListViewGroup.cs
- MailHeaderInfo.cs
- MessageSmuggler.cs
- TypedCompletedAsyncResult.cs
- GestureRecognizer.cs
- MetadataFile.cs
- ImageMapEventArgs.cs
- ObjectHandle.cs
- DataPagerCommandEventArgs.cs
- XmlComplianceUtil.cs
- DiscoveryUtility.cs
- CommandConverter.cs
- ToolStripPanel.cs
- MarginCollapsingState.cs
- BulletedListEventArgs.cs
- CompressEmulationStream.cs
- SqlNamer.cs
- TrackingProfileDeserializationException.cs
- FileInfo.cs
- MergeFailedEvent.cs
- TemplateBindingExtensionConverter.cs
- ValueCollectionParameterReader.cs
- ClientBuildManagerCallback.cs
- XpsFilter.cs
- RangeValuePattern.cs
- GeometryModel3D.cs
- ParameterBinding.cs
- HwndAppCommandInputProvider.cs
- ToolStripRenderEventArgs.cs
- SelectingProviderEventArgs.cs
- ObjectParameterCollection.cs
- UserPersonalizationStateInfo.cs
- ISFClipboardData.cs
- IdentitySection.cs
- ContextStaticAttribute.cs
- CatalogPart.cs
- XPathEmptyIterator.cs
- AccessKeyManager.cs
- ConfigDefinitionUpdates.cs
- OrderByBuilder.cs