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
- DynamicPropertyHolder.cs
- ButtonBaseAutomationPeer.cs
- QueryOutputWriterV1.cs
- HostedElements.cs
- TextLineBreak.cs
- UnsafeNativeMethods.cs
- MimeTypePropertyAttribute.cs
- WebPartRestoreVerb.cs
- TranslateTransform.cs
- FormsAuthenticationModule.cs
- Msmq3PoisonHandler.cs
- DelegatingConfigHost.cs
- HiddenField.cs
- HttpCapabilitiesBase.cs
- PropertyValueUIItem.cs
- ModelPropertyImpl.cs
- Size.cs
- SqlDependencyListener.cs
- ADRoleFactoryConfiguration.cs
- MsmqBindingElementBase.cs
- ListViewEditEventArgs.cs
- TypeHelpers.cs
- VarRefManager.cs
- TemplateBuilder.cs
- WebConfigurationFileMap.cs
- DrawingVisual.cs
- EntityStoreSchemaFilterEntry.cs
- SoapConverter.cs
- CopyAttributesAction.cs
- MustUnderstandBehavior.cs
- PageHandlerFactory.cs
- UTF32Encoding.cs
- QilTargetType.cs
- printdlgexmarshaler.cs
- SplitContainerDesigner.cs
- PlatformCulture.cs
- PlaceHolder.cs
- IdentityReference.cs
- Formatter.cs
- DataGridViewControlCollection.cs
- ConcatQueryOperator.cs
- __ConsoleStream.cs
- CompilerInfo.cs
- ReferentialConstraint.cs
- HwndHost.cs
- StructuralCache.cs
- SerialPinChanges.cs
- DesignerActionVerbItem.cs
- HMAC.cs
- SecurityTokenValidationException.cs
- ZipArchive.cs
- PropertyToken.cs
- JavaScriptSerializer.cs
- DataGridViewColumnCollection.cs
- FixedPageAutomationPeer.cs
- UrlPath.cs
- XmlCharacterData.cs
- RadialGradientBrush.cs
- RepeaterItem.cs
- TrustManager.cs
- HtmlElementCollection.cs
- CompiledIdentityConstraint.cs
- XslException.cs
- DetailsViewPagerRow.cs
- MemberDescriptor.cs
- AnonymousIdentificationSection.cs
- DomainUpDown.cs
- TableLayoutPanelCodeDomSerializer.cs
- TextServicesCompartment.cs
- JavaScriptString.cs
- UserNameSecurityTokenProvider.cs
- EntitySqlQueryBuilder.cs
- HttpApplicationFactory.cs
- ValidatorUtils.cs
- WindowsToolbarItemAsMenuItem.cs
- SoapFault.cs
- ContextMarshalException.cs
- DesignerContextDescriptor.cs
- RequestCachePolicyConverter.cs
- DataPagerField.cs
- SpeechSeg.cs
- EncodingTable.cs
- CellIdBoolean.cs
- XmlSchemaExporter.cs
- ApplicationId.cs
- SizeAnimationBase.cs
- RadioButtonFlatAdapter.cs
- XPathEmptyIterator.cs
- XmlLinkedNode.cs
- Selection.cs
- EventLogWatcher.cs
- RegisteredArrayDeclaration.cs
- XmlDictionaryReaderQuotas.cs
- DesignerSerializationManager.cs
- WebPartConnectionsDisconnectVerb.cs
- SafeLibraryHandle.cs
- DataContractSerializerServiceBehavior.cs
- Sql8ConformanceChecker.cs
- Attributes.cs
- CommandHelpers.cs