Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / System.ServiceModel.Activation / System / ServiceModel / Activation / Interop / SafeNativeMethods.cs / 1305376 / SafeNativeMethods.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Activation.Interop { using System; using System.Security; using System.Runtime.InteropServices; using System.Security.Principal; using System.Runtime.Versioning; using System.Runtime; [SuppressUnmanagedCodeSecurity] static class SafeNativeMethods { public const int ERROR_NO_TOKEN = 1008; const string ADVAPI32 = "advapi32.dll"; const string KERNEL32 = "kernel32.dll"; [DllImport(ADVAPI32, SetLastError = true, EntryPoint = "OpenThreadToken")] [ResourceExposure(ResourceScope.None)] static extern bool OpenThreadTokenCritical( [In] IntPtr ThreadHandle, [In] TokenAccessLevels DesiredAccess, [In] bool OpenAsSelf, [Out] out SafeCloseHandleCritical TokenHandle); [DllImport(KERNEL32, SetLastError = true)] [ResourceExposure(ResourceScope.None)] static extern IntPtr GetCurrentThread(); [Fx.Tag.SecurityNote(Critical = "Calls two safe native methods: GetCurrentThread and OpenThreadToken." + "Marshal.GetLastWin32Error captures current thread token in a SecurityCritical field.")] [SecurityCritical] internal static bool OpenCurrentThreadTokenCritical(TokenAccessLevels desiredAccess, bool openAsSelf, out SafeCloseHandleCritical tokenHandle, out int error) { bool result = OpenThreadTokenCritical(GetCurrentThread(), desiredAccess, openAsSelf, out tokenHandle); error = Marshal.GetLastWin32Error(); return result; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Activation.Interop { using System; using System.Security; using System.Runtime.InteropServices; using System.Security.Principal; using System.Runtime.Versioning; using System.Runtime; [SuppressUnmanagedCodeSecurity] static class SafeNativeMethods { public const int ERROR_NO_TOKEN = 1008; const string ADVAPI32 = "advapi32.dll"; const string KERNEL32 = "kernel32.dll"; [DllImport(ADVAPI32, SetLastError = true, EntryPoint = "OpenThreadToken")] [ResourceExposure(ResourceScope.None)] static extern bool OpenThreadTokenCritical( [In] IntPtr ThreadHandle, [In] TokenAccessLevels DesiredAccess, [In] bool OpenAsSelf, [Out] out SafeCloseHandleCritical TokenHandle); [DllImport(KERNEL32, SetLastError = true)] [ResourceExposure(ResourceScope.None)] static extern IntPtr GetCurrentThread(); [Fx.Tag.SecurityNote(Critical = "Calls two safe native methods: GetCurrentThread and OpenThreadToken." + "Marshal.GetLastWin32Error captures current thread token in a SecurityCritical field.")] [SecurityCritical] internal static bool OpenCurrentThreadTokenCritical(TokenAccessLevels desiredAccess, bool openAsSelf, out SafeCloseHandleCritical tokenHandle, out int error) { bool result = OpenThreadTokenCritical(GetCurrentThread(), desiredAccess, openAsSelf, out tokenHandle); error = Marshal.GetLastWin32Error(); return result; } } } // 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
- VerticalAlignConverter.cs
- PropertyChangedEventArgs.cs
- TransactionManager.cs
- ChineseLunisolarCalendar.cs
- Assembly.cs
- AsymmetricAlgorithm.cs
- RbTree.cs
- WebPartManager.cs
- TogglePatternIdentifiers.cs
- BitmapDecoder.cs
- PolicyException.cs
- NestedContainer.cs
- ZeroOpNode.cs
- WindowsEditBoxRange.cs
- ColumnResult.cs
- XsltInput.cs
- Cursor.cs
- ChangeInterceptorAttribute.cs
- ModuleConfigurationInfo.cs
- SqlTriggerContext.cs
- PasswordPropertyTextAttribute.cs
- XPathParser.cs
- NativeActivityContext.cs
- DesignerAttributeInfo.cs
- ScriptingWebServicesSectionGroup.cs
- ActivityDesignerResources.cs
- OneWayChannelListener.cs
- CachedFontFace.cs
- DownloadProgressEventArgs.cs
- DetailsView.cs
- XmlReader.cs
- GenericAuthenticationEventArgs.cs
- ControlType.cs
- XslException.cs
- followingsibling.cs
- ColorIndependentAnimationStorage.cs
- InvariantComparer.cs
- KeyValueConfigurationElement.cs
- SoapMessage.cs
- TemplateBindingExtension.cs
- QuotedStringFormatReader.cs
- BitmapSizeOptions.cs
- GeneralTransform2DTo3DTo2D.cs
- FormViewInsertedEventArgs.cs
- RelationshipManager.cs
- XDRSchema.cs
- InnerItemCollectionView.cs
- HttpModule.cs
- XsdValidatingReader.cs
- counter.cs
- ConfigurationStrings.cs
- ResourceWriter.cs
- ServiceDeploymentInfo.cs
- FontSizeConverter.cs
- DataListCommandEventArgs.cs
- Converter.cs
- DeferredRunTextReference.cs
- ObjectDataSourceSelectingEventArgs.cs
- LicenseManager.cs
- UnsafeNativeMethods.cs
- PagedDataSource.cs
- ErrorFormatterPage.cs
- _TLSstream.cs
- ContextProperty.cs
- DragDeltaEventArgs.cs
- ResizeBehavior.cs
- OrderedDictionary.cs
- DataGridViewBindingCompleteEventArgs.cs
- TargetFrameworkAttribute.cs
- SqlParameter.cs
- InputScope.cs
- InternalTypeHelper.cs
- HotCommands.cs
- Deflater.cs
- SafeCancelMibChangeNotify.cs
- SafeLocalAllocation.cs
- OleDbRowUpdatedEvent.cs
- UdpDiscoveryEndpointElement.cs
- IsolatedStorageFilePermission.cs
- Interop.cs
- input.cs
- DockEditor.cs
- ToolBar.cs
- RC2.cs
- AssemblyCollection.cs
- QueuePathDialog.cs
- TextRange.cs
- TemplateKey.cs
- SystemDiagnosticsSection.cs
- PolyLineSegment.cs
- DataServiceOperationContext.cs
- RegexCaptureCollection.cs
- TemplateKey.cs
- QilReplaceVisitor.cs
- HotSpot.cs
- RangeBaseAutomationPeer.cs
- TableDetailsCollection.cs
- ToolStripControlHost.cs
- PersonalizationStateQuery.cs
- FrameworkContentElement.cs