Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / ndp / clr / src / BCL / Microsoft / Win32 / SafeHandles / Win32SafeHandles.cs / 2 / 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 [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 [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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- NewItemsContextMenuStrip.cs
- OutOfMemoryException.cs
- NullableBoolConverter.cs
- LiteralControl.cs
- Control.cs
- ScrollPatternIdentifiers.cs
- EdmComplexPropertyAttribute.cs
- RegexCode.cs
- SByteStorage.cs
- BulletedListDesigner.cs
- ResourceReferenceExpressionConverter.cs
- ExpressionBinding.cs
- SQLDecimalStorage.cs
- StringSource.cs
- BooleanProjectedSlot.cs
- __ConsoleStream.cs
- PassportIdentity.cs
- AllMembershipCondition.cs
- ImageField.cs
- StringFunctions.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- SegmentTree.cs
- LocalFileSettingsProvider.cs
- XsltSettings.cs
- CanExecuteRoutedEventArgs.cs
- TemplatePartAttribute.cs
- XslTransform.cs
- DataMemberListEditor.cs
- TabletDeviceInfo.cs
- PlatformNotSupportedException.cs
- LinkArea.cs
- PageStatePersister.cs
- UpdateExpressionVisitor.cs
- RadioButtonRenderer.cs
- BindingFormattingDialog.cs
- DataPagerFieldCollection.cs
- Transform3DGroup.cs
- PipelineModuleStepContainer.cs
- ContainerUIElement3D.cs
- COM2PropertyBuilderUITypeEditor.cs
- ListViewCancelEventArgs.cs
- CharKeyFrameCollection.cs
- X509Certificate2Collection.cs
- ResourceKey.cs
- SafeRightsManagementSessionHandle.cs
- HybridObjectCache.cs
- ACE.cs
- ExcludePathInfo.cs
- CodeSnippetCompileUnit.cs
- NumericUpDown.cs
- TextFindEngine.cs
- DataGridPagerStyle.cs
- Behavior.cs
- PermissionListSet.cs
- ValueType.cs
- TextSelection.cs
- shaperfactoryquerycachekey.cs
- DetailsView.cs
- NavigatorOutput.cs
- GridViewColumnHeaderAutomationPeer.cs
- DataPagerCommandEventArgs.cs
- CqlParser.cs
- DataBindingExpressionBuilder.cs
- OdbcCommandBuilder.cs
- WsdlBuildProvider.cs
- TextEditorThreadLocalStore.cs
- ShapeTypeface.cs
- TextSelectionProcessor.cs
- KernelTypeValidation.cs
- SqlSupersetValidator.cs
- ImageAnimator.cs
- RadioButtonPopupAdapter.cs
- Brush.cs
- IChannel.cs
- View.cs
- LoginUtil.cs
- SizeAnimationBase.cs
- ModuleElement.cs
- translator.cs
- ImageKeyConverter.cs
- XmlIterators.cs
- PropertyGrid.cs
- LineServicesRun.cs
- FlowNode.cs
- ellipse.cs
- EntityDataSourceState.cs
- SafeLocalAllocation.cs
- FileLevelControlBuilderAttribute.cs
- HtmlTitle.cs
- SeekStoryboard.cs
- _ShellExpression.cs
- Process.cs
- FilteredReadOnlyMetadataCollection.cs
- SocketAddress.cs
- XmlSecureResolver.cs
- CryptoApi.cs
- TextHidden.cs
- OpCellTreeNode.cs
- AsymmetricKeyExchangeFormatter.cs
- TreeNodeBindingDepthConverter.cs