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
- XmlAttributeAttribute.cs
- SizeF.cs
- RuleInfoComparer.cs
- MemberDomainMap.cs
- MethodToken.cs
- StrokeFIndices.cs
- LogWriteRestartAreaState.cs
- ZipIOFileItemStream.cs
- HtmlShimManager.cs
- SqlParameter.cs
- ConfigXmlCDataSection.cs
- Validator.cs
- VarInfo.cs
- PropertyInfoSet.cs
- SHA384Cng.cs
- RsaSecurityTokenAuthenticator.cs
- WeakReadOnlyCollection.cs
- AttributedMetaModel.cs
- BufferModeSettings.cs
- NativeRightsManagementAPIsStructures.cs
- HttpCapabilitiesBase.cs
- FrugalList.cs
- FlowDocument.cs
- externdll.cs
- ExceptionUtil.cs
- TypeDelegator.cs
- MultipleViewPattern.cs
- Collection.cs
- PriorityChain.cs
- PolicyChain.cs
- HtmlAnchor.cs
- SiteMap.cs
- Compilation.cs
- SqlUserDefinedAggregateAttribute.cs
- counter.cs
- DesignerPerfEventProvider.cs
- DoubleLinkList.cs
- CellParaClient.cs
- MultiPartWriter.cs
- PropertyIDSet.cs
- Token.cs
- SqlMethodCallConverter.cs
- EntityParameterCollection.cs
- WsiProfilesElement.cs
- WinInetCache.cs
- ActivityMarkupSerializationProvider.cs
- BindingContext.cs
- SQLMoneyStorage.cs
- DocumentViewerAutomationPeer.cs
- DesignerResources.cs
- PageParser.cs
- EnumerableRowCollection.cs
- Pens.cs
- RowUpdatingEventArgs.cs
- TreeNodeSelectionProcessor.cs
- IconEditor.cs
- TrailingSpaceComparer.cs
- DesignerActionMethodItem.cs
- ImageMapEventArgs.cs
- LinqDataSourceUpdateEventArgs.cs
- RoutingService.cs
- UrlMappingsSection.cs
- UIPermission.cs
- RowUpdatingEventArgs.cs
- XmlSchemaCollection.cs
- ToolstripProfessionalRenderer.cs
- ContainerParagraph.cs
- AddressAccessDeniedException.cs
- BinaryNode.cs
- DeclarativeConditionsCollection.cs
- FacetValueContainer.cs
- XmlSchemaGroupRef.cs
- DbMetaDataFactory.cs
- WebHttpDispatchOperationSelector.cs
- WithParamAction.cs
- MarkupObject.cs
- SafeSecurityHandles.cs
- ConfigurationValidatorAttribute.cs
- IconEditor.cs
- GreaterThanOrEqual.cs
- WebServiceReceiveDesigner.cs
- Emitter.cs
- CompositeControl.cs
- RenderDataDrawingContext.cs
- Error.cs
- OLEDB_Util.cs
- EtwTrace.cs
- Validator.cs
- ToolStripEditorManager.cs
- __Error.cs
- WebPartManager.cs
- RequiredFieldValidator.cs
- FixedDocument.cs
- DataSetSchema.cs
- TextParentUndoUnit.cs
- CompiledRegexRunner.cs
- CodePropertyReferenceExpression.cs
- DeferredSelectedIndexReference.cs
- ToolStripContainer.cs
- FormsAuthenticationUser.cs