Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / 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); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FontNameConverter.cs
- Size.cs
- SafeNativeMethods.cs
- SqlInternalConnection.cs
- BoundConstants.cs
- LicenseContext.cs
- XmlArrayItemAttribute.cs
- ToolTipAutomationPeer.cs
- RawStylusInput.cs
- Attributes.cs
- Lazy.cs
- SqlTypeSystemProvider.cs
- BitmapDownload.cs
- TranslateTransform.cs
- TextDataBindingHandler.cs
- DbParameterCollectionHelper.cs
- HelpKeywordAttribute.cs
- CommentEmitter.cs
- DateTimeFormatInfo.cs
- StandardTransformFactory.cs
- RepeatBehavior.cs
- OpCellTreeNode.cs
- DragDropManager.cs
- SqlExpressionNullability.cs
- EntityViewContainer.cs
- MutexSecurity.cs
- XsltQilFactory.cs
- SqlSupersetValidator.cs
- SemaphoreSecurity.cs
- StatusBarItem.cs
- StorageRoot.cs
- GenericUriParser.cs
- HttpCachePolicyElement.cs
- CryptoApi.cs
- XmlSchemaSimpleTypeRestriction.cs
- Bold.cs
- HttpConfigurationContext.cs
- HtmlTableCell.cs
- ILGenerator.cs
- LiteralLink.cs
- Enum.cs
- QueryRelOp.cs
- ValidatedControlConverter.cs
- BinaryFormatterWriter.cs
- ResXResourceSet.cs
- Section.cs
- PreloadedPackages.cs
- WebConfigurationHost.cs
- RectangleGeometry.cs
- PixelShader.cs
- XPathNavigatorKeyComparer.cs
- ResourceAttributes.cs
- PathSegment.cs
- SqlProvider.cs
- OpCodes.cs
- ExpressionBinding.cs
- PathSegment.cs
- PropertyDescriptorComparer.cs
- IImplicitResourceProvider.cs
- BasicHttpSecurityElement.cs
- ParamArrayAttribute.cs
- LingerOption.cs
- GAC.cs
- PluralizationService.cs
- PrePrepareMethodAttribute.cs
- CodeDirectionExpression.cs
- ClientData.cs
- _AuthenticationState.cs
- ProcessHostConfigUtils.cs
- EditingMode.cs
- DefaultValueTypeConverter.cs
- NegotiateStream.cs
- DelegatingConfigHost.cs
- LinearKeyFrames.cs
- ImpersonationContext.cs
- NativeMethods.cs
- DrawingAttributeSerializer.cs
- QuaternionRotation3D.cs
- NumericUpDownAcceleration.cs
- ApplicationManager.cs
- PointValueSerializer.cs
- WebPartMovingEventArgs.cs
- NativeRecognizer.cs
- UnsafeCollabNativeMethods.cs
- CmsUtils.cs
- SchemaSetCompiler.cs
- HybridDictionary.cs
- CodeChecksumPragma.cs
- SettingsBindableAttribute.cs
- EmptyQuery.cs
- ScriptBehaviorDescriptor.cs
- CodeMemberMethod.cs
- XmlSiteMapProvider.cs
- SamlAttribute.cs
- KeySpline.cs
- ServicePoint.cs
- DesignerActionList.cs
- FontSourceCollection.cs
- ThaiBuddhistCalendar.cs
- PasswordDeriveBytes.cs