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
- FontSource.cs
- FileStream.cs
- HtmlControl.cs
- WhitespaceRule.cs
- webclient.cs
- ChildrenQuery.cs
- DbDataRecord.cs
- SqlTypeConverter.cs
- SQLMoneyStorage.cs
- DataServiceQuery.cs
- WindowsTitleBar.cs
- ExpandCollapsePattern.cs
- DataGridViewAdvancedBorderStyle.cs
- CodeSnippetStatement.cs
- CodeDomComponentSerializationService.cs
- WebPartMenuStyle.cs
- TogglePattern.cs
- Select.cs
- Models.cs
- AsymmetricSignatureFormatter.cs
- HashCodeCombiner.cs
- RSAPKCS1SignatureFormatter.cs
- Normalization.cs
- XmlSchemaIdentityConstraint.cs
- UserControl.cs
- MenuAdapter.cs
- SecurityPermission.cs
- MailAddressCollection.cs
- CodeRegionDirective.cs
- ExpressionsCollectionEditor.cs
- ByteRangeDownloader.cs
- DesignerVerbCollection.cs
- lengthconverter.cs
- AsyncOperationManager.cs
- FontStyles.cs
- LinqDataSourceHelper.cs
- Adorner.cs
- BindingExpressionBase.cs
- CookieParameter.cs
- XPathMessageFilterElementCollection.cs
- TimerEventSubscription.cs
- HtmlTableRow.cs
- VirtualPathProvider.cs
- CompiledXpathExpr.cs
- _Win32.cs
- StringComparer.cs
- PropertyConverter.cs
- EntityDataSourceColumn.cs
- QueryGenerator.cs
- AxImporter.cs
- MetabaseSettings.cs
- TraceContextEventArgs.cs
- InvalidPrinterException.cs
- SchemaInfo.cs
- DataGridDetailsPresenterAutomationPeer.cs
- Point3DAnimationBase.cs
- HttpResponseBase.cs
- EFDataModelProvider.cs
- Rotation3DAnimation.cs
- SortedList.cs
- StorageMappingItemLoader.cs
- ScrollData.cs
- WebControl.cs
- ExtensionSimplifierMarkupObject.cs
- SizeConverter.cs
- OuterGlowBitmapEffect.cs
- Rect.cs
- EventProxy.cs
- ProxyWebPartManagerDesigner.cs
- ExpressionNormalizer.cs
- MbpInfo.cs
- DataGridViewCellStateChangedEventArgs.cs
- MemberProjectionIndex.cs
- DataGridViewColumnTypeEditor.cs
- WebControlParameterProxy.cs
- TextTreeRootNode.cs
- HttpDictionary.cs
- LicenseManager.cs
- HttpResponseMessageProperty.cs
- CharEnumerator.cs
- InternalEnumValidatorAttribute.cs
- MiniCustomAttributeInfo.cs
- EDesignUtil.cs
- StylusCollection.cs
- MaskedTextProvider.cs
- ToolStripDesignerUtils.cs
- ExternalCalls.cs
- ParameterModifier.cs
- DSASignatureDeformatter.cs
- AnnotationObservableCollection.cs
- HtmlSelect.cs
- ImageSource.cs
- Range.cs
- MemoryStream.cs
- ThicknessAnimationUsingKeyFrames.cs
- VerificationException.cs
- FontInfo.cs
- ChannelManager.cs
- PermissionAttributes.cs
- Decimal.cs