Code:
/ DotNET / DotNET / 8.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
- InlinedAggregationOperator.cs
- BreakRecordTable.cs
- parserscommon.cs
- TextChangedEventArgs.cs
- StorageBasedPackageProperties.cs
- GenericIdentity.cs
- basemetadatamappingvisitor.cs
- UIElementParaClient.cs
- SqlDataReaderSmi.cs
- RoleGroup.cs
- ExecutionEngineException.cs
- ColorConvertedBitmapExtension.cs
- DataGridViewRow.cs
- LoadRetryHandler.cs
- NegotiateStream.cs
- SiteMap.cs
- XmlSchemaInclude.cs
- APCustomTypeDescriptor.cs
- WebControl.cs
- SqlProviderManifest.cs
- SerialReceived.cs
- ValidationErrorCollection.cs
- SQLCharsStorage.cs
- RegexNode.cs
- RectangleF.cs
- TreeNodeClickEventArgs.cs
- PassportIdentity.cs
- EntityProxyFactory.cs
- SiteOfOriginContainer.cs
- GenericWebPart.cs
- AutomationElementCollection.cs
- Font.cs
- SimpleModelProvider.cs
- AncillaryOps.cs
- LinkedList.cs
- FileRecordSequence.cs
- PersonalizationProviderCollection.cs
- WebBrowsableAttribute.cs
- SelectionPattern.cs
- FrugalMap.cs
- RangeExpression.cs
- SqlStream.cs
- SessionStateContainer.cs
- NativeMethods.cs
- AsyncOperationManager.cs
- MessagePropertyVariants.cs
- DesignTimeParseData.cs
- OdbcConnectionPoolProviderInfo.cs
- RegionInfo.cs
- InstanceData.cs
- BufferedStream.cs
- ImageMetadata.cs
- xml.cs
- NegotiationTokenAuthenticatorState.cs
- RowToFieldTransformer.cs
- NavigateEvent.cs
- DeviceContext2.cs
- ComEventsSink.cs
- InfoCardSymmetricAlgorithm.cs
- SchemeSettingElement.cs
- BypassElementCollection.cs
- ToolStripStatusLabel.cs
- Package.cs
- HttpListenerRequestUriBuilder.cs
- FreezableOperations.cs
- RegularExpressionValidator.cs
- InputLanguageCollection.cs
- Select.cs
- LongMinMaxAggregationOperator.cs
- BamlCollectionHolder.cs
- MaterialGroup.cs
- XslAstAnalyzer.cs
- TypeUtils.cs
- FilterEventArgs.cs
- TreeViewDataItemAutomationPeer.cs
- PermissionToken.cs
- FormsAuthenticationTicket.cs
- WhitespaceRule.cs
- VisualTreeUtils.cs
- DataTable.cs
- CodeArrayIndexerExpression.cs
- AddInActivator.cs
- ZipIOLocalFileHeader.cs
- ProofTokenCryptoHandle.cs
- NamespaceList.cs
- QueryResult.cs
- Timer.cs
- SystemTcpStatistics.cs
- keycontainerpermission.cs
- GlobalEventManager.cs
- NullableLongAverageAggregationOperator.cs
- FlowchartSizeFeature.cs
- WebBrowserHelper.cs
- RealizationContext.cs
- Int16.cs
- DefaultValueConverter.cs
- TextElementCollectionHelper.cs
- AudienceUriMode.cs
- CodePageUtils.cs
- AppDomainFactory.cs