Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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; } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ClusterRegistryConfigurationProvider.cs
- PartitionResolver.cs
- SEHException.cs
- PopOutPanel.cs
- IxmlLineInfo.cs
- FlowLayout.cs
- SamlAuthenticationStatement.cs
- ApplicationGesture.cs
- BinaryNode.cs
- VirtualPathProvider.cs
- LexicalChunk.cs
- GridViewColumn.cs
- Command.cs
- basecomparevalidator.cs
- Visitor.cs
- cookie.cs
- HuffmanTree.cs
- DatatypeImplementation.cs
- ApplicationException.cs
- MessageSecurityVersion.cs
- relpropertyhelper.cs
- selecteditemcollection.cs
- SamlDelegatingWriter.cs
- OdbcReferenceCollection.cs
- FigureParagraph.cs
- RegularExpressionValidator.cs
- WSTrustFeb2005.cs
- TransformGroup.cs
- TraceContextRecord.cs
- EntityCommandCompilationException.cs
- DocumentGrid.cs
- SecurityPolicyVersion.cs
- CodeTypeDeclaration.cs
- OptimisticConcurrencyException.cs
- WorkflowMessageEventHandler.cs
- Enum.cs
- MenuAdapter.cs
- EpmContentDeSerializer.cs
- DbTransaction.cs
- MasterPage.cs
- safesecurityhelperavalon.cs
- BookmarkScopeHandle.cs
- ViewCellRelation.cs
- HyperlinkAutomationPeer.cs
- LiteralDesigner.cs
- HttpProfileGroupBase.cs
- TTSEngineProxy.cs
- BlurEffect.cs
- ExpandedWrapper.cs
- PropertySegmentSerializationProvider.cs
- PersistenceParticipant.cs
- DesignTimeTemplateParser.cs
- CompatibleComparer.cs
- XmlWrappingReader.cs
- LayoutExceptionEventArgs.cs
- SchemaNotation.cs
- CollectionChangeEventArgs.cs
- DefinitionProperties.cs
- Pair.cs
- BuildProvidersCompiler.cs
- InvalidEnumArgumentException.cs
- MgmtResManager.cs
- TextEditorContextMenu.cs
- ExpressionPrefixAttribute.cs
- AddingNewEventArgs.cs
- ValidatedControlConverter.cs
- DesignerOptions.cs
- NamedObject.cs
- PrintingPermissionAttribute.cs
- MenuItemBinding.cs
- OleDbRowUpdatedEvent.cs
- HiddenField.cs
- ListenerServiceInstallComponent.cs
- GridEntryCollection.cs
- RoutedUICommand.cs
- DefaultSerializationProviderAttribute.cs
- TogglePattern.cs
- ConditionCollection.cs
- FirstMatchCodeGroup.cs
- LostFocusEventManager.cs
- RegexStringValidator.cs
- Primitive.cs
- SoapEnumAttribute.cs
- Int32EqualityComparer.cs
- SystemIPAddressInformation.cs
- FontCacheUtil.cs
- GenericTextProperties.cs
- Soap.cs
- PropertyChangedEventArgs.cs
- Figure.cs
- Visual3D.cs
- HashCodeCombiner.cs
- clipboard.cs
- ListViewItem.cs
- KoreanCalendar.cs
- FirstMatchCodeGroup.cs
- CreateSequence.cs
- KeysConverter.cs
- DataGridViewComboBoxCell.cs
- DocumentViewerAutomationPeer.cs