i need to block any screen capture software on the computer from taking screen shots. Since all of them are work on standard API-functions, i think i could monitor and block them. I need to use C#. All i have found is how to monitor and block them in a certain program (screen capture program). They are looking for a function in the program, then they change it address on mine function address. But how can i do it, if i haven't any certain programs? I need to block anyone which tries to take a screenshot.
-
have you thought of capturing the key press event instead ? – Sebastien H. Feb 27 '14 at 15:05
-
1Out of interest, why do they want to do that? As for hooking how would you reliably discriminate legitimate OS service calls to say bitblt (or any other entry points in to the process of taking a screen capture) from calls made by some unknown, arbitrary 3rd party application? Related; http://stackoverflow.com/questions/455623/how-can-i-prevent-users-from-taking-screenshots-of-my-application-window – Alex K. Feb 27 '14 at 15:21
-
@AlexK. - great link about this being a losing battle against any user with a little bit of skill (or just an actual camera)! – EkoostikMartin Feb 27 '14 at 15:30
-
I need it beacuse im writting a viewer for electronical library, people shouldnt be able to copy books. Why would any system processes would call screenshot function? – StewKlimp Feb 27 '14 at 15:31
-
What screenshot function? One way is getwindowdc() then bitblt() you would find these basic graphics calls used all over the place – Alex K. Feb 27 '14 at 15:36
-
1You are worried about people coping entire books using screenshots? That would be quite a feat! I expected you to be protecting highly private, "classified" or dangerous materials. – EkoostikMartin Feb 27 '14 at 16:13
-
Well, it should be done for copyright protecting. – StewKlimp Mar 02 '14 at 19:43
-
You cannot prevent somebody from using a digital camera, but you can [ask DWM to protect the contents of a particular window from normal efforts at taking a screen shot](http://blogs.msdn.com/b/oldnewthing/archive/2013/06/03/10422964.aspx) – Raymond Chen Mar 04 '14 at 18:49
3 Answers
If your final goal is possible or not I don't know, but for the hooking the API portion I can help you out.
I have used the library EasyHook many times in the past, this will let you hook and intercept system function calls from C# code fairly easily. Just read through the PDF tutorial for setup instructions.
For actually finding the API's I recommend Rohitab's API Monitor, it's still in Alpha stages but it works really well and is free. You just hook it on to a processes and it tells you every external DLL call it makes (with the parameters it passed if you have the xml definition file for the DLL, the program comes with almost all of the windows API dll's pre-defined).
The combination of EasyHook and API Monitor is a great 1-2 punch for mucking with other program's calls.

- 124,994
- 33
- 282
- 431
-
1does EasyHook work with Windows 8? Specifically in metro-style apps? I looked through the docs and couldn't find. – EkoostikMartin Feb 27 '14 at 15:13
-
1@EkoostikMartin I don't know, I can say it is likely that the hooking application must be a non-metro app, but I don't see any reason a non-metro app would not not be able to hook a metro style app. You may need to use the beta version, looking at the changelog they did make some Windows 8 x64 specific fixes recently. (See [change log](http://easyhook.codeplex.com/releases/view/85599) at the bottom.) – Scott Chamberlain Feb 27 '14 at 15:15
As Scott just posted it likely can be prevented with API hooks to see that paint events only go to desktop bound handles and not others, and refuse to paint otherwise. However, you need to consider the following scenarios and see if they're relevant threat to your approach or not:
Your software may be running in a virtual machine like VMWare. Such software has capapbilities to capture screen that does so at "virtual hardware" level, and your API hooks will not be able to discern it - and this would be the easiest way approach if I wanted to bypass your protections.
As a post suggests here, nothing also prevents someone to take monitor cable and plug it into another computer's capture card, and take screenshot that way. Again, your hooks will be helpless here.
Bottom line, you can make it somewhat harder to do, but bypassing such protection may be pretty trivial thing to do.
- My 2c.

- 4,802
- 19
- 35
It is not possible to prevent screenshots from being taken. The battle is already lost because of the DWM (Desktop Window Manager). It's lower level than Win32 and device contexts.
If you want to protect the text in your program, there are a lot easier ways to extract it than doing screenshots and OCR. TextOut and/or Direct2D hooking and accessibility APIs.
If there's a lot of IP in your program. Then don't make it all available onscreen. Make sure it's tedious to crawl the GUI for text, and hard to automate it. And don't load whole texts in memory of the program.
Possible solutions: 1. To prevent copying of text. Draw the text as an image. 2. To prevent accessibility technologies, like screen readers - override WndProc in your control, handle and ignore the window message WM_GETOBJECT. 3. To make it harder if they try to use OCR. Draw graphics behind the text. Human readable, but much harder for a machine to interpret it.
Neither of these methods are invasive for the user.
** A very invasive suggestion **: If you are really serious about preventing anyone from "stealing" your content.
- Implement mouse and keyboard hooks. Filter out typical copy shortcuts. Prevent the mouse from leaving the boundaries of your application.
- Allow your application to only run when the OS runs well-known processes and services. If any process starts which you don't recognize, black out the application and notify the user about it, and request the user to close it. And ofc make sure someone is not just spoofing a well-known process.
- Monitor the clipboard as you suggested yourself.
You can ofc soften some of these suggestions based on the context of your application.

- 814
- 4
- 9
-
Thank you. You said a lot of IP im teh porgramm. What the IP mean? Maybe I can block the clipboard in some way, because all the screenshot programs are probably use it? I realize that i can't completely prevent it, but i have to make at least low security. – StewKlimp Mar 04 '14 at 18:22
-
I can just draw the window in black each time it losts focus and protect PrintScreen button when the window is active. But that would be unconfortable for users. – StewKlimp Mar 04 '14 at 18:26
-
@user2976256 You can´t really do anything to prevent screenshots, ever. There is nothing stopping another program from capturing your window, even when only your window has focus. It's as simple as getting the device context, and bit blit the contents. I'd go for the most common method available, even used online. *Human readable, but hard for machines*. Something like capcha. http://en.wikipedia.org/wiki/Capcha – JonPall Mar 04 '14 at 18:52
-
Thanks! Im already show the document as an images. Woldn`t it be a solution if I monitor the clipboard and clear it each time I find bitmap in there? In addition I may draw user id behind the text, so I could know who steal it. And, plus, still black rectangle when the focus losts. And your second solution against screen readers. Wouldnt it be at least medial security? – StewKlimp Mar 06 '14 at 14:27
-
@user2976256 How would you know someone wanted to make a screenshot of your application? Pressing PrintScreen is for desktop use. The only sure case of someone trying to take a screenshot of your application is if the pressed ALT+PrintScreen when your program was in focus. But accusing them of stealing? That's plain wrong. It is easy to make a program which can dump images from your application when your application has focus. Which also does not require any keypresses or intermediate storage on the clipboard. – JonPall Mar 06 '14 at 19:54
-
@user2976256 WM_GETOBJECT is required for MSAA / IAccessible to work. So no screen reader would be able to request information from your application if you filtered it out. By default, WndProc will handle it properly, and expose information about your application for all standard controls, and subclasses of them. – JonPall Mar 06 '14 at 20:16
-
Then, as Raymond Chen said, I can use DWM for my purpose. Use SetWindowDisplayAffinity function, which each attempting to capture the program in a screenshot or via the Snipping Tool will result in black pixels. Since there aren`t any better ways, I should hope noone knows how to disable DWM :) – StewKlimp Mar 06 '14 at 20:36
-
If I disable ScreenReader, I still can`t disable Screen capture programs. – StewKlimp Mar 06 '14 at 20:40
-
@user2976256 Actually, SetWindowDisplayAffinity is quite promising. Only DLL injection and sadly disabling "Aero" would defeat it :P 'net stop uxsms' disables DWM. – JonPall Mar 06 '14 at 21:01
-
@StewKlimp Correct. Disabling screen readers through WM_GETOBJECT, is only specific for accessibility tech. – JonPall Mar 06 '14 at 21:03