From a7af4d001bc069b3ad3710667358dd2245f15765 Mon Sep 17 00:00:00 2001 From: Zephyron Date: Sun, 16 Feb 2025 11:57:23 +1000 Subject: [PATCH] service/vi: Improve OpenDisplay validation Updates the OpenDisplay function in IApplicationDisplayService to properly validate display names. Instead of only accepting "Default", now validates against all known valid display names: "Default", "External", "Edid", "Internal", and "Null". - Changes log level from WARNING to DEBUG since this is no longer stubbed - Adds proper validation for all valid display names - Returns ResultOperationFailed for invalid display names - Improves logging by including the requested display name --- .../vi/application_display_service.cpp | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/core/hle/service/vi/application_display_service.cpp b/src/core/hle/service/vi/application_display_service.cpp index a3673df14..4fe85d081 100644 --- a/src/core/hle/service/vi/application_display_service.cpp +++ b/src/core/hle/service/vi/application_display_service.cpp @@ -99,11 +99,25 @@ Result IApplicationDisplayService::GetIndirectDisplayTransactionService( } Result IApplicationDisplayService::OpenDisplay(Out out_display_id, DisplayName display_name) { - LOG_WARNING(Service_VI, "(STUBBED) called"); + LOG_DEBUG(Service_VI, "called with display_name={}", display_name.data()); + // Ensure the display name is null-terminated display_name[display_name.size() - 1] = '\0'; - ASSERT_MSG(strcmp(display_name.data(), "Default") == 0, - "Non-default displays aren't supported yet"); + + // According to switchbrew, only "Default", "External", "Edid", "Internal" and "Null" are valid + const std::array valid_names = { + "Default", "External", "Edid", "Internal", "Null" + }; + + bool valid_name = false; + for (const auto& name : valid_names) { + if (name == display_name.data()) { + valid_name = true; + break; + } + } + + R_UNLESS(valid_name, ResultOperationFailed); R_RETURN(m_container->OpenDisplay(out_display_id, display_name)); }