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
- WebPartChrome.cs
- StylusButtonCollection.cs
- DocumentsTrace.cs
- XdrBuilder.cs
- DrawingImage.cs
- NamedPipeProcessProtocolHandler.cs
- LabelTarget.cs
- GridViewCancelEditEventArgs.cs
- XmlnsCache.cs
- CodeNamespaceImportCollection.cs
- TextPattern.cs
- DataGridViewCellStyle.cs
- XmlSchemaChoice.cs
- Timer.cs
- FrameworkElementAutomationPeer.cs
- XPathNode.cs
- SiteMapNodeItemEventArgs.cs
- SqlAggregateChecker.cs
- AnnotationHighlightLayer.cs
- XmlAutoDetectWriter.cs
- ListViewCommandEventArgs.cs
- SelectionRange.cs
- Membership.cs
- DbConnectionPool.cs
- VariableValue.cs
- ObjectNotFoundException.cs
- SortQueryOperator.cs
- WinFormsSpinner.cs
- EntityDataSourceChangedEventArgs.cs
- XmlNodeReader.cs
- Row.cs
- BufferedOutputStream.cs
- ComplexType.cs
- IgnoreFileBuildProvider.cs
- ComplexBindingPropertiesAttribute.cs
- OleDbStruct.cs
- _RequestCacheProtocol.cs
- CustomAttribute.cs
- GeometryModel3D.cs
- DataTrigger.cs
- CultureSpecificStringDictionary.cs
- LayoutEngine.cs
- TileBrush.cs
- HttpStreamXmlDictionaryReader.cs
- MarshalByRefObject.cs
- TextBounds.cs
- TransformedBitmap.cs
- WebPartPersonalization.cs
- PasswordBox.cs
- SecurityElement.cs
- EntryIndex.cs
- ImageBrush.cs
- EntityConnection.cs
- HttpListenerContext.cs
- SafeArchiveContext.cs
- CultureMapper.cs
- ResourceDictionary.cs
- DataKey.cs
- DependencyPropertyValueSerializer.cs
- TaskbarItemInfo.cs
- CompilerCollection.cs
- AmbiguousMatchException.cs
- ColorTransform.cs
- SQLInt16Storage.cs
- NavigationService.cs
- MenuScrollingVisibilityConverter.cs
- StyleSheet.cs
- DataSourceNameHandler.cs
- LinqDataSourceHelper.cs
- CallSiteOps.cs
- WeakReferenceKey.cs
- SBCSCodePageEncoding.cs
- WmlControlAdapter.cs
- AnnotationHighlightLayer.cs
- COAUTHINFO.cs
- NameScopePropertyAttribute.cs
- ControlCachePolicy.cs
- PerfCounters.cs
- SqlInternalConnection.cs
- XmlAttribute.cs
- HttpModuleCollection.cs
- FixedSOMPage.cs
- InitialServerConnectionReader.cs
- ImageFormat.cs
- ApplicationServiceHelper.cs
- SoapEnumAttribute.cs
- input.cs
- _TransmitFileOverlappedAsyncResult.cs
- EventLogger.cs
- ScrollBarRenderer.cs
- XmlChildEnumerator.cs
- ClientFormsIdentity.cs
- SqlBuffer.cs
- QilName.cs
- WsatServiceAddress.cs
- PolyLineSegmentFigureLogic.cs
- IIS7UserPrincipal.cs
- DataException.cs
- DLinqAssociationProvider.cs
- unsafenativemethodsother.cs