| 85 | } |
| 86 | |
| 87 | ExitCode unpackFile(const std::string& inputFile, const std::string& outputFile, bool brute, const std::vector<retdec::cpdetect::DetectResult>& detectedPackers) |
| 88 | { |
| 89 | Plugin::Arguments pluginArgs = { inputFile, outputFile, brute }; |
| 90 | |
| 91 | ExitCode ret = EXIT_CODE_NOTHING_TO_DO; |
| 92 | for (const auto& detectedPacker : detectedPackers) |
| 93 | { |
| 94 | PluginList plugins = PluginMgr::matchingPlugins(detectedPacker.name, detectedPacker.versionInfo); |
| 95 | |
| 96 | if (plugins.empty()) |
| 97 | { |
| 98 | Log::error() << "No matching plugins found for '" << detectedPacker.name; |
| 99 | if (detectedPacker.versionInfo != WILDCARD_ALL_VERSIONS) |
| 100 | Log::error() << " " << detectedPacker.versionInfo; |
| 101 | Log::error() << "'" << std::endl; |
| 102 | continue; |
| 103 | } |
| 104 | |
| 105 | for (const auto& plugin : plugins) |
| 106 | { |
| 107 | PluginExitCode pluginExitCode = plugin->run(pluginArgs); |
| 108 | if (pluginExitCode == PLUGIN_EXIT_UNPACKED) |
| 109 | { |
| 110 | plugin->log("Successfully unpacked '", inputFile, "'!"); |
| 111 | return EXIT_CODE_OK; |
| 112 | } |
| 113 | else if (pluginExitCode == PLUGIN_EXIT_FAILED) |
| 114 | ret = EXIT_CODE_UNPACKING_FAILED; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | return ret; |
| 119 | } |
| 120 | |
| 121 | ExitCode processArgs(ArgHandler& handler, char argc, char** argv) |
| 122 | { |
no test coverage detected