Sign in to follow this  

[DirectX] Hooked application image capture

This topic is 2337 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.
[code]
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;
}
[/code]
Thanks for any help.

Share this post


Link to post
Share on other sites

This topic is 2337 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this