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
- arc.cs
- externdll.cs
- PictureBox.cs
- GridView.cs
- SystemWebCachingSectionGroup.cs
- ClientSettingsProvider.cs
- DataTable.cs
- MSAANativeProvider.cs
- DispatcherObject.cs
- HtmlControlPersistable.cs
- GridSplitterAutomationPeer.cs
- ToggleProviderWrapper.cs
- OdbcConnectionString.cs
- EncryptedHeaderXml.cs
- RealProxy.cs
- InlinedAggregationOperatorEnumerator.cs
- ResourcePermissionBaseEntry.cs
- XsltContext.cs
- ParagraphResult.cs
- SocketAddress.cs
- IDQuery.cs
- VScrollProperties.cs
- TypePresenter.xaml.cs
- StandardOleMarshalObject.cs
- SafeNativeMethodsOther.cs
- CaseInsensitiveHashCodeProvider.cs
- DelayDesigner.cs
- ReferencedAssemblyResolver.cs
- WebPartVerbCollection.cs
- WindowsSecurityToken.cs
- CoTaskMemHandle.cs
- ToolStripOverflow.cs
- PartitionResolver.cs
- RequestQueue.cs
- Int32CollectionConverter.cs
- SliderAutomationPeer.cs
- MachinePropertyVariants.cs
- UrlMappingsSection.cs
- TabPage.cs
- ContainerUIElement3D.cs
- Context.cs
- RtfToXamlReader.cs
- DocumentPaginator.cs
- WebHttpElement.cs
- SystemWebCachingSectionGroup.cs
- ImageSourceConverter.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- Helper.cs
- DisplayInformation.cs
- DataGridViewRowStateChangedEventArgs.cs
- DataGridViewDataErrorEventArgs.cs
- LayoutUtils.cs
- PageBreakRecord.cs
- WebBrowserNavigatedEventHandler.cs
- ToolboxComponentsCreatedEventArgs.cs
- Compress.cs
- DoubleLinkList.cs
- XmlSchemaAll.cs
- ProjectedSlot.cs
- CodeCatchClause.cs
- Mapping.cs
- ToolboxCategory.cs
- XdrBuilder.cs
- PerformanceCounterPermissionEntry.cs
- AttributeAction.cs
- MatrixCamera.cs
- HtmlTableRow.cs
- LineVisual.cs
- PolicyManager.cs
- CodeConditionStatement.cs
- OutputCacheProfileCollection.cs
- PeerApplication.cs
- WebHeaderCollection.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- CryptoProvider.cs
- MDIWindowDialog.cs
- ApplicationServiceManager.cs
- TerminateSequence.cs
- SocketException.cs
- ConstructorArgumentAttribute.cs
- SystemGatewayIPAddressInformation.cs
- GeneratedCodeAttribute.cs
- SecurityUtils.cs
- DataControlReferenceCollection.cs
- SqlSelectClauseBuilder.cs
- ThrowHelper.cs
- CryptoKeySecurity.cs
- MsmqHostedTransportConfiguration.cs
- UserControlAutomationPeer.cs
- SelectionProviderWrapper.cs
- ParameterToken.cs
- Set.cs
- NavigateUrlConverter.cs
- PassportAuthenticationEventArgs.cs
- RectAnimationClockResource.cs
- WebPartsPersonalization.cs
- DataSourceControl.cs
- ExceptionUtility.cs
- DiagnosticEventProvider.cs
- SrgsItemList.cs