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
- EntityChangedParams.cs
- ProcessHostConfigUtils.cs
- CheckBoxField.cs
- ReadOnlyObservableCollection.cs
- GlyphsSerializer.cs
- WebException.cs
- WeakEventManager.cs
- ImageCodecInfo.cs
- FixedSchema.cs
- _AutoWebProxyScriptHelper.cs
- OracleCommandSet.cs
- MessageDirection.cs
- SmiMetaData.cs
- Rijndael.cs
- PropertyValueUIItem.cs
- EntityModelSchemaGenerator.cs
- XmlAttributes.cs
- _NetworkingPerfCounters.cs
- FilteredSchemaElementLookUpTable.cs
- FormsAuthenticationTicket.cs
- MergeFilterQuery.cs
- NamespaceListProperty.cs
- CreateUserErrorEventArgs.cs
- DictionaryCustomTypeDescriptor.cs
- FreezableDefaultValueFactory.cs
- FuncTypeConverter.cs
- LineInfo.cs
- EmptyStringExpandableObjectConverter.cs
- DataGridCellClipboardEventArgs.cs
- WebPartChrome.cs
- ConditionCollection.cs
- DataGridViewAdvancedBorderStyle.cs
- ProcessThreadCollection.cs
- BamlLocalizer.cs
- IImplicitResourceProvider.cs
- NTAccount.cs
- SetIterators.cs
- XhtmlTextWriter.cs
- _SecureChannel.cs
- EnumValidator.cs
- UidPropertyAttribute.cs
- SafeThreadHandle.cs
- HostUtils.cs
- RotateTransform.cs
- WebServiceResponse.cs
- RuntimeArgumentHandle.cs
- LockedActivityGlyph.cs
- NestPullup.cs
- XmlNodeChangedEventManager.cs
- NotifyCollectionChangedEventArgs.cs
- ContainerSelectorBehavior.cs
- ComboBox.cs
- TemplateKeyConverter.cs
- XmlnsDefinitionAttribute.cs
- _BasicClient.cs
- DecoderReplacementFallback.cs
- BulletedListEventArgs.cs
- _OverlappedAsyncResult.cs
- SurrogateEncoder.cs
- EventLogPermissionEntry.cs
- ManualResetEvent.cs
- EndpointAddressProcessor.cs
- RelationshipType.cs
- DataGridViewCellValidatingEventArgs.cs
- Cursors.cs
- SchemaTypeEmitter.cs
- DrawToolTipEventArgs.cs
- EndpointDiscoveryMetadata.cs
- HexParser.cs
- FixedSOMFixedBlock.cs
- ProcessModuleCollection.cs
- SimpleApplicationHost.cs
- WebSysDefaultValueAttribute.cs
- PinnedBufferMemoryStream.cs
- ValidationEventArgs.cs
- Compiler.cs
- EntityDataSourceEntityTypeFilterItem.cs
- HtmlTitle.cs
- Function.cs
- HttpProfileGroupBase.cs
- SerializationSectionGroup.cs
- WorkflowViewService.cs
- ProfileService.cs
- RootBrowserWindow.cs
- _AutoWebProxyScriptWrapper.cs
- EnvelopedPkcs7.cs
- ResourcesChangeInfo.cs
- CollectionConverter.cs
- CodeLabeledStatement.cs
- RangeBase.cs
- ResolveNameEventArgs.cs
- SelectionItemPattern.cs
- UIHelper.cs
- ReadWriteObjectLock.cs
- ResourcesGenerator.cs
- SrgsDocumentParser.cs
- ListViewItemEventArgs.cs
- NameTable.cs
- StringValidatorAttribute.cs
- CodeDirectionExpression.cs