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
- DbTransaction.cs
- DesigntimeLicenseContextSerializer.cs
- UnsafeNativeMethods.cs
- FilteredXmlReader.cs
- XPathArrayIterator.cs
- ThreadSafeList.cs
- ObjectViewQueryResultData.cs
- latinshape.cs
- _KerberosClient.cs
- CategoryNameCollection.cs
- ExpressionReplacer.cs
- Win32Exception.cs
- AuthenticatedStream.cs
- HotSpot.cs
- InvokeWebService.cs
- ToolBar.cs
- SharedStream.cs
- PolicyLevel.cs
- AutoCompleteStringCollection.cs
- LogEntryUtils.cs
- ProgressBarBrushConverter.cs
- EventProviderWriter.cs
- ComponentResourceKey.cs
- GridViewRowEventArgs.cs
- BindingSource.cs
- MemberRelationshipService.cs
- NameHandler.cs
- ReflectTypeDescriptionProvider.cs
- FixedLineResult.cs
- HttpCapabilitiesSectionHandler.cs
- EndpointIdentity.cs
- RtfToken.cs
- IntSecurity.cs
- CollectionMarkupSerializer.cs
- AccessViolationException.cs
- CustomLineCap.cs
- Component.cs
- VisualStateChangedEventArgs.cs
- PersistenceException.cs
- HtmlInputSubmit.cs
- TagMapInfo.cs
- EntityDataSourceState.cs
- SymmetricAlgorithm.cs
- ImageListUtils.cs
- BoundPropertyEntry.cs
- Automation.cs
- InputMethodStateChangeEventArgs.cs
- RequestCachingSection.cs
- RequestBringIntoViewEventArgs.cs
- InfoCardServiceInstallComponent.cs
- WebPartVerb.cs
- PlainXmlSerializer.cs
- ParentUndoUnit.cs
- RuleInfoComparer.cs
- SocketException.cs
- CodeDefaultValueExpression.cs
- FileSecurity.cs
- ConfigurationPropertyAttribute.cs
- DataGridViewLayoutData.cs
- Viewport3DAutomationPeer.cs
- MetadataItem_Static.cs
- EventlogProvider.cs
- TagPrefixAttribute.cs
- CTreeGenerator.cs
- ViewPort3D.cs
- PageCodeDomTreeGenerator.cs
- EndSelectCardRequest.cs
- HMACSHA256.cs
- GenericPrincipal.cs
- CodeIdentifier.cs
- MaterialCollection.cs
- TextFormatterContext.cs
- SQLBytes.cs
- UpdateRecord.cs
- SelectedPathEditor.cs
- LinqExpressionNormalizer.cs
- ZoneLinkButton.cs
- SafeNativeMethods.cs
- ValidationResult.cs
- CornerRadius.cs
- StringAnimationUsingKeyFrames.cs
- BlockCollection.cs
- NonSerializedAttribute.cs
- DateTimeUtil.cs
- SendMailErrorEventArgs.cs
- OutKeywords.cs
- XmlMemberMapping.cs
- TransformerConfigurationWizardBase.cs
- ReadOnlyDictionary.cs
- Matrix3DConverter.cs
- GridViewRowPresenter.cs
- ExceptionValidationRule.cs
- ImageConverter.cs
- SiteMapProvider.cs
- DataGridViewSortCompareEventArgs.cs
- Part.cs
- CodeVariableDeclarationStatement.cs
- AlphabetConverter.cs
- EmptyEnumerator.cs
- Relationship.cs