Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- MarkupObject.cs
- WindowsListView.cs
- Unit.cs
- OracleInternalConnection.cs
- XmlSerializerFactory.cs
- SpoolingTask.cs
- BooleanAnimationUsingKeyFrames.cs
- EntityDataSourceContainerNameConverter.cs
- SplineKeyFrames.cs
- PackUriHelper.cs
- CompilerTypeWithParams.cs
- HtmlMeta.cs
- DisplayInformation.cs
- DispatcherHookEventArgs.cs
- BinaryNode.cs
- StsCommunicationException.cs
- ExtentKey.cs
- SamlNameIdentifierClaimResource.cs
- IncrementalReadDecoders.cs
- UnescapedXmlDiagnosticData.cs
- DisposableCollectionWrapper.cs
- MobileCategoryAttribute.cs
- WebPartVerbCollection.cs
- DataGridViewSelectedCellCollection.cs
- SqlFacetAttribute.cs
- PointHitTestParameters.cs
- ImageFormat.cs
- FrameworkElementAutomationPeer.cs
- LinkTarget.cs
- ColorAnimationBase.cs
- LocalizabilityAttribute.cs
- WebAdminConfigurationHelper.cs
- WCFServiceClientProxyGenerator.cs
- EventProviderWriter.cs
- SqlCommandBuilder.cs
- CurrencyWrapper.cs
- ToolboxComponentsCreatingEventArgs.cs
- ControlDesigner.cs
- SmtpMail.cs
- UncommonField.cs
- OpenTypeLayout.cs
- MergeFailedEvent.cs
- DbDeleteCommandTree.cs
- CodeSnippetStatement.cs
- Int16.cs
- FusionWrap.cs
- OuterGlowBitmapEffect.cs
- DoubleUtil.cs
- AudioFormatConverter.cs
- DbDataSourceEnumerator.cs
- DrawingGroupDrawingContext.cs
- CodeChecksumPragma.cs
- DispatcherEventArgs.cs
- PathSegment.cs
- WebDescriptionAttribute.cs
- ConditionalAttribute.cs
- ProtocolsConfiguration.cs
- CounterSampleCalculator.cs
- ClaimComparer.cs
- ClearTypeHintValidation.cs
- ExtensionFile.cs
- XsdBuildProvider.cs
- SpotLight.cs
- AffineTransform3D.cs
- FormatConvertedBitmap.cs
- CodeGenerationManager.cs
- Figure.cs
- RemoteWebConfigurationHost.cs
- SafeFileHandle.cs
- DependencyObjectPropertyDescriptor.cs
- SrgsRulesCollection.cs
- WindowsListViewGroupHelper.cs
- Win32.cs
- CapabilitiesPattern.cs
- BamlStream.cs
- ValidationRule.cs
- WS2007HttpBindingElement.cs
- StringAnimationBase.cs
- X509ChainPolicy.cs
- TimelineClockCollection.cs
- Button.cs
- wpf-etw.cs
- ByteAnimation.cs
- HttpRequest.cs
- AssociationTypeEmitter.cs
- CodeExpressionCollection.cs
- InteropAutomationProvider.cs
- CodeIdentifiers.cs
- CodeDomSerializer.cs
- brushes.cs
- AttachedAnnotation.cs
- XmlSerializerNamespaces.cs
- RepeaterDesigner.cs
- UpdateDelegates.Generated.cs
- CodeDomLocalizationProvider.cs
- AttachedAnnotation.cs
- OdbcConnection.cs
- TextParagraphCache.cs
- EnumMemberAttribute.cs
- DataRow.cs