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
- XmlNamespaceMappingCollection.cs
- UnhandledExceptionEventArgs.cs
- ScrollViewer.cs
- HttpWriter.cs
- MembershipValidatePasswordEventArgs.cs
- DocumentXPathNavigator.cs
- LocalizabilityAttribute.cs
- Underline.cs
- IxmlLineInfo.cs
- HierarchicalDataBoundControl.cs
- HitTestParameters.cs
- PrincipalPermissionMode.cs
- DynamicValidator.cs
- ThemeDirectoryCompiler.cs
- Point3DCollectionValueSerializer.cs
- IisNotInstalledException.cs
- HtmlContainerControl.cs
- XmlValidatingReaderImpl.cs
- Lasso.cs
- BamlRecordHelper.cs
- BooleanKeyFrameCollection.cs
- HtmlInputFile.cs
- ScalarType.cs
- ToolStripPanelCell.cs
- SoapReflector.cs
- RequestUriProcessor.cs
- ListViewSortEventArgs.cs
- DataGridTextBox.cs
- AlternateView.cs
- CopyAction.cs
- WebHeaderCollection.cs
- SpeakCompletedEventArgs.cs
- FileDialog_Vista.cs
- ResourceDescriptionAttribute.cs
- StorageRoot.cs
- DataServiceStreamProviderWrapper.cs
- CodeNamespaceCollection.cs
- KeyTimeConverter.cs
- FixedHighlight.cs
- ComboBoxDesigner.cs
- EntityCommand.cs
- ControlIdConverter.cs
- TraceUtils.cs
- Model3DCollection.cs
- PathGeometry.cs
- AVElementHelper.cs
- LongValidator.cs
- WriterOutput.cs
- _CommandStream.cs
- FlowSwitchLink.cs
- InstallerTypeAttribute.cs
- SendMessageRecord.cs
- XmlBindingWorker.cs
- CodeMemberEvent.cs
- DefaultCommandExtensionCallback.cs
- HebrewNumber.cs
- EventProvider.cs
- CachedPathData.cs
- WSDualHttpSecurityMode.cs
- AttributedMetaModel.cs
- ApplicationInfo.cs
- X509SecurityToken.cs
- StylusPointProperties.cs
- _IPv6Address.cs
- IPEndPointCollection.cs
- PathSegment.cs
- StandardTransformFactory.cs
- Setter.cs
- FunctionImportMapping.ReturnTypeRenameMapping.cs
- MarkupExtensionReturnTypeAttribute.cs
- ServicePointManagerElement.cs
- XmlValueConverter.cs
- ContextMarshalException.cs
- BasicBrowserDialog.designer.cs
- SqlDuplicator.cs
- ValidatorCompatibilityHelper.cs
- ColumnResult.cs
- SettingsContext.cs
- SecureEnvironment.cs
- ScrollChrome.cs
- AttributeUsageAttribute.cs
- BitmapEffect.cs
- OracleMonthSpan.cs
- TimeSpanMinutesConverter.cs
- EncodingInfo.cs
- FacetEnabledSchemaElement.cs
- RuntimeConfigLKG.cs
- TimeZone.cs
- SoapReflectionImporter.cs
- DataTableReader.cs
- ErrorHandlingReceiver.cs
- milexports.cs
- QueryExpression.cs
- LOSFormatter.cs
- DataGridViewCellValueEventArgs.cs
- ZoomingMessageFilter.cs
- AutomationTextAttribute.cs
- TextLineBreak.cs
- ContainerSelectorGlyph.cs
- ArrayTypeMismatchException.cs