Check if a program creates prt scrs

This is a discussion on Check if a program creates prt scrs within the C# Programming forums, part of the General Programming Boards category; Hi! Long time, no see. I wonder how to check if a program creates print screens. The program, which create ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    188

    Check if a program creates prt scrs

    Hi! Long time, no see.

    I wonder how to check if a program creates print screens. The program, which create print screens at random set of time, is needed to play at some servers. So, I want to check if a program creates a print screen in just that second, if now, continue as normal, but if, then I'd like to do 1 thing which is a secret.

    Example:
    Code:
    Time: 12:21:22 Normal
    Time: 12:21:23 Normal
    Time: 12:21:24 Normal
    Time: 12:21:25 Normal
    Time: 12:21:26 A program is trying to create a screenshot. Do blabla();
    Time: 12:21:27 Normal
    Time: 12:21:28 Normal
    Time: 12:21:29 Normal
    I hope you all understand. It was kind of hard to explain since there are no such program right know. If you don't understand, please tell me, otherwise I won't understand that.

    Greetings,
    Fredrik.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    "a program create print screens" does not make sense. Prt Scrn is a key on the keyboard. It causes the screen data to be copied to the clipboard.

    An application can perform a similar operation in several ways, but it is not using "Prt Scrn" to do that.

    So can you please explain what you actually want to know about? When some application copies the entire screen? If so, which of the half a dozen or more variants of doing that would you like to know about? How much driver writing experience do you have [you probably need to write a Display Filter Driver to capture those]? Does it make a difference that you will incur a penalty on any "read from frame buffer to system memory" oeprations?

    Does the application you have in mind run in a window or as a full-screen application, is it using GDI, DirectX, OpenGL API's?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    188
    Thank you for your answer!

    Okey, what i meant with "a program create print screens" was that the program - as you said - copies the entire screen. Is there any way a program can know when the other program takes the capture of the screen? I don't know in what way the program will copy the screen. The program copies the screen from a game called "Counter-Strike" which is usually played with OpenGL and full-screen.

    Is there anything you need to know before you can give me a hint?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Well, to detect that something is copying the screen requires that you intercept the system calls or driver calls that are involved in copying the screen. Since there are at least half a dozen different system calls that can possibly be used for this purpose, it would be much easier to do if you can determine which system call it is that is being used.

    Once you know which system call it is, you will need to "trap" that system call in such a way that you can see that the system call is happening, then inspect the parameters, and determine if it's copying the screen or doing something else that you don't care about. Most of the time, it will probably be the latter. And the chances of crashing the system if you get it wrong is HUGE.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I will assume you are using windows since you are using c#. You can reasonably easily just poll for changes in the clipboard content, check what the content type is, and then do your thing from there--OR what may actually prove more fruitful in actually determining if someone hit Print Screen as opposed to just copying and pasting something from Photoshop would be to implement a system hook that monitors keys and have your program do its thing if Print Screen is pressed. Which should effectively avoid you crashing your computer whilst tinking with system messages and trying to inject information into them (which is generally best avoided anyway).

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by master5001 View Post
    I will assume you are using windows since you are using c#. You can reasonably easily just poll for changes in the clipboard content, check what the content type is, and then do your thing from there--OR what may actually prove more fruitful in actually determining if someone hit Print Screen as opposed to just copying and pasting something from Photoshop would be to implement a system hook that monitors keys and have your program do its thing if Print Screen is pressed. Which should effectively avoid you crashing your computer whilst tinking with system messages and trying to inject information into them (which is generally best avoided anyway).
    But he's actually trying to determine if an application is capturing the screen for it's own purposes, not the actual "PrntScrn" button that copies to the clipboard.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    I'm not sure it would be a wise idea to use C# for this application since you'll be pinvoking a lot of Win32 functions. But anyway, one possible option is to intercept the target app's api to determine whether or not a screen capture has occured. MS has a Detours library that may be of some use to you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 01-09-2009, 08:45 PM
  2. Suggestions for my Check Book program
    By Nor in forum C++ Programming
    Replies: 2
    Last Post: 11-17-2008, 05:44 PM
  3. HELP!!!!emergency ~expert please help
    By unknowppl in forum C Programming
    Replies: 1
    Last Post: 08-19-2008, 07:35 AM
  4. Can someone check my program?
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 10-04-2001, 07:33 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21