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
- AsyncOperationManager.cs
- XmlValidatingReaderImpl.cs
- BindingList.cs
- XmlAttributeCollection.cs
- PointKeyFrameCollection.cs
- basevalidator.cs
- FixedSOMTableCell.cs
- ServiceChannelProxy.cs
- FontUnit.cs
- SafeLocalMemHandle.cs
- IteratorDescriptor.cs
- IPPacketInformation.cs
- WindowsListViewGroupHelper.cs
- ScrollItemProviderWrapper.cs
- GridErrorDlg.cs
- StatusBarDesigner.cs
- InputGestureCollection.cs
- SizeLimitedCache.cs
- DataSvcMapFileSerializer.cs
- GradientPanel.cs
- GlyphElement.cs
- CommandEventArgs.cs
- NotifyParentPropertyAttribute.cs
- RichTextBoxDesigner.cs
- ParameterBuilder.cs
- Transform3DGroup.cs
- QilSortKey.cs
- Visual3DCollection.cs
- ControlBuilder.cs
- ResizeGrip.cs
- PathGradientBrush.cs
- UnaryNode.cs
- SqlCrossApplyToCrossJoin.cs
- ViewStateException.cs
- SqlDataSourceSelectingEventArgs.cs
- DataPagerFieldCommandEventArgs.cs
- Literal.cs
- HostSecurityManager.cs
- CacheForPrimitiveTypes.cs
- TextCollapsingProperties.cs
- RawTextInputReport.cs
- ImageAutomationPeer.cs
- DetailsViewCommandEventArgs.cs
- SqlCacheDependencyDatabase.cs
- DataServiceHostWrapper.cs
- ListItemDetailViewAttribute.cs
- SQLBytesStorage.cs
- XamlRtfConverter.cs
- BitStream.cs
- BindingGroup.cs
- RegularExpressionValidator.cs
- SqlReorderer.cs
- SmiEventSink.cs
- FileCodeGroup.cs
- ToolStripHighContrastRenderer.cs
- PersistenceProvider.cs
- DocumentScope.cs
- TaskHelper.cs
- PerformanceCounterManager.cs
- StylusDevice.cs
- WebPartConnectionsConnectVerb.cs
- ZipIOExtraFieldElement.cs
- ADMembershipUser.cs
- PageVisual.cs
- UnitySerializationHolder.cs
- ValueChangedEventManager.cs
- RenderCapability.cs
- RegexWorker.cs
- IPPacketInformation.cs
- OdbcConnectionOpen.cs
- ParameterSubsegment.cs
- SelectedDatesCollection.cs
- ExpressionBindingCollection.cs
- StatementContext.cs
- ServiceManager.cs
- UpdateManifestForBrowserApplication.cs
- ExceptionUtil.cs
- CacheVirtualItemsEvent.cs
- GC.cs
- TextSpanModifier.cs
- ObjectItemLoadingSessionData.cs
- ClonableStack.cs
- QilPatternFactory.cs
- SqlXml.cs
- UnsafeNativeMethods.cs
- QilDataSource.cs
- MenuItem.cs
- WebPartEditVerb.cs
- IssuedTokenClientBehaviorsElement.cs
- CustomCategoryAttribute.cs
- SQLMoneyStorage.cs
- XmlImplementation.cs
- TriState.cs
- EffectiveValueEntry.cs
- FontWeights.cs
- util.cs
- RadioButtonList.cs
- ConfigXmlSignificantWhitespace.cs
- UserControl.cs
- ArrayTypeMismatchException.cs