Log in

View Full Version : Best way to hook PrintScreen under Windows NT/2K


foxthree
May 29th, 2002, 15:49
Hello Fellow RCEs:

I need to hook PrintScreen key under Windows NT/2000 and prvent the user from printing the contents of the screen either to clipboard or printer.

What is the best way to do this?

I know I can set a Windows Message Hook and look at WM_KEY* messages and do appropriately. Will this work on all Win* platforms (incl. Win98. I may need this later )

Grateful to any suggestions,tips,pointers...

Thanks.

Signed,
-- FoxThree

mike
May 29th, 2002, 19:57
You'll need to hook it for the whole system because you can capture the whole screen with alt-prtscn. In order to do that, you need admin privileges I think on NT/2k. It's easier to do on W98.

I know adobe printshop demo captures it at an app level but not a system level.

One place suggested registering prtscn as a hotkey and looking for wm_hotkey messages:
h**p://www.mvps.org/vbnet/index.html?code/subclass/registerhotkey.htm

There are some plugins for browsers that claim to prevent it; artistscope's copysafe is one:
h**p://www.artistscope.net/techniques.htm

You'll want to look for the VK_SNAPSHOT message, I think. You can install just a keyboard hook instead of the all-message hook and it won't slow down your system as much.

Clandestiny
May 29th, 2002, 21:51
Hiya foxthree,

Alternately you could try to hook the INT 5 which is the 'Print Screen' interrupt. This would work on win98, not sure about win2k. No doubt you would have to have admin privaleges to hook interrupts on win2k.

Persuing this line of inquiry in google with 'print screen and INT 5' turns up some good information:

"The BIOS uses INT 5 for this. Fortunately, you don't need to mess withthat interrupt handler. The standard handler, in BIOS versions dated December 1982 or later, uses a byte at 0040:0100 (= 0000:0500) to determine whether a print screen is currently in progress. If it is, pressing PrintScreen again is ignored. So to disable the screen snapshot, all you have to do is write a 1 to that byte. When the user presses PrintScreen, the BIOS will think that a print screen is already in progress and will ignore the user's keypress. You can re-enable PrintScreen by zeroing the same byte."

http://www.faqs.org/faqs/msdos-programmer-faq/part2/section-17.html

Sorry if this doesn't help with the problem in Win2k. Hehe, I'm getting antiquated, but Win98 is still my reversing OS

Cheers,
Clandestiny

The Svin
May 29th, 2002, 22:33
read about SetWindowsHookEx and KeyboardProc

foxthree
May 31st, 2002, 07:03
Fellow RCEs:

Thanks for your inputs. Yes, I've fixed the problem. However, I have one question with hooks:

Suppose say I a program has already hooked the keyboard using KeyBoardProc (system-wide) and then I install my hook also, if the previous proggie fails to call CallNextWindowsHook then I'm left to hang around forever right?

I mean, is there a way where we can specify where in the hookchain we want to hang (either the first or the last)?

Thanks again for all your knowledgeable posts.

Signed,
-- FoxThree

mike
May 31st, 2002, 15:23
As far as I know, it's a stack, so the last one to register the hook gets the messages first.

foxthree
May 31st, 2002, 20:03
Hi Mike:

Thanks once again. I appreciate it

Signed,
-- FoxThree