Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UInt16Storage.cs
- LocationSectionRecord.cs
- EventLogPermissionEntry.cs
- PrimitiveSchema.cs
- RawTextInputReport.cs
- SimpleColumnProvider.cs
- DataGridViewLayoutData.cs
- Method.cs
- HttpCacheVaryByContentEncodings.cs
- InfoCardHelper.cs
- dsa.cs
- CompositeKey.cs
- ContentFilePart.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- ObjectStateEntryDbDataRecord.cs
- BufferedGraphics.cs
- LocatorManager.cs
- IApplicationTrustManager.cs
- PtsPage.cs
- Atom10FormatterFactory.cs
- VisualTreeUtils.cs
- OLEDB_Enum.cs
- AppDomainFactory.cs
- ExpressionDumper.cs
- StylusEditingBehavior.cs
- ReverseInheritProperty.cs
- WeakReferenceKey.cs
- LoadWorkflowByKeyAsyncResult.cs
- ThaiBuddhistCalendar.cs
- ItemMap.cs
- ComProxy.cs
- Validator.cs
- EncoderFallback.cs
- ADMembershipUser.cs
- PropertyPathWorker.cs
- DataGridComboBoxColumn.cs
- Tokenizer.cs
- ConfigXmlElement.cs
- DataGridViewCellMouseEventArgs.cs
- Interop.cs
- Pkcs9Attribute.cs
- ScriptBehaviorDescriptor.cs
- DeferredSelectedIndexReference.cs
- WCFBuildProvider.cs
- AttachmentService.cs
- XmlDataDocument.cs
- EventItfInfo.cs
- QueryServiceConfigHandle.cs
- CheckBoxPopupAdapter.cs
- FolderBrowserDialog.cs
- BuildProvidersCompiler.cs
- ObjectDataSourceMethodEventArgs.cs
- OneOfTypeConst.cs
- ApplicationManager.cs
- Thumb.cs
- DocumentPageView.cs
- _ShellExpression.cs
- TaiwanCalendar.cs
- IPHostEntry.cs
- Rect3D.cs
- XmlNamedNodeMap.cs
- FtpWebRequest.cs
- Baml6ConstructorInfo.cs
- SingleSelectRootGridEntry.cs
- XmlMtomWriter.cs
- MappedMetaModel.cs
- MulticastNotSupportedException.cs
- Membership.cs
- DataGridView.cs
- NamespaceMapping.cs
- EditorPart.cs
- SQLString.cs
- CustomAttribute.cs
- TableRow.cs
- WebPartConnectionsCancelEventArgs.cs
- Assert.cs
- CompositeCollection.cs
- Header.cs
- PointKeyFrameCollection.cs
- WriteFileContext.cs
- Rotation3D.cs
- ManagementInstaller.cs
- XmlBoundElement.cs
- ExpressionDumper.cs
- WebServiceClientProxyGenerator.cs
- Object.cs
- TaskScheduler.cs
- WinFormsSpinner.cs
- SqlXml.cs
- Application.cs
- Win32MouseDevice.cs
- CodeStatement.cs
- QueryCursorEventArgs.cs
- ISO2022Encoding.cs
- SafeCryptContextHandle.cs
- DrawingContextDrawingContextWalker.cs
- SessionEndingEventArgs.cs
- RegistryKey.cs
- ManagementPath.cs
- InfoCardMetadataExchangeClient.cs