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
- EncoderFallback.cs
- GeneralTransform3DTo2D.cs
- MobileErrorInfo.cs
- CodeTypeReferenceExpression.cs
- BuildProviderCollection.cs
- XslNumber.cs
- EntityViewGenerator.cs
- SqlXmlStorage.cs
- CompiledQuery.cs
- TextElement.cs
- HandleRef.cs
- TemplateBindingExpression.cs
- TextTreeUndoUnit.cs
- UriTemplateClientFormatter.cs
- KeyGestureConverter.cs
- PropertyPath.cs
- ModelItemDictionaryImpl.cs
- BatchParser.cs
- XmlIlTypeHelper.cs
- _SslState.cs
- SerializableAttribute.cs
- _NegoState.cs
- OptimizedTemplateContent.cs
- VectorCollection.cs
- UpDownEvent.cs
- NameValuePair.cs
- securestring.cs
- ReceiveSecurityHeaderElementManager.cs
- QuaternionConverter.cs
- HTMLTextWriter.cs
- ServiceOperationParameter.cs
- ColorContextHelper.cs
- TabletDeviceInfo.cs
- HelpProvider.cs
- RuntimeCompatibilityAttribute.cs
- AccessDataSource.cs
- ConditionalAttribute.cs
- InvalidWMPVersionException.cs
- InputScopeAttribute.cs
- DocobjHost.cs
- ProgressBarHighlightConverter.cs
- ColorDialog.cs
- HTMLTagNameToTypeMapper.cs
- Tokenizer.cs
- BrushMappingModeValidation.cs
- JsonUriDataContract.cs
- DateTimePickerDesigner.cs
- InternalPermissions.cs
- ArrayExtension.cs
- CommandLibraryHelper.cs
- Expression.cs
- PeerApplicationLaunchInfo.cs
- controlskin.cs
- RadioButtonAutomationPeer.cs
- StylusCollection.cs
- SoapEnumAttribute.cs
- PageThemeBuildProvider.cs
- wgx_exports.cs
- PersistChildrenAttribute.cs
- StaticSiteMapProvider.cs
- EventDescriptorCollection.cs
- TempFiles.cs
- LZCodec.cs
- SiteMapNodeItemEventArgs.cs
- DesignTimeXamlWriter.cs
- Ppl.cs
- Regex.cs
- sqlcontext.cs
- GeneralTransformGroup.cs
- TextElementEnumerator.cs
- SqlFunctionAttribute.cs
- CopyOnWriteList.cs
- VirtualPath.cs
- ServiceDescriptionData.cs
- Misc.cs
- ToolStripDropDownButton.cs
- EntityCommandDefinition.cs
- BindingExpressionUncommonField.cs
- XmlArrayAttribute.cs
- OleDbParameter.cs
- ImpersonateTokenRef.cs
- ExternalException.cs
- Geometry.cs
- ResourceReferenceExpression.cs
- RtfControlWordInfo.cs
- SiteMapNodeItem.cs
- PolicyChain.cs
- MailAddress.cs
- QueryAccessibilityHelpEvent.cs
- CheckBoxList.cs
- Int32CollectionConverter.cs
- DateTimeValueSerializer.cs
- _SSPIWrapper.cs
- WebPartDeleteVerb.cs
- SecurityRuntime.cs
- COM2ExtendedUITypeEditor.cs
- PipeStream.cs
- ProjectionPruner.cs
- ToolStripOverflow.cs
- BuildTopDownAttribute.cs