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
- HWStack.cs
- HtmlWindowCollection.cs
- ObjectListComponentEditor.cs
- ManifestSignedXml.cs
- SqlLiftWhereClauses.cs
- ScriptRegistrationManager.cs
- TimeSpanStorage.cs
- Win32SafeHandles.cs
- SmtpException.cs
- _DynamicWinsockMethods.cs
- SetterBase.cs
- ConstraintCollection.cs
- FormsAuthenticationUser.cs
- DataServiceConfiguration.cs
- TypeConverterHelper.cs
- DataKeyCollection.cs
- PersonalizationProviderCollection.cs
- TraceContext.cs
- ICollection.cs
- EntityDataReader.cs
- ClockController.cs
- ExceptionHelpers.cs
- ILGenerator.cs
- ConnectivityStatus.cs
- UnsignedPublishLicense.cs
- UnhandledExceptionEventArgs.cs
- PathSegmentCollection.cs
- ProfileBuildProvider.cs
- EntityClientCacheKey.cs
- Addressing.cs
- WebPartMenuStyle.cs
- _ListenerAsyncResult.cs
- ImageInfo.cs
- WpfPayload.cs
- DrawingCollection.cs
- MenuItemStyleCollection.cs
- _NTAuthentication.cs
- LinqDataSourceValidationException.cs
- EditorPartChrome.cs
- EncryptedKey.cs
- IODescriptionAttribute.cs
- QuadraticBezierSegment.cs
- Point3D.cs
- TemplateBindingExtensionConverter.cs
- OleDbCommand.cs
- Mutex.cs
- DataGridViewCellFormattingEventArgs.cs
- TimeIntervalCollection.cs
- DesignerContextDescriptor.cs
- SymbolDocumentGenerator.cs
- VBIdentifierNameEditor.cs
- AuthenticatedStream.cs
- RSAOAEPKeyExchangeDeformatter.cs
- ExceptionHelpers.cs
- GridViewRowEventArgs.cs
- HostUtils.cs
- HtmlContainerControl.cs
- CheckBox.cs
- DataGrid.cs
- XNameTypeConverter.cs
- WebConfigurationManager.cs
- ComponentEditorForm.cs
- PrintEvent.cs
- DataServiceQueryException.cs
- DefaultTraceListener.cs
- dbenumerator.cs
- LinqToSqlWrapper.cs
- IFlowDocumentViewer.cs
- ColorAnimation.cs
- FormCollection.cs
- LogicalExpressionTypeConverter.cs
- RadioButtonAutomationPeer.cs
- AppDomainProtocolHandler.cs
- Point3DCollection.cs
- ThicknessAnimationBase.cs
- CompareInfo.cs
- SettingsPropertyCollection.cs
- DeclaredTypeElementCollection.cs
- IList.cs
- DeflateEmulationStream.cs
- RemotingServices.cs
- DotExpr.cs
- Message.cs
- _ConnectStream.cs
- WebExceptionStatus.cs
- WebPartChrome.cs
- TimelineGroup.cs
- SocketManager.cs
- NameTable.cs
- PropertiesTab.cs
- InfoCardProofToken.cs
- CatalogZoneBase.cs
- Blend.cs
- MenuBindingsEditorForm.cs
- FixedDSBuilder.cs
- MailMessageEventArgs.cs
- SqlCaseSimplifier.cs
- EntityParameter.cs
- BitmapDownload.cs
- BamlTreeUpdater.cs