Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CqlQuery.cs
- ItemsPanelTemplate.cs
- EndPoint.cs
- CounterCreationData.cs
- WebPartMenu.cs
- PrinterSettings.cs
- XmlUTF8TextReader.cs
- ListViewItemCollectionEditor.cs
- GroupStyle.cs
- BamlLocalizer.cs
- BamlLocalizableResourceKey.cs
- Effect.cs
- TemplateBindingExpressionConverter.cs
- DeclaredTypeElement.cs
- SqlParameter.cs
- newinstructionaction.cs
- NumberSubstitution.cs
- OdbcTransaction.cs
- SpeechSeg.cs
- DateTimeConverter.cs
- ResourceCategoryAttribute.cs
- HtmlInputImage.cs
- TextOutput.cs
- ExceptionTranslationTable.cs
- ImplicitInputBrush.cs
- StickyNoteContentControl.cs
- XmlProcessingInstruction.cs
- RightsManagementProvider.cs
- ValueQuery.cs
- Attachment.cs
- GridViewRow.cs
- AnonymousIdentificationSection.cs
- ReverseQueryOperator.cs
- PhoneCall.cs
- OutputCacheSection.cs
- safelink.cs
- TimerElapsedEvenArgs.cs
- FeatureSupport.cs
- FlowPanelDesigner.cs
- UInt16Storage.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- DesignOnlyAttribute.cs
- HttpHeaderCollection.cs
- WriteableOnDemandPackagePart.cs
- ElementsClipboardData.cs
- DefaultAuthorizationContext.cs
- DataObjectCopyingEventArgs.cs
- SymbolEqualComparer.cs
- SystemIPv4InterfaceProperties.cs
- MetadataItemEmitter.cs
- TextBlockAutomationPeer.cs
- RemotingServices.cs
- SingleTagSectionHandler.cs
- NullableBoolConverter.cs
- TransformPattern.cs
- Symbol.cs
- GlobalItem.cs
- OdbcDataAdapter.cs
- DispatchWrapper.cs
- TypeSystem.cs
- PackageRelationship.cs
- DateTimePicker.cs
- XmlSchemaInfo.cs
- ArithmeticException.cs
- XmlDownloadManager.cs
- GeneratedContractType.cs
- DataBoundControl.cs
- LOSFormatter.cs
- StringUtil.cs
- InkSerializer.cs
- AnnotationMap.cs
- Int32Storage.cs
- AppDomainFactory.cs
- SafeHGlobalHandleCritical.cs
- TcpWorkerProcess.cs
- HandlerMappingMemo.cs
- BamlRecordHelper.cs
- WorkflowTraceTransfer.cs
- Exceptions.cs
- KeyFrames.cs
- TypeConverterHelper.cs
- SqlFacetAttribute.cs
- RoutedEvent.cs
- WebPartVerb.cs
- WebPartEditorOkVerb.cs
- COM2ComponentEditor.cs
- DataSet.cs
- XmlDataDocument.cs
- RegexCapture.cs
- TagPrefixAttribute.cs
- ThreadAbortException.cs
- Model3D.cs
- TextBoxView.cs
- TextRunProperties.cs
- HijriCalendar.cs
- XmlAggregates.cs
- Socket.cs
- PreservationFileWriter.cs
- ICspAsymmetricAlgorithm.cs
- MsmqIntegrationSecurityMode.cs