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
- ProviderException.cs
- InputReportEventArgs.cs
- SafeArrayTypeMismatchException.cs
- TextTreeRootTextBlock.cs
- UriParserTemplates.cs
- _LazyAsyncResult.cs
- XmlQueryContext.cs
- UnaryNode.cs
- BuildManagerHost.cs
- LinkLabel.cs
- Stacktrace.cs
- _AutoWebProxyScriptWrapper.cs
- ByteConverter.cs
- SSmlParser.cs
- DrawingContextWalker.cs
- PeerTransportElement.cs
- StructuralCache.cs
- EntityContainer.cs
- DeploymentSection.cs
- ClosableStream.cs
- WindowsListBox.cs
- CompositeCollectionView.cs
- WinEventQueueItem.cs
- CodeEntryPointMethod.cs
- DataMember.cs
- IgnoreSection.cs
- RecognizeCompletedEventArgs.cs
- DefaultClaimSet.cs
- BaseParaClient.cs
- ClassGenerator.cs
- AttributeCollection.cs
- NodeLabelEditEvent.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- FormClosedEvent.cs
- LineSegment.cs
- MergePropertyDescriptor.cs
- SerializerWriterEventHandlers.cs
- ItemPager.cs
- IPAddress.cs
- AsyncStreamReader.cs
- SimpleTableProvider.cs
- XmlNodeComparer.cs
- HttpProfileBase.cs
- Cursor.cs
- TreeViewImageIndexConverter.cs
- SafeRightsManagementQueryHandle.cs
- EntityDataSource.cs
- ExpressionBinding.cs
- DecoratedNameAttribute.cs
- ECDiffieHellmanPublicKey.cs
- CompilerWrapper.cs
- JsonWriter.cs
- ArgumentException.cs
- SemaphoreSecurity.cs
- StrokeFIndices.cs
- WebException.cs
- BaseUriHelper.cs
- ReferentialConstraint.cs
- EntitySqlQueryState.cs
- SystemIPInterfaceStatistics.cs
- MetabaseServerConfig.cs
- CommandPlan.cs
- SamlDoNotCacheCondition.cs
- LoginCancelEventArgs.cs
- ToolStripStatusLabel.cs
- DbConnectionStringBuilder.cs
- EditCommandColumn.cs
- DatatypeImplementation.cs
- TraceEventCache.cs
- RefExpr.cs
- GiveFeedbackEventArgs.cs
- XmlSchemaSubstitutionGroup.cs
- AnnouncementSendsAsyncResult.cs
- followingquery.cs
- ThemeableAttribute.cs
- SystemIPAddressInformation.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- Catch.cs
- AnimatedTypeHelpers.cs
- IdleTimeoutMonitor.cs
- HideDisabledControlAdapter.cs
- ObjectContext.cs
- FixedSOMTableCell.cs
- ShapingEngine.cs
- LifetimeServices.cs
- RuleSetReference.cs
- GenericEnumerator.cs
- METAHEADER.cs
- EntityContainer.cs
- PropertyCondition.cs
- ReliabilityContractAttribute.cs
- LogReservationCollection.cs
- Code.cs
- InheritanceAttribute.cs
- WindowsIPAddress.cs
- FileRecordSequence.cs
- AudioFileOut.cs
- Track.cs
- DataList.cs
- SmiEventSink_DeferedProcessing.cs