From b48791bffd99f90be0faf2b343bad270af7f5ef5 Mon Sep 17 00:00:00 2001 From: skyhua0224 Date: Mon, 26 Oct 2026 18:55:07 +0000 Subject: [PATCH] fix(modes): cap SETMODES lists at 96 modes A re-created monitor did not come back when SETMODES published more than about 100 modes (98 worked, 105 and 112 failed on a real host). No limit in the driver explains this, so cap what SETMODES stages, keeping the preferred mode and the newest appended entries, and log what is dropped. --- ZakoVDD/Control/CommandHandlers.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ZakoVDD/Control/CommandHandlers.cpp b/ZakoVDD/Control/CommandHandlers.cpp index 4516cb9..4ccba9d 100644 --- a/ZakoVDD/Control/CommandHandlers.cpp +++ b/ZakoVDD/Control/CommandHandlers.cpp @@ -554,6 +554,19 @@ void HandleSetModesCommand(wchar_t *param) return; } + // Windows was observed to drop the re-created monitor when its mode list + // exceeded about 100 entries (98 worked, 105 failed). Keep index 0 (the + // preferred mode) and the newest entries at the end of the list, where + // callers append newly requested sizes. + const size_t kMaxSetModes = 96; + if (parsed.size() > kMaxSetModes) + { + VDD_LOG_WARNING_STREAM("SETMODES: " << parsed.size() << " modes exceed the limit of " << kMaxSetModes + << "; dropping " << (parsed.size() - kMaxSetModes) + << " mode(s) after the preferred mode"); + parsed.erase(parsed.begin() + 1, parsed.end() - static_cast(kMaxSetModes - 1)); + } + // Compare, replace and publish the list atomically with respect to // create/destroy commands. lock_guard lock(g_Mutex);