Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Office 2013 implement black windows for IRM?

I noticed that when I press PrntScrn while an IRM-protected email is open in Outlook 2013, the email's window is replaced with a solid black rectangle when I paste the screenshot into mspaint.

I'm not aware of any "Screenshot" window message being sent to windows, so how is this feature implemented? I never see any black pixels on my monitors so I don't think it has a keyboard hook to listen for PrntScrn and then paints the window black.

like image 448
Dai Avatar asked Jan 12 '23 09:01

Dai


1 Answers

Using the WinAPI function SetWindowDisplayAffinity with the WDA_MONITOR affinity before showing the window.

SetWindowDisplayAffinity(hwnd, WDA_MONITOR);  // Should, of course, check return value
ShowWindow(hwnd, SW_NORMAL);

Note this only works in Windows 7 and higher, only for a certain set of "public operating system features and APIs", and only when the window is DWM-composited. See the two paragraphs in the Remarks section of the linked documentation.

like image 100
Ken White Avatar answered Jan 28 '23 22:01

Ken White