Code:
/ DotNET / DotNET / 8.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
- ByteStack.cs
- PreservationFileReader.cs
- EntityTransaction.cs
- CompressStream.cs
- WindowsGraphics.cs
- ConsumerConnectionPoint.cs
- GiveFeedbackEvent.cs
- PrimitiveXmlSerializers.cs
- ExpandCollapseIsCheckedConverter.cs
- ForwardPositionQuery.cs
- GridView.cs
- NotifyParentPropertyAttribute.cs
- ReadOnlyHierarchicalDataSourceView.cs
- XmlSchemaSubstitutionGroup.cs
- XmlStreamStore.cs
- SupportingTokenListenerFactory.cs
- FileVersionInfo.cs
- RuntimeWrappedException.cs
- util.cs
- ProfilePropertyNameValidator.cs
- BuilderInfo.cs
- HashAlgorithm.cs
- NumericExpr.cs
- Stream.cs
- AuthenticatedStream.cs
- DataGridViewHitTestInfo.cs
- ISAPIWorkerRequest.cs
- CodeNamespaceImportCollection.cs
- ELinqQueryState.cs
- ActivityExecutionWorkItem.cs
- ReflectionUtil.cs
- Selector.cs
- SQLRoleProvider.cs
- ListQueryResults.cs
- EasingKeyFrames.cs
- WorkerRequest.cs
- COM2IVsPerPropertyBrowsingHandler.cs
- FileEnumerator.cs
- SQLMoney.cs
- ListInitExpression.cs
- DataGridViewCellEventArgs.cs
- XamlLoadErrorInfo.cs
- Expressions.cs
- PropVariant.cs
- NumberFunctions.cs
- HandledMouseEvent.cs
- basevalidator.cs
- recordstatefactory.cs
- MediaCommands.cs
- BlobPersonalizationState.cs
- MediaScriptCommandRoutedEventArgs.cs
- ObjectDataSourceFilteringEventArgs.cs
- XmlDictionary.cs
- FactoryGenerator.cs
- DependencyObjectPropertyDescriptor.cs
- ThemeableAttribute.cs
- ChangePassword.cs
- AttributeTable.cs
- EdmScalarPropertyAttribute.cs
- ZipIOExtraFieldElement.cs
- SystemTcpStatistics.cs
- XmlException.cs
- HandlerWithFactory.cs
- CapabilitiesAssignment.cs
- SafeEventLogWriteHandle.cs
- LOSFormatter.cs
- TdsParserStaticMethods.cs
- ApplicationException.cs
- IriParsingElement.cs
- RootBrowserWindowAutomationPeer.cs
- BitSet.cs
- XPathBinder.cs
- TableDetailsRow.cs
- PolicyLevel.cs
- NotConverter.cs
- PrinterSettings.cs
- ViewCellSlot.cs
- CompleteWizardStep.cs
- PageAdapter.cs
- UserThread.cs
- LoginView.cs
- Permission.cs
- ListenDesigner.cs
- SerialPort.cs
- XhtmlBasicSelectionListAdapter.cs
- LocalFileSettingsProvider.cs
- EventMappingSettings.cs
- NavigatorInvalidBodyAccessException.cs
- TabControl.cs
- MsmqTransportElement.cs
- TypeDescriptorContext.cs
- SqlStream.cs
- SecurityException.cs
- AddInSegmentDirectoryNotFoundException.cs
- FileSystemEventArgs.cs
- GenericAuthenticationEventArgs.cs
- oledbmetadatacollectionnames.cs
- IdnMapping.cs
- OutputScopeManager.cs
- SqlDataSourceSelectingEventArgs.cs