Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // 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); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BitmapSource.cs
- HandlerFactoryWrapper.cs
- DataGridViewColumn.cs
- WebFormDesignerActionService.cs
- ThumbButtonInfoCollection.cs
- SecurityPermission.cs
- HybridDictionary.cs
- ObjectSet.cs
- InputReport.cs
- AttachedPropertyBrowsableAttribute.cs
- MemberPathMap.cs
- DisplayNameAttribute.cs
- TypeLibConverter.cs
- AppliedDeviceFiltersEditor.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- AuthorizationSection.cs
- EmptyEnumerable.cs
- DebugView.cs
- DataGridTextBox.cs
- RadioButtonList.cs
- SynchronizedDispatch.cs
- TextElementEnumerator.cs
- WindowsAltTab.cs
- StringDictionaryEditor.cs
- EpmContentDeSerializer.cs
- ListChangedEventArgs.cs
- TextStore.cs
- AccessKeyManager.cs
- TextViewSelectionProcessor.cs
- HtmlTableRowCollection.cs
- DocumentXmlWriter.cs
- IssuedTokensHeader.cs
- DataGridBoolColumn.cs
- LinkedResourceCollection.cs
- DataGridViewCellLinkedList.cs
- ExpandCollapsePattern.cs
- DetailsViewRow.cs
- DesignerSerializerAttribute.cs
- IsolatedStorageFilePermission.cs
- WindowsTab.cs
- IPGlobalProperties.cs
- WebBrowser.cs
- Brushes.cs
- ViewKeyConstraint.cs
- Logging.cs
- WhitespaceSignificantCollectionAttribute.cs
- DbInsertCommandTree.cs
- DiscoveryExceptionDictionary.cs
- PersistenceTypeAttribute.cs
- SplineKeyFrames.cs
- CornerRadiusConverter.cs
- WebMethodAttribute.cs
- InvalidChannelBindingException.cs
- DataGridViewComboBoxCell.cs
- TypeElementCollection.cs
- ControlValuePropertyAttribute.cs
- BrowserCapabilitiesCompiler.cs
- ValidationResult.cs
- MSAAEventDispatcher.cs
- KeyFrames.cs
- DecimalAnimationBase.cs
- ArglessEventHandlerProxy.cs
- TraceLog.cs
- ConfigXmlWhitespace.cs
- WebEventTraceProvider.cs
- XmlMemberMapping.cs
- HtmlContainerControl.cs
- FilterQueryOptionExpression.cs
- ScrollEvent.cs
- LayoutTableCell.cs
- SqlException.cs
- _FtpControlStream.cs
- WorkflowRuntimeServicesBehavior.cs
- SecurityPolicySection.cs
- XmlSigningNodeWriter.cs
- XPathDocumentNavigator.cs
- FullTextBreakpoint.cs
- ListMarkerSourceInfo.cs
- SecurityToken.cs
- TraceSection.cs
- ContextBase.cs
- SpellerError.cs
- TextBounds.cs
- _HelperAsyncResults.cs
- DefaultTextStoreTextComposition.cs
- CheckBoxPopupAdapter.cs
- NamedPipeTransportManager.cs
- HostingEnvironmentSection.cs
- TextureBrush.cs
- InkPresenter.cs
- ImageConverter.cs
- JobStaple.cs
- LocalServiceSecuritySettingsElement.cs
- FontFamilyConverter.cs
- RotateTransform3D.cs
- FormDocumentDesigner.cs
- AvTraceDetails.cs
- PlainXmlWriter.cs
- VideoDrawing.cs
- HtmlEmptyTagControlBuilder.cs