using ReadPixels_t = void (__thiscall *)( IMatRenderContext *ecx, uintptr_t edx, int x, int y, int w, int h, uint8_t *data, int dst );
//
// hooked func
//
VMTHook render_context_VMT( g_render_context );
void __fastcall ReadPixels( IMatRenderContext *ecx, uintptr_t edx, int x, int y, int w, int h, uint8_t *data, int dst ) {
CViewSetup setup;
// some return inside the rendercapture C++ func
// return will be the next instruction
if( (uintptr_t)_ReturnAddress() == g_rendercapture_ret ) {
// notify client handler
// just to be safe... maybe stop rendering your visuals
g_cheat.screengrab = true;
// clear screen backbuffer
ecx->ClearBuffers( true, true, true );
// render a new frame to the backbuffer
g_chlclient->GetPlayerView( setup );
g_chlclient->RenderView( setup, ( VIEW_CLEAR_COLOR | VIEW_CLEAR_DEPTH ), ( RENDERVIEW_DRAWVIEWMODEL | RENDERVIEW_DRAWHUD ) );
g_cheat.screengrab = false;
}
render_context_VMT.get_old_func< ReadPixels_t >( 11 )( ecx, x, y, w, h, data, dst );
}
render_context_VMT.hook( 11, &ReadPixels );