Jump to content
  • Advertisement
Sign in to follow this  
rokam

[DirectX] Hooked application image capture

This topic is 2553 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I'm trying to capture a snapshot of a game. But when anti-aliasing is enabled I do only get the Desktop.
Here is my present hook.

HRESULT __stdcall PresentHook(IDirect3DDevice9* device, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion)
{
WriteHook(add_Present, backup_Present);

HRESULT hresult = S_OK;
__asm {
PUSH pDirtyRegion
PUSH hDestWindowOverride
PUSH pDestRect
PUSH pSourceRect
PUSH device

CALL add_Present
MOV hresult, EAX
}
WriteHook(add_Present, patch_Present);

if(captura)
{
LPDIRECT3DSURFACE9 FrontBuff;
LPDIRECT3DSURFACE9 DataBuff;
D3DSURFACE_DESC SurfaceDesc;
D3DDISPLAYMODE DisplayMode;
D3DLOCKED_RECT Rect;

device->GetDisplayMode(D3DADAPTER_DEFAULT, &DisplayMode);

//device->CreateOffscreenPlainSurface(DisplayMode.Width, DisplayMode.Height, D3DFMT_R8G8B8, D3DPOOL_SYSTEMMEM, &DataBuff, NULL);
device->CreateOffscreenPlainSurface(DisplayMode.Width, DisplayMode.Height, D3DFMT_R8G8B8, D3DPOOL_SYSTEMMEM, &FrontBuff, NULL);
//device->GetRenderTarget(0, &FrontBuff);
//device->StretchRect(FrontBuff, NULL, DataBuff, NULL, D3DTEXF_NONE);
device->GetFrontBufferData(D3DADAPTER_DEFAULT, FrontBuff);

FrontBuff->GetDesc(&SurfaceDesc);
//DataBuff->GetDesc(&SurfaceDesc);

FrontBuff->LockRect(&Rect,0,D3DLOCK_READONLY);
//DataBuff->LockRect(&Rect,0,D3DLOCK_READONLY);

imageBitmap = CreateBitmapFromPixels(NULL, DisplayMode.Width, DisplayMode.Height, 8, Rect.pBits);

FrontBuff->UnlockRect();
FrontBuff->Release();
captura = false;
}

return hresult;
}

Thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!