Files
CoopAllTheThings/hook/CMakeLists.txt
BlackMark 679b243974 Audio render-hook M3: wire DLL + host hooked mode + loopback fallback
End-to-end plumbing of the render-hook audio path.

Hook (coop_hook.dll):
- CMake: build audio_hook.cpp, link ole32/mmdevapi, NTDDI_WIN10_CO.
- dllmain: CoInitializeEx(MTA) on the worker thread; install the audio hooks
  even before the ring exists (so streams are counted); open the host's
  coop_audio_<pid> ring when it appears and attach it (enabling capture+silence);
  remove_audio_hooks on clean detach.

Host (coop_host.exe):
- AudioMirror now creates the shared audio ring (owns capture_enabled) and tries
  the Hooked path first: waits ~1s for the hook to publish a format, then
  re-renders the game's frames from the ring with AUTOCONVERTPCM (no echo, since
  the hook silences the game locally).
- Automatic fallback: if the ring can't be created, no format arrives in time,
  or the render client won't initialize, it disables capture (so the game stays
  audible) and reverts to the existing process-loopback path (echo, no regress).
- Exposes Source (Hooked/Loopback/None) for the upcoming panel indicator.

Loopback render loop kept intact as run_loopback. Manual end-to-end (M5) and the
panel UI (M4) are next.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 12:02:29 +02:00

25 lines
759 B
CMake

add_library(coop_hook SHARED
src/dllmain.cpp
src/xinput_hook.cpp
src/focus_spoof.cpp
src/audio_hook.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)
set_target_properties(coop_hook PROPERTIES OUTPUT_NAME "coop_hook")
# 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.