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
- DomNameTable.cs
- SocketAddress.cs
- FaultConverter.cs
- GestureRecognitionResult.cs
- ScrollBarAutomationPeer.cs
- ReliableMessagingHelpers.cs
- OracleConnection.cs
- SpoolingTask.cs
- GeometryHitTestResult.cs
- WebPartMenuStyle.cs
- CustomCredentialPolicy.cs
- UIHelper.cs
- Image.cs
- PhoneCallDesigner.cs
- _ScatterGatherBuffers.cs
- Graphics.cs
- login.cs
- Enum.cs
- CodeDOMUtility.cs
- CachedBitmap.cs
- ConstructorNeedsTagAttribute.cs
- TemplateControlBuildProvider.cs
- WebPartVerb.cs
- TrustManagerMoreInformation.cs
- SessionPageStateSection.cs
- RawStylusInputCustomData.cs
- XmlSchemaSimpleType.cs
- DiscoveryClient.cs
- TextElementAutomationPeer.cs
- BulletChrome.cs
- InitializeCorrelation.cs
- ControlCodeDomSerializer.cs
- Menu.cs
- TreeViewImageKeyConverter.cs
- BitmapImage.cs
- DataControlField.cs
- CommonXSendMessage.cs
- BitmapDownload.cs
- BufferBuilder.cs
- Header.cs
- BaseValidator.cs
- InputLanguageEventArgs.cs
- HtmlTitle.cs
- DtrList.cs
- CompilerError.cs
- _HeaderInfoTable.cs
- JournalEntry.cs
- ToolboxService.cs
- BypassElementCollection.cs
- GridViewColumn.cs
- SafeMILHandle.cs
- PointCollection.cs
- HttpVersion.cs
- ForceCopyBuildProvider.cs
- CompiledQuery.cs
- HotSpotCollection.cs
- _SecureChannel.cs
- DefaultPropertyAttribute.cs
- PersonalizationProviderCollection.cs
- CommunicationObjectAbortedException.cs
- TdsParserStateObject.cs
- InlineUIContainer.cs
- oledbmetadatacollectionnames.cs
- XPathNodeHelper.cs
- SerializableAttribute.cs
- ObjectListField.cs
- InkCanvasSelection.cs
- RenderOptions.cs
- ProfileSettings.cs
- CompiledQueryCacheKey.cs
- Point.cs
- Transform.cs
- ToolStripDropDownMenu.cs
- PathGradientBrush.cs
- CodeSnippetTypeMember.cs
- ChangeConflicts.cs
- CommandEventArgs.cs
- StorageEntityTypeMapping.cs
- PolyBezierSegment.cs
- DocumentApplicationJournalEntry.cs
- Figure.cs
- InputScopeAttribute.cs
- CodeBinaryOperatorExpression.cs
- HMACMD5.cs
- FileSystemEventArgs.cs
- ModelTypeConverter.cs
- ContentElementCollection.cs
- parserscommon.cs
- EdmConstants.cs
- precedingquery.cs
- PopupControlService.cs
- RuleEngine.cs
- Label.cs
- PathGradientBrush.cs
- AutomationPatternInfo.cs
- UserUseLicenseDictionaryLoader.cs
- CodeAttachEventStatement.cs
- TerminateSequenceResponse.cs
- SystemNetHelpers.cs
- filewebresponse.cs