PrintWindow在独立应用程序中工作,并部分在NPAPI插件中工作 [英] PrintWindow works in standalone application and does partially work in NPAPI plugin

查看:198
本文介绍了PrintWindow在独立应用程序中工作,并部分在NPAPI插件中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个代码,它通过PrintWindow函数捕获给定的窗口。具体来说,我在浏览器中捕获网页。此代码在独立的Windows应用程序中进行测试,并且工作正常。相同的代码被纳入NPAPI插件并加载到Google Chrome中。有问题发生。如果Chrome只有一个标签,则代码正常。如果Chrome有2个选项卡,代码将返回预期大小的黑盒子。我在同一个窗口句柄(Chrome_RenderWidgetHostHWND)上同时测试了独立应用程序和插件。应用程序一直工作,如果在浏览器中打开多个选项卡,插件总是失败。



如果有人提供了解决方法,我真的很感激。



预先致谢。

NB。其他捕获窗口的方法不适用,因为我的用例有更大的缺点。

我敢打赌你是运行到沙箱问题。

您的应用程序可能运行在正常完整性级别,因此在发布 WM_PRINT WM_PRINTCLIENT 讯息传送给Chrome进程。 ( PrintWindow 会在封面下使用这些消息。)



当您是Chrome中的插件时,我相信您代码作为低完整性进程运行(这减少了粉碎攻击之类的可能性)。因此,将消息发送到另一个进程中的窗口并不会令我感到意外。



不幸的是,这并不能解释为什么Chrome只有一个标签。在打开多个选项卡的情况下,您是否在应用程序和插件中找到了 Chrome_RenderWidgetHostHWND 的相同实例?一般来说,每个选项卡都有一个这样的窗口。你是如何找到窗户的?


I have a code, which captures a given window by PrintWindow function. Specifically I do capture web-pages in a browser. This code is tested in a standalone Windows application, and it works ok. The same code is incorporated into NPAPI plugin and loaded into Google Chrome. There problems happen. If Chrome has only one tab, the code works OK. If Chrome has 2 tabs, the code returns black box of expected size. I tested the standalone application and the plugin at the same moment, on the same window handle (Chrome_RenderWidgetHostHWND). Application does ALWAYS work, the plugin does ALWAYS fail if multiple tabs are open in the browser.

I'd really appreciate, if someone give a clue how to fix this.

Thanks in advance.

NB. Other methods of capturing windows are inapplicable due to even greater shortcomings for my usecase.

解决方案

I bet you're running into sandboxing issues.

Your app is likely running at the "normal" integrity level, so it has no problem posting the WM_PRINT or WM_PRINTCLIENT message to the Chrome process. (PrintWindow uses these messages under the covers.)

When you're a plugin in Chrome, I believe your code runs as a "low" integrity process (which reduces the chances of things like shatter attacks). Thus it doesn't surprise me that sending the message to a window in another process fails.

Unfortunately, that doesn't explain why it works when Chrome has only one tab. Are you finding the same instance of Chrome_RenderWidgetHostHWND in both the app and the plugin in the case where you have multiple tabs open? In general, there's one of these windows per tab. How are you finding the window?

这篇关于PrintWindow在独立应用程序中工作,并部分在NPAPI插件中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆