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
- GridErrorDlg.cs
- ToolboxControl.cs
- PropertyMetadata.cs
- ReflectionServiceProvider.cs
- StylusPointPropertyUnit.cs
- NamespaceCollection.cs
- Activity.cs
- ToolStripSeparator.cs
- RankException.cs
- validationstate.cs
- ArrayElementGridEntry.cs
- BasicKeyConstraint.cs
- WebScriptEnablingElement.cs
- BuildProvider.cs
- RoutedEventConverter.cs
- DistinctQueryOperator.cs
- InfoCardService.cs
- ResourceDefaultValueAttribute.cs
- ToolStripDropDown.cs
- Overlapped.cs
- MSAANativeProvider.cs
- PriorityQueue.cs
- HyperlinkAutomationPeer.cs
- ApplicationSecurityManager.cs
- WindowsComboBox.cs
- DelegateHelpers.Generated.cs
- InkCanvasSelection.cs
- RegisteredArrayDeclaration.cs
- ListDictionaryInternal.cs
- DelegateBodyWriter.cs
- DocumentsTrace.cs
- DataGridTable.cs
- NativeWindow.cs
- CompilerLocalReference.cs
- ImageSourceValueSerializer.cs
- HoistedLocals.cs
- AsyncCallback.cs
- DataGridTable.cs
- SolidColorBrush.cs
- DrawingDrawingContext.cs
- IndicShape.cs
- QilTernary.cs
- CodeConditionStatement.cs
- XmlElementAttribute.cs
- ConnectionOrientedTransportManager.cs
- UInt16Storage.cs
- RawStylusInput.cs
- TraceFilter.cs
- XmlObjectSerializerContext.cs
- DataGridComponentEditor.cs
- mil_sdk_version.cs
- BindingListCollectionView.cs
- PrincipalPermission.cs
- MenuAdapter.cs
- StructuralType.cs
- ContainerSelectorActiveEvent.cs
- Soap11ServerProtocol.cs
- XmlUnspecifiedAttribute.cs
- ProjectionCamera.cs
- Relationship.cs
- SmtpReplyReaderFactory.cs
- CreatingCookieEventArgs.cs
- CorrelationManager.cs
- SafeNativeMethods.cs
- SyntaxCheck.cs
- ExtractedStateEntry.cs
- OleTxTransaction.cs
- FormClosedEvent.cs
- PassportAuthenticationEventArgs.cs
- SoapExtensionReflector.cs
- WebServiceResponse.cs
- MetadataUtil.cs
- DesignerImageAdapter.cs
- ProgressBarRenderer.cs
- ScrollItemPattern.cs
- ComplexTypeEmitter.cs
- CodeExpressionStatement.cs
- ObjectList.cs
- ActivityCollectionMarkupSerializer.cs
- TextSelection.cs
- UnmanagedBitmapWrapper.cs
- XmlIgnoreAttribute.cs
- RelatedEnd.cs
- DataBoundControl.cs
- Repeater.cs
- X509Certificate.cs
- SecurityTokenAttachmentMode.cs
- basecomparevalidator.cs
- LongAverageAggregationOperator.cs
- DriveInfo.cs
- RegionIterator.cs
- ClusterSafeNativeMethods.cs
- ReaderWriterLock.cs
- SHA512Cng.cs
- ProviderCommandInfoUtils.cs
- CustomErrorCollection.cs
- MD5CryptoServiceProvider.cs
- StringAnimationUsingKeyFrames.cs
- TemplateApplicationHelper.cs
- DescendantOverDescendantQuery.cs