| 40 | } |
| 41 | |
| 42 | bool GetLibraryPath(PWCHAR path, DWORD length, PWCHAR guid) |
| 43 | { |
| 44 | LONG error = ERROR_SUCCESS; |
| 45 | |
| 46 | // Open the libraries key |
| 47 | WCHAR keyPath[MAX_PATH] = { L"Software\\Oculus VR, LLC\\Oculus\\Libraries\\" }; |
| 48 | HKEY oculusKey; |
| 49 | |
| 50 | // Open the library key |
| 51 | wcsncat(keyPath, guid, MAX_PATH); |
| 52 | error = RegOpenKeyExW(HKEY_CURRENT_USER, keyPath, 0, KEY_READ, &oculusKey); |
| 53 | if (error != ERROR_SUCCESS) |
| 54 | { |
| 55 | LOG("Unable to open Library path key."); |
| 56 | return false; |
| 57 | } |
| 58 | |
| 59 | // Get the volume path to this library |
| 60 | DWORD pathSize; |
| 61 | error = RegQueryValueExW(oculusKey, L"Path", NULL, NULL, NULL, &pathSize); |
| 62 | PWCHAR volumePath = (PWCHAR)malloc(pathSize); |
| 63 | error = RegQueryValueExW(oculusKey, L"Path", NULL, NULL, (PBYTE)volumePath, &pathSize); |
| 64 | RegCloseKey(oculusKey); |
| 65 | if (error != ERROR_SUCCESS) |
| 66 | { |
| 67 | free(volumePath); |
| 68 | LOG("Unable to read Library path."); |
| 69 | return false; |
| 70 | } |
| 71 | |
| 72 | // Resolve the volume path to a mount point |
| 73 | DWORD total; |
| 74 | WCHAR volume[50] = { L'\0' }; |
| 75 | wcsncpy(volume, volumePath, 49); |
| 76 | GetVolumePathNamesForVolumeNameW(volume, path, length, &total); |
| 77 | wcsncat(path, volumePath + 49, MAX_PATH); |
| 78 | free(volumePath); |
| 79 | |
| 80 | return true; |
| 81 | } |
| 82 | |
| 83 | bool GetDefaultLibraryPath(PWCHAR path, DWORD length) |
| 84 | { |