Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / CompMod / Microsoft / Win32 / SafeHandles / SafeUserTokenHandle.cs / 1 / SafeUserTokenHandle.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Class: SafeUserTokenHandle
**
** Author: David Gutierrez ([....])
**
** A wrapper for a user token handle
**
** Date: July 8, 2002
**
===========================================================*/
using System;
using System.Security;
using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
[HostProtectionAttribute(MayLeakOnAbort = true)]
[SuppressUnmanagedCodeSecurityAttribute]
internal sealed class SafeUserTokenHandle : SafeHandleZeroOrMinusOneIsInvalid
{
// Note that OpenProcess returns 0 on failure.
internal SafeUserTokenHandle() : base (true) {}
internal SafeUserTokenHandle(IntPtr existingHandle, bool ownsHandle) : base(ownsHandle) {
SetHandle(existingHandle);
}
#if !FEATURE_PAL
[DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Auto, SetLastError=true, BestFitMapping=false)]
internal extern static bool DuplicateTokenEx(SafeHandle hToken, int access, NativeMethods.SECURITY_ATTRIBUTES tokenAttributes, int impersonationLevel, int tokenType, out SafeUserTokenHandle hNewToken);
#endif // !FEATURE_PAL
[DllImport(ExternDll.Kernel32, ExactSpelling=true, SetLastError=true)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern bool CloseHandle(IntPtr handle);
override protected bool ReleaseHandle()
{
return CloseHandle(handle);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Class: SafeUserTokenHandle
**
** Author: David Gutierrez ([....])
**
** A wrapper for a user token handle
**
** Date: July 8, 2002
**
===========================================================*/
using System;
using System.Security;
using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
[HostProtectionAttribute(MayLeakOnAbort = true)]
[SuppressUnmanagedCodeSecurityAttribute]
internal sealed class SafeUserTokenHandle : SafeHandleZeroOrMinusOneIsInvalid
{
// Note that OpenProcess returns 0 on failure.
internal SafeUserTokenHandle() : base (true) {}
internal SafeUserTokenHandle(IntPtr existingHandle, bool ownsHandle) : base(ownsHandle) {
SetHandle(existingHandle);
}
#if !FEATURE_PAL
[DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Auto, SetLastError=true, BestFitMapping=false)]
internal extern static bool DuplicateTokenEx(SafeHandle hToken, int access, NativeMethods.SECURITY_ATTRIBUTES tokenAttributes, int impersonationLevel, int tokenType, out SafeUserTokenHandle hNewToken);
#endif // !FEATURE_PAL
[DllImport(ExternDll.Kernel32, ExactSpelling=true, SetLastError=true)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern bool CloseHandle(IntPtr handle);
override protected bool ReleaseHandle()
{
return CloseHandle(handle);
}
}
}
// 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
- FileVersionInfo.cs
- HttpAsyncResult.cs
- LostFocusEventManager.cs
- DataGridViewCellStateChangedEventArgs.cs
- WebServiceTypeData.cs
- MetadataWorkspace.cs
- ComAdminWrapper.cs
- XmlObjectSerializer.cs
- _SecureChannel.cs
- ItemChangedEventArgs.cs
- GroupAggregateExpr.cs
- HyperLinkStyle.cs
- CroppedBitmap.cs
- BoundingRectTracker.cs
- TemplateControl.cs
- SpellCheck.cs
- WorkflowCompensationBehavior.cs
- TextFindEngine.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- HttpContext.cs
- WebCategoryAttribute.cs
- WmlListAdapter.cs
- ByteStreamGeometryContext.cs
- Match.cs
- RepeatBehavior.cs
- ClassicBorderDecorator.cs
- SplitterCancelEvent.cs
- BinaryCommonClasses.cs
- SqlProviderManifest.cs
- UnsupportedPolicyOptionsException.cs
- Quaternion.cs
- GroupLabel.cs
- DependencyPropertyKind.cs
- Boolean.cs
- Processor.cs
- LayoutEditorPart.cs
- FrameworkContextData.cs
- CreateUserErrorEventArgs.cs
- Int64AnimationBase.cs
- CodeTypeMemberCollection.cs
- DocumentOrderComparer.cs
- ClipboardData.cs
- _SslStream.cs
- UnionCodeGroup.cs
- translator.cs
- BufferedWebEventProvider.cs
- ContextActivityUtils.cs
- DbProviderFactories.cs
- RegexReplacement.cs
- BinaryFormatter.cs
- SspiNegotiationTokenAuthenticator.cs
- CodeSnippetExpression.cs
- XmlSchemaObjectTable.cs
- FixedBufferAttribute.cs
- __ConsoleStream.cs
- DataGridViewHitTestInfo.cs
- FixedSOMTextRun.cs
- BaseConfigurationRecord.cs
- StringBuilder.cs
- ExternalException.cs
- MediaPlayerState.cs
- ScrollProviderWrapper.cs
- OrthographicCamera.cs
- CompositeDispatchFormatter.cs
- ListViewItem.cs
- XmlSchemaValidator.cs
- PointCollectionConverter.cs
- UrlPropertyAttribute.cs
- DataGrid.cs
- ProfileBuildProvider.cs
- xml.cs
- DriveInfo.cs
- SimpleBitVector32.cs
- TraceSource.cs
- ClientReliableChannelBinder.cs
- X509Extension.cs
- SoapParser.cs
- UnicastIPAddressInformationCollection.cs
- ApplicationDirectory.cs
- ListMarkerLine.cs
- AppDomainProtocolHandler.cs
- TextTreeInsertUndoUnit.cs
- DictionarySectionHandler.cs
- MailDefinition.cs
- FrameworkElement.cs
- RequiredFieldValidator.cs
- VScrollProperties.cs
- StringStorage.cs
- SqlProviderManifest.cs
- DataGridViewRowStateChangedEventArgs.cs
- XmlSchemaRedefine.cs
- ClipboardData.cs
- Boolean.cs
- ResourceCodeDomSerializer.cs
- Message.cs
- ThreadStaticAttribute.cs
- WrappedReader.cs
- SortedList.cs
- util.cs
- ServiceModelTimeSpanValidator.cs