| 44 | } |
| 45 | |
| 46 | std::pair<std::string, std::string> Utils::Win32::FormatModuleVersionString(const void* pBlock) { |
| 47 | UINT size = 0; |
| 48 | LPVOID lpBuffer = nullptr; |
| 49 | if (!VerQueryValueW(pBlock, L"\\", &lpBuffer, &size)) |
| 50 | throw std::runtime_error("Failed to query version information."); |
| 51 | const VS_FIXEDFILEINFO& versionInfo = *static_cast<const VS_FIXEDFILEINFO*>(lpBuffer); |
| 52 | if (versionInfo.dwSignature != 0xfeef04bd) |
| 53 | throw std::runtime_error("Invalid version info found."); |
| 54 | return std::make_pair<>( |
| 55 | std::format("{}.{}.{}.{}", |
| 56 | (versionInfo.dwFileVersionMS >> 16) & 0xFFFF, |
| 57 | (versionInfo.dwFileVersionMS >> 0) & 0xFFFF, |
| 58 | (versionInfo.dwFileVersionLS >> 16) & 0xFFFF, |
| 59 | (versionInfo.dwFileVersionLS >> 0) & 0xFFFF), |
| 60 | std::format("{}.{}.{}.{}", |
| 61 | (versionInfo.dwProductVersionMS >> 16) & 0xFFFF, |
| 62 | (versionInfo.dwProductVersionMS >> 0) & 0xFFFF, |
| 63 | (versionInfo.dwProductVersionLS >> 16) & 0xFFFF, |
| 64 | (versionInfo.dwProductVersionLS >> 0) & 0xFFFF)); |
| 65 | } |
| 66 | |
| 67 | std::pair<std::string, std::string> Utils::Win32::FormatModuleVersionString(const std::filesystem::path& path) { |
| 68 | const auto pathw = path.wstring(); |
nothing calls this directly
no test coverage detected