Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- PrimitiveDataContract.cs
- TreeIterator.cs
- LookupNode.cs
- MaskedTextBoxDesigner.cs
- ExceptionNotification.cs
- WebServiceParameterData.cs
- RijndaelManaged.cs
- XsltInput.cs
- GroupBox.cs
- ImageSource.cs
- CutCopyPasteHelper.cs
- SerializationException.cs
- StringExpressionSet.cs
- FeatureSupport.cs
- StringAttributeCollection.cs
- FormatSettings.cs
- StronglyTypedResourceBuilder.cs
- DesignerActionUIStateChangeEventArgs.cs
- AdornedElementPlaceholder.cs
- DataRecordInternal.cs
- ByteConverter.cs
- EmptyEnumerable.cs
- Stylus.cs
- DurationConverter.cs
- SQLGuidStorage.cs
- MonthChangedEventArgs.cs
- RightsManagementEncryptedStream.cs
- PackageProperties.cs
- EditorReuseAttribute.cs
- DataGridTextBox.cs
- TraceXPathNavigator.cs
- SqlAliaser.cs
- PasswordRecovery.cs
- ScriptServiceAttribute.cs
- Privilege.cs
- ProtocolsConfigurationEntry.cs
- AsyncSerializedWorker.cs
- BuildManagerHost.cs
- HttpListenerContext.cs
- XmlQueryStaticData.cs
- EntityStoreSchemaFilterEntry.cs
- LongTypeConverter.cs
- ElapsedEventArgs.cs
- WebPartAddingEventArgs.cs
- DictionaryContent.cs
- DefaultEventAttribute.cs
- AssemblySettingAttributes.cs
- CategoryEditor.cs
- ReliableMessagingVersion.cs
- StrokeSerializer.cs
- MemberInfoSerializationHolder.cs
- Native.cs
- BaseDataList.cs
- OdbcErrorCollection.cs
- Rect3D.cs
- EncodingTable.cs
- ModelPerspective.cs
- TrackPoint.cs
- DependencyPropertyAttribute.cs
- TableLayoutPanelBehavior.cs
- DocumentApplication.cs
- CustomGrammar.cs
- CompilerInfo.cs
- SubordinateTransaction.cs
- TableLayoutPanelBehavior.cs
- RedistVersionInfo.cs
- SplineQuaternionKeyFrame.cs
- LicFileLicenseProvider.cs
- HandledMouseEvent.cs
- WebPartUtil.cs
- DragEventArgs.cs
- StatusBarDrawItemEvent.cs
- HostingEnvironmentException.cs
- CustomAttributeBuilder.cs
- ReaderContextStackData.cs
- OrderByBuilder.cs
- PeerNearMe.cs
- InitializerFacet.cs
- SpinWait.cs
- DescriptionAttribute.cs
- HostSecurityManager.cs
- HatchBrush.cs
- ControlParameter.cs
- WhitespaceRuleLookup.cs
- HeaderPanel.cs
- FixedLineResult.cs
- Visual3DCollection.cs
- SrgsElement.cs
- ScriptManagerProxy.cs
- XmlValidatingReader.cs
- XomlCompiler.cs
- PageRequestManager.cs
- _IPv6Address.cs
- InfoCardRSAPKCS1KeyExchangeFormatter.cs
- SapiRecoContext.cs
- ExpressionTable.cs
- HostingEnvironmentException.cs
- RectAnimationUsingKeyFrames.cs
- login.cs
- NameObjectCollectionBase.cs