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
- ImageFormatConverter.cs
- Utils.cs
- StyleXamlTreeBuilder.cs
- HttpDebugHandler.cs
- DiscoveryDocumentSearchPattern.cs
- Page.cs
- EventLogPermission.cs
- CharacterBufferReference.cs
- Geometry3D.cs
- TextServicesProperty.cs
- Rectangle.cs
- IgnoreFileBuildProvider.cs
- ScriptComponentDescriptor.cs
- ValidationErrorInfo.cs
- TextTreeObjectNode.cs
- SoapFault.cs
- PasswordDeriveBytes.cs
- SequentialUshortCollection.cs
- CodeDelegateInvokeExpression.cs
- assemblycache.cs
- ObjectQuery_EntitySqlExtensions.cs
- OutputCacheSection.cs
- BinaryUtilClasses.cs
- ArrayTypeMismatchException.cs
- CmsInterop.cs
- DependencyPropertyConverter.cs
- CodeArrayIndexerExpression.cs
- BrowserCapabilitiesFactoryBase.cs
- HasRunnableWorkflowEvent.cs
- LinkClickEvent.cs
- ListViewItemMouseHoverEvent.cs
- VirtualizingStackPanel.cs
- ToolboxService.cs
- MailFileEditor.cs
- Block.cs
- WindowVisualStateTracker.cs
- RegularExpressionValidator.cs
- CurrentTimeZone.cs
- autovalidator.cs
- RegionInfo.cs
- HostedTransportConfigurationManager.cs
- Pointer.cs
- ConfigurationProperty.cs
- HtmlInputHidden.cs
- WindowsButton.cs
- DesignerWithHeader.cs
- RuntimeHelpers.cs
- MiniModule.cs
- LinearGradientBrush.cs
- TextFormatterHost.cs
- ArithmeticLiteral.cs
- SimpleRecyclingCache.cs
- DetailsViewPageEventArgs.cs
- AdditionalEntityFunctions.cs
- WarningException.cs
- Base64Encoder.cs
- UnsafeNativeMethods.cs
- RecordManager.cs
- AdapterUtil.cs
- ISAPIWorkerRequest.cs
- ApplicationTrust.cs
- CopyNodeSetAction.cs
- ProfileModule.cs
- WorkflowInstanceProxy.cs
- PointConverter.cs
- DispatcherEventArgs.cs
- BindingValueChangedEventArgs.cs
- ToolStripRenderer.cs
- DriveNotFoundException.cs
- DataBoundControl.cs
- EncodingNLS.cs
- Binding.cs
- SurrogateSelector.cs
- LocalizedNameDescriptionPair.cs
- DeclaredTypeValidator.cs
- WebServiceHandler.cs
- IISMapPath.cs
- RealProxy.cs
- InheritanceRules.cs
- VsPropertyGrid.cs
- SiblingIterators.cs
- GridViewUpdatedEventArgs.cs
- ComAdminInterfaces.cs
- MessageBodyDescription.cs
- FrameworkElementFactory.cs
- NotifyIcon.cs
- Journal.cs
- BooleanFunctions.cs
- WebPartCatalogAddVerb.cs
- Win32Native.cs
- FrameworkElementFactory.cs
- HttpEncoderUtility.cs
- XmlExtensionFunction.cs
- UnSafeCharBuffer.cs
- CompositionTarget.cs
- Privilege.cs
- RemotingException.cs
- PartialCachingAttribute.cs
- ScriptIgnoreAttribute.cs
- HwndHost.cs