| 52 | } |
| 53 | |
| 54 | std::string GetVersionFromFiles(const std::string& filePath) { |
| 55 | char modulePath[MAX_PATH] = { 0 }; |
| 56 | strcpy_s(modulePath, filePath.c_str()); |
| 57 | std::string exePath(modulePath); |
| 58 | size_t lastSlash = exePath.find_last_of("\\/"); |
| 59 | std::string exeDir; |
| 60 | if (lastSlash != std::string::npos) |
| 61 | exeDir = exePath.substr(0, lastSlash); |
| 62 | std::vector<std::string> candidates; |
| 63 | candidates.push_back(exeDir + "\\Engine\\Build\\Build.version"); |
| 64 | candidates.push_back(exeDir + "\\UE4Version.txt"); |
| 65 | candidates.push_back(exeDir + "\\UE5Version.txt"); |
| 66 | size_t parentSlash = exeDir.find_last_of("\\/"); |
| 67 | if (parentSlash != std::string::npos) { |
| 68 | std::string parentDir = exeDir.substr(0, parentSlash); |
| 69 | candidates.push_back(parentDir + "\\Engine\\Build\\Build.version"); |
| 70 | candidates.push_back(parentDir + "\\UE4Version.txt"); |
| 71 | candidates.push_back(parentDir + "\\UE5Version.txt"); |
| 72 | } |
| 73 | for (auto& path : candidates) { |
| 74 | if (FileExists(path)) { |
| 75 | std::string content = ReadEntireFile(path); |
| 76 | if (!content.empty()) { |
| 77 | content.erase(std::remove(content.begin(), content.end(), '\r'), content.end()); |
| 78 | content.erase(std::remove(content.begin(), content.end(), '\n'), content.end()); |
| 79 | return content; |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | return ""; |
| 84 | } |
| 85 | |
| 86 | std::string GetVersionFromMemoryScan() { |
| 87 | HMODULE hModule = GetModuleHandleA(NULL); |
no test coverage detected