Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Configuration / Microsoft / Win32 / SafeCryptContextHandle.cs / 1 / SafeCryptContextHandle.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace Microsoft.Win32 {
using System;
using System.Security.Permissions;
using Microsoft.Win32.SafeHandles;
using System.Configuration;
// Safehandle for crypt context handles
[System.Security.SuppressUnmanagedCodeSecurityAttribute()]
internal sealed class SafeCryptContextHandle : SafeHandleZeroOrMinusOneIsInvalid {
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
internal SafeCryptContextHandle()
: base(true) {
}
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
internal SafeCryptContextHandle(IntPtr handle, bool ownsHandle)
: base(ownsHandle) {
SetHandle(handle);
}
override protected bool ReleaseHandle() {
if (handle != IntPtr.Zero) {
UnsafeNativeMethods.CryptReleaseContext(this, 0);
return true;
}
return false;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace Microsoft.Win32 {
using System;
using System.Security.Permissions;
using Microsoft.Win32.SafeHandles;
using System.Configuration;
// Safehandle for crypt context handles
[System.Security.SuppressUnmanagedCodeSecurityAttribute()]
internal sealed class SafeCryptContextHandle : SafeHandleZeroOrMinusOneIsInvalid {
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
internal SafeCryptContextHandle()
: base(true) {
}
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
internal SafeCryptContextHandle(IntPtr handle, bool ownsHandle)
: base(ownsHandle) {
SetHandle(handle);
}
override protected bool ReleaseHandle() {
if (handle != IntPtr.Zero) {
UnsafeNativeMethods.CryptReleaseContext(this, 0);
return true;
}
return false;
}
}
}
// 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
- IndexOutOfRangeException.cs
- ToolStripSplitButton.cs
- MediaElement.cs
- Conditional.cs
- IdentityNotMappedException.cs
- UnsafeMethods.cs
- ReliableChannelListener.cs
- WriteFileContext.cs
- ComplexTypeEmitter.cs
- UTF7Encoding.cs
- ProxyFragment.cs
- TypeUtil.cs
- FixedDocumentSequencePaginator.cs
- MethodBuilder.cs
- FirstMatchCodeGroup.cs
- MetadataSource.cs
- XsdCachingReader.cs
- AsyncCompletedEventArgs.cs
- Expression.DebuggerProxy.cs
- TextInfo.cs
- CodeTypeConstructor.cs
- HandlerFactoryCache.cs
- Translator.cs
- TextAction.cs
- CodeConstructor.cs
- OutgoingWebResponseContext.cs
- Material.cs
- FacetDescriptionElement.cs
- CroppedBitmap.cs
- WebPartDisplayMode.cs
- DependencyObjectType.cs
- ProtocolsConfiguration.cs
- Config.cs
- XmlWrappingWriter.cs
- Converter.cs
- ModelVisual3D.cs
- ConnectionPointCookie.cs
- SchemaAttDef.cs
- ChannelFactory.cs
- FormsAuthentication.cs
- InfoCardCryptoHelper.cs
- SByteConverter.cs
- Propagator.JoinPropagator.cs
- WindowsListViewGroup.cs
- SynchronizationValidator.cs
- DataGridColumnCollection.cs
- DataSysAttribute.cs
- ClientData.cs
- OperationContractAttribute.cs
- KeysConverter.cs
- OrderPreservingMergeHelper.cs
- ByteConverter.cs
- MobileUserControl.cs
- BinHexEncoder.cs
- WebPartEditVerb.cs
- DocumentCollection.cs
- selecteditemcollection.cs
- ColorKeyFrameCollection.cs
- ContentElement.cs
- AssertFilter.cs
- IndentedWriter.cs
- ChooseAction.cs
- odbcmetadatacollectionnames.cs
- IsolatedStorage.cs
- DESCryptoServiceProvider.cs
- CodeGenerator.cs
- MaterializeFromAtom.cs
- TypeLibConverter.cs
- SqlGenerator.cs
- DragCompletedEventArgs.cs
- TextEncodedRawTextWriter.cs
- WindowsFormsLinkLabel.cs
- ObjectIDGenerator.cs
- ScriptHandlerFactory.cs
- VersionedStream.cs
- CapabilitiesState.cs
- OracleBFile.cs
- HandleCollector.cs
- DbXmlEnabledProviderManifest.cs
- XMLSchema.cs
- SeekStoryboard.cs
- SmtpFailedRecipientException.cs
- PolicyException.cs
- TypeExtensionSerializer.cs
- ObjectStateFormatter.cs
- UserPreferenceChangingEventArgs.cs
- coordinatorfactory.cs
- DbExpressionVisitor.cs
- HtmlInputControl.cs
- SqlTypeConverter.cs
- LayoutExceptionEventArgs.cs
- DataGridColumnDropSeparator.cs
- ListViewPagedDataSource.cs
- TagPrefixAttribute.cs
- ChangesetResponse.cs
- PointKeyFrameCollection.cs
- Size3D.cs
- SqlConnectionString.cs
- EditingScope.cs
- Certificate.cs