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
- CTreeGenerator.cs
- BinaryReader.cs
- DataKey.cs
- Int32CAMarshaler.cs
- MapPathBasedVirtualPathProvider.cs
- HttpHandlersSection.cs
- LineGeometry.cs
- VirtualPathProvider.cs
- SecurityCredentialsManager.cs
- InternalTypeHelper.cs
- EffectiveValueEntry.cs
- SessionStateModule.cs
- MachineSettingsSection.cs
- ContentElementCollection.cs
- EventProxy.cs
- CodeTypeReference.cs
- RadioButtonBaseAdapter.cs
- HebrewCalendar.cs
- XmlSchemaCompilationSettings.cs
- SolidBrush.cs
- Rect3D.cs
- UrlMappingsSection.cs
- EventDescriptor.cs
- Compiler.cs
- Executor.cs
- UserPersonalizationStateInfo.cs
- TextComposition.cs
- TagElement.cs
- TiffBitmapEncoder.cs
- DynamicDataExtensions.cs
- PropertyPathWorker.cs
- XmlElement.cs
- BooleanFunctions.cs
- PreviewPrintController.cs
- AsyncResult.cs
- XPathBinder.cs
- IgnoreSection.cs
- HtmlLinkAdapter.cs
- DbProviderSpecificTypePropertyAttribute.cs
- IxmlLineInfo.cs
- keycontainerpermission.cs
- DataControlLinkButton.cs
- WinCategoryAttribute.cs
- CrossContextChannel.cs
- ChildChangedEventArgs.cs
- FastEncoderWindow.cs
- ReceiveContent.cs
- XamlHostingSectionGroup.cs
- WpfPayload.cs
- RootBrowserWindow.cs
- XmlReaderSettings.cs
- OlePropertyStructs.cs
- UrlMappingsModule.cs
- StringPropertyBuilder.cs
- XComponentModel.cs
- AppSecurityManager.cs
- InkSerializer.cs
- VariableQuery.cs
- ObjectMaterializedEventArgs.cs
- VirtualPathProvider.cs
- ScriptReferenceBase.cs
- TraceLevelStore.cs
- ComponentResourceKey.cs
- MyContact.cs
- SecurityTokenTypes.cs
- VisualBrush.cs
- EmbeddedMailObject.cs
- WindowsRegion.cs
- DragStartedEventArgs.cs
- ChangeProcessor.cs
- ACL.cs
- HttpRawResponse.cs
- InputReport.cs
- GridViewSortEventArgs.cs
- XmlTextWriter.cs
- NetSectionGroup.cs
- ToolStripDropTargetManager.cs
- PipeStream.cs
- HelloOperationAsyncResult.cs
- XPathAncestorQuery.cs
- DbSetClause.cs
- TypeDescriptionProviderAttribute.cs
- RadioButton.cs
- _emptywebproxy.cs
- TdsParserStaticMethods.cs
- FormViewUpdateEventArgs.cs
- DateTimeOffset.cs
- PartBasedPackageProperties.cs
- Root.cs
- ReflectionUtil.cs
- TextEditorTables.cs
- NameScopePropertyAttribute.cs
- Globals.cs
- ErrorInfoXmlDocument.cs
- Column.cs
- DBSchemaRow.cs
- GeneratedCodeAttribute.cs
- PersonalizationState.cs
- EllipticalNodeOperations.cs
- CodeGeneratorOptions.cs