Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- SQLGuidStorage.cs
- PageWrapper.cs
- CompoundFileStreamReference.cs
- XamlFrame.cs
- XmlDataLoader.cs
- GroupBox.cs
- FormViewModeEventArgs.cs
- CodeTypeDelegate.cs
- SingleObjectCollection.cs
- SimpleHandlerBuildProvider.cs
- ScrollableControl.cs
- MethodRental.cs
- SqlDependencyListener.cs
- WebPartDisplayModeCancelEventArgs.cs
- MediaContext.cs
- _NetRes.cs
- WebExceptionStatus.cs
- Compiler.cs
- SiteIdentityPermission.cs
- VarInfo.cs
- SettingsPropertyNotFoundException.cs
- DuplicateWaitObjectException.cs
- ListViewCommandEventArgs.cs
- Label.cs
- HtmlTableCell.cs
- DPTypeDescriptorContext.cs
- ComponentSerializationService.cs
- TypeSemantics.cs
- ListViewItemMouseHoverEvent.cs
- ContainerParagraph.cs
- DataServiceEntityAttribute.cs
- BuildDependencySet.cs
- DataServiceRequestException.cs
- DataGridViewTextBoxEditingControl.cs
- EdmItemCollection.cs
- altserialization.cs
- RSAProtectedConfigurationProvider.cs
- StorageComplexPropertyMapping.cs
- coordinator.cs
- DBDataPermission.cs
- PackWebRequestFactory.cs
- ValueType.cs
- EpmSyndicationContentDeSerializer.cs
- BatchWriter.cs
- DesignParameter.cs
- BrushConverter.cs
- BrowserDefinitionCollection.cs
- XmlWriterDelegator.cs
- Enumerable.cs
- WS2007HttpBindingElement.cs
- CodeDomDecompiler.cs
- JavaScriptObjectDeserializer.cs
- StructuralComparisons.cs
- WorkflowInspectionServices.cs
- MsmqBindingElementBase.cs
- ConfigXmlElement.cs
- ZoneLinkButton.cs
- BindingBase.cs
- FieldNameLookup.cs
- DiscoveryMessageSequence.cs
- HWStack.cs
- RuntimeConfigLKG.cs
- BinaryObjectWriter.cs
- _NestedSingleAsyncResult.cs
- MetadataItemEmitter.cs
- EventlogProvider.cs
- SlipBehavior.cs
- NamespaceCollection.cs
- SecurityDocument.cs
- PenContexts.cs
- ArraySet.cs
- MenuItem.cs
- XmlQueryOutput.cs
- SqlStatistics.cs
- OutputScopeManager.cs
- MessageFilterException.cs
- SectionInput.cs
- EndCreateSecurityTokenRequest.cs
- validation.cs
- DoubleStorage.cs
- LinqMaximalSubtreeNominator.cs
- PathStreamGeometryContext.cs
- ItemCheckedEvent.cs
- HtmlControlAdapter.cs
- ChineseLunisolarCalendar.cs
- ZoneButton.cs
- Style.cs
- XmlNamespaceMappingCollection.cs
- SourceElementsCollection.cs
- XamlToRtfParser.cs
- CacheHelper.cs
- MatrixValueSerializer.cs
- ResourceSetExpression.cs
- LoginAutoFormat.cs
- ImageDrawing.cs
- DataGridAutoFormatDialog.cs
- Speller.cs
- SerializerWriterEventHandlers.cs
- Function.cs
- SmtpTransport.cs