所以,我一直在尝试使用EndScene钩子检索后备缓冲区数据,事情是因为某些原因我的GetBackBuffer返回了无效结果(我认为),因为当我使用pSurface-> GetDesc()时返回后备缓冲区的宽度为1且高度为1,并且它总是返回填充为0的pBits。
HRESULT WINAPI hkEndScene(LPDIRECT3DDEVICE9 pDevice)
{
IDirect3DSurface9* pSurface = 0;
IDirect3DSurface9* pBBuffer = 0;
D3DLOCKED_RECT Lock;
D3DSURFACE_DESC desc;
if (pDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pSurface) != D3D_OK)
{
logg << "ERROR GetBackBuffer: " << GetLastError() << endl;
return pEndScene(pDevice);
}
pSurface->GetDesc(&desc);
logg << "Size: " << desc.Width << ", " << desc.Height << endl;
HRESULT hRes = pDevice->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pBBuffer, NULL);
if (hRes != D3D_OK)
{
logg << "ERROR CreateOffscreenPlainSurface: " << GetLastError() << endl;
return pEndScene(pDevice);
}
hRes = pDevice->GetRenderTargetData(pSurface, pBBuffer);
if (hRes != D3D_OK)
{
logg << "ERROR GetRenderTargetData: " << GetLastError() << endl;
return pEndScene(pDevice);
}
pBBuffer->LockRect(&Lock, NULL, D3DLOCK_READONLY);
Com.DrawBuffer(Lock.pBits);
logg << Lock.pBits << endl;
//Usual free memory functions
pSurface->Release();
pBBuffer->UnlockRect();
pBBuffer->Release();
return pEndScene(pDevice);
}