Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- Receive.cs
- _CookieModule.cs
- SatelliteContractVersionAttribute.cs
- WindowsFormsSynchronizationContext.cs
- ConfigViewGenerator.cs
- BCryptSafeHandles.cs
- WindowsListViewItemCheckBox.cs
- PrePostDescendentsWalker.cs
- MarginCollapsingState.cs
- ToolStripInSituService.cs
- Regex.cs
- CursorConverter.cs
- AttachedPropertiesService.cs
- PenThreadPool.cs
- AdornerPresentationContext.cs
- SiteIdentityPermission.cs
- LogSwitch.cs
- ValidatorCollection.cs
- WebPartEditorApplyVerb.cs
- CodeIdentifier.cs
- ToolStripDropDownButton.cs
- BufferedGraphics.cs
- SelectedDatesCollection.cs
- WebBrowserProgressChangedEventHandler.cs
- WebPartEditorCancelVerb.cs
- TextServicesLoader.cs
- UrlAuthFailedErrorFormatter.cs
- BrowserTree.cs
- _ListenerAsyncResult.cs
- SchemaImporterExtensionElementCollection.cs
- ToolStripHighContrastRenderer.cs
- Rule.cs
- CurrentChangedEventManager.cs
- NativeMethods.cs
- HierarchicalDataBoundControl.cs
- ExceptionUtil.cs
- OraclePermissionAttribute.cs
- XslTransform.cs
- DataTableReader.cs
- AsyncResult.cs
- CodeBlockBuilder.cs
- CodePropertyReferenceExpression.cs
- AdornerLayer.cs
- ViewBox.cs
- ImageList.cs
- ToggleButton.cs
- RSAPKCS1SignatureFormatter.cs
- AppSettings.cs
- ProtocolsConfiguration.cs
- WebPartZone.cs
- StsCommunicationException.cs
- AutomationInteropProvider.cs
- BoundField.cs
- SymmetricKey.cs
- SynchronizedInputHelper.cs
- ErrorHandler.cs
- BooleanAnimationBase.cs
- ControlIdConverter.cs
- StylusEventArgs.cs
- Debug.cs
- HttpCachePolicy.cs
- EncryptedReference.cs
- Script.cs
- ProcessHostConfigUtils.cs
- HtmlInputCheckBox.cs
- DataControlButton.cs
- WindowsFormsHostAutomationPeer.cs
- ExponentialEase.cs
- LinearGradientBrush.cs
- XPathNodeInfoAtom.cs
- ParallelEnumerable.cs
- AuthenticationConfig.cs
- ResourceDescriptionAttribute.cs
- NativeMethods.cs
- AuthenticatingEventArgs.cs
- AvtEvent.cs
- Span.cs
- XmlSchemaType.cs
- IfJoinedCondition.cs
- SourceSwitch.cs
- XslNumber.cs
- InputManager.cs
- ListBindableAttribute.cs
- DiagnosticsConfigurationHandler.cs
- InstalledFontCollection.cs
- WebPartTransformer.cs
- ADRoleFactory.cs
- WebPart.cs
- CalendarDay.cs
- FontFamily.cs
- OleDbError.cs
- StateMachine.cs
- AlphabeticalEnumConverter.cs
- Block.cs
- RegexRunnerFactory.cs
- ConsoleEntryPoint.cs
- SqlPersistenceWorkflowInstanceDescription.cs
- Soap.cs
- BehaviorEditorPart.cs
- ComponentEditorPage.cs