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
- Socket.cs
- MessageContractImporter.cs
- OledbConnectionStringbuilder.cs
- QueryableFilterUserControl.cs
- PagerSettings.cs
- ToolStripContextMenu.cs
- RayMeshGeometry3DHitTestResult.cs
- DateTimeUtil.cs
- HttpResponseHeader.cs
- XPathNodeList.cs
- TextFormatter.cs
- StrokeCollectionDefaultValueFactory.cs
- PathSegment.cs
- DoubleConverter.cs
- EventWaitHandleSecurity.cs
- ExtendedPropertyDescriptor.cs
- PlainXmlWriter.cs
- SymbolEqualComparer.cs
- FacetDescription.cs
- NetNamedPipeSecurityElement.cs
- IdentityModelDictionary.cs
- ItemAutomationPeer.cs
- StringUtil.cs
- SslStream.cs
- SqlDataSourceStatusEventArgs.cs
- Util.cs
- RegexGroup.cs
- SeparatorAutomationPeer.cs
- EncodingInfo.cs
- SqlCommandSet.cs
- TimerElapsedEvenArgs.cs
- SafeProcessHandle.cs
- remotingproxy.cs
- PropertyCollection.cs
- ProvidersHelper.cs
- TextTreeNode.cs
- StructuralObject.cs
- SecurityTokenInclusionMode.cs
- ClientProtocol.cs
- ImageListUtils.cs
- SourceElementsCollection.cs
- SourceFileBuildProvider.cs
- Base64Encoder.cs
- DESCryptoServiceProvider.cs
- CompiledQuery.cs
- DisplayNameAttribute.cs
- SpecialFolderEnumConverter.cs
- SQLBytesStorage.cs
- MissingManifestResourceException.cs
- RemotingAttributes.cs
- AuthorizationSection.cs
- InvariantComparer.cs
- SelectionRange.cs
- SignatureConfirmationElement.cs
- _HeaderInfo.cs
- Header.cs
- ProfilePropertySettingsCollection.cs
- ZoneButton.cs
- OrderedDictionaryStateHelper.cs
- UserUseLicenseDictionaryLoader.cs
- GridViewPageEventArgs.cs
- DeflateStream.cs
- baseshape.cs
- PocoEntityKeyStrategy.cs
- Int64Animation.cs
- MenuItem.cs
- TailPinnedEventArgs.cs
- Error.cs
- AttachmentCollection.cs
- MouseWheelEventArgs.cs
- LabelEditEvent.cs
- TransactionChannelListener.cs
- FontDialog.cs
- DataGridViewCellMouseEventArgs.cs
- XmlComplianceUtil.cs
- PropertyMap.cs
- DefaultObjectMappingItemCollection.cs
- HandlerMappingMemo.cs
- DataControlFieldsEditor.cs
- StringUtil.cs
- ColumnTypeConverter.cs
- UdpDuplexChannel.cs
- WinFormsComponentEditor.cs
- KnownTypesHelper.cs
- datacache.cs
- WorkflowRuntimeSection.cs
- WrappedIUnknown.cs
- GeneralTransform3DGroup.cs
- StylusSystemGestureEventArgs.cs
- RangeContentEnumerator.cs
- Size.cs
- HttpGetClientProtocol.cs
- SafeRightsManagementHandle.cs
- OleDbCommand.cs
- VerbConverter.cs
- CacheRequest.cs
- DocumentPageViewAutomationPeer.cs
- DebugView.cs
- SmiEventSink_Default.cs
- RadioButtonPopupAdapter.cs