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
- ManagementEventArgs.cs
- CFStream.cs
- DataGridPreparingCellForEditEventArgs.cs
- BulletedListDesigner.cs
- selecteditemcollection.cs
- PersonalizableTypeEntry.cs
- X509ThumbprintKeyIdentifierClause.cs
- ConfigurationElement.cs
- SecurityKeyType.cs
- AbsoluteQuery.cs
- ResourceReferenceExpression.cs
- OdbcError.cs
- Table.cs
- ReadWriteSpinLock.cs
- XmlCodeExporter.cs
- ZipPackage.cs
- CompoundFileIOPermission.cs
- VersionValidator.cs
- DragStartedEventArgs.cs
- BlurBitmapEffect.cs
- OracleConnectionStringBuilder.cs
- TransactionScope.cs
- ArgumentException.cs
- HtmlWindow.cs
- XNodeNavigator.cs
- EditingMode.cs
- XsdBuildProvider.cs
- XamlPoint3DCollectionSerializer.cs
- SqlServices.cs
- URIFormatException.cs
- ProviderConnectionPoint.cs
- ItemsPresenter.cs
- VirtualDirectoryMapping.cs
- ServerValidateEventArgs.cs
- __Filters.cs
- TdsEnums.cs
- ReceiveActivityDesigner.cs
- RSACryptoServiceProvider.cs
- SplitterPanel.cs
- XmlDataSource.cs
- LogicalMethodInfo.cs
- MsmqActivation.cs
- RemoteWebConfigurationHostServer.cs
- DesignerToolboxInfo.cs
- ButtonBase.cs
- UrlMapping.cs
- GridViewRowPresenterBase.cs
- Stack.cs
- SystemIPGlobalStatistics.cs
- HtmlInputButton.cs
- TreeNode.cs
- FrameworkElementFactory.cs
- TitleStyle.cs
- EventManager.cs
- OleDbException.cs
- BuildProvider.cs
- OracleEncoding.cs
- ApplicationTrust.cs
- TraceSource.cs
- EventLogEntryCollection.cs
- RequestQueryProcessor.cs
- BufferedStream.cs
- TrackingSection.cs
- StyleReferenceConverter.cs
- ObjectDataSourceSelectingEventArgs.cs
- XmlSchemaSimpleContentRestriction.cs
- XmlSerializerAssemblyAttribute.cs
- UserPersonalizationStateInfo.cs
- StorageEntityTypeMapping.cs
- ThrowOnMultipleAssignment.cs
- ModuleBuilder.cs
- DelayedRegex.cs
- Expression.cs
- FixedTextBuilder.cs
- IntPtr.cs
- ItemList.cs
- SystemInformation.cs
- KnownBoxes.cs
- RowParagraph.cs
- SchemaAttDef.cs
- GridSplitterAutomationPeer.cs
- MiniModule.cs
- AnimationClockResource.cs
- PersonalizationDictionary.cs
- BamlMapTable.cs
- HttpCookiesSection.cs
- FirewallWrapper.cs
- CutCopyPasteHelper.cs
- SettingsSavedEventArgs.cs
- Number.cs
- WebPartConnectionsCancelEventArgs.cs
- ScriptControlManager.cs
- SafeBitVector32.cs
- KeyManager.cs
- BuildProviderCollection.cs
- SourceInterpreter.cs
- BulletedList.cs
- IdentityModelDictionary.cs
- ToolboxItemFilterAttribute.cs
- BulletChrome.cs