可以“ addinProcess.exe停止工作”被抑制?

发布于 2024-12-05 07:12:37 字数 842 浏览 0 评论 0原文

我试图通过在自己的进程中启动的 MAF 插件中执行它来沙箱潜在的恶意代码:

    var x = token.Activate<Ix>(new AddInProcess(), AddInSecurityLevel.Internet);

这似乎工作得很好,除了在处理 StackOverflowException 时显示一个对话框:“AddInProcess.exe 已停止工作”。这使得测试变得非常困难,

    [TestMethod]
    public void TestStackOverflow() {
        var host = new Host(Environment.CurrentDirectory
            + "/../../../build/pipeline");
        host.Run("foo");
        host.Tick();
        Thread.Sleep(1000);
        host.Monitors.Count.Should().Be(0);
        host.Shutdown();
    }

如果我在睡眠到期之前单击“关闭”按钮,则测试成功,否则失败。这表明在按下“关闭”按钮之前该进程不会退出。鉴于我期望进程终止,如何确保它在不引发此对话框的情况下终止?我尝试将操作系统设置为“从不检查解决方案”,但对话框仍然出现。将其设置为“自动检查解决方案”可以避免出现对话框,但最多需要十秒钟,这是不希望的......我宁愿避免操作系统设置。

AddInProcess.exe 已停止工作

I am attempting to sandbox potentially malicious code by executing it within a MAF plugin launched in its own process:

    var x = token.Activate<Ix>(new AddInProcess(), AddInSecurityLevel.Internet);

This seems to work well except that when handling a StackOverflowException a dialog is shown: "AddInProcess.exe has stopped working". This makes it very hard to test

    [TestMethod]
    public void TestStackOverflow() {
        var host = new Host(Environment.CurrentDirectory
            + "/../../../build/pipeline");
        host.Run("foo");
        host.Tick();
        Thread.Sleep(1000);
        host.Monitors.Count.Should().Be(0);
        host.Shutdown();
    }

If I click the "close" button before the Sleep expires, the test succeeds, otherwise it fails. This indicates that the process does not exit until the "close" button is pressed. Given I am expecting the process to terminate, how can I make sure it does so without raising this dialog? I have tried setting my OS to "never check for solutions" but the dialog still comes up. Setting it to "automatically check for solutions" avoids the dialog but takes up to ten seconds which is not desirable... and I would rather avoid an OS setting.

AddInProcess.exe has stopped working

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瞎闹 2024-12-12 07:12:37

您可以调用 seterrormode 类似的addin过程:

    [Flags]
    enum ErrorModes : uint {
        SYSTEM_DEFAULT = 0x0,
        SEM_FAILCRITICALERRORS = 0x0001,
        SEM_NOALIGNMENTFAULTEXCEPT = 0x0004,
        SEM_NOGPFAULTERRORBOX = 0x0002,
        SEM_NOOPENFILEERRORBOX = 0x8000
    }

    [DllImport( "kernel32.dll" )]
    static extern ErrorModes SetErrorMode( ErrorModes uMode );

    var em = SetErrorMode( 0 );
    SetErrorMode( em | ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOOPENFILEERRORBOX );

You can call SetErrorMode somewhere inside the addin process like so:

    [Flags]
    enum ErrorModes : uint {
        SYSTEM_DEFAULT = 0x0,
        SEM_FAILCRITICALERRORS = 0x0001,
        SEM_NOALIGNMENTFAULTEXCEPT = 0x0004,
        SEM_NOGPFAULTERRORBOX = 0x0002,
        SEM_NOOPENFILEERRORBOX = 0x8000
    }

    [DllImport( "kernel32.dll" )]
    static extern ErrorModes SetErrorMode( ErrorModes uMode );

    var em = SetErrorMode( 0 );
    SetErrorMode( em | ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOOPENFILEERRORBOX );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文