From: Liam Middlebrook Subject: [PATCH 5/5] winevulkan: Add executable name Quirk regkey handling Message-Id: <20200914123146.12912-5-lmiddlebrook@nvidia.com> Date: Mon, 14 Sep 2020 05:31:46 -0700 In-Reply-To: <20200914123146.12912-1-lmiddlebrook@nvidia.com> References: <20200914123146.12912-1-lmiddlebrook@nvidia.com> Add support for regkeys to set Quirks bits depending the executable name of the currently running program. Signed-off-by: Liam Middlebrook Signed-off-by: Daniel Koch --- dlls/winevulkan/vulkan.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index e78ca1eda62..a77664a7e5f 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -670,21 +670,51 @@ static LSTATUS wine_vk_open_regkey_with_suffix(HKEY *key, const char *path_prefi return RegOpenKeyA(HKEY_CURRENT_USER, buf, key); } +static uint32_t wine_vk_get_exe_name(char *name, uint32_t length) +{ + char buf[MAX_PATH]; + uint32_t buf_len; + char *p, *exe_path; + + buf_len = GetModuleFileNameA(0, buf, MAX_PATH); + if (!buf_len || buf_len == MAX_PATH) + return 0; + + exe_path = buf; + if ((p = strrchr(exe_path, '/'))) + exe_path = p + 1; + if ((p = strrchr(exe_path, '\\'))) + exe_path = p + 1; + + buf_len = strlen(exe_path) + 1; + if (buf_len > length) + return 0; + + lstrcpynA(name, exe_path, length); + return length; +} + static void wine_vk_process_quirks(const VkApplicationInfo *pApplicationInfo, struct VkInstance_T *object) { + char exe_name[MAX_PATH]; uint8_t validKeysMask = 0; int keyIndex = 0; - HKEY keys[3]; + HKEY keys[4]; int i; memset(&keys, 0, sizeof(keys)); + if (!wine_vk_get_exe_name(exe_name, MAX_PATH)) + exe_name[0] = '\0'; + /* Match regkey settings in the following order, breaking early if settings * are found: * pApplicationInfo->pApplicationName * @@ Wine registry key: HKCU\Software\Wine\Vulkan\pApplicationName\ * pApplicationInfo->pEngineName * @@ Wine registry key: HKCU\Software\Wine\Vulkan\pEngineName\ + * executable name + * @@ Wine registry key: HKCU\Software\Wine\Vulkan\exeName\app.exe * global defaults * @@ Wine registry key: HKCU\Software\Wine\Vulkan */ @@ -692,6 +722,8 @@ static void wine_vk_process_quirks(const VkApplicationInfo *pApplicationInfo, st validKeysMask |= (1 << (keyIndex - 1)); if (wine_vk_open_regkey_with_suffix(keys + keyIndex++, "Software\\Wine\\Vulkan\\pEngineName\\", pApplicationInfo->pEngineName, FALSE) == 0) validKeysMask |= (1 << (keyIndex - 1)); + if (wine_vk_open_regkey_with_suffix(keys + keyIndex++, "Software\\Wine\\Vulkan\\exeName\\", exe_name, FALSE) == 0) + validKeysMask |= (1 << (keyIndex - 1)); if (wine_vk_open_regkey_with_suffix(keys + keyIndex++, "Software\\Wine\\Vulkan", NULL, TRUE) == 0) validKeysMask |= (1 << (keyIndex - 1)); -- 2.17.1