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
- NavigationCommands.cs
- SystemIPGlobalStatistics.cs
- InteropAutomationProvider.cs
- PrintDialog.cs
- precedingquery.cs
- ToolboxComponentsCreatingEventArgs.cs
- HighContrastHelper.cs
- OperandQuery.cs
- DesignerActionVerbList.cs
- OdbcHandle.cs
- UIServiceHelper.cs
- SQLBoolean.cs
- DataBinding.cs
- StrongNamePublicKeyBlob.cs
- IdentifierCreationService.cs
- HttpPostServerProtocol.cs
- CharacterShapingProperties.cs
- OdbcReferenceCollection.cs
- MediaTimeline.cs
- AjaxFrameworkAssemblyAttribute.cs
- AffineTransform3D.cs
- TitleStyle.cs
- RequestBringIntoViewEventArgs.cs
- XmlDownloadManager.cs
- ReadOnlyTernaryTree.cs
- PriorityChain.cs
- COM2TypeInfoProcessor.cs
- ProcessHostConfigUtils.cs
- AssociationTypeEmitter.cs
- SecurityIdentifierConverter.cs
- WrappedIUnknown.cs
- XmlParserContext.cs
- SqlMetaData.cs
- PersonalizationProviderCollection.cs
- ConnectionManagementElementCollection.cs
- OleAutBinder.cs
- SelectionEditingBehavior.cs
- NamespaceList.cs
- GenericPrincipal.cs
- ProviderMetadataCachedInformation.cs
- XMLSchema.cs
- CellCreator.cs
- XmlSerializerAssemblyAttribute.cs
- SQLDoubleStorage.cs
- HttpCachePolicy.cs
- Cursors.cs
- Point4DValueSerializer.cs
- DoubleLink.cs
- SqlProviderManifest.cs
- EncryptedType.cs
- ReadContentAsBinaryHelper.cs
- TextChange.cs
- MTConfigUtil.cs
- DataPagerFieldCollection.cs
- LightweightCodeGenerator.cs
- DependencyObjectType.cs
- HtmlHead.cs
- ClientBuildManager.cs
- _NetworkingPerfCounters.cs
- OutputCacheProfileCollection.cs
- DataServiceRequest.cs
- SchemaNamespaceManager.cs
- EventRoute.cs
- CodeSnippetExpression.cs
- HtmlButton.cs
- MetadataSerializer.cs
- ManagementOptions.cs
- RequestCachePolicyConverter.cs
- ObjRef.cs
- BorderGapMaskConverter.cs
- Converter.cs
- CodeAccessPermission.cs
- DataSvcMapFile.cs
- AttributeTable.cs
- Application.cs
- EditorPart.cs
- Module.cs
- BindingSourceDesigner.cs
- HtmlHead.cs
- AssemblyCacheEntry.cs
- SessionSwitchEventArgs.cs
- srgsitem.cs
- XmlSchemaIdentityConstraint.cs
- LogEntryHeaderSerializer.cs
- SystemIcons.cs
- GetMemberBinder.cs
- WebAdminConfigurationHelper.cs
- Pkcs9Attribute.cs
- StrongNameMembershipCondition.cs
- FileChangesMonitor.cs
- ImageAnimator.cs
- BufferedStream.cs
- TargetConverter.cs
- ForEachAction.cs
- PropertyKey.cs
- BitmapEffect.cs
- XmlSchemaInfo.cs
- StylusEditingBehavior.cs
- CustomErrorsSectionWrapper.cs
- ResourceType.cs