summaryrefslogtreecommitdiff
path: root/loader
diff options
context:
space:
mode:
authorLenny Komow <lenny@lunarg.com>2017-03-01 17:22:29 -0700
committerLenny Komow <lenny@lunarg.com>2017-03-02 11:30:51 -0700
commit1b9da316f15b56b52cdaae0f5056cca0f9de1791 (patch)
tree9410d21612aeade0474a88a80eaf4021f8f2f967 /loader
parent20eb1b803282d8158dab6a1aa583b57b75408089 (diff)
loader: gh1153 - Modify layer search path
The loader will now seach HKEY_CURRENT_USER in addition to HKEY_LOCAL_MACHINE when looking up layers in the registries. Change-Id: I899dc7d65a2fe08f1e471fa8dccba5255f8ef7b7
Diffstat (limited to 'loader')
-rw-r--r--loader/loader.c90
-rw-r--r--loader/vk_loader_platform.h3
2 files changed, 52 insertions, 41 deletions
diff --git a/loader/loader.c b/loader/loader.c
index 4d6d168a..f8d94962 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -379,14 +379,14 @@ static char *loader_get_next_path(char *path);
//
// *reg_data contains a string list of filenames as pointer.
// When done using the returned string list, the caller should free the pointer.
-VkResult loaderGetRegistryFiles(const struct loader_instance *inst, char *location, char **reg_data) {
+VkResult loaderGetRegistryFiles(const struct loader_instance *inst, char *location, bool use_secondary_hive, char **reg_data) {
LONG rtn_value;
- HKEY hive, key;
+ HKEY hive = DEFAULT_VK_REGISTRY_HIVE, key;
DWORD access_flags;
char name[2048];
char *loc = location;
char *next;
- DWORD idx = 0;
+ DWORD idx;
DWORD name_size = sizeof(name);
DWORD value;
DWORD total_size = 4096;
@@ -401,51 +401,59 @@ VkResult loaderGetRegistryFiles(const struct loader_instance *inst, char *locati
while (*loc) {
next = loader_get_next_path(loc);
- hive = DEFAULT_VK_REGISTRY_HIVE;
access_flags = KEY_QUERY_VALUE;
rtn_value = RegOpenKeyEx(hive, loc, 0, access_flags, &key);
- if (ERROR_SUCCESS != rtn_value) {
- // We still couldn't find the key, so give up:
- loc = next;
- continue;
- }
-
- while ((rtn_value = RegEnumValue(key, idx++, name, &name_size, NULL, NULL, (LPBYTE)&value, &value_size)) == ERROR_SUCCESS) {
- if (value_size == sizeof(value) && value == 0) {
- if (NULL == *reg_data) {
- *reg_data = loader_instance_heap_alloc(inst, total_size, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ if (ERROR_SUCCESS == rtn_value) {
+ idx = 0;
+ while ((rtn_value = RegEnumValue(key, idx++, name, &name_size, NULL, NULL, (LPBYTE)&value, &value_size)) ==
+ ERROR_SUCCESS) {
+ if (value_size == sizeof(value) && value == 0) {
if (NULL == *reg_data) {
- loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "loaderGetRegistryFiles: Failed to allocate "
- "space for registry data for key %s",
- name);
- result = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
+ *reg_data = loader_instance_heap_alloc(inst, total_size, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ if (NULL == *reg_data) {
+ loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
+ "loaderGetRegistryFiles: Failed to allocate "
+ "space for registry data for key %s",
+ name);
+ result = VK_ERROR_OUT_OF_HOST_MEMORY;
+ goto out;
+ }
+ *reg_data[0] = '\0';
+ } else if (strlen(*reg_data) + name_size + 1 > total_size) {
+ *reg_data = loader_instance_heap_realloc(inst, *reg_data, total_size, total_size * 2,
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ if (NULL == *reg_data) {
+ loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
+ "loaderGetRegistryFiles: Failed to reallocate "
+ "space for registry value of size %d for key %s",
+ total_size * 2, name);
+ result = VK_ERROR_OUT_OF_HOST_MEMORY;
+ goto out;
+ }
+ total_size *= 2;
}
- *reg_data[0] = '\0';
- } else if (strlen(*reg_data) + name_size + 1 > total_size) {
- *reg_data = loader_instance_heap_realloc(inst, *reg_data, total_size, total_size * 2,
- VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
- if (NULL == *reg_data) {
- loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
- "loaderGetRegistryFiles: Failed to reallocate "
- "space for registry value of size %d for key %s",
- total_size * 2, name);
- result = VK_ERROR_OUT_OF_HOST_MEMORY;
- goto out;
+ loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0,
+ "Located json file \"%s\" from registry \"%s\\%s\"", name,
+ hive == DEFAULT_VK_REGISTRY_HIVE ? DEFAULT_VK_REGISTRY_HIVE_STR : SECONDARY_VK_REGISTRY_HIVE_STR,
+ location);
+ if (strlen(*reg_data) == 0) {
+ (void)snprintf(*reg_data, name_size + 1, "%s", name);
+ } else {
+ (void)snprintf(*reg_data + strlen(*reg_data), name_size + 2, "%c%s", PATH_SEPARATOR, name);
}
- total_size *= 2;
- }
- if (strlen(*reg_data) == 0) {
- (void)snprintf(*reg_data, name_size + 1, "%s", name);
- } else {
- (void)snprintf(*reg_data + strlen(*reg_data), name_size + 2, "%c%s", PATH_SEPARATOR, name);
+ found = true;
}
- found = true;
+ name_size = 2048;
}
- name_size = 2048;
}
- loc = next;
+
+ // Advance the location - if the next location is in the secondary hive, then reset the locations and advance the hive
+ if (use_secondary_hive && (hive == DEFAULT_VK_REGISTRY_HIVE) && (*next == '\0')) {
+ loc = location;
+ hive = SECONDARY_VK_REGISTRY_HIVE;
+ } else {
+ loc = next;
+ }
}
if (!found) {
@@ -2451,7 +2459,7 @@ static VkResult loader_get_manifest_files(const struct loader_instance *inst, co
*loc_write = '\0';
#if defined(_WIN32)
- VkResult reg_result = loaderGetRegistryFiles(inst, loc, &reg);
+ VkResult reg_result = loaderGetRegistryFiles(inst, loc, is_layer, &reg);
if (VK_SUCCESS != reg_result || NULL == reg) {
if (!is_layer) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
diff --git a/loader/vk_loader_platform.h b/loader/vk_loader_platform.h
index 9af64a9e..d93ca589 100644
--- a/loader/vk_loader_platform.h
+++ b/loader/vk_loader_platform.h
@@ -164,6 +164,9 @@ static inline void loader_platform_thread_cond_broadcast(loader_platform_thread_
#define PATH_SEPARATOR ';'
#define DIRECTORY_SYMBOL '\\'
#define DEFAULT_VK_REGISTRY_HIVE HKEY_LOCAL_MACHINE
+#define DEFAULT_VK_REGISTRY_HIVE_STR "HKEY_LOCAL_MACHINE"
+#define SECONDARY_VK_REGISTRY_HIVE HKEY_CURRENT_USER
+#define SECONDARY_VK_REGISTRY_HIVE_STR "HKEY_CURRENT_USER"
#define DEFAULT_VK_DRIVERS_INFO "SOFTWARE\\Khronos\\" API_NAME "\\Drivers"
#define DEFAULT_VK_DRIVERS_PATH ""
#define DEFAULT_VK_ELAYERS_INFO "SOFTWARE\\Khronos\\" API_NAME "\\ExplicitLayers"