| 1280 | } |
| 1281 | |
| 1282 | void BrowserFactory::GetIEExecutableLocation() { |
| 1283 | LOG(TRACE) << "Entering BrowserFactory::GetIEExecutableLocation"; |
| 1284 | |
| 1285 | std::wstring redirection; |
| 1286 | if (RegistryUtilities::GetRegistryValue(HKEY_LOCAL_MACHINE, |
| 1287 | IE_REDIRECT, |
| 1288 | L"{1FD49718-1D00-4B19-AF5F-070AF6D5D54C}", |
| 1289 | &redirection)) { |
| 1290 | this->ie_redirects_edge_ = redirection == L"1"; |
| 1291 | } |
| 1292 | else { |
| 1293 | LOG(WARN) << "Unable to determine IE to Edge Redirection"; |
| 1294 | } |
| 1295 | |
| 1296 | std::wstring class_id; |
| 1297 | if (RegistryUtilities::GetRegistryValue(HKEY_LOCAL_MACHINE, |
| 1298 | IE_CLSID_REGISTRY_KEY, |
| 1299 | L"", |
| 1300 | &class_id)) { |
| 1301 | std::wstring location_key = L"SOFTWARE\\Classes\\CLSID\\" + |
| 1302 | class_id + |
| 1303 | L"\\LocalServer32"; |
| 1304 | std::wstring executable_location; |
| 1305 | |
| 1306 | // If we are a 32-bit driver instance, running on 64-bit Windows, |
| 1307 | // we want to bypass the registry redirection so that we can get |
| 1308 | // the actual location of the browser executable. The primary place |
| 1309 | // this matters is when getting the browser version; the secondary |
| 1310 | // place is if the user specifies to use the CreateProcess API for |
| 1311 | // launching the browser, hence the 'true' argument in the following |
| 1312 | // call to RegistryUtilities::GetRegistryValue. |
| 1313 | if (RegistryUtilities::GetRegistryValue(HKEY_LOCAL_MACHINE, |
| 1314 | location_key, |
| 1315 | L"", |
| 1316 | true, |
| 1317 | &executable_location)) { |
| 1318 | // If the executable location in the registry has an environment |
| 1319 | // variable in it, expand the environment variable to an absolute |
| 1320 | // path. |
| 1321 | DWORD expanded_location_size = ::ExpandEnvironmentStrings(executable_location.c_str(), NULL, 0); |
| 1322 | std::vector<wchar_t> expanded_location(expanded_location_size); |
| 1323 | ::ExpandEnvironmentStrings(executable_location.c_str(), &expanded_location[0], expanded_location_size); |
| 1324 | executable_location = &expanded_location[0]; |
| 1325 | this->ie_executable_location_ = executable_location; |
| 1326 | size_t arg_start_pos = executable_location.find(L" -"); |
| 1327 | if (arg_start_pos != std::string::npos) { |
| 1328 | this->ie_executable_location_ = executable_location.substr(0, arg_start_pos); |
| 1329 | } |
| 1330 | if (this->ie_executable_location_.substr(0, 1) == L"\"") { |
| 1331 | this->ie_executable_location_.erase(0, 1); |
| 1332 | this->ie_executable_location_.erase(this->ie_executable_location_.size() - 1, 1); |
| 1333 | } |
| 1334 | } else { |
| 1335 | LOG(WARN) << "Unable to get IE executable location from registry"; |
| 1336 | } |
| 1337 | } else { |
| 1338 | LOG(WARN) << "Unable to get IE class id from registry"; |
| 1339 | } |
no test coverage detected