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
- IncrementalReadDecoders.cs
- XmlNamedNodeMap.cs
- ThemeableAttribute.cs
- Validator.cs
- DoWorkEventArgs.cs
- FlowSwitchLink.cs
- Native.cs
- SystemMulticastIPAddressInformation.cs
- DispatcherProcessingDisabled.cs
- LinkUtilities.cs
- SqlIdentifier.cs
- ConfigPathUtility.cs
- AppModelKnownContentFactory.cs
- BookmarkScopeHandle.cs
- Screen.cs
- SqlErrorCollection.cs
- MetabaseServerConfig.cs
- IChannel.cs
- Statements.cs
- SerializableAttribute.cs
- SpeechRecognitionEngine.cs
- ReferencedCollectionType.cs
- _Events.cs
- WorkflowOperationBehavior.cs
- AppLevelCompilationSectionCache.cs
- ModifierKeysValueSerializer.cs
- SQLInt64Storage.cs
- RC2.cs
- ColorContext.cs
- AsyncDataRequest.cs
- PropertyRef.cs
- BamlResourceDeserializer.cs
- InkCanvasFeedbackAdorner.cs
- DataGridViewCheckBoxCell.cs
- MimeMultiPart.cs
- DataRecordObjectView.cs
- _ConnectionGroup.cs
- ConfigPathUtility.cs
- CredentialCache.cs
- CodeChecksumPragma.cs
- ProcessHostServerConfig.cs
- MetadataCache.cs
- TextRenderingModeValidation.cs
- GcSettings.cs
- BitmapInitialize.cs
- MultipartContentParser.cs
- EventHandlers.cs
- ClientBuildManagerCallback.cs
- BamlRecordWriter.cs
- ConnectionPointCookie.cs
- OLEDB_Enum.cs
- PerformanceCounterTraceRecord.cs
- TailPinnedEventArgs.cs
- OverrideMode.cs
- NTAccount.cs
- InputProviderSite.cs
- Slider.cs
- webeventbuffer.cs
- ExpressionBuilderContext.cs
- IndexedGlyphRun.cs
- XmlReaderSettings.cs
- EventManager.cs
- ObjectViewListener.cs
- XmlNavigatorStack.cs
- Calendar.cs
- ServiceOperationParameter.cs
- DialogResultConverter.cs
- MenuAdapter.cs
- FixedSOMLineCollection.cs
- WCFModelStrings.Designer.cs
- ArrangedElementCollection.cs
- PrintPageEvent.cs
- SqlEnums.cs
- WebPartDeleteVerb.cs
- IChannel.cs
- AdPostCacheSubstitution.cs
- DataGridTableCollection.cs
- ApplicationDirectoryMembershipCondition.cs
- Regex.cs
- ColorEditor.cs
- __TransparentProxy.cs
- InternalConfigRoot.cs
- SqlWebEventProvider.cs
- HitTestWithPointDrawingContextWalker.cs
- SqlServices.cs
- ConfigXmlAttribute.cs
- CacheMode.cs
- ImageMap.cs
- CodePrimitiveExpression.cs
- ComponentGuaranteesAttribute.cs
- SkewTransform.cs
- EdgeModeValidation.cs
- XmlTextReaderImpl.cs
- OutputCacheProfileCollection.cs
- SurrogateSelector.cs
- FixedStringLookup.cs
- WebPartPersonalization.cs
- ViewManager.cs
- CompensationDesigner.cs
- XmlReaderSettings.cs