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
- OdbcDataAdapter.cs
- TraceSource.cs
- ImpersonateTokenRef.cs
- RoleManagerEventArgs.cs
- VisualBrush.cs
- CompositeDesignerAccessibleObject.cs
- DbReferenceCollection.cs
- BamlWriter.cs
- DesignerObject.cs
- RoleManagerSection.cs
- AutomationElementIdentifiers.cs
- ViewSimplifier.cs
- StylusCaptureWithinProperty.cs
- CursorInteropHelper.cs
- TypedReference.cs
- ObjectItemCollection.cs
- DiscoveryEndpoint.cs
- NoResizeSelectionBorderGlyph.cs
- ProbeMatchesMessageCD1.cs
- StringComparer.cs
- ToolStripDropDownClosedEventArgs.cs
- SchemaImporterExtensionElement.cs
- Membership.cs
- CalendarAutoFormatDialog.cs
- JoinElimination.cs
- EmissiveMaterial.cs
- CorrelationActionMessageFilter.cs
- EmptyEnumerator.cs
- WebPartMenu.cs
- DataGridTablesFactory.cs
- XmlIlVisitor.cs
- AbsoluteQuery.cs
- ActiveXSite.cs
- SolidColorBrush.cs
- Vertex.cs
- BookmarkList.cs
- ScriptingAuthenticationServiceSection.cs
- PointCollection.cs
- StylusEditingBehavior.cs
- WhitespaceSignificantCollectionAttribute.cs
- Range.cs
- SecurityTokenValidationException.cs
- ButtonChrome.cs
- TextEditorCharacters.cs
- RowType.cs
- PathHelper.cs
- InvalidPrinterException.cs
- IdlingCommunicationPool.cs
- SqlConnectionString.cs
- ProfileGroupSettingsCollection.cs
- CSharpCodeProvider.cs
- ObjectCacheHost.cs
- ConfigurationManagerHelper.cs
- MimeTypeMapper.cs
- ConfigXmlReader.cs
- ButtonPopupAdapter.cs
- XPathDocumentNavigator.cs
- SecurityResources.cs
- QilSortKey.cs
- SignedXml.cs
- MenuItemStyle.cs
- CommandID.cs
- ScriptServiceAttribute.cs
- Clock.cs
- util.cs
- MultilineStringConverter.cs
- RouteParametersHelper.cs
- DeleteStoreRequest.cs
- DataGridViewBindingCompleteEventArgs.cs
- EmptyQuery.cs
- DesignTimeParseData.cs
- RoutedEventConverter.cs
- Unit.cs
- ProxyWebPartConnectionCollection.cs
- BufferCache.cs
- ellipse.cs
- SatelliteContractVersionAttribute.cs
- ParenthesizePropertyNameAttribute.cs
- DesignRelationCollection.cs
- DataPagerField.cs
- SqlDependencyUtils.cs
- WeakReferenceEnumerator.cs
- EnumType.cs
- GroupItemAutomationPeer.cs
- ContainerUIElement3D.cs
- SqlParameter.cs
- PackageFilter.cs
- MarkupCompilePass1.cs
- ConstraintConverter.cs
- MediaContextNotificationWindow.cs
- updateconfighost.cs
- XmlSequenceWriter.cs
- DependencyPropertyConverter.cs
- TypePresenter.xaml.cs
- AppDomainGrammarProxy.cs
- TableRowGroupCollection.cs
- ContentElement.cs
- SafePointer.cs
- Sql8ExpressionRewriter.cs
- InvokePatternIdentifiers.cs