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
- OneWayChannelListener.cs
- LinkLabel.cs
- reliableinputsessionchannel.cs
- EnterpriseServicesHelper.cs
- ButtonField.cs
- WSTransactionSection.cs
- PageRanges.cs
- DetailsViewUpdatedEventArgs.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- CodeVariableDeclarationStatement.cs
- SchemaCollectionCompiler.cs
- StyleSheetDesigner.cs
- IntegrationExceptionEventArgs.cs
- ConnectionsZone.cs
- ProcessProtocolHandler.cs
- UrlAuthorizationModule.cs
- FixedPageAutomationPeer.cs
- SafeNativeMemoryHandle.cs
- MessageEventSubscriptionService.cs
- Msec.cs
- MarkupObject.cs
- BooleanFunctions.cs
- BinaryObjectWriter.cs
- RadioButtonAutomationPeer.cs
- XmlStreamStore.cs
- newinstructionaction.cs
- FixedTextSelectionProcessor.cs
- XsltCompileContext.cs
- CfgSemanticTag.cs
- basecomparevalidator.cs
- GacUtil.cs
- HtmlEmptyTagControlBuilder.cs
- UniqueID.cs
- DataGridViewComboBoxColumn.cs
- MSAAEventDispatcher.cs
- GetPageNumberCompletedEventArgs.cs
- shaperfactory.cs
- RenderData.cs
- LambdaCompiler.cs
- VisualStyleElement.cs
- AccessibleObject.cs
- ColorAnimation.cs
- WebEvents.cs
- System.Data_BID.cs
- FileLevelControlBuilderAttribute.cs
- SoapReflectionImporter.cs
- ModuleBuilderData.cs
- KeyValuePair.cs
- SecureUICommand.cs
- RotationValidation.cs
- ResourceDisplayNameAttribute.cs
- _Events.cs
- translator.cs
- ToolStripGrip.cs
- ListChangedEventArgs.cs
- ServiceOperationViewControl.cs
- SchemaNames.cs
- DefaultTextStore.cs
- LocalsItemDescription.cs
- TailCallAnalyzer.cs
- Annotation.cs
- CompensationHandlingFilter.cs
- SqlRecordBuffer.cs
- TimestampInformation.cs
- CommaDelimitedStringAttributeCollectionConverter.cs
- Function.cs
- SqlProviderUtilities.cs
- SmtpNtlmAuthenticationModule.cs
- ViewManager.cs
- AddInIpcChannel.cs
- ZipIOExtraFieldZip64Element.cs
- FileRecordSequence.cs
- XmlIlGenerator.cs
- CryptoKeySecurity.cs
- basecomparevalidator.cs
- IIS7WorkerRequest.cs
- DataControlPagerLinkButton.cs
- Types.cs
- AnnouncementService.cs
- MsdtcWrapper.cs
- WindowsListViewItemCheckBox.cs
- ToolStripStatusLabel.cs
- PtsPage.cs
- DisplayNameAttribute.cs
- WmlSelectionListAdapter.cs
- MethodCallTranslator.cs
- AsymmetricSignatureDeformatter.cs
- CodeNamespaceCollection.cs
- ServiceBehaviorElement.cs
- ExtendedPropertyDescriptor.cs
- MouseWheelEventArgs.cs
- Transactions.cs
- ProfileInfo.cs
- UnsafeNativeMethodsTablet.cs
- XmlCharType.cs
- Separator.cs
- ProfileProvider.cs
- DrawingContextDrawingContextWalker.cs
- PreviewPageInfo.cs
- AnimationClock.cs