Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / clr / src / BCL / System / Security / Cryptography / X509Certificates / safex509handles.cs / 1 / safex509handles.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // // SafeX509Handles.cs // namespace System.Security.Cryptography.X509Certificates { using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using Microsoft.Win32.SafeHandles; // Since we need sometimes to delete the key container associated with a cert // context, the handle used in this class is actually a pointer // to a CERT_CTX unmanaged structure defined in COMX509Certificate.h internal sealed class SafeCertContextHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeCertContextHandle() : base (true) {} // 0 is an Invalid Handle internal SafeCertContextHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeCertContextHandle InvalidHandle { get { return new SafeCertContextHandle(IntPtr.Zero); } } internal IntPtr pCertContext { get { if (handle == IntPtr.Zero) return IntPtr.Zero; return Marshal.ReadIntPtr(handle); } } // This method handles the case where pCert == NULL [MethodImplAttribute(MethodImplOptions.InternalCall)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern void _FreePCertContext(IntPtr pCert); override protected bool ReleaseHandle() { _FreePCertContext(handle); return true; } } internal sealed class SafeCertStoreHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeCertStoreHandle() : base (true) {} // 0 is an Invalid Handle internal SafeCertStoreHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeCertStoreHandle InvalidHandle { get { return new SafeCertStoreHandle(IntPtr.Zero); } } // This method handles the case where hCertStore == NULL [MethodImplAttribute(MethodImplOptions.InternalCall)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern void _FreeCertStoreContext(IntPtr hCertStore); override protected bool ReleaseHandle() { _FreeCertStoreContext(handle); return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // // SafeX509Handles.cs // namespace System.Security.Cryptography.X509Certificates { using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using Microsoft.Win32.SafeHandles; // Since we need sometimes to delete the key container associated with a cert // context, the handle used in this class is actually a pointer // to a CERT_CTX unmanaged structure defined in COMX509Certificate.h internal sealed class SafeCertContextHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeCertContextHandle() : base (true) {} // 0 is an Invalid Handle internal SafeCertContextHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeCertContextHandle InvalidHandle { get { return new SafeCertContextHandle(IntPtr.Zero); } } internal IntPtr pCertContext { get { if (handle == IntPtr.Zero) return IntPtr.Zero; return Marshal.ReadIntPtr(handle); } } // This method handles the case where pCert == NULL [MethodImplAttribute(MethodImplOptions.InternalCall)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern void _FreePCertContext(IntPtr pCert); override protected bool ReleaseHandle() { _FreePCertContext(handle); return true; } } internal sealed class SafeCertStoreHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeCertStoreHandle() : base (true) {} // 0 is an Invalid Handle internal SafeCertStoreHandle(IntPtr handle) : base (true) { SetHandle(handle); } internal static SafeCertStoreHandle InvalidHandle { get { return new SafeCertStoreHandle(IntPtr.Zero); } } // This method handles the case where hCertStore == NULL [MethodImplAttribute(MethodImplOptions.InternalCall)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern void _FreeCertStoreContext(IntPtr hCertStore); override protected bool ReleaseHandle() { _FreeCertStoreContext(handle); return true; } } } // 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
- RelatedCurrencyManager.cs
- StyleConverter.cs
- CorrelationValidator.cs
- FileUtil.cs
- WebPartRestoreVerb.cs
- HiddenField.cs
- CodeThrowExceptionStatement.cs
- SplashScreenNativeMethods.cs
- TransformedBitmap.cs
- TextPenaltyModule.cs
- Transform3DGroup.cs
- FontSource.cs
- Enum.cs
- OutOfMemoryException.cs
- querybuilder.cs
- DynamicValidatorEventArgs.cs
- ClientRolePrincipal.cs
- DesignColumnCollection.cs
- XamlStyleSerializer.cs
- EllipseGeometry.cs
- ClientProxyGenerator.cs
- GenericsInstances.cs
- DictionarySectionHandler.cs
- FontStretches.cs
- XamlVector3DCollectionSerializer.cs
- Run.cs
- WsdlBuildProvider.cs
- DrawingVisualDrawingContext.cs
- BoolLiteral.cs
- DiagnosticStrings.cs
- NullableDecimalSumAggregationOperator.cs
- LambdaCompiler.Expressions.cs
- RotateTransform3D.cs
- SqlInternalConnection.cs
- RetrieveVirtualItemEventArgs.cs
- ToolStripDesignerUtils.cs
- BamlLocalizabilityResolver.cs
- TextBounds.cs
- BitSet.cs
- TextContainer.cs
- ZipIORawDataFileBlock.cs
- BrowserInteropHelper.cs
- ReadWriteControlDesigner.cs
- DataBoundControlHelper.cs
- PropertyDescriptorComparer.cs
- DrawingCollection.cs
- MouseCaptureWithinProperty.cs
- DesignerOptionService.cs
- InvokeMethod.cs
- UdpDiscoveryMessageFilter.cs
- SqlAliasesReferenced.cs
- PolyBezierSegmentFigureLogic.cs
- ScrollChrome.cs
- DesignerForm.cs
- ApplicationFileParser.cs
- ClientOptions.cs
- PropertyPath.cs
- CipherData.cs
- CodeVariableReferenceExpression.cs
- XmlWriter.cs
- ConfigurationStrings.cs
- FloaterBaseParaClient.cs
- SqlInfoMessageEvent.cs
- SpellerStatusTable.cs
- AdjustableArrowCap.cs
- SchemaTypeEmitter.cs
- WizardForm.cs
- ExpressionBindingCollection.cs
- DataException.cs
- DescendentsWalker.cs
- _NativeSSPI.cs
- Stackframe.cs
- TablePatternIdentifiers.cs
- PageThemeCodeDomTreeGenerator.cs
- MinimizableAttributeTypeConverter.cs
- HttpVersion.cs
- IntegrationExceptionEventArgs.cs
- PointUtil.cs
- WebZone.cs
- DecimalKeyFrameCollection.cs
- FontStyles.cs
- ScriptControl.cs
- DataGridItemCollection.cs
- designeractionbehavior.cs
- RoleGroup.cs
- XmlSchemaProviderAttribute.cs
- ForeignConstraint.cs
- ProviderSettingsCollection.cs
- DataMemberFieldEditor.cs
- TransactionFilter.cs
- ObjectListTitleAttribute.cs
- FollowerQueueCreator.cs
- DecimalAnimationUsingKeyFrames.cs
- BindValidationContext.cs
- MarkedHighlightComponent.cs
- EncodingNLS.cs
- WebPartRestoreVerb.cs
- ConfigurationStrings.cs
- FamilyTypeface.cs
- EndPoint.cs