Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Core / CSharp / System / Windows / Media / UnsafeNativeMethodsMilCoreApi.cs / 1 / UnsafeNativeMethodsMilCoreApi.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // // // ABOUT THIS FILE: // -- This file contains native methods which are deemed NOT SAFE in the sense that any usage of them // must be carefully reviewed. FXCop will flag callers of these for review. // -- These methods DO have the SuppressUnmanagedCodeSecurity attribute which means stalk walks for unmanaged // code will stop with the immediate caler. // -- Put methods in here when a stack walk is innappropriate due to performance concerns // -- If you have questions about how to use this file, email avsee //----------------------------------------------------------------------------- using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using System.Runtime.ConstrainedExecution; using System; using MS.Internal; using System.Security; using System.Security.Permissions; using System.Collections; using System.IO; using System.Text; using System.Windows.Media.Composition; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows; using Microsoft.Internal; using MS.Win32; using IComDataObject = System.Runtime.InteropServices.ComTypes.IDataObject; #pragma warning disable 1634, 1691 // suppressing PreSharp warnings namespace MS.Win32.PresentationCore { internal static partial class UnsafeNativeMethods { [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class MilCoreApi { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore, EntryPoint = "MilCompositionEngine_EnterCompositionEngineLock")] internal static extern void EnterCompositionEngineLock(); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore, EntryPoint = "MilCompositionEngine_ExitCompositionEngineLock")] internal static extern void ExitCompositionEngineLock(); [DllImport(DllImport.MilCore, EntryPoint = "MilCompositionEngine_EnterMediaSystemLock")] internal static extern void EnterMediaSystemLock(); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore, EntryPoint = "MilCompositionEngine_ExitMediaSystemLock")] internal static extern void ExitMediaSystemLock(); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] internal static extern int MilVersionCheck( uint uiCallerMilSdkVersion ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] internal static extern int MilTransport_CreateTransportParameters( bool fForcedLocalTransport, out bool fIsConnected, out UInt32 pDwGeneration, out bool fGraphicsStreamClientPresent); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] internal static extern int MilTransport_Create(out IntPtr ppTranspManager); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] internal static extern int MilSyncPacketTransport_Create( out IntPtr ppPacketTransport); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] internal static extern int MilTransport_CreateFromPacketTransport( IntPtr pSyncPacketTransport, out IntPtr ppPacketTransport ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] internal static extern int MilTransport_DisconnectTransport( IntPtr pTranspManager ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] internal extern static int /* HRESULT */ MILCreateStreamFromStreamDescriptor(ref System.Windows.Media.StreamDescriptor pSD, out IntPtr ppStream); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] unsafe internal static extern void MilUtility_GetTileBrushMapping( D3DMATRIX* transform, D3DMATRIX* relativeTransform, Stretch stretch, AlignmentX alignmentX, AlignmentY alignmentY, BrushMappingMode viewPortUnits, BrushMappingMode viewBoxUnits, Rect* shapeFillBounds, Rect* contentBounds, ref Rect viewport, ref Rect viewbox, out D3DMATRIX contentToShape, out int brushIsEmpty ); ////// This seems safe - the net effect of this command is to return the bounds of a Path. /// Although this seems safe - I'm putting it in unsafe as it takes pointers and is using the unsafe keyword. /// The unmanaged function does some validation - but it looks like you can pass it bogus data. /// However it looks like the worse that can happen - is you get invalid Rect returned. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilUtility_PathGeometryBounds( MIL_PEN_DATA *pPenData, double *pDashArray, MilMatrix3x2D* pWorldMatrix, FillRule fillRule, byte* pPathData, UInt32 nSize, MilMatrix3x2D* pGeometryMatrix, double rTolerance, bool fRelative, bool fSkipHollows, MilRectD* pBounds); ////// Seems safe - the net effect combines one path with another. /// Left in Unsafe native methods - as it manipulates pointers. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilUtility_PathGeometryCombine( MilMatrix3x2D* pMatrix, MilMatrix3x2D* pMatrix1, FillRule fillRule1, byte* pPathData1, UInt32 nSize1, MilMatrix3x2D* pMatrix2, FillRule fillRule2, byte* pPathData2, UInt32 nSize2, double rTolerance, bool fRelative, Delegate addFigureCallback, GeometryCombineMode combineMode, out FillRule resultFillRule); ////// Creates one flavor of a Path from another. /// use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilUtility_PathGeometryWiden( MIL_PEN_DATA *pPenData, double *pDashArray, MilMatrix3x2D* pMatrix, FillRule fillRule, byte* pPathData, UInt32 nSize, double rTolerance, bool fRelative, Delegate addFigureCallback, out FillRule widenedFillRule); ////// Creates one flavor of a Path from another. /// use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilUtility_PathGeometryOutline( MilMatrix3x2D* pMatrix, FillRule fillRule, byte* pPathData, UInt32 nSize, double rTolerance, bool fRelative, Delegate addFigureCallback, out FillRule outlinedFillRule); ////// Creates one flavor of a Path from another. /// use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilUtility_PathGeometryFlatten( MilMatrix3x2D* pMatrix, FillRule fillRule, byte* pPathData, UInt32 nSize, double rTolerance, bool fRelative, Delegate addFigureCallback, out FillRule resultFillRule); ////// Sets a global callback pointer to the function that creates Glyph bitmaps. /// Use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int /* HRESULT */ MilGlyphCache_SetCreateGlyphBitmapsCallback( MulticastDelegate del ); ////// Emulates DUCE.Channel.BeginCommand but circumvents the channel directly to CMilSlaveGlyphCache. /// Use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilGlyphCache_BeginCommandAtRenderTime( IntPtr pMilSlaveGlyphCacheTarget, byte* pbData, uint cbSize, uint cbExtra ); ////// Emulates DUCE.Channel.AppendCommandData but circumvents the channel directly to CMilSlaveGlyphCache. /// Use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilGlyphCache_AppendCommandDataAtRenderTime( IntPtr pMilSlaveGlyphCacheTarget, byte* pbData, uint cbSize ); ////// Emulates DUCE.Channel.EndCommand but circumvents the channel directly to CMilSlaveGlyphCache. /// Use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilGlyphCache_EndCommandAtRenderTime( IntPtr pMilSlaveGlyphCacheTarget ); ////// Circumvents channel and access a CGlyphRunResource directly /// Use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilGlyphRun_SetGeometryAtRenderTime( IntPtr pMilGlyphRunTarget, byte* pCmd, uint cbCmd ); [DllImport(DllImport.MilCore, EntryPoint = "MilCreateReversePInvokeWrapper")] internal unsafe static extern /*HRESULT*/ int MilCreateReversePInvokeWrapper( IntPtr pFcn, out IntPtr reversePInvokeWrapper); [DllImport(DllImport.MilCore, EntryPoint = "MilReleasePInvokePtrBlocking")] internal unsafe static extern void MilReleasePInvokePtrBlocking( IntPtr reversePInvokeWrapper); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICComponentInfo { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentInfo_GetCLSID_Proxy")] internal static extern int /* HRESULT */ GetCLSID( System.Windows.Media.SafeMILHandle /* IWICComponentInfo */ THIS_PTR, out Guid pclsid); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentInfo_GetAuthor_Proxy")] internal static extern int /* HRESULT */ GetAuthor( System.Windows.Media.SafeMILHandle /* IWICComponentInfo */ THIS_PTR, UInt32 cchAuthor, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzAuthor, out UInt32 pcchActual); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentInfo_GetVersion_Proxy")] internal static extern int /* HRESULT */ GetVersion( System.Windows.Media.SafeMILHandle /* IWICComponentInfo */ THIS_PTR, UInt32 cchVersion, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzVersion, out UInt32 pcchActual); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentInfo_GetSpecVersion_Proxy")] internal static extern int /* HRESULT */ GetSpecVersion( System.Windows.Media.SafeMILHandle /* IWICComponentInfo */ THIS_PTR, UInt32 cchSpecVersion, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzSpecVersion, out UInt32 pcchActual); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentInfo_GetFriendlyName_Proxy")] internal static extern int /* HRESULT */ GetFriendlyName( System.Windows.Media.SafeMILHandle /* IWICComponentInfo */ THIS_PTR, UInt32 cchFriendlyName, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFriendlyName, out UInt32 pcchActual); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapCodecInfo { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_GetContainerFormat_Proxy")] internal static extern int /* HRESULT */ GetContainerFormat( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, out Guid pguidContainerFormat); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_GetDeviceManufacturer_Proxy")] internal static extern int /* HRESULT */ GetDeviceManufacturer( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, UInt32 cchDeviceManufacturer, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDeviceManufacturer, out UInt32 pcchActual ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_GetDeviceModels_Proxy")] internal static extern int /* HRESULT */ GetDeviceModels( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, UInt32 cchDeviceModels, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDeviceModels, out UInt32 pcchActual ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_GetMimeTypes_Proxy")] internal static extern int /* HRESULT */ GetMimeTypes( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, UInt32 cchMimeTypes, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzMimeTypes, out UInt32 pcchActual ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_GetFileExtensions_Proxy")] internal static extern int /* HRESULT */ GetFileExtensions( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, UInt32 cchFileExtensions, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFileExtensions, out UInt32 pcchActual ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_DoesSupportAnimation_Proxy")] internal static extern int /* HRESULT */ DoesSupportAnimation( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, out bool pfSupportAnimation ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_DoesSupportLossless_Proxy")] internal static extern int /* HRESULT */ DoesSupportLossless( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, out bool pfSupportLossless ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_DoesSupportMultiframe_Proxy")] internal static extern int /* HRESULT */ DoesSupportMultiframe( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, out bool pfSupportMultiframe ); } ////// Critical as this code performs an elevation. /// [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICMetadataQueryReader { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryReader_GetContainerFormat_Proxy")] internal static extern int /* HRESULT */ GetContainerFormat( System.Windows.Media.SafeMILHandle /* IWICMetadataQueryReader */ THIS_PTR, out Guid pguidContainerFormat); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryReader_GetLocation_Proxy")] internal static extern int /* HRESULT */ GetLocation( System.Windows.Media.SafeMILHandle /* IWICMetadataQueryReader */ THIS_PTR, UInt32 cchLocation, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzNamespace, out UInt32 pcchActual ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryReader_GetMetadataByName_Proxy")] internal static extern int /* HRESULT */ GetMetadataByName( System.Windows.Media.SafeMILHandle /* IWICMetadataQueryReader */ THIS_PTR, [Out, MarshalAs(UnmanagedType.LPWStr)] String wzName, ref System.Windows.Media.Imaging.PROPVARIANT propValue ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryReader_GetMetadataByName_Proxy")] internal static extern int /* HRESULT */ ContainsMetadataByName( System.Windows.Media.SafeMILHandle /* IWICMetadataQueryReader */ THIS_PTR, [Out, MarshalAs(UnmanagedType.LPWStr)] String wzName, IntPtr propVar ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryReader_GetEnumerator_Proxy")] internal static extern int /* HRESULT */ GetEnumerator( System.Windows.Media.SafeMILHandle /* IWICMetadataQueryReader */ THIS_PTR, out System.Windows.Media.SafeMILHandle /* IEnumString */ enumString ); } ////// Critical as this code performs an elevation. /// [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICMetadataQueryWriter { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryWriter_SetMetadataByName_Proxy")] internal static extern int /* HRESULT */ SetMetadataByName( System.Windows.Media.SafeMILHandle /* IWICMetadataQueryWriter */ THIS_PTR, [Out, MarshalAs(UnmanagedType.LPWStr)] String wzName, ref System.Windows.Media.Imaging.PROPVARIANT propValue ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryWriter_RemoveMetadataByName_Proxy")] internal static extern int /* HRESULT */ RemoveMetadataByName( System.Windows.Media.SafeMILHandle /* IWICMetadataQueryWriter */ THIS_PTR, [Out, MarshalAs(UnmanagedType.LPWStr)] String wzName ); } ////// Critical as this code performs an elevation. /// [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICFastMetadataEncoder { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICFastMetadataEncoder_Commit_Proxy")] internal static extern int /* HRESULT */ Commit( System.Windows.Media.SafeMILHandle /* IWICFastMetadataEncoder */ THIS_PTR ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICFastMetadataEncoder_GetMetadataQueryWriter_Proxy")] internal static extern int /* HRESULT */ GetMetadataQueryWriter( System.Windows.Media.SafeMILHandle /* IWICFastMetadataEncoder */ THIS_PTR, out SafeMILHandle /* IWICMetadataQueryWriter */ ppIQueryWriter ); } ////// Critical as this code performs an elevation. /// [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class EnumString { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IEnumString_Next_WIC_Proxy")] internal static extern int /* HRESULT */ Next( System.Windows.Media.SafeMILHandle /* IEnumString */ THIS_PTR, Int32 celt, ref IntPtr rgElt, ref Int32 pceltFetched ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IEnumString_Reset_WIC_Proxy")] internal static extern int /* HRESULT */ Reset( System.Windows.Media.SafeMILHandle /* IEnumString */ THIS_PTR ); } ////// Critical as this code performs an elevation. /// [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class IPropertyBag2 { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IPropertyBag2_Write_Proxy")] internal static extern int /* HRESULT */ Write( System.Windows.Media.SafeMILHandle /* IPropertyBag2 */ THIS_PTR, UInt32 cProperties, ref System.Windows.Media.Imaging.PROPBAG2 propBag, ref System.Windows.Media.Imaging.PROPVARIANT propValue ); } internal class IMILBitmapEffectRenderContext { protected IMILBitmapEffectRenderContext() { } [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_SetOutputPixelFormat")] internal static extern int /* HRESULT */ SetOutputPixelFormat( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, ref Guid /* REFWICPixelFormatGUID */ format); #if never [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_GetOutputPixelFormat")] internal static extern int /* HRESULT */ GetOutputPixelFormat( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, out Guid /* WICPixelFormatGUID */ format); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_SetUseSoftwareRenderer")] internal static extern int /* HRESULT */ SetUseSoftwareRenderer( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, [MarshalAs(UnmanagedType.VariantBool)]System.Boolean /* VARIANT_BOOL */ fSoftware); #endif [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_SetInitialTransform")] internal static extern int /* HRESULT */ SetInitialTransform( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, double m11, double m12, double m21, double m22, double m31, double m32); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_GetFinalTransform")] internal static extern int /* HRESULT */ GetFinalTransform( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, out double m11, out double m12, out double m21, out double m22, out double m31, out double m32); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_SetRegionOfInterest")] internal static extern int /* HRESULT */ SetRegionOfInterest( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, ref Rect pRect); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_SetOutputDPI")] internal static extern int /* HRESULT */ SetOutputDPI( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, double dblDpiX, double dblDpiY); #if never [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_GetOutputDPI")] internal static extern int /* HRESULT */ GetOutputDPI( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, out double pdblDpiX, out double pdblDpiY); #endif } internal class IMILBitmapEffect { [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_GetOutput")] internal static extern int /* HRESULT */ GetOutput( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 uiIndex, SafeMILHandle /* IMILBitmapEffectRenderContext */ pContext, out BitmapSourceSafeMILHandle /* IWICBitmapSource */ ppBitmapSource); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_GetParentEffect")] internal static extern int /* HRESULT */ GetParentEffect( SafeHandle /* IMILBitmapEffect */ THIS_PTR, out SafeMILHandle /* IMILBitmapEffectGroup */ ppParentEffect); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_SetInputSource")] internal static extern int /* HRESULT */ SetInputSource( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 uiIndex, BitmapSourceSafeMILHandle /* IWICBitmapSource */ pBitmapSource); //********************************************************************* // Interfaces from IMILBitmapEffectConnectionsInfo which we will // QI from IMILBitmapEffect //********************************************************************* [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectConnectionsInfo_GetNumberInputs")] internal static extern int /* HRESULT */ GetNumberInputs( SafeHandle /* IMILBitmapEffect */ THIS_PTR, out UInt32 piNumInputs); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectConnectionsInfo_GetNumberOutputs")] internal static extern int /* HRESULT */ GetNumberOutputs( SafeHandle /* IMILBitmapEffect */ THIS_PTR, out UInt32 piNumOutputs); //********************************************************************** // Interfaces from IMILBitmapEffectConnections which we will // QI from IMILBitmapEffect //********************************************************************* [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectConnections_GetInputConnector")] internal static extern int /* HRESULT */ GetInputConnector( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 uiIndex, out SafeMILHandle /* IMILBitmapEffectInputConnector */ ppConnector); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectConnections_GetOutputConnector")] internal static extern int /* HRESULT */ GetOutputConnector( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 uiIndex, out SafeMILHandle /* IMILBitmapEffectOutputConnector */ ppConnector); //********************************************************************** // These methods aren't actually exposed by the effects layer, but are // just helpers for setting/getting values through the interop layer. // (However, they do set the value through IPropertyBag2 on the effect // primitive itself, which we will QI THIS_PTR). //********************************************************************** [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectPrimitive_SetValue")] internal static extern int /* HRESULT */ SetValue( SafeHandle /* IMILBitmapEffect */ THIS_PTR, [MarshalAs(UnmanagedType.BStr)]System.String /* BSTR */ bstrName, [MarshalAs(UnmanagedType.Struct)]ref System.Object /* VARIANT* */ varValue); #if never [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectPrimitive_GetValue")] internal static extern int /* HRESULT */ GetValue( SafeHandle /* IMILBitmapEffect */ THIS_PTR, [MarshalAs(UnmanagedType.BStr)]System.String /* BSTR */ bstrName, [MarshalAs(UnmanagedType.Struct)]out System.Object /* VARIANT* */ varValue); #endif //********************************************************************* // Interfaces from IMILBitmapEffectGroup which we will QI from IMILBitmapEffect //********************************************************************** [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectGroup_GetInteriorInputConnector")] internal static extern int /* HRESULT */ GetInteriorInputConnector( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 iIndex, out SafeMILHandle /* IMILBitmapEffectOutputConnector */ pConnector); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectGroup_GetInteriorOutputConnector")] internal static extern int /* HRESULT */ GetInteriorOutputConnector( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 iIndex, out SafeMILHandle /* IMILBitmapEffectInputConnector */ pConnector); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectGroup_Add")] internal static extern int /* HRESULT */ Add( SafeHandle /* IMILBitmapEffect */ THIS_PTR, SafeHandle /* IMILBitmapEffect */ pEffect); //********************************************************************* // Interfaces from IMILBitmapEffectPrimitive which we will QI from IMILBitmapEffect //********************************************************************* [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectPrimitive_TransformPoint")] internal static extern int /* HRESULT */ TransformPoint( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 iIndex, ref System.Windows.Point p, [MarshalAs(UnmanagedType.VariantBool)] System.Boolean /* VARIANT_BOOL */ fForwardTransform, SafeMILHandle /* IMILBitmapEffectRenderContext */ pContext, [MarshalAs(UnmanagedType.VariantBool)] out System.Boolean /* VARIANT_BOOL */ fPointTransformed); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectPrimitive_TransformRect")] internal static extern int /* HRESULT */ TransformRect( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 iIndex, ref Rect p, [MarshalAs(UnmanagedType.VariantBool)] System.Boolean /* VARIANT_BOOL */ fForwardTransform, SafeMILHandle /* IMILBitmapEffectRenderContext */ pContext); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectPrimitive_HasAffineTransform")] internal static extern int /* HRESULT */ HasAffineTransform( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 iIndex, [MarshalAs(UnmanagedType.VariantBool)] out System.Boolean /* VARIANT_BOOL */ fAffine); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectPrimitive_HasInverseTransform")] internal static extern int /* HRESULT */ HasInverseTransform( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 iIndex, [MarshalAs(UnmanagedType.VariantBool)] out System.Boolean /* VARIANT_BOOL */ fInverse); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectPrimitive_GetAffineMatrix")] internal static extern int /* HRESULT */ GetAffineMatrix( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 iIndex, ref MilMatrix3x2D pMatrix); }; internal class IMILBitmapEffectConnectorInfo { [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectConnectorInfo_GetOptimalFormat")] internal static extern int /* HRESULT */ GetOptimalFormat( SafeMILHandle /* IMILBitmapEffectConnectorInfo */ THIS_PTR, out Guid /* WICPixelFormatGUID */ format); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectConnectorInfo_GetNumberFormats")] internal static extern int /* HRESULT */ GetNumberFormats( SafeMILHandle /* IMILBitmapEffectConnectorInfo */ THIS_PTR, out UInt32 pulNumberFormats); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectConnectorInfo_GetFormat")] internal static extern int /* HRESULT */ GetFormat( SafeMILHandle /* IMILBitmapEffectConnectorInfo */ THIS_PTR, out Guid /* WICPixelFormatGUID */ format); } internal class IMILBitmapEffectConnector : IMILBitmapEffectConnectorInfo { [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectConnector_IsConnected")] internal static extern int /* HRESULT */ IsConnected( SafeMILHandle /* IMILBitmapEffectConnector */ THIS_PTR, [MarshalAs(UnmanagedType.VariantBool)] out System.Boolean /* VARIANT_BOOL */ pFormat); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectConnector_GetBitmapEffect")] internal static extern int /* HRESULT */ GetBitmapEffect( SafeMILHandle /* IMILBitmapEffectConnector */ THIS_PTR, out SafeHandle /* IMILBitmapEffect */ ppEffect); } internal class IMILBitmapEffectInputConnector : IMILBitmapEffectConnector { [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectInputConnector_ConnectTo")] internal static extern int /* HRESULT */ ConnectTo( SafeMILHandle /* IMILBitmapEffectInputConnector */ THIS_PTR, SafeMILHandle /* IMILBitmapEffectOutputConnector */ pConnector); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectInputConnector_GetConnection")] internal static extern int /* HRESULT */ GetConnection( SafeMILHandle /* IMILBitmapEffectInputConnector */ THIS_PTR, out SafeMILHandle /* IMILBitmapEffectOutputConnector */ ppConnector); } internal class IMILBitmapEffectOutputConnector : IMILBitmapEffectConnector { [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectOutputConnector_GetNumberConnections")] internal static extern int /* HRESULT */ GetNumberConnections( SafeMILHandle /* IMILBitmapEffectOutputConnector */ THIS_PTR, out UInt32 piNumberConnections); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectOutputConnector_GetConnection")] internal static extern int /* HRESULT */ GetConnection( SafeMILHandle /* IMILBitmapEffectOutputConnector */ THIS_PTR, UInt32 iIndex, out SafeMILHandle /* IMILBitmapEffectInputConnector */ ppConnection); } internal class IMILBitmapEffectInteriorOutputConnector { [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectInteriorOutputConnector_GetOutputConnector")] internal static extern int /* HRESULT */ GetOutputConnector( SafeHandle /* IMILBitmapEffectInteriorOutputConnector */ THIS_PTR, out SafeMILHandle /* IMILBitmapEffectOutputConnector */ ppConnector); } internal class IMILBitmapEffectInteriorInputConnector { [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectInteriorInputConnector_GetInputConnector")] internal static extern int /* HRESULT */ GetInputConnector( SafeHandle /* IMILBitmapEffectInteriorInputConnector */ THIS_PTR, out SafeMILHandle /* IMILBitmapEffectInputConnector */ ppConnector); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapSource { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_GetSize_Proxy")] internal static extern int /* HRESULT */ GetSize( System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ THIS_PTR, out UInt32 puiWidth, out UInt32 puiHeight); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_GetPixelFormat_Proxy")] internal static extern int /* HRESULT */ GetPixelFormat( System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ THIS_PTR, out Guid pPixelFormatEnum); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_GetResolution_Proxy")] internal static extern int /* HRESULT */ GetResolution( System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ THIS_PTR, out double pDpiX, out double pDpiY); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_CopyPalette_Proxy")] internal static extern int /* HRESULT */ CopyPalette( System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IMILPalette */ pIPalette); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_CopyPixels_Proxy")] internal static extern int /* HRESULT */ CopyPixels( SafeMILHandle /* IWICBitmapSource */ THIS_PTR, ref Int32Rect prc, UInt32 cbStride, UInt32 cbBufferSize, IntPtr /* BYTE* */ pvPixels); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapDecoder { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetDecoderInfo_Proxy")] internal static extern int /* HRESULT */ GetDecoderInfo( SafeMILHandle THIS_PTR, out SafeMILHandle /* IWICBitmapDecoderInfo */ ppIDecoderInfo); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_CopyPalette_Proxy")] internal static extern int /* HRESULT */ CopyPalette( SafeMILHandle /* IWICBitmapDecoder */ THIS_PTR, SafeMILHandle /* IMILPalette */ pIPalette); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetPreview_Proxy")] internal static extern int /* HRESULT */ GetPreview( SafeMILHandle THIS_PTR, out IntPtr /* IWICBitmapSource */ ppIBitmapSource ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetColorContexts_Proxy")] internal static extern int /* HRESULT */ GetColorContexts( SafeMILHandle THIS_PTR, uint nIndex, IntPtr /* IWICColorContext */ ppIColorContext, out uint /* IWICColorContext */ pCount ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetThumbnail_Proxy")] internal static extern int /* HRESULT */ GetThumbnail( SafeMILHandle /* IWICBitmapDecoder */ THIS_PTR, out IntPtr /* IWICBitmapSource */ ppIThumbnail ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetMetadataQueryReader_Proxy")] internal static extern int /* HRESULT */ GetMetadataQueryReader( SafeMILHandle /* IWICBitmapDecoder */ THIS_PTR, out IntPtr /* IWICMetadataQueryReader */ ppIQueryReader ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetFrameCount_Proxy")] internal static extern int /* HRESULT */ GetFrameCount( SafeMILHandle THIS_PTR, out uint pFrameCount ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetFrame_Proxy")] internal static extern int /* HRESULT */ GetFrame( SafeMILHandle /* IWICBitmapDecoder */ THIS_PTR, UInt32 index, out IntPtr /* IWICBitmapFrameDecode */ ppIFrameDecode ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapFrameDecode { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameDecode_GetThumbnail_Proxy")] internal static extern int /* HRESULT */ GetThumbnail( SafeMILHandle /* IWICBitmapFrameDecode */ THIS_PTR, out IntPtr /* IWICBitmap */ ppIThumbnail ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameDecode_GetMetadataQueryReader_Proxy")] internal static extern int /* HRESULT */ GetMetadataQueryReader( SafeMILHandle /* IWICBitmapFrameDecode */ THIS_PTR, out IntPtr /* IWICMetadataQueryReader */ ppIQueryReader ); [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameDecode_GetColorContexts_Proxy")] internal static extern int /* HRESULT */ GetColorContexts( SafeMILHandle /* IWICBitmapFrameDecode */ THIS_PTR, uint nIndex, IntPtr /* IWICColorContext */ ppIColorContext, out uint pCount ); } ////// Critical as this code performs an elevation. /// [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class MILUnknown { [DllImport(DllImport.MilCore, EntryPoint = "MILAddRef")] internal static extern UInt32 AddRef(SafeMILHandle pIUnkown); [DllImport(DllImport.MilCore, EntryPoint = "MILAddRef")] internal static extern UInt32 AddRef(SafeReversePInvokeWrapper pIUnknown); [DllImport(DllImport.MilCore, EntryPoint = "MILRelease"), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] internal static extern int Release(IntPtr pIUnkown); internal static void ReleaseInterface(ref IntPtr ptr) { if (ptr != IntPtr.Zero) { #pragma warning suppress 6031 // Return value ignored on purpose. UnsafeNativeMethods.MILUnknown.Release(ptr); ptr = IntPtr.Zero; } } [DllImport(DllImport.MilCore, EntryPoint = "MILQueryInterface")] internal static extern int /* HRESULT */ QueryInterface( IntPtr pIUnknown, ref Guid guid, out IntPtr ppvObject); [DllImport(DllImport.MilCore, EntryPoint = "MILQueryInterface")] internal static extern int /* HRESULT */ QueryInterface( SafeMILHandle pIUnknown, ref Guid guid, out IntPtr ppvObject); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICStream { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICStream_InitializeFromIStream_Proxy")] internal static extern int /*HRESULT*/ InitializeFromIStream( IntPtr pIWICStream, IntPtr pIStream); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICStream_InitializeFromMemory_Proxy")] internal static extern int /*HRESULT*/ InitializeFromMemory( IntPtr pIWICStream, IntPtr pbBuffer, uint cbSize); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WindowsCodecApi { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "WICCreateBitmapFromSection")] internal static extern int /*HRESULT*/ CreateBitmapFromSection( UInt32 width, UInt32 height, ref Guid pixelFormatGuid, IntPtr hSection, UInt32 stride, UInt32 offset, out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap); } internal static class WICBitmapFrameEncode { ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapFrameEncode_Initialize_Proxy")] internal static extern int /* HRESULT */ Initialize(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR, SafeMILHandle /* IPropertyBag2* */ pIEncoderOptions); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapFrameEncode_Commit_Proxy")] internal static extern int /* HRESULT */ Commit(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapFrameEncode_SetSize_Proxy")] internal static extern int /* HRESULT */ SetSize(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR, int width, int height); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapFrameEncode_SetResolution_Proxy")] internal static extern int /* HRESULT */ SetResolution(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR, double dpiX, double dpiY); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapFrameEncode_WriteSource_Proxy")] internal static extern int /* HRESULT */ WriteSource(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR, SafeMILHandle /* IMILBitmapSource* */ pIBitmapSource, ref Int32Rect /* MILRect* */ r); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameEncode_SetThumbnail_Proxy")] internal static extern int /* HRESULT */ SetThumbnail(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICBitmapSource* */ pIThumbnail); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameEncode_GetMetadataQueryWriter_Proxy")] internal static extern int /* HRESULT */ GetMetadataQueryWriter( SafeMILHandle /* IWICBitmapFrameEncode */ THIS_PTR, out SafeMILHandle /* IWICMetadataQueryWriter */ ppIQueryWriter ); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameEncode_SetColorContexts_Proxy")] internal static extern int /* HRESULT */ SetColorContexts(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR, uint nIndex, IntPtr /* IWICColorContext */ ppIColorContext); } internal static class WICBitmapEncoder { ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_Initialize_Proxy")] internal static extern int /* HRESULT */ Initialize(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR, IntPtr /* IStream */ pStream, WICBitmapEncodeCacheOption option); [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_GetEncoderInfo_Proxy")] internal static extern int /* HRESULT */ GetEncoderInfo(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR, out SafeMILHandle /* IWICBitmapEncoderInfo ** */ ppIEncoderInfo ); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_CreateNewFrame_Proxy")] internal static extern int /* HRESULT */ CreateNewFrame(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR, out SafeMILHandle /* IWICBitmapFrameEncode ** */ ppIFramEncode, out SafeMILHandle /* IPropertyBag2 ** */ ppIEncoderOptions ); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_SetThumbnail_Proxy")] internal static extern int /* HRESULT */ SetThumbnail(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICBitmapSource* */ pIThumbnail); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_SetPalette_Proxy")] internal static extern int /* HRESULT */ SetPalette(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICPalette* */ pIPalette); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapEncoder_GetMetadataQueryWriter_Proxy")] internal static extern int /* HRESULT */ GetMetadataQueryWriter( SafeMILHandle /* IWICBitmapEncoder */ THIS_PTR, out SafeMILHandle /* IWICMetadataQueryWriter */ ppIQueryWriter ); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_Commit_Proxy")] internal static extern int /* HRESULT */ Commit(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR); } internal static class WICPalette { [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_InitializePredefined_Proxy")] internal static extern int /* HRESULT */ InitializePredefined(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, WICPaletteType ePaletteType, bool fAddTransparentColor); [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_InitializeCustom_Proxy")] internal static extern int /* HRESULT */ InitializeCustom(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, IntPtr /* MILColor* */ pColors, int colorCount); [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_InitializeFromBitmap_Proxy")] internal static extern int /* HRESULT */ InitializeFromBitmap(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IMILBitmapSource* */ pISurface, int colorCount, bool fAddTransparentColor); [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_InitializeFromPalette_Proxy")] internal static extern int /* HRESULT */ InitializeFromPalette(IntPtr /* IWICPalette */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICPalette */ pIWICPalette); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_GetType_Proxy")] internal static extern int /* HRESULT */ GetType(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, out WICPaletteType pePaletteType); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_GetColorCount_Proxy")] internal static extern int /* HRESULT */ GetColorCount(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, out int pColorCount); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_GetColors_Proxy")] internal static extern int /* HRESULT */ GetColors(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, int colorCount, IntPtr /* MILColor* */ pColors, out int pcActualCount); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_HasAlpha_Proxy")] internal static extern int /* HRESULT */ HasAlpha(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, out bool pfHasAlpha); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICImagingFactory { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateDecoderFromStream_Proxy")] internal static extern int /*HRESULT*/ CreateDecoderFromStream( IntPtr pICodecFactory, IntPtr /* IStream */ pIStream, ref Guid guidVendor, UInt32 metadataFlags, out IntPtr /* IWICBitmapDecoder */ ppIDecode); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateDecoderFromFileHandle_Proxy")] internal static extern int /*HRESULT*/ CreateDecoderFromFileHandle( IntPtr pICodecFactory, Microsoft.Win32.SafeHandles.SafeFileHandle /*ULONG_PTR*/ hFileHandle, ref Guid guidVendor, UInt32 metadataFlags, out IntPtr /* IWICBitmapDecoder */ ppIDecode); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateComponentInfo_Proxy")] internal static extern int /*HRESULT*/ CreateComponentInfo( IntPtr pICodecFactory, ref Guid clsidComponent, out IntPtr /* IWICComponentInfo */ ppIComponentInfo); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreatePalette_Proxy")] internal static extern int /*HRESULT*/ CreatePalette( IntPtr pICodecFactory, out SafeMILHandle /* IWICPalette */ ppIPalette); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateFormatConverter_Proxy")] internal static extern int /* HRESULT */ CreateFormatConverter( IntPtr pICodecFactory, out BitmapSourceSafeMILHandle /* IWICFormatConverter */ ppFormatConverter); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapScaler_Proxy")] internal static extern int /* HRESULT */ CreateBitmapScaler( IntPtr pICodecFactory, out BitmapSourceSafeMILHandle /* IWICBitmapScaler */ ppBitmapScaler); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapClipper_Proxy")] internal static extern int /* HRESULT */ CreateBitmapClipper( IntPtr pICodecFactory, out BitmapSourceSafeMILHandle /* IWICBitmapClipper */ ppBitmapClipper); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFlipRotator_Proxy")] internal static extern int /* HRESULT */ CreateBitmapFlipRotator( IntPtr pICodecFactory, out BitmapSourceSafeMILHandle /* IWICBitmapFlipRotator */ ppBitmapFlipRotator); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateStream_Proxy")] internal static extern int /* HRESULT */ CreateStream( IntPtr pICodecFactory, out IntPtr /* IWICBitmapStream */ ppIStream); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateEncoder_Proxy")] internal static extern int /* HRESULT */ CreateEncoder( IntPtr pICodecFactory, ref Guid guidContainerFormat, ref Guid guidVendor, out SafeMILHandle /* IUnknown** */ ppICodec); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFromSource_Proxy")] internal static extern int /*HRESULT*/ CreateBitmapFromSource( IntPtr THIS_PTR, SafeMILHandle /* IWICBitmapSource */ pIBitmapSource, WICBitmapCreateCacheOptions options, out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFromMemory_Proxy")] internal static extern int /*HRESULT*/ CreateBitmapFromMemory( IntPtr THIS_PTR, UInt32 width, UInt32 height, ref Guid pixelFormatGuid, UInt32 stride, UInt32 cbBufferSize, IntPtr /* BYTE* */ pvPixels, out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmap_Proxy")] internal static extern int /*HRESULT*/ CreateBitmap( IntPtr THIS_PTR, UInt32 width, UInt32 height, ref Guid pixelFormatGuid, WICBitmapCreateCacheOptions options, out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFromHBITMAP_Proxy")] internal static extern int /*HRESULT*/ CreateBitmapFromHBITMAP( IntPtr THIS_PTR, IntPtr hBitmap, IntPtr hPalette, WICBitmapAlphaChannelOption options, out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFromHICON_Proxy")] internal static extern int /*HRESULT*/ CreateBitmapFromHICON( IntPtr THIS_PTR, IntPtr hIcon, out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateFastMetadataEncoderFromDecoder_Proxy")] internal static extern int /*HRESULT*/ CreateFastMetadataEncoderFromDecoder( IntPtr THIS_PTR, SafeMILHandle /* IWICBitmapDecoder */ pIDecoder, out SafeMILHandle /* IWICFastMetadataEncoder */ ppIFME); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateFastMetadataEncoderFromFrameDecode_Proxy")] internal static extern int /*HRESULT*/ CreateFastMetadataEncoderFromFrameDecode( IntPtr THIS_PTR, BitmapSourceSafeMILHandle /* IWICBitmapFrameDecode */ pIFrameDecode, out SafeMILHandle /* IWICFastMetadataEncoder */ ppIBitmap); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateQueryWriter_Proxy")] internal static extern int /*HRESULT*/ CreateQueryWriter( IntPtr THIS_PTR, ref Guid metadataFormat, ref Guid guidVendor, out IntPtr /* IWICMetadataQueryWriter */ queryWriter ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateQueryWriterFromReader_Proxy")] internal static extern int /*HRESULT*/ CreateQueryWriterFromReader( IntPtr THIS_PTR, SafeMILHandle /* IWICMetadataQueryReader */ queryReader, ref Guid guidVendor, out IntPtr /* IWICMetadataQueryWriter */ queryWriter ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICComponentFactory { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentFactory_CreateMetadataWriterFromReader_Proxy")] internal static extern int /*HRESULT*/ CreateMetadataWriterFromReader( IntPtr pICodecFactory, SafeMILHandle pIMetadataReader, ref Guid guidVendor, out IntPtr metadataWriter ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentFactory_CreateQueryWriterFromBlockWriter_Proxy")] internal static extern int /*HRESULT*/ CreateQueryWriterFromBlockWriter( IntPtr pICodecFactory, IntPtr pIBlockWriter, ref IntPtr ppIQueryWriter ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICMetadataBlockReader { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataBlockReader_GetCount_Proxy")] internal static extern int /*HRESULT*/ GetCount( IntPtr pIBlockReader, out UInt32 count ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataBlockReader_GetReaderByIndex_Proxy")] internal static extern int /*HRESULT*/ GetReaderByIndex( IntPtr pIBlockReader, UInt32 index, out SafeMILHandle /* IWICMetadataReader* */ pIMetadataReader ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICPixelFormatInfo { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPixelFormatInfo_GetBitsPerPixel_Proxy")] internal static extern int /*HRESULT*/ GetBitsPerPixel( IntPtr /* IWICPixelFormatInfo */ pIPixelFormatInfo, out UInt32 uiBitsPerPixel ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPixelFormatInfo_GetChannelCount_Proxy")] internal static extern int /*HRESULT*/ GetChannelCount( IntPtr /* IWICPixelFormatInfo */ pIPixelFormatInfo, out UInt32 uiChannelCount ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPixelFormatInfo_GetChannelMask_Proxy")] internal unsafe static extern int /*HRESULT*/ GetChannelMask( IntPtr /* IWICPixelFormatInfo */ pIPixelFormatInfo, UInt32 uiChannelIndex, UInt32 cbMaskBuffer, byte *pbMaskBuffer, out UInt32 cbActual ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapClipper { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapClipper_Initialize_Proxy")] internal static extern int /* HRESULT */ Initialize( System.Windows.Media.SafeMILHandle /* IWICBitmapClipper */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source, ref Int32Rect prc); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapFlipRotator { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFlipRotator_Initialize_Proxy")] internal static extern int /* HRESULT */ Initialize( System.Windows.Media.SafeMILHandle /* IWICBitmapFlipRotator */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source, WICBitmapTransformOptions options); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapScaler { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapScaler_Initialize_Proxy")] internal static extern int /* HRESULT */ Initialize( System.Windows.Media.SafeMILHandle /* IWICBitmapScaler */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source, uint width, uint height, WICInterpolationMode mode); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICFormatConverter { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICFormatConverter_Initialize_Proxy")] internal static extern int /* HRESULT */ Initialize( System.Windows.Media.SafeMILHandle /* IWICFormatConverter */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source, ref Guid dstFormat, DitherType dither, System.Windows.Media.SafeMILHandle /* IWICBitmapPalette */ bitmapPalette, double alphaThreshold, WICPaletteType paletteTranslate ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICColorTransform { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecsExt, EntryPoint = "IWICColorTransform_Initialize_Proxy")] internal static extern int /* HRESULT */ Initialize( System.Windows.Media.SafeMILHandle /* IWICColorTransform */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source, System.Windows.Media.SafeMILHandle /* IWICColorContext */ pIContextSource, System.Windows.Media.SafeMILHandle /* IWICColorContext */ pIContextDest, ref Guid pixelFmtDest ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmap { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmap_Lock_Proxy")] internal static extern int /* HRESULT */ Lock( System.Windows.Media.SafeMILHandle /* IWICBitmap */ THIS_PTR, ref Int32Rect prcLock, LockFlags flags, out SafeMILHandle /* IWICBitmapLock* */ ppILock); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmap_SetResolution_Proxy")] internal static extern int /* HRESULT */ SetResolution( System.Windows.Media.SafeMILHandle /* IWICBitmap */ THIS_PTR, double dpiX, double dpiY); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmap_SetPalette_Proxy")] internal static extern int /* HRESULT */ SetPalette( System.Windows.Media.SafeMILHandle /* IWICBitmap */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IMILPalette */ pIPalette); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapLock { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapLock_GetStride_Proxy")] internal static extern int /* HRESULT */ GetStride( SafeMILHandle /* IWICBitmapLock */ pILock, ref uint pcbStride ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapLock_GetDataPointer_STA_Proxy")] internal static extern int /* HRESULT */ GetDataPointer( SafeMILHandle /* IWICBitmapLock */ pILock, ref uint pcbBufferSize, ref IntPtr ppbData ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICCodec { // When updating this value be sure to update milrender.h's version // Reserve the number by editing and resubmitting SDKVersion.txt internal const int WINCODEC_SDK_VERSION = 0x0236; ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "WICCreateImagingFactory_Proxy")] internal static extern int CreateImagingFactory( UInt32 SDKVersion, out IntPtr ppICodecFactory ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "WICConvertBitmapSource")] internal static extern int /* HRESULT */ WICConvertBitmapSource( ref Guid dstPixelFormatGuid, SafeMILHandle /* IWICBitmapSource */ pISrc, out BitmapSourceSafeMILHandle /* IWICBitmapSource* */ ppIDst); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "WICSetEncoderFormat_Proxy")] internal static extern int /* HRESULT */ WICSetEncoderFormat( SafeMILHandle /* IWICBitmapSource */ pSourceIn, SafeMILHandle /* IMILPalette */ pIPalette, SafeMILHandle /* IWICBitmapFrameEncode* */ pIFrameEncode, out SafeMILHandle /* IWICBitmapSource** */ ppSourceOut); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "WICMapGuidToShortName")]//CASRemoval: internal static extern int /* HRESULT */ WICMapGuidToShortName( ref Guid guid, uint cchName, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzName, ref uint pcchActual); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "WICMapShortNameToGuid")]//CASRemoval: internal static extern int /* HRESULT */ WICMapShortNameToGuid( [Out, MarshalAs(UnmanagedType.LPWStr)] String wzName, ref Guid guid); [DllImport(DllImport.WindowsCodecsExt, EntryPoint = "WICCreateColorTransform_Proxy")] internal static extern int /* HRESULT */ CreateColorTransform( out BitmapSourceSafeMILHandle /* IWICColorTransform */ ppWICColorTransform); [DllImport(DllImport.WindowsCodecs, EntryPoint = "WICCreateColorContext_Proxy")] internal static extern int /* HRESULT */ CreateColorContext( IntPtr pICodecFactory, out System.Windows.Media.SafeMILHandle /* IWICColorContext */ ppColorContext); [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICColorContext_InitializeFromMemory_Proxy")] internal static extern int /* HRESULT */ ColorContext_InitializeFromMemory( SafeMILHandle THIS_PTR, IntPtr pvParameters, uint parameterSize); [DllImport("ole32.dll")] internal static extern int /* HRESULT */ CoInitialize( IntPtr reserved); [DllImport("ole32.dll")] internal static extern void CoUninitialize(); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class Mscms { [DllImport(DllImport.Mscms, EntryPoint = "CreateMultiProfileTransform")] internal static extern ColorTransformHandle /* HTRANSFORM */ CreateMultiProfileTransform(IntPtr[] /* PHPROFILE */ pahProfiles, UInt32 nProfiles, UInt32[] padwIntent, UInt32 nIntents, UInt32 dwFlags, UInt32 indexPreferredCMM); [DllImport(DllImport.Mscms, EntryPoint = "DeleteColorTransform")] internal static extern bool DeleteColorTransform(IntPtr /* HTRANSFORM */ hColorTransform); [DllImport(DllImport.Mscms, EntryPoint = "TranslateColors")] internal static extern int /* HRESULT */ TranslateColors(ColorTransformHandle /* HTRANSFORM */ hColorTransform, IntPtr paInputColors, UInt32 nColors, UInt32 ctInput, IntPtr paOutputColors, UInt32 ctOutput); [DllImport(DllImport.Mscms, EntryPoint = "OpenColorProfile")] internal static extern SafeProfileHandle /* HANDLE */ OpenColorProfile(IntPtr /* PPROFILE */ pProfile, UInt32 dwDesiredAccess, UInt32 dwShareMode, UInt32 dwCreationMode); [DllImport(DllImport.Mscms, EntryPoint = "CloseColorProfile")] internal static extern bool CloseColorProfile(IntPtr /* HANDLE */ phProfile); [DllImport(DllImport.Mscms, EntryPoint = "GetColorProfileHeader")] internal static extern int /* HRESULT */ GetColorProfileHeader(SafeProfileHandle /* HANDLE */ phProfile, IntPtr pHeader); [DllImport(DllImport.Mscms, CharSet = CharSet.Auto, BestFitMapping = false)] internal static extern int /* HRESULT */ GetColorDirectory(IntPtr pMachineName, StringBuilder pBuffer, out uint pdwSize); [DllImport(DllImport.Mscms, CharSet = CharSet.Auto, BestFitMapping = false)] internal static extern int /* HRESULT */ GetStandardColorSpaceProfile(IntPtr pMachineName, uint dwProfileID, StringBuilder pProfileName, out uint pdwSize); [DllImport(DllImport.Mscms, EntryPoint = "GetColorProfileFromHandle")] internal static extern int /* HRESULT */ GetColorProfileFromHandle(SafeProfileHandle /* HANDLE */ hProfile, IntPtr pBuffer, IntPtr pdwSize); } ////// Critical as this code performs an elevation. /// [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class MILFactory2 { [DllImport(DllImport.MilCore, EntryPoint = "MILCreateFactory")] internal static extern int CreateFactory( out IntPtr ppIFactory, UInt32 SDKVersion ); [DllImport(DllImport.MilCore, EntryPoint = "MILFactoryCreateMediaPlayer")] internal static extern int /*HRESULT*/ CreateMediaPlayer( IntPtr THIS_PTR, SafeMILHandle /* CEventProxy */ pEventProxy, bool canOpenAllMedia, Guid deviceId, out SafeMediaHandle /* IMILMedia */ ppMedia); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore, EntryPoint = "MILFactoryCreateBitmapRenderTarget")] internal static extern int /* HRESULT */ CreateBitmapRenderTarget( IntPtr THIS_PTR, UInt32 width, UInt32 height, PixelFormatEnum pixelFormatEnum, float dpiX, float dpiY, MILRTInitializationFlags dwFlags, out SafeMILHandle /* IMILRenderTargetBitmap */ ppIRenderTargetBitmap); [DllImport(DllImport.MilCore, EntryPoint = "MILFactoryCreateSWRenderTargetForBitmap")] internal static extern int /* HRESULT */ CreateBitmapRenderTargetForBitmap( IntPtr THIS_PTR, IntPtr /* IMILBitmap */ pIBitmap, out SafeMILHandle /* IMILRenderTargetBitmap */ ppIRenderTargetBitmap); } internal static class MILFactoryEffects { [DllImport(DllImport.MilCore, EntryPoint = "MILFactoryCreateBitmapEffect")] internal static extern int /* HRESULT */ CreateBitmapEffect( IntPtr THIS_PTR, ref Guid /*GUID*/ effectGUID, out SafeMILHandle /* IMILBitmapEffectPrimitive */ ppEffect); [DllImport(DllImport.MilCore, EntryPoint = "MILFactoryCreateBitmapEffectContext")] internal static extern int /* HRESULT */ CreateBitmapEffectContext( IntPtr THIS_PTR, out SafeMILHandle /* IMILBitmapEffectRenderContext */ ppContext); [DllImport(DllImport.MilCore, EntryPoint = "MILCreateBitmapEffectOuterPublic")] internal static extern int /* HRESULT */ CreateBitmapEffectOuter(out SafeMILHandle/* IMILBitmapEffect */ ppEffect); [DllImport(DllImport.MilCore, EntryPoint = "MILInitializeBitmapEffectPublic")] internal static extern int /* HRESULT */ InitializeBitmapEffect(SafeHandle /*IMILBitmapEffect */ pOuter, SafeHandle/* IMILBitmapEffectPrimitice */ pInner); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class InteropDeviceBitmap { internal delegate void FrontBufferAvailableCallback(bool lost, uint version); [DllImport(DllImport.MilCore, EntryPoint = "InteropDeviceBitmap_Create")] internal static extern int Create( ref Guid deviceId, IntPtr d3dResource, double dpiX, double dpiY, uint version, FrontBufferAvailableCallback pfnCallback, out SafeMILHandle ppInteropDeviceBitmap, out uint pixelWidth, out uint pixelHeight ); [DllImport(DllImport.MilCore, EntryPoint = "InteropDeviceBitmap_Detach")] internal static extern void Detach( SafeMILHandle pInteropDeviceBitmap ); [DllImport(DllImport.MilCore, EntryPoint = "InteropDeviceBitmap_AddDirtyRect")] internal static extern int AddDirtyRect( int x, int y, int w, int h, SafeMILHandle pInteropDeviceBitmap ); [DllImport(DllImport.MilCore, EntryPoint = "InteropDeviceBitmap_GetAsSoftwareBitmap")] internal static extern int GetAsSoftwareBitmap(SafeMILHandle pInteropDeviceBitmap, out BitmapSourceSafeMILHandle pIMILBitmapSource); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // // // ABOUT THIS FILE: // -- This file contains native methods which are deemed NOT SAFE in the sense that any usage of them // must be carefully reviewed. FXCop will flag callers of these for review. // -- These methods DO have the SuppressUnmanagedCodeSecurity attribute which means stalk walks for unmanaged // code will stop with the immediate caler. // -- Put methods in here when a stack walk is innappropriate due to performance concerns // -- If you have questions about how to use this file, email avsee //----------------------------------------------------------------------------- using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using System.Runtime.ConstrainedExecution; using System; using MS.Internal; using System.Security; using System.Security.Permissions; using System.Collections; using System.IO; using System.Text; using System.Windows.Media.Composition; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows; using Microsoft.Internal; using MS.Win32; using IComDataObject = System.Runtime.InteropServices.ComTypes.IDataObject; #pragma warning disable 1634, 1691 // suppressing PreSharp warnings namespace MS.Win32.PresentationCore { internal static partial class UnsafeNativeMethods { [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class MilCoreApi { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore, EntryPoint = "MilCompositionEngine_EnterCompositionEngineLock")] internal static extern void EnterCompositionEngineLock(); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore, EntryPoint = "MilCompositionEngine_ExitCompositionEngineLock")] internal static extern void ExitCompositionEngineLock(); [DllImport(DllImport.MilCore, EntryPoint = "MilCompositionEngine_EnterMediaSystemLock")] internal static extern void EnterMediaSystemLock(); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore, EntryPoint = "MilCompositionEngine_ExitMediaSystemLock")] internal static extern void ExitMediaSystemLock(); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] internal static extern int MilVersionCheck( uint uiCallerMilSdkVersion ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] internal static extern int MilTransport_CreateTransportParameters( bool fForcedLocalTransport, out bool fIsConnected, out UInt32 pDwGeneration, out bool fGraphicsStreamClientPresent); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] internal static extern int MilTransport_Create(out IntPtr ppTranspManager); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] internal static extern int MilSyncPacketTransport_Create( out IntPtr ppPacketTransport); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] internal static extern int MilTransport_CreateFromPacketTransport( IntPtr pSyncPacketTransport, out IntPtr ppPacketTransport ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] internal static extern int MilTransport_DisconnectTransport( IntPtr pTranspManager ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] internal extern static int /* HRESULT */ MILCreateStreamFromStreamDescriptor(ref System.Windows.Media.StreamDescriptor pSD, out IntPtr ppStream); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore)] unsafe internal static extern void MilUtility_GetTileBrushMapping( D3DMATRIX* transform, D3DMATRIX* relativeTransform, Stretch stretch, AlignmentX alignmentX, AlignmentY alignmentY, BrushMappingMode viewPortUnits, BrushMappingMode viewBoxUnits, Rect* shapeFillBounds, Rect* contentBounds, ref Rect viewport, ref Rect viewbox, out D3DMATRIX contentToShape, out int brushIsEmpty ); ////// This seems safe - the net effect of this command is to return the bounds of a Path. /// Although this seems safe - I'm putting it in unsafe as it takes pointers and is using the unsafe keyword. /// The unmanaged function does some validation - but it looks like you can pass it bogus data. /// However it looks like the worse that can happen - is you get invalid Rect returned. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilUtility_PathGeometryBounds( MIL_PEN_DATA *pPenData, double *pDashArray, MilMatrix3x2D* pWorldMatrix, FillRule fillRule, byte* pPathData, UInt32 nSize, MilMatrix3x2D* pGeometryMatrix, double rTolerance, bool fRelative, bool fSkipHollows, MilRectD* pBounds); ////// Seems safe - the net effect combines one path with another. /// Left in Unsafe native methods - as it manipulates pointers. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilUtility_PathGeometryCombine( MilMatrix3x2D* pMatrix, MilMatrix3x2D* pMatrix1, FillRule fillRule1, byte* pPathData1, UInt32 nSize1, MilMatrix3x2D* pMatrix2, FillRule fillRule2, byte* pPathData2, UInt32 nSize2, double rTolerance, bool fRelative, Delegate addFigureCallback, GeometryCombineMode combineMode, out FillRule resultFillRule); ////// Creates one flavor of a Path from another. /// use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilUtility_PathGeometryWiden( MIL_PEN_DATA *pPenData, double *pDashArray, MilMatrix3x2D* pMatrix, FillRule fillRule, byte* pPathData, UInt32 nSize, double rTolerance, bool fRelative, Delegate addFigureCallback, out FillRule widenedFillRule); ////// Creates one flavor of a Path from another. /// use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilUtility_PathGeometryOutline( MilMatrix3x2D* pMatrix, FillRule fillRule, byte* pPathData, UInt32 nSize, double rTolerance, bool fRelative, Delegate addFigureCallback, out FillRule outlinedFillRule); ////// Creates one flavor of a Path from another. /// use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilUtility_PathGeometryFlatten( MilMatrix3x2D* pMatrix, FillRule fillRule, byte* pPathData, UInt32 nSize, double rTolerance, bool fRelative, Delegate addFigureCallback, out FillRule resultFillRule); ////// Sets a global callback pointer to the function that creates Glyph bitmaps. /// Use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int /* HRESULT */ MilGlyphCache_SetCreateGlyphBitmapsCallback( MulticastDelegate del ); ////// Emulates DUCE.Channel.BeginCommand but circumvents the channel directly to CMilSlaveGlyphCache. /// Use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilGlyphCache_BeginCommandAtRenderTime( IntPtr pMilSlaveGlyphCacheTarget, byte* pbData, uint cbSize, uint cbExtra ); ////// Emulates DUCE.Channel.AppendCommandData but circumvents the channel directly to CMilSlaveGlyphCache. /// Use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilGlyphCache_AppendCommandDataAtRenderTime( IntPtr pMilSlaveGlyphCacheTarget, byte* pbData, uint cbSize ); ////// Emulates DUCE.Channel.EndCommand but circumvents the channel directly to CMilSlaveGlyphCache. /// Use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilGlyphCache_EndCommandAtRenderTime( IntPtr pMilSlaveGlyphCacheTarget ); ////// Circumvents channel and access a CGlyphRunResource directly /// Use of "unsafe" keyword prevents this from being considered safe. /// [DllImport(DllImport.MilCore)] internal unsafe static extern int MilGlyphRun_SetGeometryAtRenderTime( IntPtr pMilGlyphRunTarget, byte* pCmd, uint cbCmd ); [DllImport(DllImport.MilCore, EntryPoint = "MilCreateReversePInvokeWrapper")] internal unsafe static extern /*HRESULT*/ int MilCreateReversePInvokeWrapper( IntPtr pFcn, out IntPtr reversePInvokeWrapper); [DllImport(DllImport.MilCore, EntryPoint = "MilReleasePInvokePtrBlocking")] internal unsafe static extern void MilReleasePInvokePtrBlocking( IntPtr reversePInvokeWrapper); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICComponentInfo { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentInfo_GetCLSID_Proxy")] internal static extern int /* HRESULT */ GetCLSID( System.Windows.Media.SafeMILHandle /* IWICComponentInfo */ THIS_PTR, out Guid pclsid); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentInfo_GetAuthor_Proxy")] internal static extern int /* HRESULT */ GetAuthor( System.Windows.Media.SafeMILHandle /* IWICComponentInfo */ THIS_PTR, UInt32 cchAuthor, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzAuthor, out UInt32 pcchActual); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentInfo_GetVersion_Proxy")] internal static extern int /* HRESULT */ GetVersion( System.Windows.Media.SafeMILHandle /* IWICComponentInfo */ THIS_PTR, UInt32 cchVersion, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzVersion, out UInt32 pcchActual); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentInfo_GetSpecVersion_Proxy")] internal static extern int /* HRESULT */ GetSpecVersion( System.Windows.Media.SafeMILHandle /* IWICComponentInfo */ THIS_PTR, UInt32 cchSpecVersion, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzSpecVersion, out UInt32 pcchActual); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentInfo_GetFriendlyName_Proxy")] internal static extern int /* HRESULT */ GetFriendlyName( System.Windows.Media.SafeMILHandle /* IWICComponentInfo */ THIS_PTR, UInt32 cchFriendlyName, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFriendlyName, out UInt32 pcchActual); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapCodecInfo { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_GetContainerFormat_Proxy")] internal static extern int /* HRESULT */ GetContainerFormat( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, out Guid pguidContainerFormat); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_GetDeviceManufacturer_Proxy")] internal static extern int /* HRESULT */ GetDeviceManufacturer( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, UInt32 cchDeviceManufacturer, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDeviceManufacturer, out UInt32 pcchActual ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_GetDeviceModels_Proxy")] internal static extern int /* HRESULT */ GetDeviceModels( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, UInt32 cchDeviceModels, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDeviceModels, out UInt32 pcchActual ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_GetMimeTypes_Proxy")] internal static extern int /* HRESULT */ GetMimeTypes( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, UInt32 cchMimeTypes, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzMimeTypes, out UInt32 pcchActual ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_GetFileExtensions_Proxy")] internal static extern int /* HRESULT */ GetFileExtensions( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, UInt32 cchFileExtensions, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFileExtensions, out UInt32 pcchActual ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_DoesSupportAnimation_Proxy")] internal static extern int /* HRESULT */ DoesSupportAnimation( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, out bool pfSupportAnimation ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_DoesSupportLossless_Proxy")] internal static extern int /* HRESULT */ DoesSupportLossless( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, out bool pfSupportLossless ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapCodecInfo_DoesSupportMultiframe_Proxy")] internal static extern int /* HRESULT */ DoesSupportMultiframe( System.Windows.Media.SafeMILHandle /* IWICBitmapCodecInfo */ THIS_PTR, out bool pfSupportMultiframe ); } ////// Critical as this code performs an elevation. /// [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICMetadataQueryReader { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryReader_GetContainerFormat_Proxy")] internal static extern int /* HRESULT */ GetContainerFormat( System.Windows.Media.SafeMILHandle /* IWICMetadataQueryReader */ THIS_PTR, out Guid pguidContainerFormat); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryReader_GetLocation_Proxy")] internal static extern int /* HRESULT */ GetLocation( System.Windows.Media.SafeMILHandle /* IWICMetadataQueryReader */ THIS_PTR, UInt32 cchLocation, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzNamespace, out UInt32 pcchActual ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryReader_GetMetadataByName_Proxy")] internal static extern int /* HRESULT */ GetMetadataByName( System.Windows.Media.SafeMILHandle /* IWICMetadataQueryReader */ THIS_PTR, [Out, MarshalAs(UnmanagedType.LPWStr)] String wzName, ref System.Windows.Media.Imaging.PROPVARIANT propValue ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryReader_GetMetadataByName_Proxy")] internal static extern int /* HRESULT */ ContainsMetadataByName( System.Windows.Media.SafeMILHandle /* IWICMetadataQueryReader */ THIS_PTR, [Out, MarshalAs(UnmanagedType.LPWStr)] String wzName, IntPtr propVar ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryReader_GetEnumerator_Proxy")] internal static extern int /* HRESULT */ GetEnumerator( System.Windows.Media.SafeMILHandle /* IWICMetadataQueryReader */ THIS_PTR, out System.Windows.Media.SafeMILHandle /* IEnumString */ enumString ); } ////// Critical as this code performs an elevation. /// [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICMetadataQueryWriter { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryWriter_SetMetadataByName_Proxy")] internal static extern int /* HRESULT */ SetMetadataByName( System.Windows.Media.SafeMILHandle /* IWICMetadataQueryWriter */ THIS_PTR, [Out, MarshalAs(UnmanagedType.LPWStr)] String wzName, ref System.Windows.Media.Imaging.PROPVARIANT propValue ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataQueryWriter_RemoveMetadataByName_Proxy")] internal static extern int /* HRESULT */ RemoveMetadataByName( System.Windows.Media.SafeMILHandle /* IWICMetadataQueryWriter */ THIS_PTR, [Out, MarshalAs(UnmanagedType.LPWStr)] String wzName ); } ////// Critical as this code performs an elevation. /// [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICFastMetadataEncoder { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICFastMetadataEncoder_Commit_Proxy")] internal static extern int /* HRESULT */ Commit( System.Windows.Media.SafeMILHandle /* IWICFastMetadataEncoder */ THIS_PTR ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICFastMetadataEncoder_GetMetadataQueryWriter_Proxy")] internal static extern int /* HRESULT */ GetMetadataQueryWriter( System.Windows.Media.SafeMILHandle /* IWICFastMetadataEncoder */ THIS_PTR, out SafeMILHandle /* IWICMetadataQueryWriter */ ppIQueryWriter ); } ////// Critical as this code performs an elevation. /// [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class EnumString { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IEnumString_Next_WIC_Proxy")] internal static extern int /* HRESULT */ Next( System.Windows.Media.SafeMILHandle /* IEnumString */ THIS_PTR, Int32 celt, ref IntPtr rgElt, ref Int32 pceltFetched ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IEnumString_Reset_WIC_Proxy")] internal static extern int /* HRESULT */ Reset( System.Windows.Media.SafeMILHandle /* IEnumString */ THIS_PTR ); } ////// Critical as this code performs an elevation. /// [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class IPropertyBag2 { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IPropertyBag2_Write_Proxy")] internal static extern int /* HRESULT */ Write( System.Windows.Media.SafeMILHandle /* IPropertyBag2 */ THIS_PTR, UInt32 cProperties, ref System.Windows.Media.Imaging.PROPBAG2 propBag, ref System.Windows.Media.Imaging.PROPVARIANT propValue ); } internal class IMILBitmapEffectRenderContext { protected IMILBitmapEffectRenderContext() { } [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_SetOutputPixelFormat")] internal static extern int /* HRESULT */ SetOutputPixelFormat( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, ref Guid /* REFWICPixelFormatGUID */ format); #if never [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_GetOutputPixelFormat")] internal static extern int /* HRESULT */ GetOutputPixelFormat( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, out Guid /* WICPixelFormatGUID */ format); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_SetUseSoftwareRenderer")] internal static extern int /* HRESULT */ SetUseSoftwareRenderer( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, [MarshalAs(UnmanagedType.VariantBool)]System.Boolean /* VARIANT_BOOL */ fSoftware); #endif [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_SetInitialTransform")] internal static extern int /* HRESULT */ SetInitialTransform( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, double m11, double m12, double m21, double m22, double m31, double m32); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_GetFinalTransform")] internal static extern int /* HRESULT */ GetFinalTransform( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, out double m11, out double m12, out double m21, out double m22, out double m31, out double m32); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_SetRegionOfInterest")] internal static extern int /* HRESULT */ SetRegionOfInterest( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, ref Rect pRect); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_SetOutputDPI")] internal static extern int /* HRESULT */ SetOutputDPI( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, double dblDpiX, double dblDpiY); #if never [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectRenderContext_GetOutputDPI")] internal static extern int /* HRESULT */ GetOutputDPI( SafeMILHandle /* IMILBitmapEffectRenderContext */ THIS_PTR, out double pdblDpiX, out double pdblDpiY); #endif } internal class IMILBitmapEffect { [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_GetOutput")] internal static extern int /* HRESULT */ GetOutput( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 uiIndex, SafeMILHandle /* IMILBitmapEffectRenderContext */ pContext, out BitmapSourceSafeMILHandle /* IWICBitmapSource */ ppBitmapSource); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_GetParentEffect")] internal static extern int /* HRESULT */ GetParentEffect( SafeHandle /* IMILBitmapEffect */ THIS_PTR, out SafeMILHandle /* IMILBitmapEffectGroup */ ppParentEffect); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_SetInputSource")] internal static extern int /* HRESULT */ SetInputSource( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 uiIndex, BitmapSourceSafeMILHandle /* IWICBitmapSource */ pBitmapSource); //********************************************************************* // Interfaces from IMILBitmapEffectConnectionsInfo which we will // QI from IMILBitmapEffect //********************************************************************* [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectConnectionsInfo_GetNumberInputs")] internal static extern int /* HRESULT */ GetNumberInputs( SafeHandle /* IMILBitmapEffect */ THIS_PTR, out UInt32 piNumInputs); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectConnectionsInfo_GetNumberOutputs")] internal static extern int /* HRESULT */ GetNumberOutputs( SafeHandle /* IMILBitmapEffect */ THIS_PTR, out UInt32 piNumOutputs); //********************************************************************** // Interfaces from IMILBitmapEffectConnections which we will // QI from IMILBitmapEffect //********************************************************************* [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectConnections_GetInputConnector")] internal static extern int /* HRESULT */ GetInputConnector( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 uiIndex, out SafeMILHandle /* IMILBitmapEffectInputConnector */ ppConnector); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectConnections_GetOutputConnector")] internal static extern int /* HRESULT */ GetOutputConnector( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 uiIndex, out SafeMILHandle /* IMILBitmapEffectOutputConnector */ ppConnector); //********************************************************************** // These methods aren't actually exposed by the effects layer, but are // just helpers for setting/getting values through the interop layer. // (However, they do set the value through IPropertyBag2 on the effect // primitive itself, which we will QI THIS_PTR). //********************************************************************** [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectPrimitive_SetValue")] internal static extern int /* HRESULT */ SetValue( SafeHandle /* IMILBitmapEffect */ THIS_PTR, [MarshalAs(UnmanagedType.BStr)]System.String /* BSTR */ bstrName, [MarshalAs(UnmanagedType.Struct)]ref System.Object /* VARIANT* */ varValue); #if never [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectPrimitive_GetValue")] internal static extern int /* HRESULT */ GetValue( SafeHandle /* IMILBitmapEffect */ THIS_PTR, [MarshalAs(UnmanagedType.BStr)]System.String /* BSTR */ bstrName, [MarshalAs(UnmanagedType.Struct)]out System.Object /* VARIANT* */ varValue); #endif //********************************************************************* // Interfaces from IMILBitmapEffectGroup which we will QI from IMILBitmapEffect //********************************************************************** [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectGroup_GetInteriorInputConnector")] internal static extern int /* HRESULT */ GetInteriorInputConnector( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 iIndex, out SafeMILHandle /* IMILBitmapEffectOutputConnector */ pConnector); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectGroup_GetInteriorOutputConnector")] internal static extern int /* HRESULT */ GetInteriorOutputConnector( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 iIndex, out SafeMILHandle /* IMILBitmapEffectInputConnector */ pConnector); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectGroup_Add")] internal static extern int /* HRESULT */ Add( SafeHandle /* IMILBitmapEffect */ THIS_PTR, SafeHandle /* IMILBitmapEffect */ pEffect); //********************************************************************* // Interfaces from IMILBitmapEffectPrimitive which we will QI from IMILBitmapEffect //********************************************************************* [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectPrimitive_TransformPoint")] internal static extern int /* HRESULT */ TransformPoint( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 iIndex, ref System.Windows.Point p, [MarshalAs(UnmanagedType.VariantBool)] System.Boolean /* VARIANT_BOOL */ fForwardTransform, SafeMILHandle /* IMILBitmapEffectRenderContext */ pContext, [MarshalAs(UnmanagedType.VariantBool)] out System.Boolean /* VARIANT_BOOL */ fPointTransformed); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectPrimitive_TransformRect")] internal static extern int /* HRESULT */ TransformRect( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 iIndex, ref Rect p, [MarshalAs(UnmanagedType.VariantBool)] System.Boolean /* VARIANT_BOOL */ fForwardTransform, SafeMILHandle /* IMILBitmapEffectRenderContext */ pContext); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectPrimitive_HasAffineTransform")] internal static extern int /* HRESULT */ HasAffineTransform( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 iIndex, [MarshalAs(UnmanagedType.VariantBool)] out System.Boolean /* VARIANT_BOOL */ fAffine); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectPrimitive_HasInverseTransform")] internal static extern int /* HRESULT */ HasInverseTransform( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 iIndex, [MarshalAs(UnmanagedType.VariantBool)] out System.Boolean /* VARIANT_BOOL */ fInverse); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffect_IMILBitmapEffectPrimitive_GetAffineMatrix")] internal static extern int /* HRESULT */ GetAffineMatrix( SafeHandle /* IMILBitmapEffect */ THIS_PTR, UInt32 iIndex, ref MilMatrix3x2D pMatrix); }; internal class IMILBitmapEffectConnectorInfo { [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectConnectorInfo_GetOptimalFormat")] internal static extern int /* HRESULT */ GetOptimalFormat( SafeMILHandle /* IMILBitmapEffectConnectorInfo */ THIS_PTR, out Guid /* WICPixelFormatGUID */ format); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectConnectorInfo_GetNumberFormats")] internal static extern int /* HRESULT */ GetNumberFormats( SafeMILHandle /* IMILBitmapEffectConnectorInfo */ THIS_PTR, out UInt32 pulNumberFormats); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectConnectorInfo_GetFormat")] internal static extern int /* HRESULT */ GetFormat( SafeMILHandle /* IMILBitmapEffectConnectorInfo */ THIS_PTR, out Guid /* WICPixelFormatGUID */ format); } internal class IMILBitmapEffectConnector : IMILBitmapEffectConnectorInfo { [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectConnector_IsConnected")] internal static extern int /* HRESULT */ IsConnected( SafeMILHandle /* IMILBitmapEffectConnector */ THIS_PTR, [MarshalAs(UnmanagedType.VariantBool)] out System.Boolean /* VARIANT_BOOL */ pFormat); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectConnector_GetBitmapEffect")] internal static extern int /* HRESULT */ GetBitmapEffect( SafeMILHandle /* IMILBitmapEffectConnector */ THIS_PTR, out SafeHandle /* IMILBitmapEffect */ ppEffect); } internal class IMILBitmapEffectInputConnector : IMILBitmapEffectConnector { [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectInputConnector_ConnectTo")] internal static extern int /* HRESULT */ ConnectTo( SafeMILHandle /* IMILBitmapEffectInputConnector */ THIS_PTR, SafeMILHandle /* IMILBitmapEffectOutputConnector */ pConnector); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectInputConnector_GetConnection")] internal static extern int /* HRESULT */ GetConnection( SafeMILHandle /* IMILBitmapEffectInputConnector */ THIS_PTR, out SafeMILHandle /* IMILBitmapEffectOutputConnector */ ppConnector); } internal class IMILBitmapEffectOutputConnector : IMILBitmapEffectConnector { [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectOutputConnector_GetNumberConnections")] internal static extern int /* HRESULT */ GetNumberConnections( SafeMILHandle /* IMILBitmapEffectOutputConnector */ THIS_PTR, out UInt32 piNumberConnections); [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectOutputConnector_GetConnection")] internal static extern int /* HRESULT */ GetConnection( SafeMILHandle /* IMILBitmapEffectOutputConnector */ THIS_PTR, UInt32 iIndex, out SafeMILHandle /* IMILBitmapEffectInputConnector */ ppConnection); } internal class IMILBitmapEffectInteriorOutputConnector { [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectInteriorOutputConnector_GetOutputConnector")] internal static extern int /* HRESULT */ GetOutputConnector( SafeHandle /* IMILBitmapEffectInteriorOutputConnector */ THIS_PTR, out SafeMILHandle /* IMILBitmapEffectOutputConnector */ ppConnector); } internal class IMILBitmapEffectInteriorInputConnector { [DllImport(DllImport.MilCore, EntryPoint = "IMILBitmapEffectInteriorInputConnector_GetInputConnector")] internal static extern int /* HRESULT */ GetInputConnector( SafeHandle /* IMILBitmapEffectInteriorInputConnector */ THIS_PTR, out SafeMILHandle /* IMILBitmapEffectInputConnector */ ppConnector); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapSource { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_GetSize_Proxy")] internal static extern int /* HRESULT */ GetSize( System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ THIS_PTR, out UInt32 puiWidth, out UInt32 puiHeight); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_GetPixelFormat_Proxy")] internal static extern int /* HRESULT */ GetPixelFormat( System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ THIS_PTR, out Guid pPixelFormatEnum); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_GetResolution_Proxy")] internal static extern int /* HRESULT */ GetResolution( System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ THIS_PTR, out double pDpiX, out double pDpiY); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_CopyPalette_Proxy")] internal static extern int /* HRESULT */ CopyPalette( System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IMILPalette */ pIPalette); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapSource_CopyPixels_Proxy")] internal static extern int /* HRESULT */ CopyPixels( SafeMILHandle /* IWICBitmapSource */ THIS_PTR, ref Int32Rect prc, UInt32 cbStride, UInt32 cbBufferSize, IntPtr /* BYTE* */ pvPixels); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapDecoder { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetDecoderInfo_Proxy")] internal static extern int /* HRESULT */ GetDecoderInfo( SafeMILHandle THIS_PTR, out SafeMILHandle /* IWICBitmapDecoderInfo */ ppIDecoderInfo); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_CopyPalette_Proxy")] internal static extern int /* HRESULT */ CopyPalette( SafeMILHandle /* IWICBitmapDecoder */ THIS_PTR, SafeMILHandle /* IMILPalette */ pIPalette); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetPreview_Proxy")] internal static extern int /* HRESULT */ GetPreview( SafeMILHandle THIS_PTR, out IntPtr /* IWICBitmapSource */ ppIBitmapSource ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetColorContexts_Proxy")] internal static extern int /* HRESULT */ GetColorContexts( SafeMILHandle THIS_PTR, uint nIndex, IntPtr /* IWICColorContext */ ppIColorContext, out uint /* IWICColorContext */ pCount ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetThumbnail_Proxy")] internal static extern int /* HRESULT */ GetThumbnail( SafeMILHandle /* IWICBitmapDecoder */ THIS_PTR, out IntPtr /* IWICBitmapSource */ ppIThumbnail ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetMetadataQueryReader_Proxy")] internal static extern int /* HRESULT */ GetMetadataQueryReader( SafeMILHandle /* IWICBitmapDecoder */ THIS_PTR, out IntPtr /* IWICMetadataQueryReader */ ppIQueryReader ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetFrameCount_Proxy")] internal static extern int /* HRESULT */ GetFrameCount( SafeMILHandle THIS_PTR, out uint pFrameCount ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapDecoder_GetFrame_Proxy")] internal static extern int /* HRESULT */ GetFrame( SafeMILHandle /* IWICBitmapDecoder */ THIS_PTR, UInt32 index, out IntPtr /* IWICBitmapFrameDecode */ ppIFrameDecode ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapFrameDecode { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameDecode_GetThumbnail_Proxy")] internal static extern int /* HRESULT */ GetThumbnail( SafeMILHandle /* IWICBitmapFrameDecode */ THIS_PTR, out IntPtr /* IWICBitmap */ ppIThumbnail ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameDecode_GetMetadataQueryReader_Proxy")] internal static extern int /* HRESULT */ GetMetadataQueryReader( SafeMILHandle /* IWICBitmapFrameDecode */ THIS_PTR, out IntPtr /* IWICMetadataQueryReader */ ppIQueryReader ); [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameDecode_GetColorContexts_Proxy")] internal static extern int /* HRESULT */ GetColorContexts( SafeMILHandle /* IWICBitmapFrameDecode */ THIS_PTR, uint nIndex, IntPtr /* IWICColorContext */ ppIColorContext, out uint pCount ); } ////// Critical as this code performs an elevation. /// [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class MILUnknown { [DllImport(DllImport.MilCore, EntryPoint = "MILAddRef")] internal static extern UInt32 AddRef(SafeMILHandle pIUnkown); [DllImport(DllImport.MilCore, EntryPoint = "MILAddRef")] internal static extern UInt32 AddRef(SafeReversePInvokeWrapper pIUnknown); [DllImport(DllImport.MilCore, EntryPoint = "MILRelease"), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] internal static extern int Release(IntPtr pIUnkown); internal static void ReleaseInterface(ref IntPtr ptr) { if (ptr != IntPtr.Zero) { #pragma warning suppress 6031 // Return value ignored on purpose. UnsafeNativeMethods.MILUnknown.Release(ptr); ptr = IntPtr.Zero; } } [DllImport(DllImport.MilCore, EntryPoint = "MILQueryInterface")] internal static extern int /* HRESULT */ QueryInterface( IntPtr pIUnknown, ref Guid guid, out IntPtr ppvObject); [DllImport(DllImport.MilCore, EntryPoint = "MILQueryInterface")] internal static extern int /* HRESULT */ QueryInterface( SafeMILHandle pIUnknown, ref Guid guid, out IntPtr ppvObject); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICStream { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICStream_InitializeFromIStream_Proxy")] internal static extern int /*HRESULT*/ InitializeFromIStream( IntPtr pIWICStream, IntPtr pIStream); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICStream_InitializeFromMemory_Proxy")] internal static extern int /*HRESULT*/ InitializeFromMemory( IntPtr pIWICStream, IntPtr pbBuffer, uint cbSize); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WindowsCodecApi { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "WICCreateBitmapFromSection")] internal static extern int /*HRESULT*/ CreateBitmapFromSection( UInt32 width, UInt32 height, ref Guid pixelFormatGuid, IntPtr hSection, UInt32 stride, UInt32 offset, out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap); } internal static class WICBitmapFrameEncode { ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapFrameEncode_Initialize_Proxy")] internal static extern int /* HRESULT */ Initialize(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR, SafeMILHandle /* IPropertyBag2* */ pIEncoderOptions); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapFrameEncode_Commit_Proxy")] internal static extern int /* HRESULT */ Commit(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapFrameEncode_SetSize_Proxy")] internal static extern int /* HRESULT */ SetSize(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR, int width, int height); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapFrameEncode_SetResolution_Proxy")] internal static extern int /* HRESULT */ SetResolution(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR, double dpiX, double dpiY); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapFrameEncode_WriteSource_Proxy")] internal static extern int /* HRESULT */ WriteSource(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR, SafeMILHandle /* IMILBitmapSource* */ pIBitmapSource, ref Int32Rect /* MILRect* */ r); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameEncode_SetThumbnail_Proxy")] internal static extern int /* HRESULT */ SetThumbnail(SafeMILHandle /* IWICBitmapFrameEncode* */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICBitmapSource* */ pIThumbnail); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameEncode_GetMetadataQueryWriter_Proxy")] internal static extern int /* HRESULT */ GetMetadataQueryWriter( SafeMILHandle /* IWICBitmapFrameEncode */ THIS_PTR, out SafeMILHandle /* IWICMetadataQueryWriter */ ppIQueryWriter ); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFrameEncode_SetColorContexts_Proxy")] internal static extern int /* HRESULT */ SetColorContexts(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR, uint nIndex, IntPtr /* IWICColorContext */ ppIColorContext); } internal static class WICBitmapEncoder { ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_Initialize_Proxy")] internal static extern int /* HRESULT */ Initialize(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR, IntPtr /* IStream */ pStream, WICBitmapEncodeCacheOption option); [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_GetEncoderInfo_Proxy")] internal static extern int /* HRESULT */ GetEncoderInfo(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR, out SafeMILHandle /* IWICBitmapEncoderInfo ** */ ppIEncoderInfo ); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_CreateNewFrame_Proxy")] internal static extern int /* HRESULT */ CreateNewFrame(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR, out SafeMILHandle /* IWICBitmapFrameEncode ** */ ppIFramEncode, out SafeMILHandle /* IPropertyBag2 ** */ ppIEncoderOptions ); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_SetThumbnail_Proxy")] internal static extern int /* HRESULT */ SetThumbnail(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICBitmapSource* */ pIThumbnail); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_SetPalette_Proxy")] internal static extern int /* HRESULT */ SetPalette(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICPalette* */ pIPalette); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapEncoder_GetMetadataQueryWriter_Proxy")] internal static extern int /* HRESULT */ GetMetadataQueryWriter( SafeMILHandle /* IWICBitmapEncoder */ THIS_PTR, out SafeMILHandle /* IWICMetadataQueryWriter */ ppIQueryWriter ); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICBitmapEncoder_Commit_Proxy")] internal static extern int /* HRESULT */ Commit(SafeMILHandle /* IWICBitmapEncoder* */ THIS_PTR); } internal static class WICPalette { [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_InitializePredefined_Proxy")] internal static extern int /* HRESULT */ InitializePredefined(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, WICPaletteType ePaletteType, bool fAddTransparentColor); [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_InitializeCustom_Proxy")] internal static extern int /* HRESULT */ InitializeCustom(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, IntPtr /* MILColor* */ pColors, int colorCount); [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_InitializeFromBitmap_Proxy")] internal static extern int /* HRESULT */ InitializeFromBitmap(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IMILBitmapSource* */ pISurface, int colorCount, bool fAddTransparentColor); [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_InitializeFromPalette_Proxy")] internal static extern int /* HRESULT */ InitializeFromPalette(IntPtr /* IWICPalette */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICPalette */ pIWICPalette); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_GetType_Proxy")] internal static extern int /* HRESULT */ GetType(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, out WICPaletteType pePaletteType); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_GetColorCount_Proxy")] internal static extern int /* HRESULT */ GetColorCount(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, out int pColorCount); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_GetColors_Proxy")] internal static extern int /* HRESULT */ GetColors(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, int colorCount, IntPtr /* MILColor* */ pColors, out int pcActualCount); ////// Critical as this code performs an elevation. /// [SecurityCritical] [SuppressUnmanagedCodeSecurity] [DllImport(DllImport.WindowsCodecs, EntryPoint="IWICPalette_HasAlpha_Proxy")] internal static extern int /* HRESULT */ HasAlpha(System.Windows.Media.SafeMILHandle /* IWICPalette */ THIS_PTR, out bool pfHasAlpha); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICImagingFactory { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateDecoderFromStream_Proxy")] internal static extern int /*HRESULT*/ CreateDecoderFromStream( IntPtr pICodecFactory, IntPtr /* IStream */ pIStream, ref Guid guidVendor, UInt32 metadataFlags, out IntPtr /* IWICBitmapDecoder */ ppIDecode); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateDecoderFromFileHandle_Proxy")] internal static extern int /*HRESULT*/ CreateDecoderFromFileHandle( IntPtr pICodecFactory, Microsoft.Win32.SafeHandles.SafeFileHandle /*ULONG_PTR*/ hFileHandle, ref Guid guidVendor, UInt32 metadataFlags, out IntPtr /* IWICBitmapDecoder */ ppIDecode); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateComponentInfo_Proxy")] internal static extern int /*HRESULT*/ CreateComponentInfo( IntPtr pICodecFactory, ref Guid clsidComponent, out IntPtr /* IWICComponentInfo */ ppIComponentInfo); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreatePalette_Proxy")] internal static extern int /*HRESULT*/ CreatePalette( IntPtr pICodecFactory, out SafeMILHandle /* IWICPalette */ ppIPalette); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateFormatConverter_Proxy")] internal static extern int /* HRESULT */ CreateFormatConverter( IntPtr pICodecFactory, out BitmapSourceSafeMILHandle /* IWICFormatConverter */ ppFormatConverter); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapScaler_Proxy")] internal static extern int /* HRESULT */ CreateBitmapScaler( IntPtr pICodecFactory, out BitmapSourceSafeMILHandle /* IWICBitmapScaler */ ppBitmapScaler); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapClipper_Proxy")] internal static extern int /* HRESULT */ CreateBitmapClipper( IntPtr pICodecFactory, out BitmapSourceSafeMILHandle /* IWICBitmapClipper */ ppBitmapClipper); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFlipRotator_Proxy")] internal static extern int /* HRESULT */ CreateBitmapFlipRotator( IntPtr pICodecFactory, out BitmapSourceSafeMILHandle /* IWICBitmapFlipRotator */ ppBitmapFlipRotator); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateStream_Proxy")] internal static extern int /* HRESULT */ CreateStream( IntPtr pICodecFactory, out IntPtr /* IWICBitmapStream */ ppIStream); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateEncoder_Proxy")] internal static extern int /* HRESULT */ CreateEncoder( IntPtr pICodecFactory, ref Guid guidContainerFormat, ref Guid guidVendor, out SafeMILHandle /* IUnknown** */ ppICodec); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFromSource_Proxy")] internal static extern int /*HRESULT*/ CreateBitmapFromSource( IntPtr THIS_PTR, SafeMILHandle /* IWICBitmapSource */ pIBitmapSource, WICBitmapCreateCacheOptions options, out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFromMemory_Proxy")] internal static extern int /*HRESULT*/ CreateBitmapFromMemory( IntPtr THIS_PTR, UInt32 width, UInt32 height, ref Guid pixelFormatGuid, UInt32 stride, UInt32 cbBufferSize, IntPtr /* BYTE* */ pvPixels, out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmap_Proxy")] internal static extern int /*HRESULT*/ CreateBitmap( IntPtr THIS_PTR, UInt32 width, UInt32 height, ref Guid pixelFormatGuid, WICBitmapCreateCacheOptions options, out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFromHBITMAP_Proxy")] internal static extern int /*HRESULT*/ CreateBitmapFromHBITMAP( IntPtr THIS_PTR, IntPtr hBitmap, IntPtr hPalette, WICBitmapAlphaChannelOption options, out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateBitmapFromHICON_Proxy")] internal static extern int /*HRESULT*/ CreateBitmapFromHICON( IntPtr THIS_PTR, IntPtr hIcon, out BitmapSourceSafeMILHandle /* IWICBitmap */ ppIBitmap); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateFastMetadataEncoderFromDecoder_Proxy")] internal static extern int /*HRESULT*/ CreateFastMetadataEncoderFromDecoder( IntPtr THIS_PTR, SafeMILHandle /* IWICBitmapDecoder */ pIDecoder, out SafeMILHandle /* IWICFastMetadataEncoder */ ppIFME); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateFastMetadataEncoderFromFrameDecode_Proxy")] internal static extern int /*HRESULT*/ CreateFastMetadataEncoderFromFrameDecode( IntPtr THIS_PTR, BitmapSourceSafeMILHandle /* IWICBitmapFrameDecode */ pIFrameDecode, out SafeMILHandle /* IWICFastMetadataEncoder */ ppIBitmap); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateQueryWriter_Proxy")] internal static extern int /*HRESULT*/ CreateQueryWriter( IntPtr THIS_PTR, ref Guid metadataFormat, ref Guid guidVendor, out IntPtr /* IWICMetadataQueryWriter */ queryWriter ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICImagingFactory_CreateQueryWriterFromReader_Proxy")] internal static extern int /*HRESULT*/ CreateQueryWriterFromReader( IntPtr THIS_PTR, SafeMILHandle /* IWICMetadataQueryReader */ queryReader, ref Guid guidVendor, out IntPtr /* IWICMetadataQueryWriter */ queryWriter ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICComponentFactory { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentFactory_CreateMetadataWriterFromReader_Proxy")] internal static extern int /*HRESULT*/ CreateMetadataWriterFromReader( IntPtr pICodecFactory, SafeMILHandle pIMetadataReader, ref Guid guidVendor, out IntPtr metadataWriter ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICComponentFactory_CreateQueryWriterFromBlockWriter_Proxy")] internal static extern int /*HRESULT*/ CreateQueryWriterFromBlockWriter( IntPtr pICodecFactory, IntPtr pIBlockWriter, ref IntPtr ppIQueryWriter ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICMetadataBlockReader { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataBlockReader_GetCount_Proxy")] internal static extern int /*HRESULT*/ GetCount( IntPtr pIBlockReader, out UInt32 count ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICMetadataBlockReader_GetReaderByIndex_Proxy")] internal static extern int /*HRESULT*/ GetReaderByIndex( IntPtr pIBlockReader, UInt32 index, out SafeMILHandle /* IWICMetadataReader* */ pIMetadataReader ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICPixelFormatInfo { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPixelFormatInfo_GetBitsPerPixel_Proxy")] internal static extern int /*HRESULT*/ GetBitsPerPixel( IntPtr /* IWICPixelFormatInfo */ pIPixelFormatInfo, out UInt32 uiBitsPerPixel ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPixelFormatInfo_GetChannelCount_Proxy")] internal static extern int /*HRESULT*/ GetChannelCount( IntPtr /* IWICPixelFormatInfo */ pIPixelFormatInfo, out UInt32 uiChannelCount ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICPixelFormatInfo_GetChannelMask_Proxy")] internal unsafe static extern int /*HRESULT*/ GetChannelMask( IntPtr /* IWICPixelFormatInfo */ pIPixelFormatInfo, UInt32 uiChannelIndex, UInt32 cbMaskBuffer, byte *pbMaskBuffer, out UInt32 cbActual ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapClipper { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapClipper_Initialize_Proxy")] internal static extern int /* HRESULT */ Initialize( System.Windows.Media.SafeMILHandle /* IWICBitmapClipper */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source, ref Int32Rect prc); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapFlipRotator { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapFlipRotator_Initialize_Proxy")] internal static extern int /* HRESULT */ Initialize( System.Windows.Media.SafeMILHandle /* IWICBitmapFlipRotator */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source, WICBitmapTransformOptions options); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapScaler { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapScaler_Initialize_Proxy")] internal static extern int /* HRESULT */ Initialize( System.Windows.Media.SafeMILHandle /* IWICBitmapScaler */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source, uint width, uint height, WICInterpolationMode mode); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICFormatConverter { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICFormatConverter_Initialize_Proxy")] internal static extern int /* HRESULT */ Initialize( System.Windows.Media.SafeMILHandle /* IWICFormatConverter */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source, ref Guid dstFormat, DitherType dither, System.Windows.Media.SafeMILHandle /* IWICBitmapPalette */ bitmapPalette, double alphaThreshold, WICPaletteType paletteTranslate ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICColorTransform { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecsExt, EntryPoint = "IWICColorTransform_Initialize_Proxy")] internal static extern int /* HRESULT */ Initialize( System.Windows.Media.SafeMILHandle /* IWICColorTransform */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IWICBitmapSource */ source, System.Windows.Media.SafeMILHandle /* IWICColorContext */ pIContextSource, System.Windows.Media.SafeMILHandle /* IWICColorContext */ pIContextDest, ref Guid pixelFmtDest ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmap { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmap_Lock_Proxy")] internal static extern int /* HRESULT */ Lock( System.Windows.Media.SafeMILHandle /* IWICBitmap */ THIS_PTR, ref Int32Rect prcLock, LockFlags flags, out SafeMILHandle /* IWICBitmapLock* */ ppILock); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmap_SetResolution_Proxy")] internal static extern int /* HRESULT */ SetResolution( System.Windows.Media.SafeMILHandle /* IWICBitmap */ THIS_PTR, double dpiX, double dpiY); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmap_SetPalette_Proxy")] internal static extern int /* HRESULT */ SetPalette( System.Windows.Media.SafeMILHandle /* IWICBitmap */ THIS_PTR, System.Windows.Media.SafeMILHandle /* IMILPalette */ pIPalette); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICBitmapLock { ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapLock_GetStride_Proxy")] internal static extern int /* HRESULT */ GetStride( SafeMILHandle /* IWICBitmapLock */ pILock, ref uint pcbStride ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICBitmapLock_GetDataPointer_STA_Proxy")] internal static extern int /* HRESULT */ GetDataPointer( SafeMILHandle /* IWICBitmapLock */ pILock, ref uint pcbBufferSize, ref IntPtr ppbData ); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class WICCodec { // When updating this value be sure to update milrender.h's version // Reserve the number by editing and resubmitting SDKVersion.txt internal const int WINCODEC_SDK_VERSION = 0x0236; ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "WICCreateImagingFactory_Proxy")] internal static extern int CreateImagingFactory( UInt32 SDKVersion, out IntPtr ppICodecFactory ); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "WICConvertBitmapSource")] internal static extern int /* HRESULT */ WICConvertBitmapSource( ref Guid dstPixelFormatGuid, SafeMILHandle /* IWICBitmapSource */ pISrc, out BitmapSourceSafeMILHandle /* IWICBitmapSource* */ ppIDst); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "WICSetEncoderFormat_Proxy")] internal static extern int /* HRESULT */ WICSetEncoderFormat( SafeMILHandle /* IWICBitmapSource */ pSourceIn, SafeMILHandle /* IMILPalette */ pIPalette, SafeMILHandle /* IWICBitmapFrameEncode* */ pIFrameEncode, out SafeMILHandle /* IWICBitmapSource** */ ppSourceOut); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "WICMapGuidToShortName")]//CASRemoval: internal static extern int /* HRESULT */ WICMapGuidToShortName( ref Guid guid, uint cchName, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzName, ref uint pcchActual); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.WindowsCodecs, EntryPoint = "WICMapShortNameToGuid")]//CASRemoval: internal static extern int /* HRESULT */ WICMapShortNameToGuid( [Out, MarshalAs(UnmanagedType.LPWStr)] String wzName, ref Guid guid); [DllImport(DllImport.WindowsCodecsExt, EntryPoint = "WICCreateColorTransform_Proxy")] internal static extern int /* HRESULT */ CreateColorTransform( out BitmapSourceSafeMILHandle /* IWICColorTransform */ ppWICColorTransform); [DllImport(DllImport.WindowsCodecs, EntryPoint = "WICCreateColorContext_Proxy")] internal static extern int /* HRESULT */ CreateColorContext( IntPtr pICodecFactory, out System.Windows.Media.SafeMILHandle /* IWICColorContext */ ppColorContext); [DllImport(DllImport.WindowsCodecs, EntryPoint = "IWICColorContext_InitializeFromMemory_Proxy")] internal static extern int /* HRESULT */ ColorContext_InitializeFromMemory( SafeMILHandle THIS_PTR, IntPtr pvParameters, uint parameterSize); [DllImport("ole32.dll")] internal static extern int /* HRESULT */ CoInitialize( IntPtr reserved); [DllImport("ole32.dll")] internal static extern void CoUninitialize(); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class Mscms { [DllImport(DllImport.Mscms, EntryPoint = "CreateMultiProfileTransform")] internal static extern ColorTransformHandle /* HTRANSFORM */ CreateMultiProfileTransform(IntPtr[] /* PHPROFILE */ pahProfiles, UInt32 nProfiles, UInt32[] padwIntent, UInt32 nIntents, UInt32 dwFlags, UInt32 indexPreferredCMM); [DllImport(DllImport.Mscms, EntryPoint = "DeleteColorTransform")] internal static extern bool DeleteColorTransform(IntPtr /* HTRANSFORM */ hColorTransform); [DllImport(DllImport.Mscms, EntryPoint = "TranslateColors")] internal static extern int /* HRESULT */ TranslateColors(ColorTransformHandle /* HTRANSFORM */ hColorTransform, IntPtr paInputColors, UInt32 nColors, UInt32 ctInput, IntPtr paOutputColors, UInt32 ctOutput); [DllImport(DllImport.Mscms, EntryPoint = "OpenColorProfile")] internal static extern SafeProfileHandle /* HANDLE */ OpenColorProfile(IntPtr /* PPROFILE */ pProfile, UInt32 dwDesiredAccess, UInt32 dwShareMode, UInt32 dwCreationMode); [DllImport(DllImport.Mscms, EntryPoint = "CloseColorProfile")] internal static extern bool CloseColorProfile(IntPtr /* HANDLE */ phProfile); [DllImport(DllImport.Mscms, EntryPoint = "GetColorProfileHeader")] internal static extern int /* HRESULT */ GetColorProfileHeader(SafeProfileHandle /* HANDLE */ phProfile, IntPtr pHeader); [DllImport(DllImport.Mscms, CharSet = CharSet.Auto, BestFitMapping = false)] internal static extern int /* HRESULT */ GetColorDirectory(IntPtr pMachineName, StringBuilder pBuffer, out uint pdwSize); [DllImport(DllImport.Mscms, CharSet = CharSet.Auto, BestFitMapping = false)] internal static extern int /* HRESULT */ GetStandardColorSpaceProfile(IntPtr pMachineName, uint dwProfileID, StringBuilder pProfileName, out uint pdwSize); [DllImport(DllImport.Mscms, EntryPoint = "GetColorProfileFromHandle")] internal static extern int /* HRESULT */ GetColorProfileFromHandle(SafeProfileHandle /* HANDLE */ hProfile, IntPtr pBuffer, IntPtr pdwSize); } ////// Critical as this code performs an elevation. /// [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class MILFactory2 { [DllImport(DllImport.MilCore, EntryPoint = "MILCreateFactory")] internal static extern int CreateFactory( out IntPtr ppIFactory, UInt32 SDKVersion ); [DllImport(DllImport.MilCore, EntryPoint = "MILFactoryCreateMediaPlayer")] internal static extern int /*HRESULT*/ CreateMediaPlayer( IntPtr THIS_PTR, SafeMILHandle /* CEventProxy */ pEventProxy, bool canOpenAllMedia, Guid deviceId, out SafeMediaHandle /* IMILMedia */ ppMedia); ////// Critical as this code performs an elevation. /// [DllImport(DllImport.MilCore, EntryPoint = "MILFactoryCreateBitmapRenderTarget")] internal static extern int /* HRESULT */ CreateBitmapRenderTarget( IntPtr THIS_PTR, UInt32 width, UInt32 height, PixelFormatEnum pixelFormatEnum, float dpiX, float dpiY, MILRTInitializationFlags dwFlags, out SafeMILHandle /* IMILRenderTargetBitmap */ ppIRenderTargetBitmap); [DllImport(DllImport.MilCore, EntryPoint = "MILFactoryCreateSWRenderTargetForBitmap")] internal static extern int /* HRESULT */ CreateBitmapRenderTargetForBitmap( IntPtr THIS_PTR, IntPtr /* IMILBitmap */ pIBitmap, out SafeMILHandle /* IMILRenderTargetBitmap */ ppIRenderTargetBitmap); } internal static class MILFactoryEffects { [DllImport(DllImport.MilCore, EntryPoint = "MILFactoryCreateBitmapEffect")] internal static extern int /* HRESULT */ CreateBitmapEffect( IntPtr THIS_PTR, ref Guid /*GUID*/ effectGUID, out SafeMILHandle /* IMILBitmapEffectPrimitive */ ppEffect); [DllImport(DllImport.MilCore, EntryPoint = "MILFactoryCreateBitmapEffectContext")] internal static extern int /* HRESULT */ CreateBitmapEffectContext( IntPtr THIS_PTR, out SafeMILHandle /* IMILBitmapEffectRenderContext */ ppContext); [DllImport(DllImport.MilCore, EntryPoint = "MILCreateBitmapEffectOuterPublic")] internal static extern int /* HRESULT */ CreateBitmapEffectOuter(out SafeMILHandle/* IMILBitmapEffect */ ppEffect); [DllImport(DllImport.MilCore, EntryPoint = "MILInitializeBitmapEffectPublic")] internal static extern int /* HRESULT */ InitializeBitmapEffect(SafeHandle /*IMILBitmapEffect */ pOuter, SafeHandle/* IMILBitmapEffectPrimitice */ pInner); } [SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity] internal static class InteropDeviceBitmap { internal delegate void FrontBufferAvailableCallback(bool lost, uint version); [DllImport(DllImport.MilCore, EntryPoint = "InteropDeviceBitmap_Create")] internal static extern int Create( ref Guid deviceId, IntPtr d3dResource, double dpiX, double dpiY, uint version, FrontBufferAvailableCallback pfnCallback, out SafeMILHandle ppInteropDeviceBitmap, out uint pixelWidth, out uint pixelHeight ); [DllImport(DllImport.MilCore, EntryPoint = "InteropDeviceBitmap_Detach")] internal static extern void Detach( SafeMILHandle pInteropDeviceBitmap ); [DllImport(DllImport.MilCore, EntryPoint = "InteropDeviceBitmap_AddDirtyRect")] internal static extern int AddDirtyRect( int x, int y, int w, int h, SafeMILHandle pInteropDeviceBitmap ); [DllImport(DllImport.MilCore, EntryPoint = "InteropDeviceBitmap_GetAsSoftwareBitmap")] internal static extern int GetAsSoftwareBitmap(SafeMILHandle pInteropDeviceBitmap, out BitmapSourceSafeMILHandle pIMILBitmapSource); } } } // 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
- SqlMethodTransformer.cs
- CryptoProvider.cs
- ChangeBlockUndoRecord.cs
- processwaithandle.cs
- dataSvcMapFileLoader.cs
- HttpCacheVary.cs
- View.cs
- DbConnectionStringCommon.cs
- GenericTypeParameterConverter.cs
- VectorAnimation.cs
- ProcessStartInfo.cs
- WebHeaderCollection.cs
- DataGridViewCellStyleBuilderDialog.cs
- InfoCardRSACryptoProvider.cs
- JapaneseLunisolarCalendar.cs
- UserThread.cs
- XmlAttributeAttribute.cs
- ContextInformation.cs
- HttpCapabilitiesBase.cs
- FindCriteriaCD1.cs
- DesignerActionTextItem.cs
- SequenceRangeCollection.cs
- VirtualPathProvider.cs
- DispatcherProcessingDisabled.cs
- SequentialUshortCollection.cs
- ScalarType.cs
- ObjectToken.cs
- DataBoundControlAdapter.cs
- ZoomingMessageFilter.cs
- HyperLinkField.cs
- DateTimeSerializationSection.cs
- EmptyControlCollection.cs
- PkcsMisc.cs
- FormViewDeletedEventArgs.cs
- CollectionView.cs
- ViewGenerator.cs
- SmiXetterAccessMap.cs
- SoapObjectWriter.cs
- GradientStop.cs
- sqlser.cs
- Literal.cs
- HtmlWindow.cs
- InheritedPropertyChangedEventArgs.cs
- WebPartVerbCollection.cs
- XmlDocumentFragment.cs
- AssemblyNameUtility.cs
- AnimationClock.cs
- DesignerActionPropertyItem.cs
- XXXOnTypeBuilderInstantiation.cs
- Menu.cs
- ContentPropertyAttribute.cs
- FontFamilyValueSerializer.cs
- FieldToken.cs
- MouseDevice.cs
- AnnotationResource.cs
- SapiRecognizer.cs
- DesignTableCollection.cs
- ToolStripMenuItem.cs
- GenericsInstances.cs
- ExpressionEvaluator.cs
- IdentityNotMappedException.cs
- WebBrowserUriTypeConverter.cs
- ClipboardProcessor.cs
- GlobalDataBindingHandler.cs
- StaticExtension.cs
- XmlAutoDetectWriter.cs
- CodeAccessPermission.cs
- ConfigurationSettings.cs
- sqlcontext.cs
- RegexBoyerMoore.cs
- GeneralTransform3DTo2DTo3D.cs
- WebPartZoneBase.cs
- MouseBinding.cs
- ProcessProtocolHandler.cs
- ConnectionConsumerAttribute.cs
- FieldAccessException.cs
- TableProviderWrapper.cs
- CodeComment.cs
- HtmlImage.cs
- SqlRetyper.cs
- Crypto.cs
- VersionUtil.cs
- MessagePropertyDescription.cs
- WindowsListViewSubItem.cs
- unitconverter.cs
- ToolStripSeparatorRenderEventArgs.cs
- XhtmlBasicPageAdapter.cs
- TaskForm.cs
- BitmapFrame.cs
- _CookieModule.cs
- ConstraintManager.cs
- Walker.cs
- MatrixStack.cs
- ContainerControl.cs
- MessageHeaders.cs
- BaseDataList.cs
- MarkedHighlightComponent.cs
- ProvidePropertyAttribute.cs
- DesignerContextDescriptor.cs
- Translator.cs