Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / SafeReversePInvokeHandle.cs / 1305600 / SafeReversePInvokeHandle.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: // A safe way to deal with unmanaged MIL interface pointers. //--------------------------------------------------------------------------- using System; using System.IO; using System.Security; using System.Security.Permissions; using System.Collections; using System.Reflection; using MS.Internal; using MS.Win32; using System.Diagnostics; using System.Windows.Media; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Microsoft.Win32.SafeHandles; using Microsoft.Internal; using UnsafeNativeMethods=MS.Win32.PresentationCore.UnsafeNativeMethods; namespace System.Windows.Media { internal class SafeReversePInvokeWrapper : SafeHandleZeroOrMinusOneIsInvalid { ////// Use this constructor if the handle isn't ready yet and later /// set the handle with SetHandle. SafeMILHandle owns the release /// of the handle. /// ////// Critical: This derives from a class that has a link demand and inheritance demand /// TreatAsSafe: Ok to call constructor /// [SecurityCritical] internal SafeReversePInvokeWrapper() : base(true) { } ////// Use this constructor if the handle exists at construction time. /// SafeMILHandle owns the release of the parameter. /// ////// Calls into native code to wrap a reverse p-invoke delegate into a CReversePInvokeDelegateWrapper. /// [SecurityCritical] internal SafeReversePInvokeWrapper(IntPtr delegatePtr) : base(true) { // Wrap the reverse p-invoke into a reversePInvokeWrapper. IntPtr reversePInvokeWrapper; HRESULT.Check(UnsafeNativeMethods.MilCoreApi.MilCreateReversePInvokeWrapper(delegatePtr, out reversePInvokeWrapper)); SetHandle(reversePInvokeWrapper); } ////// Critical - calls unmanaged code, not treat as safe because you must /// validate that handle is a valid COM object. /// [SecurityCritical] protected override bool ReleaseHandle() { if (handle != IntPtr.Zero) { UnsafeNativeMethods.MilCoreApi.MilReleasePInvokePtrBlocking(handle); } UnsafeNativeMethods.MILUnknown.ReleaseInterface(ref handle); return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PointAnimationUsingKeyFrames.cs
- XsdValidatingReader.cs
- FilterEventArgs.cs
- ViewGenResults.cs
- IgnorePropertiesAttribute.cs
- GradientBrush.cs
- ScriptingProfileServiceSection.cs
- TraceUtility.cs
- DeviceContext.cs
- ServiceNameCollection.cs
- InternalConfigEventArgs.cs
- EventItfInfo.cs
- ChannelManager.cs
- GeneralTransformGroup.cs
- ExpressionLexer.cs
- ValidatedControlConverter.cs
- FindCriteria11.cs
- ContractComponent.cs
- FileEnumerator.cs
- FullTextBreakpoint.cs
- ServerType.cs
- WebPartConnectionsCancelEventArgs.cs
- Exceptions.cs
- XmlSerializableServices.cs
- StorageComplexPropertyMapping.cs
- Queue.cs
- CqlBlock.cs
- FixedPosition.cs
- TextEffect.cs
- SystemUdpStatistics.cs
- TableChangeProcessor.cs
- SourceFileBuildProvider.cs
- MessageQueueTransaction.cs
- bidPrivateBase.cs
- CacheHelper.cs
- PasswordRecovery.cs
- HostingEnvironmentWrapper.cs
- DecimalMinMaxAggregationOperator.cs
- LinkArea.cs
- StateRuntime.cs
- SecUtil.cs
- ResourcePermissionBase.cs
- PathFigureCollection.cs
- SecurityHeaderLayout.cs
- CapabilitiesSection.cs
- SafeBitVector32.cs
- DrawListViewSubItemEventArgs.cs
- Timer.cs
- _emptywebproxy.cs
- UpDownEvent.cs
- UriTemplateDispatchFormatter.cs
- EntityAdapter.cs
- SimpleType.cs
- COM2ICategorizePropertiesHandler.cs
- TablePattern.cs
- Condition.cs
- TimeSpan.cs
- ThreadInterruptedException.cs
- AttachedPropertyMethodSelector.cs
- AspNetSynchronizationContext.cs
- EventLogInternal.cs
- Font.cs
- PlatformNotSupportedException.cs
- TextTreeText.cs
- InkCollectionBehavior.cs
- MethodRental.cs
- Range.cs
- WarningException.cs
- DataGridViewUtilities.cs
- PropertiesTab.cs
- BaseCodePageEncoding.cs
- xsdvalidator.cs
- KnownAssemblyEntry.cs
- HtmlHistory.cs
- TextServicesPropertyRanges.cs
- DrawingState.cs
- ColumnMapVisitor.cs
- LocalServiceSecuritySettingsElement.cs
- SiteMapSection.cs
- LinkedResource.cs
- ToolStripRenderEventArgs.cs
- ListViewVirtualItemsSelectionRangeChangedEvent.cs
- FontDriver.cs
- SortKey.cs
- RenderingEventArgs.cs
- AtomPub10ServiceDocumentFormatter.cs
- CngProvider.cs
- Fonts.cs
- ExcCanonicalXml.cs
- BezierSegment.cs
- EndpointDiscoveryElement.cs
- RoleServiceManager.cs
- DataList.cs
- SafeRightsManagementHandle.cs
- categoryentry.cs
- SortDescriptionCollection.cs
- CompareInfo.cs
- OneOf.cs
- SizeAnimationUsingKeyFrames.cs
- Type.cs