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
- TextRange.cs
- JumpItem.cs
- CodeRegionDirective.cs
- Latin1Encoding.cs
- ZoneIdentityPermission.cs
- GlyphsSerializer.cs
- Cursors.cs
- TextStore.cs
- ContainerFilterService.cs
- AccessControlEntry.cs
- BaseCodeDomTreeGenerator.cs
- ArithmeticException.cs
- TextSegment.cs
- CompilationLock.cs
- Crypto.cs
- ConfigurationLockCollection.cs
- XmlSchemaIdentityConstraint.cs
- FixedElement.cs
- FlowDocumentReaderAutomationPeer.cs
- XmlSchemaExporter.cs
- Literal.cs
- FormViewInsertEventArgs.cs
- DataMisalignedException.cs
- Brushes.cs
- hresults.cs
- UnsafeCollabNativeMethods.cs
- DataSvcMapFileSerializer.cs
- XmlAttributeOverrides.cs
- TraceLog.cs
- ErrorLog.cs
- RuntimeConfigLKG.cs
- TypedElement.cs
- NamespaceListProperty.cs
- DisplayMemberTemplateSelector.cs
- TemplateInstanceAttribute.cs
- OptimizedTemplateContentHelper.cs
- GridViewRow.cs
- DashStyles.cs
- CollectionCodeDomSerializer.cs
- CellLabel.cs
- CustomValidator.cs
- ValueChangedEventManager.cs
- RegistryPermission.cs
- WindowManager.cs
- FunctionParameter.cs
- EventLogEntry.cs
- ProfilePropertyMetadata.cs
- CodeCatchClause.cs
- SafeBitVector32.cs
- LogConverter.cs
- TypeElementCollection.cs
- XmlConvert.cs
- PropertyEmitterBase.cs
- BinaryMessageEncoder.cs
- HttpConfigurationSystem.cs
- StylusSystemGestureEventArgs.cs
- NumericExpr.cs
- LayoutEditorPart.cs
- XmlSchemaObject.cs
- BaseCollection.cs
- DiscoveryMessageSequence.cs
- GlyphRun.cs
- WindowsFont.cs
- CloudCollection.cs
- SqlGatherConsumedAliases.cs
- BitmapEffectGeneralTransform.cs
- ClaimTypeElement.cs
- FunctionDetailsReader.cs
- TextTreeUndo.cs
- EmptyReadOnlyDictionaryInternal.cs
- HttpProfileBase.cs
- TdsParser.cs
- SettingsAttributeDictionary.cs
- DispatcherExceptionEventArgs.cs
- EnumBuilder.cs
- connectionpool.cs
- ConfigUtil.cs
- ToggleProviderWrapper.cs
- ThreadAbortException.cs
- ResourceSetExpression.cs
- TypeNameConverter.cs
- XamlStyleSerializer.cs
- DocumentGridPage.cs
- SmiRequestExecutor.cs
- CatalogZone.cs
- Zone.cs
- AddInPipelineAttributes.cs
- DnsEndpointIdentity.cs
- GradientStop.cs
- TemplateKeyConverter.cs
- Base64Stream.cs
- EdmComplexPropertyAttribute.cs
- WpfSharedXamlSchemaContext.cs
- VectorCollectionValueSerializer.cs
- NetworkInformationException.cs
- SrgsGrammarCompiler.cs
- XmlUtilWriter.cs
- documentsequencetextcontainer.cs
- PropertyValueUIItem.cs
- SecurityTokenRequirement.cs