Link to home
Start Free TrialLog in
Avatar of eXecutiVe
eXecutiVe

asked on

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
Avatar of williamcampbell
williamcampbell
Flag of United States of America image


 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 :)
 



Avatar of eXecutiVe
eXecutiVe

ASKER

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!
Avatar of DanRollins
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
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.
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!
  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
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
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!
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
ASKER CERTIFIED SOLUTION
Avatar of williamcampbell
williamcampbell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

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

Greetz