Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / Microsoft / Win32 / SafeHandles / Win32SafeHandles.cs / 1305376 / 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). // // namespace Microsoft.Win32.SafeHandles { using System; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Security.Permissions; using System.Runtime.ConstrainedExecution; // Class of safe handle which uses 0 or -1 as an invalid handle. [System.Security.SecurityCritical] // auto-generated_required [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] public abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected SafeHandleZeroOrMinusOneIsInvalid(bool ownsHandle) : base(IntPtr.Zero, ownsHandle) { } #if FEATURE_CORECLR // A default constructor is needed to satisfy CoreCLR inheritence rules. It should not be called at runtime protected SafeHandleZeroOrMinusOneIsInvalid() { throw new NotImplementedException(); } #endif // FEATURE_CORECLR public override bool IsInvalid { [System.Security.SecurityCritical] get { return handle.IsNull() || handle == new IntPtr(-1); } } } // Class of safe handle which uses only -1 as an invalid handle. [System.Security.SecurityCritical] // auto-generated_required [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] public abstract class SafeHandleMinusOneIsInvalid : SafeHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected SafeHandleMinusOneIsInvalid(bool ownsHandle) : base(new IntPtr(-1), ownsHandle) { } #if FEATURE_CORECLR // A default constructor is needed to satisfy CoreCLR inheritence rules. It should not be called at runtime protected SafeHandleMinusOneIsInvalid() { throw new NotImplementedException(); } #endif // FEATURE_CORECLR public override bool IsInvalid { [System.Security.SecurityCritical] get { return handle == new IntPtr(-1); } } } // Class of critical handle which uses 0 or -1 as an invalid handle. [System.Security.SecurityCritical] // auto-generated_required [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] public abstract class CriticalHandleZeroOrMinusOneIsInvalid : CriticalHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected CriticalHandleZeroOrMinusOneIsInvalid() : base(IntPtr.Zero) { } public override bool IsInvalid { [System.Security.SecurityCritical] get { return handle.IsNull() || handle == new IntPtr(-1); } } } // Class of critical handle which uses only -1 as an invalid handle. [System.Security.SecurityCritical] // auto-generated_required [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] public abstract class CriticalHandleMinusOneIsInvalid : CriticalHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected CriticalHandleMinusOneIsInvalid() : base(new IntPtr(-1)) { } public override bool IsInvalid { [System.Security.SecurityCritical] 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). // // namespace Microsoft.Win32.SafeHandles { using System; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Security.Permissions; using System.Runtime.ConstrainedExecution; // Class of safe handle which uses 0 or -1 as an invalid handle. [System.Security.SecurityCritical] // auto-generated_required [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] public abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected SafeHandleZeroOrMinusOneIsInvalid(bool ownsHandle) : base(IntPtr.Zero, ownsHandle) { } #if FEATURE_CORECLR // A default constructor is needed to satisfy CoreCLR inheritence rules. It should not be called at runtime protected SafeHandleZeroOrMinusOneIsInvalid() { throw new NotImplementedException(); } #endif // FEATURE_CORECLR public override bool IsInvalid { [System.Security.SecurityCritical] get { return handle.IsNull() || handle == new IntPtr(-1); } } } // Class of safe handle which uses only -1 as an invalid handle. [System.Security.SecurityCritical] // auto-generated_required [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] public abstract class SafeHandleMinusOneIsInvalid : SafeHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected SafeHandleMinusOneIsInvalid(bool ownsHandle) : base(new IntPtr(-1), ownsHandle) { } #if FEATURE_CORECLR // A default constructor is needed to satisfy CoreCLR inheritence rules. It should not be called at runtime protected SafeHandleMinusOneIsInvalid() { throw new NotImplementedException(); } #endif // FEATURE_CORECLR public override bool IsInvalid { [System.Security.SecurityCritical] get { return handle == new IntPtr(-1); } } } // Class of critical handle which uses 0 or -1 as an invalid handle. [System.Security.SecurityCritical] // auto-generated_required [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] public abstract class CriticalHandleZeroOrMinusOneIsInvalid : CriticalHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected CriticalHandleZeroOrMinusOneIsInvalid() : base(IntPtr.Zero) { } public override bool IsInvalid { [System.Security.SecurityCritical] get { return handle.IsNull() || handle == new IntPtr(-1); } } } // Class of critical handle which uses only -1 as an invalid handle. [System.Security.SecurityCritical] // auto-generated_required [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] public abstract class CriticalHandleMinusOneIsInvalid : CriticalHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected CriticalHandleMinusOneIsInvalid() : base(new IntPtr(-1)) { } public override bool IsInvalid { [System.Security.SecurityCritical] 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
- Rotation3DAnimationUsingKeyFrames.cs
- DbCommandDefinition.cs
- BufferedReadStream.cs
- ContentType.cs
- MulticastDelegate.cs
- ArgumentNullException.cs
- GetIndexBinder.cs
- InstanceOwner.cs
- x509store.cs
- DataGridViewEditingControlShowingEventArgs.cs
- TranslateTransform.cs
- AuthorizationRule.cs
- FrameworkObject.cs
- SafeNativeMethods.cs
- StringBuilder.cs
- LinkedList.cs
- XmlJsonWriter.cs
- DecimalConstantAttribute.cs
- DeploymentSectionCache.cs
- TileBrush.cs
- Baml2006Reader.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- CompiledRegexRunner.cs
- StyleCollection.cs
- RtfControls.cs
- ClaimComparer.cs
- ResourceAttributes.cs
- HMACSHA384.cs
- HttpStaticObjectsCollectionBase.cs
- ValidateNames.cs
- AnnotationHighlightLayer.cs
- InputBuffer.cs
- DataGridLinkButton.cs
- FormatConvertedBitmap.cs
- XmlElementList.cs
- LongMinMaxAggregationOperator.cs
- QueryContinueDragEvent.cs
- DirectionalLight.cs
- ExtendedProperty.cs
- ExtensionSimplifierMarkupObject.cs
- _Events.cs
- ProfileModule.cs
- Walker.cs
- TypeLibConverter.cs
- FunctionImportElement.cs
- InteropDesigner.xaml.cs
- CqlLexer.cs
- Attachment.cs
- EventHandlers.cs
- ThemeDictionaryExtension.cs
- ImmutableObjectAttribute.cs
- HandleCollector.cs
- UnhandledExceptionEventArgs.cs
- HttpProfileBase.cs
- Pool.cs
- CryptoStream.cs
- Update.cs
- WebPartActionVerb.cs
- Hex.cs
- AssemblyHash.cs
- DataControlLinkButton.cs
- WhileDesigner.cs
- CompatibleIComparer.cs
- GlobalProxySelection.cs
- Part.cs
- ProfileEventArgs.cs
- HttpStaticObjectsCollectionWrapper.cs
- WebPartDisplayModeCancelEventArgs.cs
- BaseCodeDomTreeGenerator.cs
- TreeWalkHelper.cs
- RectAnimationBase.cs
- HyperLinkColumn.cs
- OdbcStatementHandle.cs
- DataPagerFieldCommandEventArgs.cs
- Point.cs
- Convert.cs
- XmlSchemaSimpleTypeUnion.cs
- Section.cs
- MatrixKeyFrameCollection.cs
- dtdvalidator.cs
- FixedFindEngine.cs
- InputReportEventArgs.cs
- SearchForVirtualItemEventArgs.cs
- ScriptDescriptor.cs
- StreamingContext.cs
- TypeLibConverter.cs
- SiteMap.cs
- RuntimeVariablesExpression.cs
- BitmapEffectvisualstate.cs
- XDeferredAxisSource.cs
- ParagraphVisual.cs
- SymbolDocumentInfo.cs
- TemplateEditingService.cs
- Int32RectConverter.cs
- HiddenField.cs
- DiscreteKeyFrames.cs
- ResourceAssociationType.cs
- TripleDESCryptoServiceProvider.cs
- SqlDataSourceWizardForm.cs
- DescendantBaseQuery.cs