| 81 | } |
| 82 | |
| 83 | bool GetDefaultLibraryPath(PWCHAR path, DWORD length) |
| 84 | { |
| 85 | LONG error = ERROR_SUCCESS; |
| 86 | |
| 87 | // Open the libraries key |
| 88 | WCHAR keyPath[MAX_PATH] = { L"Software\\Oculus VR, LLC\\Oculus\\Libraries\\" }; |
| 89 | HKEY oculusKey; |
| 90 | error = RegOpenKeyExW(HKEY_CURRENT_USER, keyPath, 0, KEY_READ, &oculusKey); |
| 91 | if (error != ERROR_SUCCESS) |
| 92 | { |
| 93 | LOG("Unable to open Libraries key."); |
| 94 | return false; |
| 95 | } |
| 96 | |
| 97 | // Get the default library |
| 98 | WCHAR guid[40] = { L'\0' }; |
| 99 | DWORD guidSize = sizeof(guid); |
| 100 | error = RegQueryValueExW(oculusKey, L"DefaultLibrary", NULL, NULL, (PBYTE)guid, &guidSize); |
| 101 | RegCloseKey(oculusKey); |
| 102 | if (error != ERROR_SUCCESS) |
| 103 | { |
| 104 | LOG("Unable to read DefaultLibrary guid."); |
| 105 | return false; |
| 106 | } |
| 107 | |
| 108 | // Open the default library key |
| 109 | wcsncat(keyPath, guid, MAX_PATH); |
| 110 | error = RegOpenKeyExW(HKEY_CURRENT_USER, keyPath, 0, KEY_READ, &oculusKey); |
| 111 | if (error != ERROR_SUCCESS) |
| 112 | { |
| 113 | LOG("Unable to open Library path key."); |
| 114 | return false; |
| 115 | } |
| 116 | |
| 117 | // Get the volume path to this library |
| 118 | DWORD pathSize; |
| 119 | error = RegQueryValueExW(oculusKey, L"Path", NULL, NULL, NULL, &pathSize); |
| 120 | PWCHAR volumePath = (PWCHAR)malloc(pathSize); |
| 121 | error = RegQueryValueExW(oculusKey, L"Path", NULL, NULL, (PBYTE)volumePath, &pathSize); |
| 122 | RegCloseKey(oculusKey); |
| 123 | if (error != ERROR_SUCCESS) |
| 124 | { |
| 125 | free(volumePath); |
| 126 | LOG("Unable to read Library path."); |
| 127 | return false; |
| 128 | } |
| 129 | |
| 130 | // Resolve the volume path to a mount point |
| 131 | DWORD total; |
| 132 | WCHAR volume[50] = { L'\0' }; |
| 133 | wcsncpy(volume, volumePath, 49); |
| 134 | GetVolumePathNamesForVolumeNameW(volume, path, length, &total); |
| 135 | wcsncat(path, volumePath + 49, MAX_PATH); |
| 136 | free(volumePath); |
| 137 | |
| 138 | return true; |
| 139 | } |
| 140 | |