Files
CoopAllTheThings/hook/CMakeLists.txt
BlackMark 67c1940d52 M2(DX9): D3D9 capture via Present read-back (covers plain D3D9 + D3D9Ex)
New d3d9_hook.cpp (own file like opengl_hook): inline-hooks
IDirect3DDevice9::Present (vtable index 17, discovered from a throwaway device;
clean prologue so inline is safe, stdcall() on x86) and read-backs the backbuffer
with GetRenderTargetData into a D3DPOOL_SYSTEMMEM surface, swizzles BGRA->RGBA,
and uploads it into the shared keyed-mutex texture on a hook-owned D3D11 device
(a D3D9 surface isn't D3D11-shareable). Both plain D3D9 and D3D9Ex call this same
Present, so one read-back path serves both -- the GPU shared-surface fast path
the plan sketched for D3D9Ex wasn't worth it. Wired into the video subsystem
(install/remove in dllmain); hook links d3d9.

mock_game_test decodes DX9 + DX9Ex frames through the hook; 15/15 ctest (incl.
the x86 sub-build). Roadmap: DX9 milestone done and removed (remaining
renumbered); architecture + lessons updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 11:55:06 +02:00

40 lines
1.2 KiB
CMake

add_library(coop_hook SHARED
src/dllmain.cpp
src/xinput_hook.cpp
src/focus_spoof.cpp
src/audio_hook.cpp
src/present_hook.cpp
src/opengl_hook.cpp
src/d3d9_hook.cpp
src/mkb_hook.cpp
src/debug_log.cpp
src/hook_registry.cpp)
target_include_directories(coop_hook PRIVATE src)
# The audio render-hook uses IAudioClient3 / process-audio interfaces, which need
# the Windows 10 20H1 (NTDDI_WIN10_CO) headers.
target_compile_definitions(coop_hook PRIVATE NTDDI_VERSION=0x0A00000B)
target_link_libraries(coop_hook PRIVATE
coop_common
safetyhook::safetyhook
user32
ole32
mmdevapi
d3d11
d3d9
dxgi)
# The x86 sub-build (COOP_X86_HELPER_BUILD) stages alongside the x64 DLL in the
# same bin/<config> dir, so give it a distinct name the host loads for 32-bit games.
if(COOP_X86_HELPER_BUILD)
set_target_properties(coop_hook PROPERTIES OUTPUT_NAME "coop_hook_x86")
else()
set_target_properties(coop_hook PROPERTIES OUTPUT_NAME "coop_hook")
endif()
# TODO(dist): statically link the VC runtime (/MT) so the DLL loads in games on
# machines without the matching VC redist. Deferred until SafetyHook + Zydis are
# also forced to a static CRT to avoid a /MT-vs-/MD mismatch.