Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- SafeNativeMethods.cs
- ImportContext.cs
- EndpointAddressMessageFilter.cs
- TextServicesHost.cs
- StyleHelper.cs
- FirstMatchCodeGroup.cs
- processwaithandle.cs
- DocumentXmlWriter.cs
- StructureChangedEventArgs.cs
- EnumType.cs
- ProcessRequestArgs.cs
- PaperSource.cs
- DynamicDataRoute.cs
- AssociativeAggregationOperator.cs
- SizeAnimationUsingKeyFrames.cs
- UpdatePanel.cs
- NetCodeGroup.cs
- codemethodreferenceexpression.cs
- PartialCachingAttribute.cs
- FormsAuthenticationEventArgs.cs
- _AutoWebProxyScriptHelper.cs
- Thread.cs
- EntityViewContainer.cs
- InputScopeNameConverter.cs
- ConnectionStringsSection.cs
- RawStylusInputReport.cs
- DispatcherFrame.cs
- Sequence.cs
- WindowsRegion.cs
- ReflectTypeDescriptionProvider.cs
- SizeAnimation.cs
- DataTrigger.cs
- HijriCalendar.cs
- ComplexLine.cs
- TrustLevelCollection.cs
- NameSpaceExtractor.cs
- CreateUserErrorEventArgs.cs
- SystemBrushes.cs
- KeyTime.cs
- SQLBytesStorage.cs
- HttpCachePolicyElement.cs
- CopyAction.cs
- ServiceReference.cs
- KeyNameIdentifierClause.cs
- Timer.cs
- CompiledAction.cs
- GCHandleCookieTable.cs
- PointCollectionConverter.cs
- XPathExpr.cs
- MsmqIntegrationMessagePool.cs
- FileChangesMonitor.cs
- WebSysDefaultValueAttribute.cs
- UnsafeNativeMethods.cs
- ListBox.cs
- TimelineCollection.cs
- NumberSubstitution.cs
- EngineSiteSapi.cs
- XamlBrushSerializer.cs
- RectangleGeometry.cs
- SecurityStandardsManager.cs
- SqlFactory.cs
- TriggerActionCollection.cs
- RoleGroupCollection.cs
- HttpRequestWrapper.cs
- FixedPage.cs
- Focus.cs
- ReferencedCollectionType.cs
- CachedTypeface.cs
- Attribute.cs
- _AcceptOverlappedAsyncResult.cs
- TableLayoutPanelCellPosition.cs
- _LoggingObject.cs
- TypeFieldSchema.cs
- ViewKeyConstraint.cs
- EpmTargetTree.cs
- XPathEmptyIterator.cs
- SelectionWordBreaker.cs
- XmlException.cs
- ByteConverter.cs
- GcHandle.cs
- cookiecontainer.cs
- CalendarDataBindingHandler.cs
- DataGridDesigner.cs
- AsynchronousChannelMergeEnumerator.cs
- PageParserFilter.cs
- StringAnimationUsingKeyFrames.cs
- SQLSingle.cs
- EventListener.cs
- MessageAction.cs
- Group.cs
- WindowsStatusBar.cs
- ControlLocalizer.cs
- TextTreeInsertElementUndoUnit.cs
- BrowserCapabilitiesCodeGenerator.cs
- NetCodeGroup.cs
- SqlMethods.cs
- RegexWorker.cs
- ReliabilityContractAttribute.cs
- SqlExpressionNullability.cs
- MaskedTextBoxTextEditorDropDown.cs