MCPcopy Create free account
hub / github.com/LibreVR/Revive / GetDefaultLibraryPath

Method GetDefaultLibraryPath

ReviveOverlay/revivemanifestcontroller.cpp:126–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126bool CReviveManifestController::GetDefaultLibraryPath(wchar_t* path, uint32_t length)
127{
128 LONG error = ERROR_SUCCESS;
129
130 // Open the libraries key
131 WCHAR keyPath[MAX_PATH] = { L"Software\\Oculus VR, LLC\\Oculus\\Libraries\\" };
132 HKEY oculusKey;
133 error = RegOpenKeyExW(HKEY_CURRENT_USER, keyPath, 0, KEY_READ, &oculusKey);
134 if (error != ERROR_SUCCESS)
135 {
136 qDebug("Unable to open Libraries key.");
137 return false;
138 }
139
140 // Get the default library
141 WCHAR guid[40] = { L'\0' };
142 DWORD guidSize = sizeof(guid);
143 error = RegQueryValueExW(oculusKey, L"DefaultLibrary", NULL, NULL, (PBYTE)guid, &guidSize);
144 RegCloseKey(oculusKey);
145 if (error != ERROR_SUCCESS)
146 {
147 qDebug("Unable to read DefaultLibrary guid.");
148 return false;
149 }
150
151 // Open the default library key
152 wcsncat(keyPath, guid, MAX_PATH);
153 error = RegOpenKeyExW(HKEY_CURRENT_USER, keyPath, 0, KEY_READ, &oculusKey);
154 if (error != ERROR_SUCCESS)
155 {
156 qDebug("Unable to open Library path key.");
157 return false;
158 }
159
160 // Get the volume path to this library
161 DWORD pathSize;
162 error = RegQueryValueExW(oculusKey, L"Path", NULL, NULL, NULL, &pathSize);
163 PWCHAR volumePath = (PWCHAR)malloc(pathSize);
164 error = RegQueryValueExW(oculusKey, L"Path", NULL, NULL, (PBYTE)volumePath, &pathSize);
165 RegCloseKey(oculusKey);
166 if (error != ERROR_SUCCESS)
167 {
168 free(volumePath);
169 qDebug("Unable to read Library path.");
170 return false;
171 }
172
173 // Resolve the volume path to a mount point
174 DWORD total;
175 WCHAR volume[50] = { L'\0' };
176 wcsncpy(volume, volumePath, 49);
177 GetVolumePathNamesForVolumeNameW(volume, path, length, &total);
178 wcsncat(path, volumePath + 49, MAX_PATH);
179 free(volumePath);
180
181 return true;
182}
183

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected