WPF';s SafeSecurityHelper.ClientToScreen是否防止?

WPF';s SafeSecurityHelper.ClientToScreen是否防止?,wpf,security,controls,Wpf,Security,Controls,我的应用程序需要一个自定义版本的WPFThumb控件(来自System.Windows.Controls.Primitives命名空间)。我发现很难自定义该控件以满足我的特殊需要,因此我正在尝试创建自己的控件,并复制/调整我在类中找到的内容 我看到thumb调用了一个内部函数: 显然,我不能在代码中使用内部类。所以我不得不怀疑,我需要它吗?看看它的来源,我不知道为什么 /// <SecurityNote> /// Critical: This code accesses Pr

我的应用程序需要一个自定义版本的WPF
Thumb
控件(来自
System.Windows.Controls.Primitives
命名空间)。我发现很难自定义该控件以满足我的特殊需要,因此我正在尝试创建自己的控件,并复制/调整我在类中找到的内容

我看到thumb调用了一个内部函数:

显然,我不能在代码中使用内部类。所以我不得不怀疑,我需要它吗?看看它的来源,我不知道为什么

/// <SecurityNote>
///     Critical: This code accesses PresentationSource which is critical but does not
///     expose it.
///     TreatAsSafe: PresentationSource is not exposed and Client to Screen co-ordinates is
///     safe to expose
/// </SecurityNote>
[SecurityCritical,SecurityTreatAsSafe]
internal static Point ClientToScreen(UIElement relativeTo, Point point)
{
    GeneralTransform transform;
    PresentationSource source = PresentationSource.CriticalFromVisual(relativeTo);

    if (source == null)
    {
        return new Point(double.NaN, double.NaN);
    }
    transform = relativeTo.TransformToAncestor(source.RootVisual);
    Point ptRoot;
    transform.TryTransform(point, out ptRoot);
    Point ptClient = PointUtil.RootToClient(ptRoot, source);
    Point ptScreen = PointUtil.ClientToScreen(ptClient, source);

    return ptScreen;
}
//
///Critical:此代码访问PresentationSource,该PresentationSource是关键的,但不是关键的
///暴露它。
///治疗安全:演示源未公开,客户端与屏幕的坐标为
///安全暴露
/// 
[SecurityCritical,SecurityTreatAsSafe]
内部静态点客户端至屏幕(UIElement relativeTo,Point-Point)
{
一般变换;
PresentationSource=PresentationSource.CriticalFromVisual(relativeTo);
if(source==null)
{
返回新点(double.NaN,double.NaN);
}
transform=相对于TransformToAncestor(source.RootVisual);
点根;
transform.tryttransform(point,out-ptRoot);
Point ptClient=PointUtil.RootToClient(ptRoot,源);
点ptScreen=PointUtil.ClientToScreen(ptClient,source);
返回屏幕;
}
显然这里肯定有某种安全问题,但这是什么?我简单地把微软认为有必要保护的常规客户端称为屏幕有什么危险?有人知道吗

/// <SecurityNote>
///     Critical: This code accesses PresentationSource which is critical but does not
///     expose it.
///     TreatAsSafe: PresentationSource is not exposed and Client to Screen co-ordinates is
///     safe to expose
/// </SecurityNote>
[SecurityCritical,SecurityTreatAsSafe]
internal static Point ClientToScreen(UIElement relativeTo, Point point)
{
    GeneralTransform transform;
    PresentationSource source = PresentationSource.CriticalFromVisual(relativeTo);

    if (source == null)
    {
        return new Point(double.NaN, double.NaN);
    }
    transform = relativeTo.TransformToAncestor(source.RootVisual);
    Point ptRoot;
    transform.TryTransform(point, out ptRoot);
    Point ptClient = PointUtil.RootToClient(ptRoot, source);
    Point ptScreen = PointUtil.ClientToScreen(ptClient, source);

    return ptScreen;
}