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
- SQLBinary.cs
- SelectionPattern.cs
- StylusDownEventArgs.cs
- XhtmlTextWriter.cs
- XmlComplianceUtil.cs
- PeerResolverMode.cs
- HttpRequestBase.cs
- DataFormat.cs
- ErrorRuntimeConfig.cs
- BooleanFacetDescriptionElement.cs
- EnumConverter.cs
- FrameworkElementFactory.cs
- ListViewUpdatedEventArgs.cs
- EditCommandColumn.cs
- ObjectHandle.cs
- SqlFlattener.cs
- RegexCompilationInfo.cs
- GridViewPageEventArgs.cs
- BrowserDefinition.cs
- RegisteredHiddenField.cs
- SmtpSection.cs
- DataGridPageChangedEventArgs.cs
- BitmapEffectInput.cs
- Vector3D.cs
- RegexRunner.cs
- LateBoundBitmapDecoder.cs
- ScriptServiceAttribute.cs
- ShaderEffect.cs
- ApplyTemplatesAction.cs
- dbenumerator.cs
- PrimaryKeyTypeConverter.cs
- CompModSwitches.cs
- MimePart.cs
- StyleBamlTreeBuilder.cs
- ServiceNameElement.cs
- SecurityHeaderElementInferenceEngine.cs
- PopupControlService.cs
- SQLRoleProvider.cs
- URIFormatException.cs
- PixelShader.cs
- RemotingServices.cs
- WebPartVerbCollection.cs
- AmbiguousMatchException.cs
- InstanceLockTracking.cs
- ArrayHelper.cs
- PolyLineSegment.cs
- DummyDataSource.cs
- EventListener.cs
- ContextMarshalException.cs
- DocumentReferenceCollection.cs
- uribuilder.cs
- Pkcs9Attribute.cs
- ToolStripItemTextRenderEventArgs.cs
- StylusButton.cs
- SequenceDesigner.xaml.cs
- Duration.cs
- RoutedEventConverter.cs
- CollectionBuilder.cs
- NativeCompoundFileAPIs.cs
- HostedHttpContext.cs
- XPathSelectionIterator.cs
- Base64Stream.cs
- XmlWrappingReader.cs
- DataGridState.cs
- ScrollEventArgs.cs
- WindowsScrollBarBits.cs
- BinaryObjectReader.cs
- HttpCookieCollection.cs
- PopOutPanel.cs
- EditCommandColumn.cs
- DbProviderManifest.cs
- DataGridViewUtilities.cs
- Config.cs
- ObjectSet.cs
- DockPattern.cs
- LabelLiteral.cs
- ActivityInterfaces.cs
- DecoderExceptionFallback.cs
- XdrBuilder.cs
- FormatterConverter.cs
- XhtmlMobileTextWriter.cs
- TypeDelegator.cs
- assemblycache.cs
- LocatorManager.cs
- CatalogPartChrome.cs
- GPPOINTF.cs
- RoleServiceManager.cs
- WorkflowApplicationAbortedEventArgs.cs
- ObjectParameterCollection.cs
- CompilationSection.cs
- DrawingContextDrawingContextWalker.cs
- StretchValidation.cs
- LocalizedNameDescriptionPair.cs
- ColumnPropertiesGroup.cs
- AdjustableArrowCap.cs
- Triangle.cs
- CompatibleIComparer.cs
- RegexTree.cs
- LiteralLink.cs
- EUCJPEncoding.cs