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
- ProcessInfo.cs
- GeneralTransform.cs
- SplineQuaternionKeyFrame.cs
- ReachPrintTicketSerializerAsync.cs
- EmbeddedMailObject.cs
- PhysicalAddress.cs
- DataGridViewRowsRemovedEventArgs.cs
- CssStyleCollection.cs
- ChannelSinkStacks.cs
- LocatorBase.cs
- MatrixKeyFrameCollection.cs
- XmlComment.cs
- SocketPermission.cs
- BaseContextMenu.cs
- ValueSerializer.cs
- sqlmetadatafactory.cs
- XmlWhitespace.cs
- LocalizableResourceBuilder.cs
- OverlappedAsyncResult.cs
- EffectiveValueEntry.cs
- HttpHandlerActionCollection.cs
- Animatable.cs
- DefaultExpression.cs
- SafeProcessHandle.cs
- DecimalAnimationUsingKeyFrames.cs
- LayoutInformation.cs
- MembershipSection.cs
- ParagraphVisual.cs
- RemotingService.cs
- SolidColorBrush.cs
- BinaryCommonClasses.cs
- FusionWrap.cs
- ToggleButtonAutomationPeer.cs
- InteropExecutor.cs
- CodeTypeParameter.cs
- IndentTextWriter.cs
- DataServiceHostWrapper.cs
- ClientConfigPaths.cs
- WebServiceBindingAttribute.cs
- NodeFunctions.cs
- Attributes.cs
- LayoutEditorPart.cs
- StylusPointCollection.cs
- SizeChangedInfo.cs
- Wizard.cs
- AddInSegmentDirectoryNotFoundException.cs
- PrintPreviewDialog.cs
- X509SubjectKeyIdentifierClause.cs
- EdmToObjectNamespaceMap.cs
- NameNode.cs
- XmlHierarchicalEnumerable.cs
- DependencyObject.cs
- CalendarDataBindingHandler.cs
- ConnectionModeReader.cs
- ArraySubsetEnumerator.cs
- Soap.cs
- CodeIterationStatement.cs
- SqlDataReader.cs
- AsymmetricSecurityProtocolFactory.cs
- IResourceProvider.cs
- SafeViewOfFileHandle.cs
- SoapMessage.cs
- DataGridViewCellLinkedList.cs
- XmlSchemaComplexContent.cs
- ObjectDataSourceEventArgs.cs
- PackagePart.cs
- DefaultDiscoveryServiceExtension.cs
- RotateTransform3D.cs
- RoleServiceManager.cs
- SqlNamer.cs
- BindingNavigator.cs
- ControlValuePropertyAttribute.cs
- DocumentGridPage.cs
- FixedSOMGroup.cs
- Baml2006Reader.cs
- GlobalAllocSafeHandle.cs
- SettingsPropertyWrongTypeException.cs
- MethodCallExpression.cs
- PropertyDescriptorCollection.cs
- TimeSpanConverter.cs
- ZoomPercentageConverter.cs
- ColorConverter.cs
- Int32Storage.cs
- HitTestWithPointDrawingContextWalker.cs
- ListChunk.cs
- WindowInteractionStateTracker.cs
- BaseResourcesBuildProvider.cs
- GeneralTransform.cs
- CacheAxisQuery.cs
- FileReservationCollection.cs
- RadioButton.cs
- ListViewPagedDataSource.cs
- HwndHost.cs
- CompositionTarget.cs
- PageFunction.cs
- BinaryHeap.cs
- MsmqException.cs
- WindowsFormsHostAutomationPeer.cs
- RectangleGeometry.cs
- AggregatePushdown.cs