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
- HttpChannelHelpers.cs
- ColorPalette.cs
- BinaryCommonClasses.cs
- ReachDocumentSequenceSerializerAsync.cs
- FixedTextContainer.cs
- SqlTrackingService.cs
- DataObjectPastingEventArgs.cs
- DataGridViewRowCancelEventArgs.cs
- CodePageEncoding.cs
- FrameworkRichTextComposition.cs
- TemplateBindingExtensionConverter.cs
- SmtpNtlmAuthenticationModule.cs
- PageThemeBuildProvider.cs
- FontStyle.cs
- HostSecurityManager.cs
- ImportedNamespaceContextItem.cs
- Size.cs
- DbConnectionPoolGroup.cs
- CapabilitiesAssignment.cs
- AssemblyAssociatedContentFileAttribute.cs
- NoneExcludedImageIndexConverter.cs
- DataGridViewTopLeftHeaderCell.cs
- WebPartsSection.cs
- WindowsRichEdit.cs
- UnsafeMethods.cs
- Wizard.cs
- PortCache.cs
- DictionarySurrogate.cs
- BezierSegment.cs
- StorageModelBuildProvider.cs
- AnonymousIdentificationModule.cs
- LinkClickEvent.cs
- CompilationUtil.cs
- Classification.cs
- ToolStripControlHost.cs
- ToolTipAutomationPeer.cs
- InstanceKeyNotReadyException.cs
- OleDbMetaDataFactory.cs
- SQLChars.cs
- Queue.cs
- sortedlist.cs
- OLEDB_Enum.cs
- UpDownBase.cs
- TypeToken.cs
- CharacterShapingProperties.cs
- MarshalByRefObject.cs
- ComAdminWrapper.cs
- filewebrequest.cs
- PropertyCollection.cs
- Int32RectValueSerializer.cs
- BasicHttpSecurityMode.cs
- ExtendedProtectionPolicy.cs
- XXXOnTypeBuilderInstantiation.cs
- XmlElementElementCollection.cs
- HostedNamedPipeTransportManager.cs
- ReservationCollection.cs
- NativeObjectSecurity.cs
- XmlDictionary.cs
- XmlAtomicValue.cs
- HttpException.cs
- WebBrowserDocumentCompletedEventHandler.cs
- _NativeSSPI.cs
- BinHexEncoder.cs
- DragEvent.cs
- ExpandedProjectionNode.cs
- HashMembershipCondition.cs
- DocComment.cs
- TableAutomationPeer.cs
- BooleanFunctions.cs
- EmptyEnumerable.cs
- DataBinding.cs
- InkCanvasFeedbackAdorner.cs
- ComponentEditorForm.cs
- ColorMap.cs
- DataBindingValueUIHandler.cs
- MsmqException.cs
- CalendarKeyboardHelper.cs
- CqlParserHelpers.cs
- SchemaImporter.cs
- CheckableControlBaseAdapter.cs
- TraceSource.cs
- XmlILStorageConverter.cs
- RectValueSerializer.cs
- ThousandthOfEmRealDoubles.cs
- RowsCopiedEventArgs.cs
- FilteredAttributeCollection.cs
- GenericAuthenticationEventArgs.cs
- TableStyle.cs
- JsonReader.cs
- BinaryParser.cs
- ListViewGroup.cs
- AddValidationError.cs
- AstTree.cs
- PathTooLongException.cs
- ListDictionaryInternal.cs
- EventRoute.cs
- EntityWrapperFactory.cs
- UserCancellationException.cs
- XmlQuerySequence.cs
- oledbmetadatacolumnnames.cs