M2(Vulkan layer): registry register/unregister + opt-in Injection-panel checkbox

Host helper register_vk_layer/unregister_vk_layer registers coop_vk_layer's
manifest as a per-user (HKCU, no admin) implicit Vulkan layer and writes the
scoping file (%TEMP%\coop_vk_target.txt) naming the target game's exe, so the
layer captures only that game and stays inert for every other Vulkan app. The
Injection panel gains an opt-in "Set up Vulkan layer" checkbox (next to Auto
re-attach, which the too-late banner points at); it registers on tick,
unregisters on untick, and the panel destructor unregisters on host exit so no
stale registration is left behind.

Verified live: a registry-registered layer is loaded by the loader for a fresh
vk launch (no env vars) and the scoping matches (active=1), then cleans up.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-22 13:29:14 +02:00
parent 2532ffed56
commit 23a6408e52
5 changed files with 132 additions and 0 deletions

View File

@@ -1,5 +1,7 @@
#include "injection_panel.hpp"
#include "vk_layer_setup.hpp"
#include <cmath>
#include <windows.h>
@@ -96,6 +98,10 @@ void InjectionPanel::refresh_targets()
InjectionPanel::~InjectionPanel()
{
if (vk_layer_enabled_)
{
unregister_vk_layer(); // don't leave the implicit layer registered after the tool closes
}
close_target_handle();
}
@@ -580,6 +586,27 @@ void InjectionPanel::draw(bool debug_details)
ImGui::SameLine();
ImGui::TextColored(kGrey, "(watching for %s...)", narrow(selected_name_).c_str());
}
// Opt-in Vulkan capture layer: for Vulkan games that initialize Vulkan immediately
// (where even auto-attach injects too late -- see the red banner), register a per-user
// implicit layer scoped to this game so the next launch is captured from the first frame.
// Removed when unticked or the host exits.
if (ImGui::Checkbox("Set up Vulkan layer (for immediate-init Vulkan games)", &vk_layer_enabled_))
{
if (vk_layer_enabled_)
{
vk_layer_enabled_ = register_vk_layer(selected_name_);
}
else
{
unregister_vk_layer();
}
}
if (ImGui::IsItemHovered())
{
ImGui::SetTooltip("Registers a per-user (HKCU, no admin) implicit Vulkan layer scoped to\n"
"this game, so a relaunch is captured before Vulkan init. Pair with\n"
"Auto re-attach. Removed when you untick it or close the tool.");
}
}
ImGui::Separator();
}