Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- CompareValidator.cs
- DataGridDesigner.cs
- XmlWhitespace.cs
- ServerReliableChannelBinder.cs
- FunctionImportElement.cs
- MetadataCache.cs
- ImageFormat.cs
- X500Name.cs
- Schedule.cs
- Utility.cs
- PrimitiveType.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- InputMethodStateTypeInfo.cs
- MaskDescriptors.cs
- VerticalAlignConverter.cs
- CmsInterop.cs
- DeviceContexts.cs
- SourceSwitch.cs
- ChtmlPageAdapter.cs
- StyleModeStack.cs
- PropertyPathConverter.cs
- HandleRef.cs
- Canvas.cs
- Evidence.cs
- SqlCacheDependencyDatabase.cs
- WebPartDescriptionCollection.cs
- DbParameterCollectionHelper.cs
- ProcessRequestArgs.cs
- TextBox.cs
- WindowsUpDown.cs
- OdbcCommandBuilder.cs
- ValidationRule.cs
- NonPrimarySelectionGlyph.cs
- TraceInternal.cs
- SqlCacheDependencyDatabase.cs
- SmiContext.cs
- DataPager.cs
- BinaryCommonClasses.cs
- ListControl.cs
- ZeroOpNode.cs
- BindableAttribute.cs
- DataServiceQueryException.cs
- BooleanFunctions.cs
- FullTextBreakpoint.cs
- URLAttribute.cs
- COAUTHIDENTITY.cs
- PropertyGrid.cs
- FormViewDeleteEventArgs.cs
- TypeFieldSchema.cs
- DataColumnSelectionConverter.cs
- SamlAdvice.cs
- HandlerBase.cs
- EmptyWorkItem.cs
- XmlDataSourceView.cs
- EditingMode.cs
- ArrayList.cs
- QueuePropertyVariants.cs
- PageStatePersister.cs
- ObjectPropertyMapping.cs
- IOException.cs
- SqlBooleanMismatchVisitor.cs
- CacheVirtualItemsEvent.cs
- TouchesOverProperty.cs
- CounterSampleCalculator.cs
- CompositionCommandSet.cs
- BitmapEffectGroup.cs
- Int32Converter.cs
- UpdateProgress.cs
- SqlAggregateChecker.cs
- UserControl.cs
- PerformanceCounterLib.cs
- RsaSecurityTokenParameters.cs
- ADMembershipProvider.cs
- EncodingNLS.cs
- TreeView.cs
- XmlNavigatorStack.cs
- PropertyConverter.cs
- ServicePrincipalNameElement.cs
- InvalidDataException.cs
- ExtendedPropertiesHandler.cs
- SpecialNameAttribute.cs
- SystemColorTracker.cs
- Models.cs
- XmlChoiceIdentifierAttribute.cs
- securitycriticaldata.cs
- EdmPropertyAttribute.cs
- OracleDataReader.cs
- TrackingRecord.cs
- externdll.cs
- OraclePermissionAttribute.cs
- _ListenerRequestStream.cs
- OutputCacheSection.cs
- ListBoxItemAutomationPeer.cs
- XmlObjectSerializerContext.cs
- XmlSchemaSimpleTypeRestriction.cs
- PaintEvent.cs
- PropertyKey.cs
- cache.cs
- ControlBuilderAttribute.cs
- BrowserInteropHelper.cs