Solved

Prevent a Screen Capture

Posted on 2003-11-04
14
691 Views
Last Modified: 2013-11-20
Hi,

I'm writing an application, and I'm trying to prevent the user to grab a screen capture using the Print Screen button, or a third-party tool.
What is the best way? It doens't has to be full waterproof, just dummyproof.
The more secure, the better.

Can I use MFC with some hooks?

Thanks in advance,
Nicolas
0
Comment
Question by:eXecutiVe
  • 5
  • 5
  • 2
  • +1
14 Comments
 
LVL 12

Expert Comment

by:williamcampbell
ID: 9683573

 Yes you should use SetWindowsHookEx and CallNextHookEx
   
         http://tinyurl.com/tnvm

  You can hook the keyboard and stop ctrl and alt printscreen getting through by not calling the next hook function.
 
  With third party apps is could be difficult because to capture the screen simply requires you to create a compatible bitmap with the desktop an do a bitblt..you could hook into the bitblt API see this article

   http://www.planet-source-code.com/vb/scripts/showcode.asp?txtCodeId=31105&lngWId=1

   or

   http://msdn.microsoft.com/msdnmag/issues/1200/bugslayer/

   You might also want to monitor the clipboard as useually the image is placed there during this operation.

   Let me know which line of attack you'd like to pursue :)
 



0
 

Author Comment

by:eXecutiVe
ID: 9683748
The article of bugslayer points to Smooth Working Set (I don't know what that is).

Can you give me some more information about that hook into bitblt? What exactly should I override or something? I think we're on the right track.

Thanks in advance!
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9684963
Not an answer, but I am curious...
I have racked my brain and can't think of a single reasonable purpose for such a function.  Why do you need it?
-- Dan
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 9685143
http://msdn.microsoft.com/msdnmag/issues/0700/Win32/default.aspx

DisableLowLevelKeys sample disables Alt+Tab, Ctrl+Esc and other key combinations. You can use this sample, jusr change the keys you want to disable in the LowLevelKeyboardProc function.
0
 

Author Comment

by:eXecutiVe
ID: 9685195
To DanRollins:
I have to design such tool for some architects who want to preview images to their customers, but the danger is that the customer doesn't pay the architect, but runs away with the jpeg inside.

(Sorry for my bad english, I'm aware if it hehe)

Is there anybody with some more info on the bitblt hook?

Thanks in advance!
0
 
LVL 12

Expert Comment

by:williamcampbell
ID: 9688589
  If you take a look a HFIBN_Test.cpp in the bugslayer example  

Here are the changes you need to make to the test program for BitBlt

Here is the BitBlt function

BOOL My_NewBitBlt (
  HDC hdcDest, // handle to destination DC
  int nXDest,  // x-coord of destination upper-left corner
  int nYDest,  // y-coord of destination upper-left corner
  int nWidth,  // width of destination rectangle
  int nHeight, // height of destination rectangle
  HDC hdcSrc,  // handle to source DC
  int nXSrc,   // x-coordinate of source upper-left corner
  int nYSrc,   // y-coordinate of source upper-left corner
  DWORD dwRop  // raster operation code
)
{
    // Handle the Call
}


  typedef int (__stdcall *BITBLTPROC)(HDC ,int ,int ,int ,int ,HDC,int ,int ,DWORD) ;

   BITBLTPROC pfnOrigBitBlt = NULL ;
   
   HOOKFUNCDESC stToHook ;

    stToHook.szFunc = "BitBltA" ;  // none unicode version
    stToHook.pProc  = (PROC)My_NewBitBlt;  // this is your new proc for BitBlt

    DWORD uiCount ;

    BOOL bRet =
        HookImportedFunctionsByName ( GetModuleHandle ( NULL ) ,
                                      "GDI32.DLL"             ,
                                      1                        ,
                                      &stToHook                ,
                                      (PROC*)&pfnOrigBitBlt    ,
                                      &uiCount                  ) ;

You will need to use HookImportedFunctionByName.Cpp and BugSlayerUtil.h

Build a sample program first and let us know how it goes
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:eXecutiVe
ID: 9691190
Getting closer...

The hook works now fine (I've tested it with a button that does a BitBlt), but when I use a screen capture program, my hook isn't called. They seem to use another function.

Anybody some ideas?

Thank you very much william campbell

Greetz,
Nicolas
0
 
LVL 12

Expert Comment

by:williamcampbell
ID: 9695534
Do you have access to the Resource Kit for Win2k? There is a program called APIMON.EXE. Perhaps you could use this to find out what API's they are using. There is also StretchBlt!
0
 

Author Comment

by:eXecutiVe
ID: 9697822
I think they do a bitblt from the desktop window and it seems I'm not able to catch that call.
But there must be a way I believe.
Can't I modify the onDraw function? Or clear every 100miliseconds  the clipboard or something?

I'm really desperate
Thank you in advance for your time

Nicolas
0
 
LVL 12

Accepted Solution

by:
williamcampbell earned 500 total points
ID: 9697993

 I think I might have an idea.

 Create an app with the image as part of the resource (in a dll) when the app is launched it goes full screen and displays the image. If the app looses focus close the app immediately (they are trying to get to another app). Or if ctrl or alt are pressed immediately close the app, do this via the keyboard hook. What do you think?

 
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9698063
You *might* find some sort of kludgy workaround, but the only valid solution to this problem is to not send a usable image to somebody who will steal it from you.  

I recommend embedding a "watermark" (say the words "CONFIDENTIAL, Do Not COPY") writen in dim grey text in a diagonal lines all over the "background" of the image.  And obviously, place a bright, clear, copyright notice at several places in the image.

You could also show them an image in which the resolution had been so compormised that the result would provide a reasonable idea of what the final would look like, but still not be usable.  

Another idea is to do what map-makers have done for years... intentionally embed subtle mistakes in the image.  If the image gets passed around, the mistakes act as a signature.  You can sue the person who infringes your copyright and get a nice new home in Beverly Hills, California and never need to work another day in your life.

-- Dan
0
 
LVL 12

Expert Comment

by:williamcampbell
ID: 9698086

 You could also create a screen saver of the image and lock the workstation with a password :) Doesnt prevent them from taking a picture with a digital camera however :p
0
 

Author Comment

by:eXecutiVe
ID: 9698231
Is there a way using directX and overlay or something so the screen can't be captured?

Greetz
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video discusses moving either the default database or any database to a new volume.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now