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
- ToolStripPanelRenderEventArgs.cs
- ToolStripSeparatorRenderEventArgs.cs
- OleStrCAMarshaler.cs
- PageEventArgs.cs
- XmlILModule.cs
- BamlLocalizableResource.cs
- SystemException.cs
- StylusCollection.cs
- KnownBoxes.cs
- MasterPageParser.cs
- CommandHelper.cs
- PolicyVersion.cs
- InputEventArgs.cs
- SaveLedgerEntryRequest.cs
- TdsEnums.cs
- InternalEnumValidatorAttribute.cs
- PeerCustomResolverSettings.cs
- DataSourceHelper.cs
- SafeSecurityHandles.cs
- ErrorWrapper.cs
- AuthorizationRuleCollection.cs
- LazyTextWriterCreator.cs
- OverrideMode.cs
- StrokeCollectionDefaultValueFactory.cs
- PaperSource.cs
- OrderByBuilder.cs
- DocumentXPathNavigator.cs
- XmlSchemaAll.cs
- RunInstallerAttribute.cs
- DeviceContext2.cs
- CultureInfoConverter.cs
- TextEmbeddedObject.cs
- TemplateControl.cs
- Expression.cs
- DesignerMetadata.cs
- AsymmetricSignatureDeformatter.cs
- TextDpi.cs
- InlineObject.cs
- FontConverter.cs
- SubpageParaClient.cs
- DocumentOrderComparer.cs
- HtmlContainerControl.cs
- HandledEventArgs.cs
- DbProviderFactoriesConfigurationHandler.cs
- WebPartEditorOkVerb.cs
- EntityDataSourceQueryBuilder.cs
- JsonDataContract.cs
- GlyphElement.cs
- ConfigurationManagerInternalFactory.cs
- HtmlControl.cs
- Helper.cs
- nulltextnavigator.cs
- CommunicationException.cs
- XmlStringTable.cs
- SerialErrors.cs
- XDRSchema.cs
- MetadataExporter.cs
- MemberDescriptor.cs
- SiteMapDataSource.cs
- HtmlEmptyTagControlBuilder.cs
- HandlerBase.cs
- SqlPersonalizationProvider.cs
- PerformanceCounterNameAttribute.cs
- XsltArgumentList.cs
- CodeDirectoryCompiler.cs
- ChannelProtectionRequirements.cs
- DataListItemCollection.cs
- ConsumerConnectionPointCollection.cs
- LinkLabelLinkClickedEvent.cs
- WebRequest.cs
- MetadataProperty.cs
- WebPartDisplayModeEventArgs.cs
- WebPartManagerInternals.cs
- Claim.cs
- DataRelationPropertyDescriptor.cs
- DayRenderEvent.cs
- RIPEMD160Managed.cs
- WebPartCollection.cs
- _UriSyntax.cs
- Process.cs
- RemotingServices.cs
- SourceLineInfo.cs
- PlainXmlSerializer.cs
- IDReferencePropertyAttribute.cs
- FileNotFoundException.cs
- PermissionRequestEvidence.cs
- CFStream.cs
- IfJoinedCondition.cs
- DataException.cs
- SessionEndedEventArgs.cs
- RsaSecurityKey.cs
- MailWriter.cs
- Serializer.cs
- DataGridViewCellEventArgs.cs
- GeneratedCodeAttribute.cs
- CompensationHandlingFilter.cs
- PasswordPropertyTextAttribute.cs
- HatchBrush.cs
- PropertyTab.cs
- DataGridTextBox.cs