Clean up a stale Vulkan-layer registration at host startup

register_vk_layer writes an HKCU implicit-layer entry that makes the loader pull
our DLL into every Vulkan app; it's session-scoped (unregistered on clean exit).
If the host crashed or was killed while registered, the entry leaked and kept
loading our DLL into every Vulkan process until the next clean run.

Add cleanup_stale_vk_layer(), called once at the top of run(): since registration
is opt-in per session, anything registered at startup is a crash leftover, so it
removes it (delegates to unregister_vk_layer). No-op when nothing is registered.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-24 02:22:06 +02:00
parent d318ae62a1
commit b96a559500
4 changed files with 18 additions and 4 deletions

View File

@@ -35,6 +35,7 @@
#include "log_panel.hpp"
#include "test_harness.hpp"
#include "ui/app_chrome.hpp"
#include "vk_layer_setup.hpp"
namespace
{
@@ -316,6 +317,10 @@ bool wait_for_hooked_frame(coop::D3D11Window& window, coop::InjectionPanel& inje
int run()
{
// Clear any leftover Vulkan-layer registration from a host that crashed while registered, before
// it can keep loading our DLL into every Vulkan app this session.
coop::cleanup_stale_vk_layer();
coop::D3D11Window window;
if (!window.create(L"CoopAllTheThings"))
{