Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Security / Cryptography / X509Certificates / safex509handles.cs / 1305376 / 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 System.Runtime.Versioning; 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 [System.Security.SecurityCritical] // auto-generated 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 [ResourceExposure(ResourceScope.None)] [MethodImplAttribute(MethodImplOptions.InternalCall)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern void _FreePCertContext(IntPtr pCert); [System.Security.SecurityCritical] override protected bool ReleaseHandle() { _FreePCertContext(handle); return true; } } [System.Security.SecurityCritical] // auto-generated 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 [ResourceExposure(ResourceScope.None)] [MethodImplAttribute(MethodImplOptions.InternalCall)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern void _FreeCertStoreContext(IntPtr hCertStore); [System.Security.SecurityCritical] 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 System.Runtime.Versioning; 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 [System.Security.SecurityCritical] // auto-generated 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 [ResourceExposure(ResourceScope.None)] [MethodImplAttribute(MethodImplOptions.InternalCall)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern void _FreePCertContext(IntPtr pCert); [System.Security.SecurityCritical] override protected bool ReleaseHandle() { _FreePCertContext(handle); return true; } } [System.Security.SecurityCritical] // auto-generated 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 [ResourceExposure(ResourceScope.None)] [MethodImplAttribute(MethodImplOptions.InternalCall)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern void _FreeCertStoreContext(IntPtr hCertStore); [System.Security.SecurityCritical] 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
- BinaryWriter.cs
- SortedDictionary.cs
- FileDialog.cs
- SmiEventSink.cs
- ToolBarButtonClickEvent.cs
- ManifestBasedResourceGroveler.cs
- SmtpAuthenticationManager.cs
- EmbeddedMailObjectCollectionEditor.cs
- MenuBase.cs
- WebControl.cs
- SchemaImporterExtensionElementCollection.cs
- WarningException.cs
- BindingList.cs
- ArraySet.cs
- CodeArrayIndexerExpression.cs
- FlowDocumentReader.cs
- DbFunctionCommandTree.cs
- BindingElementCollection.cs
- GcSettings.cs
- Selector.cs
- Effect.cs
- ToolboxService.cs
- StringExpressionSet.cs
- PingReply.cs
- GreenMethods.cs
- KnownColorTable.cs
- MetadataCollection.cs
- WebZone.cs
- ValidationSummary.cs
- ParallelTimeline.cs
- Package.cs
- CodeNamespaceImport.cs
- OletxResourceManager.cs
- KeyValuePairs.cs
- HighContrastHelper.cs
- PlainXmlWriter.cs
- OrderByQueryOptionExpression.cs
- BuildProvider.cs
- LiteralTextContainerControlBuilder.cs
- StreamWriter.cs
- Models.cs
- HttpModuleActionCollection.cs
- PenContext.cs
- _CookieModule.cs
- PersonalizationStateInfo.cs
- ClassImporter.cs
- ContractsBCL.cs
- LiteralText.cs
- SchemaElementDecl.cs
- RenamedEventArgs.cs
- Compiler.cs
- ProcessThreadCollection.cs
- KeyValueInternalCollection.cs
- MarginsConverter.cs
- BufferAllocator.cs
- FilteredReadOnlyMetadataCollection.cs
- ProgressBar.cs
- WebResourceAttribute.cs
- WebPartZoneBase.cs
- ServiceModelSecurityTokenRequirement.cs
- DataColumnSelectionConverter.cs
- DetailsViewDeletedEventArgs.cs
- EventData.cs
- VisualTreeUtils.cs
- RoleManagerSection.cs
- FlowDocumentPaginator.cs
- StylusPointProperty.cs
- SslStreamSecurityBindingElement.cs
- StrongNameUtility.cs
- DataGridAutoGeneratingColumnEventArgs.cs
- TableRow.cs
- UnsafePeerToPeerMethods.cs
- COM2Properties.cs
- PasswordBox.cs
- FileAuthorizationModule.cs
- ToolStripArrowRenderEventArgs.cs
- ToolStripScrollButton.cs
- CharacterMetrics.cs
- RegexMatchCollection.cs
- StoreAnnotationsMap.cs
- OdbcRowUpdatingEvent.cs
- ThousandthOfEmRealPoints.cs
- HttpCookieCollection.cs
- XomlCompilerResults.cs
- PositiveTimeSpanValidatorAttribute.cs
- WebPartRestoreVerb.cs
- IMembershipProvider.cs
- ColorAnimation.cs
- UserControlDocumentDesigner.cs
- DbQueryCommandTree.cs
- BamlTreeUpdater.cs
- NamespaceEmitter.cs
- HttpHandlersSection.cs
- AsynchronousChannelMergeEnumerator.cs
- FontFamilyValueSerializer.cs
- PropertyPushdownHelper.cs
- HttpCookiesSection.cs
- SamlAttribute.cs
- SqlBulkCopyColumnMappingCollection.cs
- DefaultAssemblyResolver.cs