IDirect3DDevice9::EndScene hook sometimes get NULL in the parameter IDirect3DDevice9
问题 I made a trampoline hook for the function IDirect3DDevice9::EndScene. The codecave I modified the start if the EndScene function to jump to is this: __declspec(naked) HRESULT EndScene_Hook(IDirect3DDevice9* device) { ScreenCapture::Capture(device); __asm { PUSH 0x14 MOV EAX, 0x718E6478 JMP address } } The problem is that sometimes device is NULL, why is that? if I add a small condition like this: if(device != NULL) ScreenCapture::Capture(device); Everything works as intended with no errors.