Vista (ingame) screen capturing.

Hello,

I'm tring to capture a ingame screen shot with my external program.
My program uses the known XP style of capturing:

Code Snippet

Void CaptureScreen()

{

int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);

int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);

HWND hDesktopWnd = GetDesktopWindow();

HDC hDesktopDC = GetDC(hDesktopWnd);

HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);

HBITMAP hCaptureBitmap = CreateCompatibleBitmap(hDesktopDC, nScreenWidth, nScreenHeight);

SelectObject(hCaptureDC, hCaptureBitmap);

BitBlt(hCaptureDC,0,0,nScreenWidth,nScreenHeight,hDesktopDC,0,0,SRCCOPY);

SaveCapturedBitmap(hCaptureBitmap); //Place holder

ReleaseDC(hDesktopWnd,hDesktopDC);

DeleteDC(hCaptureDC);

DeleteObject(hCaptureBitmap);

}


That works fine as long is it XP or a vista desktop capture. The problam starts when in a game (OpenGL and DirectX), that the capture is allways black or on some computers (depending on configuration) and it captures the desktop behind it (with only half the title bar of the game showing in the cornor) . The active window is the game window! so how should I capture it on vista since it looks like the rendering is done somewhere else...

Thanks.

[3224 byte] By [DoublyLinked] at [2008-1-10]
# 1
Here are some other people expirencing the problam:
http://forums.2kgames.com/forums/showthread.php?t=12163
http://www.hyperionics.com/forum/topic.asp?TOPIC_ID=2853, to quote:

From first thread:

"Ok I can take screen shots in xp but in vista if you try the same thing they all come up either black or your desktop.
I push print screen button and then go to paste it in say paint but those are my results thus far is there any way to make a screen shot of in game play?"

From second:

" I've downloaded version 6.13.02 and all I get to capture is the desktop. No matter what game I try to capture screenshots all I get is the desktop. I've read all previous posts related to this issue but none of the suggested solutions works. I'm using Home Vista Premium and a NVIDIA 8800 GTX. Any clue on where the problem might be?

Edit... Downloaded the new NVIDIA drivers 158.18_forceware_winvista_32bit_english_whql
and now the screenshot is black..."

Another guy from second:

" I have the same problem here, I let Hypersnap save the snapshots automatically, and just looked at the ingame-screens I took in the last two days, and they were all black.
I'm using the latest available version (6.13.02) a Nvidia 8800GTX (driver 158.18 (latest atm))
also, not sure if this is an issue too, I have two monitors attached to my system (game running on primary though)"

I wish not to resolve to hooking games in order to get the back buffer since its dirty,
Can you think of another way?

Thanks.

Doublylink22 at 2007-10-3 > top of Msdn Tech,Software Development for Windows Vista,General Windows Vista Development Issues...
# 2

It's a shame that no-one here feels able to reply to your thread, I suppose it's simply because no-one knows the answer.

I'm also experiencing the problem, for the same development reason. I believe part of the issue is that it's now perceived in Vista that an application should not be permitted to screenshot another window, i've seen it described on some threads as a "bug" which is interesting.

http://www.opengl.org/pipeline/article/vol003_7/ is a useful link describing parts of the problem, i.e. operations like BitBlt will not work.

http://blogs.msdn.com/greg_schechter/default.aspx is also v.useful - ive mailed Greg regarding this issue but have yet to receive a response, although he seems best placed from all ive read so far about the issue to comment and potentially guide on it.

FRAPS and other utils manage to do it by hooking, which isnt really an option for anti cheat developers as you know, as they risk their software being seen as a cheat itself.

At this point in time I believe the way forward - although complicated and not for the faint hearted, is to follow people like Punkbuster into the Kernel and ring0, and use some sort of mirror driver - which would also need to be signed in order to work on Vista64.

Microsoft provides a vanilla mirror driver sample to get started with in the Windows DDK, so maybe that will come in useful when you've got nothing left to lose (like me).

Other than that i'm going to keep trying to get some information that allows me to maybe use some sort of memory offset to read the correct hDC, or failing that actually find some documentation on the MSOGL implementation, and the DirectX translation layer itself.

Sorry I wasnt able to answer your question, but I hope you feel a little more informed about whats actually causing the issue, you're definitely not alone either, most of the AC community has this issue atm.

Crispinw at 2007-10-3 > top of Msdn Tech,Software Development for Windows Vista,General Windows Vista Development Issues...

Software Development for Windows Vista

Site Classified