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
- Floater.cs
- RawUIStateInputReport.cs
- XamlTypeWithExplicitNamespace.cs
- rsa.cs
- DocumentOrderComparer.cs
- TransformGroup.cs
- TypeSchema.cs
- ConfigurationManager.cs
- SqlDataSourceWizardForm.cs
- CacheHelper.cs
- StylusPointProperty.cs
- ChannelSinkStacks.cs
- ErrorWebPart.cs
- PermissionSetTriple.cs
- ImageUrlEditor.cs
- ResizeGrip.cs
- GridViewRowEventArgs.cs
- MultiDataTrigger.cs
- glyphs.cs
- OpCellTreeNode.cs
- SafeCryptoHandles.cs
- ColorPalette.cs
- KerberosSecurityTokenProvider.cs
- DataGridViewButtonColumn.cs
- ConnectionPoolManager.cs
- TTSEngineProxy.cs
- Query.cs
- WindowsNonControl.cs
- SplitterPanelDesigner.cs
- CLRBindingWorker.cs
- BindingValueChangedEventArgs.cs
- ActivityCompletionCallbackWrapper.cs
- DoubleStorage.cs
- RecordsAffectedEventArgs.cs
- WeakRefEnumerator.cs
- ReachDocumentPageSerializer.cs
- TreeNodeStyle.cs
- ListViewGroupConverter.cs
- SharedPersonalizationStateInfo.cs
- _TLSstream.cs
- InternalConfigEventArgs.cs
- MemberDescriptor.cs
- DataGridViewBand.cs
- xmlfixedPageInfo.cs
- ConfigurationPermission.cs
- SqlCacheDependencyDatabase.cs
- MultipleViewProviderWrapper.cs
- IndexerNameAttribute.cs
- Compilation.cs
- UriSectionReader.cs
- exports.cs
- SingleStorage.cs
- TypeConverter.cs
- Tile.cs
- FontDifferentiator.cs
- RegexRunnerFactory.cs
- ManagementObjectCollection.cs
- XmlIgnoreAttribute.cs
- XmlSerializerAssemblyAttribute.cs
- XmlNamedNodeMap.cs
- XPathDocumentNavigator.cs
- IdentityNotMappedException.cs
- DetailsViewRowCollection.cs
- ExpressionList.cs
- RtfToXamlLexer.cs
- ConvertersCollection.cs
- DispatcherObject.cs
- SamlSecurityTokenAuthenticator.cs
- ObjectListDataBindEventArgs.cs
- ApplicationFileCodeDomTreeGenerator.cs
- WpfPayload.cs
- NonBatchDirectoryCompiler.cs
- UserPreferenceChangingEventArgs.cs
- ByteAnimation.cs
- NavigationWindow.cs
- KeyProperty.cs
- BindingCompleteEventArgs.cs
- XmlSchemaComplexType.cs
- QueryableDataSourceView.cs
- ApplicationInfo.cs
- EndPoint.cs
- DragAssistanceManager.cs
- FilterableAttribute.cs
- ToolStripProgressBar.cs
- EventMappingSettings.cs
- OleDbConnectionFactory.cs
- ToolStripDropDownClosingEventArgs.cs
- DispatcherOperation.cs
- LinkUtilities.cs
- EventSinkActivity.cs
- DataGridColumnHeaderAutomationPeer.cs
- MaskedTextBox.cs
- WebServiceBindingAttribute.cs
- ConvertEvent.cs
- FormsAuthenticationTicket.cs
- XmlElement.cs
- HttpContext.cs
- _Win32.cs
- precedingquery.cs
- ConfigurationSection.cs