Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- parserscommon.cs
- TrackingProfileDeserializationException.cs
- Quad.cs
- SessionStateSection.cs
- TreeNode.cs
- _NTAuthentication.cs
- PeerCollaborationPermission.cs
- SqlBuilder.cs
- SqlBooleanMismatchVisitor.cs
- SymbolPair.cs
- CodeSnippetStatement.cs
- XPathCompileException.cs
- ComNativeDescriptor.cs
- DetailsViewPageEventArgs.cs
- HwndHostAutomationPeer.cs
- ConfigurationValidatorAttribute.cs
- ValidationResult.cs
- GroupBoxAutomationPeer.cs
- CompressEmulationStream.cs
- DataBinder.cs
- CssClassPropertyAttribute.cs
- TriState.cs
- SizeAnimation.cs
- DelegateBodyWriter.cs
- BamlLocalizableResource.cs
- Geometry3D.cs
- WindowsGrip.cs
- util.cs
- DataGridViewColumn.cs
- MimeTypeAttribute.cs
- DurableEnlistmentState.cs
- HtmlWindow.cs
- HitTestDrawingContextWalker.cs
- Size.cs
- BitmapFrameEncode.cs
- __FastResourceComparer.cs
- InternalSafeNativeMethods.cs
- TaskSchedulerException.cs
- PropertySegmentSerializer.cs
- NeutralResourcesLanguageAttribute.cs
- UiaCoreProviderApi.cs
- InkCanvasSelectionAdorner.cs
- TypeInitializationException.cs
- XmlDataSourceNodeDescriptor.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- CallbackCorrelationInitializer.cs
- DocumentOrderComparer.cs
- ButtonField.cs
- Vector3dCollection.cs
- PixelFormat.cs
- FileSystemInfo.cs
- RegistrySecurity.cs
- DbParameterHelper.cs
- JsonReader.cs
- ThrowHelper.cs
- ListComponentEditor.cs
- StringAttributeCollection.cs
- InternalConfigConfigurationFactory.cs
- PropertyChangeTracker.cs
- objectresult_tresulttype.cs
- XmlSchemaSubstitutionGroup.cs
- SessionStateModule.cs
- ReversePositionQuery.cs
- BitmapMetadataEnumerator.cs
- FieldBuilder.cs
- DbConnectionPoolCounters.cs
- RequestCachePolicy.cs
- OuterGlowBitmapEffect.cs
- SecureEnvironment.cs
- DataGridViewCellValidatingEventArgs.cs
- WindowsTooltip.cs
- EncryptedXml.cs
- XmlAttributeCollection.cs
- UInt16Storage.cs
- CriticalHandle.cs
- MembershipAdapter.cs
- EditingScopeUndoUnit.cs
- BasicHttpMessageSecurityElement.cs
- XomlDesignerLoader.cs
- DNS.cs
- PrimitiveDataContract.cs
- RuleSetCollection.cs
- ScriptResourceDefinition.cs
- TrackingStringDictionary.cs
- SchemaNames.cs
- translator.cs
- KnownTypesHelper.cs
- EditorBrowsableAttribute.cs
- BitVector32.cs
- SeparatorAutomationPeer.cs
- RotateTransform.cs
- StrongNameIdentityPermission.cs
- TableLayoutPanelCellPosition.cs
- DrawItemEvent.cs
- LoadWorkflowCommand.cs
- PermissionToken.cs
- InputDevice.cs
- RequestBringIntoViewEventArgs.cs
- UTF7Encoding.cs
- AttributeData.cs