From 361a93fd37652d00f072e9395c1aad7ed58ba1a3 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 24 Dec 2021 12:26:34 +0100 Subject: [PATCH] (Windows) Added support for appending strings to the winregistryvalue find rule. --- es-app/src/FileData.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 71f861695..d20b39b17 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -1268,6 +1268,16 @@ const std::string FileData::findEmulatorPath(std::string& command) } for (std::string value : emulatorWinRegistryValues) { + // If the pipe character is found, then the string following this should be appended + // to the key value, assuming the key is found. + std::string appendString; + size_t pipePos = value.find('|'); + + if (pipePos != std::string::npos) { + appendString = value.substr(pipePos + 1, std::string::npos); + value = value.substr(0, pipePos); + } + // Search for the defined value in the Windows Registry. std::string registryValueKey = Utils::String::replace(Utils::FileSystem::getParent(value), "/", "\\"); @@ -1300,6 +1310,14 @@ const std::string FileData::findEmulatorPath(std::string& command) continue; } + if (strlen(path) == 0) { + RegCloseKey(registryKey); + continue; + } + + if (!appendString.empty()) + strncat_s(path, 1024, appendString.c_str(), appendString.length()); + // That a value was found does not guarantee that the emulator binary actually exists, // so check for that as well. if (pathStatus == ERROR_SUCCESS) {