Thread: Read Graphic Card Output

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    21

    Read Graphic Card Output

    I hope im in the right section so if not please can a mod move this

    So now to my "prob."

    I was playing CoD and again was frustrated about all the cheater ingame. So i thought about "how would i prevent ppl from cheating in my game" and came up with the idea to check the useres screen at a specific point. If e.g. a wallhack is applyed the shown image should differ from the original. anyway i dont wanna discuss anti-cheat techniques but want to know, how (can i at all?) directly access the graphic card output with c++ under MS windows?

    since im a newby at graphic programming (had some tries with OpenGL) i guess you have to read some sort of buffer that is send to the monitor via the port (dvi, vga, what ever).
    I hope any1 of you can enlight me here a bit (or more )

    thanks in advance

    ghost

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Believe me, it would be a LOT easier to find a game that's not overrun by lamearsed wimps who's only way to get along in life is to cheat (lie, steal, etc.)

  3. #3
    Registered User
    Join Date
    Dec 2010
    Posts
    21
    the game (or others) are not the reason but the trigger for my research. im just curious "how to"

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    If it's on a different computer there's not much chance of doing it in any effective way... It would require planting code in the other machine to send the information to you... At best you might get a screen snapshot (a still picture) but the code to do this would be extremely invasive of the other system and would certainly qualify as a virus.

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Quote Originally Posted by ghostcoder View Post
    the game (or others) are not the reason but the trigger for my research. im just curious "how to"
    This is known as a RAT (remote access tool), I used to build them into my apps for ease of support.

    Look here for code on capturing bitmaps / screens (I have posted this code before). It will show you how to get the current image on the sceen and convert it to a bitmap.

    Then you only have the problem of getting that code to run on the other machine, connect and send the bitmap to your machine and display the bitmap (which is against the rules on this site).
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  6. #6
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    Bear in mind that direct access to the hardware framebuffer is restricted. You can copy back into system memory to do your comparison but this will affect the FPS. If your game is a strategy game then you might be able to get away with it.

  7. #7
    Registered User
    Join Date
    Dec 2010
    Posts
    21
    thank you all for your responds. as i said im not about to build a anti-cheat engine and i dont want to code some sort of virus or trojan. ill check forum and inet for this screenshot code and for more tuts on framebuffer reading.

    ot. the idea to use this as an anti-cheat was to build a hash of the image and compare it with the original .. on a Full HD resolution thats about 6mb to transform into a hash value which shouldnt kill a standart system.

  8. #8
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Quote Originally Posted by ghostcoder View Post
    on a Full HD resolution thats about 6mb to transform into a hash value which shouldnt kill a standart system.
    Think again!
    Devoted my life to programming...

  9. #9
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    There are ways to gain access to the framebuffer via Direct3D and OGL. It is also possible to gain access to this buffer from another process but it is not something we normally discuss in this forum. Screenshots are fairly harmless but if you force another computer to take screenshots keep in mind you will probably cause more problems in the game due to lag than solving any cheating issues. My recommendation is let PunkBuster or the mods handle the cheaters and/or move on to a game with less cheating.

  10. #10
    Registered User
    Join Date
    Dec 2010
    Posts
    21
    @Sipher:
    1920x1080 is about 2million, since each pixel consits of 3 colors u have 3 byte per pixel which is about 6mb in total. a normal graphic card has transfer rates of like several gb per second same with RAM. now most of current games dont make use of multi core systems and even if so, as long you dont use an extravagant hash function you dont stress cpu too much. besides you can still use several small areas of the screen instead of the full.
    if the cpu power doesnt is enougth there is still the possibility to use the graphic card itself with its billions of fpo. would probably cost 1 or 2 frames.

    or do i miss something?

    @bubba
    thank you for ur rating. but again. this is not a project to replace pb or mods but just to learn about the possebilities. i know there is probably a better way to prevent cheating (there are companies for this for some reason aren't they) .
    Last edited by ghostcoder; 02-06-2011 at 11:52 AM.

  11. #11
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Quote Originally Posted by ghostcoder View Post
    a normal graphic card has transfer rates of like several gb per second same with RAM. now most of current games dont make use of multi core systems and even if so, as long you dont use an extravagant hash function you dont stress cpu too much. besides you can still use several small areas of the screen instead of the full.
    if the cpu power doesnt is enougth there is still the possibility to use the graphic card itself with its billions of fpo. would probably cost 1 or 2 frames.
    You can only guess the type of GPU the *other* has, as well as its speed and capabilities.

    Transfer from anything to RAM and vice-versa is time-consuming.

    What small areas of the screen? Take yet another guess?

    EDIT: Make it 8 or 10 frames.
    Devoted my life to programming...

  12. #12
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    learn about the possebilities.
    Unfortunately what you are talking about is usually something we do not discuss on the forums because it involves poking around in the address space of another process. It is possible to execute your code in the address space of another process but you can google that and find a million sites willing to tell you how to do it. If this is an OpenGL app you will need to execute the call to grab the frame buffer in the address space of the game. For Direct3D you will need to execute IDirect3DDevce9::GetBackBuffer() (for DirectX 9.0c) or the equivalent in DirectX 10 (depending on the version the game uses). Once you grab that then you can write the data to a file using D3DXSaveTextureToFile().

    When you have your own Direct3D device this is a very simple process but the hurdle you must overcome is you are trying to get the game to execute your code on a keypress or on a timer event.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. IDE for C embedded advanced editing
    By Undici77 in forum Tech Board
    Replies: 32
    Last Post: 01-16-2010, 05:17 PM
  2. How can I access a struct (from a header file)?
    By loxslay in forum C++ Programming
    Replies: 3
    Last Post: 10-07-2006, 01:25 PM
  3. How to read the execl() output?
    By estratos in forum C Programming
    Replies: 3
    Last Post: 06-07-2006, 12:39 AM
  4. Sorting and help with arrays
    By cproghelp123 in forum C Programming
    Replies: 4
    Last Post: 03-10-2005, 12:24 PM
  5. To all who read last post formatted output
    By spliff in forum C Programming
    Replies: 8
    Last Post: 08-21-2001, 03:37 AM