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
- EncodingInfo.cs
- CheckBoxBaseAdapter.cs
- InstanceLockLostException.cs
- SchemaImporter.cs
- Utils.cs
- InteropDesigner.xaml.cs
- SqlDataSourceEnumerator.cs
- UDPClient.cs
- Table.cs
- InputElement.cs
- SignedPkcs7.cs
- ActiveXSite.cs
- SqlBuilder.cs
- CommandField.cs
- recordstatefactory.cs
- NamedPipeAppDomainProtocolHandler.cs
- BitmapSizeOptions.cs
- SystemIcons.cs
- EventLogQuery.cs
- GeneralTransform2DTo3DTo2D.cs
- TextTabProperties.cs
- DetailsViewAutoFormat.cs
- TextFormatterHost.cs
- SynchronousReceiveBehavior.cs
- Schema.cs
- LinkButton.cs
- DesignerObject.cs
- CompareValidator.cs
- ArraySortHelper.cs
- ConnectionStringSettingsCollection.cs
- XmlTypeMapping.cs
- SQLBinary.cs
- Transactions.cs
- PointHitTestResult.cs
- WebDescriptionAttribute.cs
- HostedNamedPipeTransportManager.cs
- PanelStyle.cs
- ApplicationServiceHelper.cs
- StringSorter.cs
- EpmContentSerializerBase.cs
- ApplyImportsAction.cs
- DiscreteKeyFrames.cs
- ImportStoreException.cs
- FixedSOMPage.cs
- PeerInvitationResponse.cs
- MaskedTextProvider.cs
- WorkflowApplicationCompletedEventArgs.cs
- COM2PropertyPageUITypeConverter.cs
- SqlErrorCollection.cs
- SourceFileBuildProvider.cs
- RemotingConfiguration.cs
- TraceInternal.cs
- SqlXmlStorage.cs
- CollectionViewSource.cs
- WbemProvider.cs
- UpDownBase.cs
- SqlCommand.cs
- TemplateBindingExtension.cs
- LineServices.cs
- UseAttributeSetsAction.cs
- LinkUtilities.cs
- XmlComplianceUtil.cs
- SubstitutionList.cs
- SurrogateChar.cs
- ExpressionBuilder.cs
- WindowsSolidBrush.cs
- TransactedBatchContext.cs
- WhitespaceSignificantCollectionAttribute.cs
- StringDictionaryCodeDomSerializer.cs
- EventOpcode.cs
- Path.cs
- ToolStripArrowRenderEventArgs.cs
- MetadataItemEmitter.cs
- xdrvalidator.cs
- CacheRequest.cs
- XhtmlTextWriter.cs
- SqlStatistics.cs
- ViewStateException.cs
- XmlSchemaType.cs
- CannotUnloadAppDomainException.cs
- Point4DValueSerializer.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- ProcessProtocolHandler.cs
- ViewSimplifier.cs
- Gdiplus.cs
- BitmapEffectInput.cs
- ExpressionBuilderContext.cs
- WizardForm.cs
- PartialArray.cs
- DebuggerAttributes.cs
- ToolStripScrollButton.cs
- SyndicationDeserializer.cs
- ErrorActivity.cs
- EnglishPluralizationService.cs
- ActiveXHost.cs
- RefExpr.cs
- FontConverter.cs
- HttpListenerResponse.cs
- SectionInformation.cs
- Base64Decoder.cs