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
- AdCreatedEventArgs.cs
- CodeExporter.cs
- QuadraticBezierSegment.cs
- DataControlFieldCell.cs
- MetadataPropertyAttribute.cs
- DbConnectionClosed.cs
- UITypeEditors.cs
- OleDbException.cs
- XmlIncludeAttribute.cs
- PaperSource.cs
- ConfigurationValidatorAttribute.cs
- DictionaryEntry.cs
- InputScope.cs
- SymDocumentType.cs
- ReflectionUtil.cs
- XPathParser.cs
- ExpandCollapseProviderWrapper.cs
- SortedDictionary.cs
- FeatureManager.cs
- ToolStripItemCollection.cs
- ASCIIEncoding.cs
- BitmapSourceSafeMILHandle.cs
- ClientScriptManager.cs
- RightNameExpirationInfoPair.cs
- HtmlTernaryTree.cs
- HttpListenerContext.cs
- Transform.cs
- WindowsToolbarItemAsMenuItem.cs
- DataGridViewComboBoxEditingControl.cs
- SchemaTableOptionalColumn.cs
- SchemaConstraints.cs
- HashHelper.cs
- Vector3DIndependentAnimationStorage.cs
- MethodCallConverter.cs
- ControlType.cs
- SpotLight.cs
- SystemIPInterfaceStatistics.cs
- SqlConnectionPoolGroupProviderInfo.cs
- CodeTypeOfExpression.cs
- NavigationProperty.cs
- RelationalExpressions.cs
- WsdlBuildProvider.cs
- ElementMarkupObject.cs
- LocationSectionRecord.cs
- SafeBitVector32.cs
- SafeViewOfFileHandle.cs
- RenderContext.cs
- MatrixStack.cs
- XmlILAnnotation.cs
- OneOfElement.cs
- AppSecurityManager.cs
- BuildProvidersCompiler.cs
- AuthorizationRule.cs
- Brush.cs
- wgx_sdk_version.cs
- EditorZone.cs
- SafeHandle.cs
- JournalEntry.cs
- ConfigXmlElement.cs
- ServiceDescriptionData.cs
- TextWriterTraceListener.cs
- Soap.cs
- ModelUIElement3D.cs
- XPathParser.cs
- TextBox.cs
- WorkflowViewManager.cs
- GridSplitter.cs
- CompressedStack.cs
- DiagnosticsConfigurationHandler.cs
- PropertyNames.cs
- ToolBarButtonClickEvent.cs
- Currency.cs
- httpstaticobjectscollection.cs
- SqlTypesSchemaImporter.cs
- relpropertyhelper.cs
- MembershipPasswordException.cs
- SyndicationDeserializer.cs
- MediaSystem.cs
- UriTemplatePathSegment.cs
- GetWinFXPath.cs
- ExpandSegmentCollection.cs
- CriticalExceptions.cs
- DragEventArgs.cs
- EntityProxyTypeInfo.cs
- PartialClassGenerationTaskInternal.cs
- PreviousTrackingServiceAttribute.cs
- InstanceDataCollectionCollection.cs
- MultilineStringConverter.cs
- BitmapFrameEncode.cs
- OutputBuffer.cs
- ListViewCommandEventArgs.cs
- BinaryFormatter.cs
- AsyncOperation.cs
- UserCancellationException.cs
- Filter.cs
- DynamicRendererThreadManager.cs
- RevocationPoint.cs
- ScriptManagerProxy.cs
- AddInSegmentDirectoryNotFoundException.cs
- PolicyStatement.cs