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
- PathFigureCollectionValueSerializer.cs
- RootDesignerSerializerAttribute.cs
- HtmlButton.cs
- Font.cs
- TextInfo.cs
- DataGridViewColumnEventArgs.cs
- LoadMessageLogger.cs
- DivideByZeroException.cs
- validationstate.cs
- AdapterUtil.cs
- FusionWrap.cs
- NotSupportedException.cs
- MemberAssignmentAnalysis.cs
- ExtendedPropertyDescriptor.cs
- ObjectListGeneralPage.cs
- HttpHandlerActionCollection.cs
- _SSPISessionCache.cs
- XmlSchemaAppInfo.cs
- CombinedGeometry.cs
- OleDbConnectionFactory.cs
- Substitution.cs
- CreateUserWizard.cs
- HttpCachePolicyElement.cs
- GenericTransactionFlowAttribute.cs
- TriggerAction.cs
- BitmapDownload.cs
- COM2EnumConverter.cs
- UnsafeNativeMethods.cs
- GlyphInfoList.cs
- PreservationFileWriter.cs
- TaskFormBase.cs
- SqlRowUpdatingEvent.cs
- IdentityNotMappedException.cs
- DataGridViewSelectedCellCollection.cs
- Point4DValueSerializer.cs
- BufferedReceiveElement.cs
- CustomErrorCollection.cs
- HashAlgorithm.cs
- TransactionInterop.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- ClipboardData.cs
- GridPattern.cs
- Cursors.cs
- MetadataItemEmitter.cs
- DocumentsTrace.cs
- SetStateEventArgs.cs
- ExpandableObjectConverter.cs
- ScriptResourceHandler.cs
- AnonymousIdentificationSection.cs
- SvcMapFileLoader.cs
- HitTestParameters.cs
- IntegerValidator.cs
- ProfileEventArgs.cs
- AutomationElementCollection.cs
- KoreanLunisolarCalendar.cs
- Geometry3D.cs
- DoubleCollectionValueSerializer.cs
- TargetException.cs
- ObjectDataSourceMethodEventArgs.cs
- EntityDesignerUtils.cs
- DataGridColumnReorderingEventArgs.cs
- DataSourceSerializationException.cs
- ModelItemDictionaryImpl.cs
- MultiView.cs
- PeerNameRecord.cs
- EntryIndex.cs
- ToolBarButtonClickEvent.cs
- QualifierSet.cs
- AppModelKnownContentFactory.cs
- LambdaCompiler.ControlFlow.cs
- RecognizedWordUnit.cs
- DuplexClientBase.cs
- QilTargetType.cs
- CustomActivityDesigner.cs
- DrawingContextWalker.cs
- EventLogPermission.cs
- KeyToListMap.cs
- TdsParserSafeHandles.cs
- ComAdminInterfaces.cs
- AnonymousIdentificationModule.cs
- UpdatableWrapper.cs
- Vector3dCollection.cs
- unitconverter.cs
- DataGridHeaderBorder.cs
- WindowsTokenRoleProvider.cs
- SecurityAppliedMessage.cs
- PictureBoxDesigner.cs
- JulianCalendar.cs
- MetadataCacheItem.cs
- SemanticBasicElement.cs
- BamlLocalizableResource.cs
- NotSupportedException.cs
- CanonicalXml.cs
- cookieexception.cs
- PromptBuilder.cs
- CodeGotoStatement.cs
- TableItemProviderWrapper.cs
- RequestResizeEvent.cs
- MessageBuilder.cs
- TransformConverter.cs