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
- JsonCollectionDataContract.cs
- figurelengthconverter.cs
- VerificationException.cs
- WebServiceEndpoint.cs
- UpdatableWrapper.cs
- JournalNavigationScope.cs
- TraceSection.cs
- RootBrowserWindowProxy.cs
- ChameleonKey.cs
- ConnectionManagementElement.cs
- SendingRequestEventArgs.cs
- DescendantBaseQuery.cs
- DetailsViewInsertedEventArgs.cs
- XmlStreamNodeWriter.cs
- RenderContext.cs
- AppDomain.cs
- StringCollectionEditor.cs
- AuthenticatingEventArgs.cs
- _FixedSizeReader.cs
- RoleManagerSection.cs
- DbParameterHelper.cs
- MailAddress.cs
- baseaxisquery.cs
- ImageSourceValueSerializer.cs
- CollectionBase.cs
- CacheDependency.cs
- ToolStripSystemRenderer.cs
- PersistChildrenAttribute.cs
- ClientConfigurationHost.cs
- DesignerTransaction.cs
- RTLAwareMessageBox.cs
- UInt64Storage.cs
- PackagePart.cs
- basevalidator.cs
- Matrix.cs
- _SslState.cs
- DesignerCommandSet.cs
- WaitingCursor.cs
- UserPrincipalNameElement.cs
- TreeWalkHelper.cs
- CodeStatement.cs
- DateTimeFormatInfoScanner.cs
- PageHandlerFactory.cs
- DictationGrammar.cs
- CodeCompiler.cs
- TypedReference.cs
- FreezableCollection.cs
- XamlInt32CollectionSerializer.cs
- InteropEnvironment.cs
- HttpListenerRequest.cs
- UsernameTokenFactoryCredential.cs
- DictionaryCustomTypeDescriptor.cs
- CompatibleComparer.cs
- MobileControlDesigner.cs
- WebServiceClientProxyGenerator.cs
- DataSourceDescriptorCollection.cs
- TableCellsCollectionEditor.cs
- KeyMatchBuilder.cs
- PartitionResolver.cs
- AlternateViewCollection.cs
- RootContext.cs
- ErrorStyle.cs
- SQLInt32Storage.cs
- KnownBoxes.cs
- WebPartUserCapability.cs
- Context.cs
- OleDbFactory.cs
- WebConfigurationHost.cs
- ModelUIElement3D.cs
- ContractMapping.cs
- TrustManagerMoreInformation.cs
- SettingsSavedEventArgs.cs
- JobInputBins.cs
- EdmFunction.cs
- HttpDebugHandler.cs
- DateTimeParse.cs
- DataGridViewRowCollection.cs
- FunctionParameter.cs
- LinqToSqlWrapper.cs
- safelinkcollection.cs
- TemplateField.cs
- MultiplexingFormatMapping.cs
- DataServiceQueryContinuation.cs
- SelectorAutomationPeer.cs
- SemaphoreSlim.cs
- BrowserDefinitionCollection.cs
- DataRowChangeEvent.cs
- XslTransformFileEditor.cs
- Control.cs
- CultureTable.cs
- CallId.cs
- ListItemCollection.cs
- SmtpReplyReader.cs
- TreeNode.cs
- SingleStorage.cs
- EnumerableWrapperWeakToStrong.cs
- ContentIterators.cs
- SpeechUI.cs
- InlineUIContainer.cs
- BamlLocalizabilityResolver.cs