PrintWindow runs in a standalone application and partially works in the NPAPI plugin

I have code that captures this window with the PrintWindow function. In particular, I am capturing web pages in a browser. This code has been tested in a standalone Windows application and it works fine. The same code is included in the NPAPI plugin and uploaded to Google Chrome. There are problems. If Chrome has only one tab, the code works fine. If Chrome has 2 tabs, the code returns a black box of the expected size. I tested the stand-alone application and the plugin at the same moment, in the same window handle (Chrome_RenderWidgetHostHWND). The application ALWAYS works, the plugin ALWAYS fails if several tabs are open in the browser.

I would really appreciate if someone could tell me how to fix this.

Thanks in advance.

NB. Other window capture methods are not applicable due to even greater flaws for my use.

+1
source share
1 answer

I bet you have a sandbox problem.

Your application most likely runs at a "normal" integrity level, so it has no problem sending the WM_PRINT or WM_PRINTCLIENT to the Chrome process. ( PrintWindow uses these messages under covers.)

When you are a plugin in Chrome, I think your code works as a “low” integrity process (which reduces the chances of things like breaking attacks). Thus, it does not surprise me that sending a message to the window of another process fails.

Unfortunately, this does not explain why this works when Chrome has only one tab. Do you find the same instance of Chrome_RenderWidgetHostHWND both in the application and in the plugin if you open multiple tabs? In general, there is one of these windows per tab. How do you find the window?

0
source

Source: https://habr.com/ru/post/1432910/


All Articles