Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- WindowsFont.cs
- EncoderParameters.cs
- Geometry3D.cs
- RedistVersionInfo.cs
- RtfToXamlLexer.cs
- VectorAnimationBase.cs
- EncryptedXml.cs
- RenderingEventArgs.cs
- DataGridViewButtonCell.cs
- EdmMember.cs
- FixedSOMElement.cs
- DecimalConverter.cs
- RuleSettings.cs
- PasswordRecovery.cs
- IdentityHolder.cs
- EpmCustomContentWriterNodeData.cs
- XhtmlTextWriter.cs
- DisableDpiAwarenessAttribute.cs
- PageAsyncTaskManager.cs
- Int64AnimationUsingKeyFrames.cs
- NavigationPropertyEmitter.cs
- TrackBar.cs
- MergePropertyDescriptor.cs
- ConnectionManagementSection.cs
- OrderedDictionary.cs
- CacheAxisQuery.cs
- UnauthorizedAccessException.cs
- MailMessageEventArgs.cs
- UnmanagedBitmapWrapper.cs
- OraclePermission.cs
- Timer.cs
- HScrollBar.cs
- CustomValidator.cs
- Selector.cs
- AdCreatedEventArgs.cs
- RelationshipFixer.cs
- Int16.cs
- ListViewItemSelectionChangedEvent.cs
- GenericEnumerator.cs
- FlowDocumentView.cs
- TreeNodeBinding.cs
- MultipartContentParser.cs
- PointAnimationBase.cs
- EdmType.cs
- FieldNameLookup.cs
- MessageDecoder.cs
- RoutingTable.cs
- EditorPartChrome.cs
- Journaling.cs
- FilterQuery.cs
- ThicknessAnimation.cs
- RayMeshGeometry3DHitTestResult.cs
- ValueProviderWrapper.cs
- ControlIdConverter.cs
- FolderBrowserDialogDesigner.cs
- ValidatingReaderNodeData.cs
- DockAndAnchorLayout.cs
- CalendarKeyboardHelper.cs
- Enlistment.cs
- XPathDocument.cs
- DeviceContext2.cs
- Tag.cs
- SpeakProgressEventArgs.cs
- SystemDiagnosticsSection.cs
- cookie.cs
- PieceNameHelper.cs
- JulianCalendar.cs
- MetaData.cs
- RMEnrollmentPage2.cs
- VisualBrush.cs
- ControlDesigner.cs
- Quaternion.cs
- OleServicesContext.cs
- Inflater.cs
- FlowNode.cs
- TemplateXamlTreeBuilder.cs
- SqlDataSourceStatusEventArgs.cs
- ActivityTypeDesigner.xaml.cs
- UseManagedPresentationElement.cs
- FragmentQueryProcessor.cs
- EntityDataSourceContainerNameConverter.cs
- sortedlist.cs
- StreamInfo.cs
- TraceRecord.cs
- LockedHandleGlyph.cs
- NumberFunctions.cs
- HtmlShim.cs
- UpdateCompiler.cs
- BaseComponentEditor.cs
- XPathNavigatorKeyComparer.cs
- QuadraticBezierSegment.cs
- ParseElement.cs
- Size.cs
- LinqDataSourceDisposeEventArgs.cs
- UseLicense.cs
- sqlmetadatafactory.cs
- ResolveNameEventArgs.cs
- ReceiveDesigner.xaml.cs
- WaitHandleCannotBeOpenedException.cs
- ResourceReferenceExpressionConverter.cs