aboutsummaryrefslogtreecommitdiff
path: root/loader/loader.c
diff options
context:
space:
mode:
authorTony Barbour <tony@LunarG.com>2015-07-29 14:26:21 -0600
committerCourtney Goeltzenleuchter <courtney@LunarG.com>2015-07-31 14:15:23 -0600
commitd7802ab8c5c6c06796bcffe5d595b9cf431ddfae (patch)
treef7ff326ec6af16109e78fe677c8f732bb97a120d /loader/loader.c
parent0d3d1b895eb8b4f1e189991c5e7622cbb0f3d5cc (diff)
downloadusermoji-d7802ab8c5c6c06796bcffe5d595b9cf431ddfae.tar.xz
loader: get_registry_files needs to parse a list
Diffstat (limited to 'loader/loader.c')
-rw-r--r--loader/loader.c71
1 files changed, 41 insertions, 30 deletions
diff --git a/loader/loader.c b/loader/loader.c
index c3e28fbc..e10b9aa7 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -175,6 +175,7 @@ static void loader_log(VkFlags msg_type, int32_t msg_code,
}
#if defined(WIN32)
+static char *loader_get_next_path(char *path);
/**
* Find the list of registry files (names within a key) in key "location".
*
@@ -196,45 +197,55 @@ static char *loader_get_registry_files(char *location)
DWORD access_flags = KEY_QUERY_VALUE;
char name[2048];
char *out = NULL;
-
- hive = DEFAULT_VK_REGISTRY_HIVE;
- rtn_value = RegOpenKeyEx(hive, location, 0, access_flags, &key);
- if (rtn_value != ERROR_SUCCESS) {
- // We didn't find the key. Try the 32-bit hive (where we've seen the
- // key end up on some people's systems):
- access_flags |= KEY_WOW64_32KEY;
- rtn_value = RegOpenKeyEx(hive, location, 0, access_flags, &key);
- if (rtn_value != ERROR_SUCCESS) {
- // We still couldn't find the key, so give up:
- return NULL;
- }
- }
-
+ char *loc = location;
+ char *next;
DWORD idx = 0;
DWORD name_size = sizeof(name);
DWORD value;
DWORD total_size = 4096;
DWORD value_size = sizeof(value);
- 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 (out == NULL) {
- out = malloc(total_size);
- out[0] = '\0';
- }
- else if (strlen(out) + name_size + 1 > total_size) {
- out = realloc(out, total_size * 2);
- total_size *= 2;
+
+ while(*loc)
+ {
+ next = loader_get_next_path(loc);
+ hive = DEFAULT_VK_REGISTRY_HIVE;
+ rtn_value = RegOpenKeyEx(hive, loc, 0, access_flags, &key);
+ if (rtn_value != ERROR_SUCCESS) {
+ // We didn't find the key. Try the 32-bit hive (where we've seen the
+ // key end up on some people's systems):
+ access_flags |= KEY_WOW64_32KEY;
+ rtn_value = RegOpenKeyEx(hive, loc, 0, access_flags, &key);
+ if (rtn_value != ERROR_SUCCESS) {
+ // We still couldn't find the key, so give up:
+ loc = next;
+ continue;
}
- if (out == NULL) {
- loader_log(VK_DBG_REPORT_ERROR_BIT, 0, "Out of memory, failed loader_get_registry_files");
- return NULL;
+ }
+
+ 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 (out == NULL) {
+ out = malloc(total_size);
+ out[0] = '\0';
+ }
+ else if (strlen(out) + name_size + 1 > total_size) {
+ out = realloc(out, total_size * 2);
+ total_size *= 2;
+ }
+ if (out == NULL) {
+ loader_log(VK_DBG_REPORT_ERROR_BIT, 0, "Out of memory, failed loader_get_registry_files");
+ return NULL;
+ }
+ if (strlen(out) == 0)
+ snprintf(out, name_size + 1, "%s", name);
+ else
+ snprintf(out + strlen(out), name_size + 2, "%c%s", PATH_SEPERATOR, name);
}
- if (strlen(out) == 0)
- snprintf(out, name_size + 1, "%s", name);
- else
- snprintf(out + strlen(out), name_size + 1, "%c%s", PATH_SEPERATOR, name);
+ name_size = 2048;
}
+ loc = next;
}
+
return out;
}