Prevent a Screen Capture

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
eXecutiVeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

williamcampbellCommented:

 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
eXecutiVeAuthor Commented:
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
DanRollinsCommented:
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

AlexFMCommented:
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
eXecutiVeAuthor Commented:
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
williamcampbellCommented:
  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
eXecutiVeAuthor Commented:
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
williamcampbellCommented:
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
eXecutiVeAuthor Commented:
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
williamcampbellCommented:

 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DanRollinsCommented:
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
williamcampbellCommented:

 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
eXecutiVeAuthor Commented:
Is there a way using directX and overlay or something so the screen can't be captured?

Greetz
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.