Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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; } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CompilerCollection.cs
- PanelDesigner.cs
- ProtocolsSection.cs
- wmiprovider.cs
- XPathNavigatorKeyComparer.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- DeploymentSection.cs
- ProjectedWrapper.cs
- PrivilegeNotHeldException.cs
- OrderedDictionary.cs
- XmlSerializerNamespaces.cs
- XmlSchemaProviderAttribute.cs
- WebPartConnectionCollection.cs
- ReadOnlyDictionary.cs
- SubMenuStyle.cs
- SignalGate.cs
- TypeConverterHelper.cs
- XmlAtomicValue.cs
- CompilerInfo.cs
- CollectionBuilder.cs
- ActivityAction.cs
- GraphicsPath.cs
- RemotingServices.cs
- CqlParser.cs
- GPRECTF.cs
- DeviceContext2.cs
- UIPermission.cs
- CheckBoxBaseAdapter.cs
- SqlConnectionFactory.cs
- DataSetFieldSchema.cs
- OdbcUtils.cs
- StructuredTypeEmitter.cs
- TabControlCancelEvent.cs
- ClientSideQueueItem.cs
- SessionStateContainer.cs
- BinaryObjectInfo.cs
- XmlSchemaDocumentation.cs
- CodeCompileUnit.cs
- DataGridColumn.cs
- TableLayoutPanelCellPosition.cs
- SecureEnvironment.cs
- UrlMappingsModule.cs
- CaseInsensitiveComparer.cs
- GC.cs
- ParentUndoUnit.cs
- LocalizableAttribute.cs
- ExtractedStateEntry.cs
- TabControlCancelEvent.cs
- ProfileManager.cs
- WebServiceData.cs
- HttpModulesSection.cs
- ImageDesigner.cs
- HttpException.cs
- SchemaTypeEmitter.cs
- Form.cs
- NavigationExpr.cs
- Compress.cs
- TextAction.cs
- RemotingException.cs
- GeneralTransformCollection.cs
- PreviewKeyDownEventArgs.cs
- TextCompositionManager.cs
- CompositeKey.cs
- ThreadExceptionDialog.cs
- FileLevelControlBuilderAttribute.cs
- ClaimSet.cs
- RenamedEventArgs.cs
- SerializerDescriptor.cs
- CompilationUnit.cs
- XsltSettings.cs
- SerTrace.cs
- NumericPagerField.cs
- XmlSecureResolver.cs
- KerberosTicketHashIdentifierClause.cs
- XmlChildEnumerator.cs
- ReadOnlyHierarchicalDataSource.cs
- XdrBuilder.cs
- ThrowOnMultipleAssignment.cs
- Selection.cs
- EmbeddedMailObject.cs
- XmlHierarchicalDataSourceView.cs
- EventLogPermissionEntryCollection.cs
- EmptyReadOnlyDictionaryInternal.cs
- SqlFactory.cs
- OleDbRowUpdatedEvent.cs
- InkCollectionBehavior.cs
- IconHelper.cs
- HandlerBase.cs
- SafeNativeMemoryHandle.cs
- WindowAutomationPeer.cs
- DeviceContext2.cs
- DataList.cs
- XmlIncludeAttribute.cs
- CodeTypeMember.cs
- Atom10FeedFormatter.cs
- TextViewBase.cs
- TraceUtils.cs
- Merger.cs
- LayeredChannelFactory.cs
- ExtensionFile.cs