| 375 | } |
| 376 | |
| 377 | void QueryAndLoad(const wchar_t* query) |
| 378 | { |
| 379 | try |
| 380 | { |
| 381 | if (query == nullptr) |
| 382 | return; |
| 383 | // strip GDI added prefix '@' |
| 384 | if (*query == L'@') |
| 385 | ++query; |
| 386 | // skip empty string |
| 387 | if (*query == L'\0') |
| 388 | return; |
| 389 | if (!QueryCache::GetInstance().IsQueryNeeded(query)) |
| 390 | return; |
| 391 | auto response = QueryFont(query); |
| 392 | |
| 393 | std::vector<std::wstring> paths; |
| 394 | for (int i = 0; i < response.fonts_size(); ++i) |
| 395 | { |
| 396 | auto& font = response.fonts()[i]; |
| 397 | auto path = Utf8ToWideString(font.path()); |
| 398 | paths.emplace_back(std::move(path)); |
| 399 | } |
| 400 | QueryCache::GetInstance().AddToCache(query); |
| 401 | std::vector<const wchar_t*> logData; |
| 402 | for (auto& s : paths) |
| 403 | { |
| 404 | logData.push_back(s.c_str()); |
| 405 | } |
| 406 | if (logData.empty()) |
| 407 | { |
| 408 | EventLog::GetInstance().LogDllQueryNoResult(GetCurrentProcessId(), GetCurrentThreadId(), query); |
| 409 | } |
| 410 | else |
| 411 | { |
| 412 | EventLog::GetInstance().LogDllQuerySuccess(GetCurrentProcessId(), GetCurrentThreadId(), query, logData); |
| 413 | } |
| 414 | |
| 415 | TryLoad(query, response); |
| 416 | } |
| 417 | catch (std::exception& e) |
| 418 | { |
| 419 | EventLog::GetInstance().LogDllQueryFailure(GetCurrentProcessId(), GetCurrentThreadId(), query, |
| 420 | AnsiStringToWideString(e.what()).c_str()); |
| 421 | // ignore exceptions |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | void QueryAndLoad(const char* query) |
| 426 | { |
no test coverage detected