From 43d1bd4262280c5bfc95a878d2208df62d15f040 Mon Sep 17 00:00:00 2001 From: nezu <29180158+dumbasPL@users.noreply.github.com> Date: Sat, 30 Sep 2023 16:37:16 +0200 Subject: [PATCH] add output_file param to fumo_encoder --- src/encoder/fumo_encoder.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/encoder/fumo_encoder.cpp b/src/encoder/fumo_encoder.cpp index 83c7d1f..020f4c7 100644 --- a/src/encoder/fumo_encoder.cpp +++ b/src/encoder/fumo_encoder.cpp @@ -11,38 +11,37 @@ #include int main(int argc, char** argv) { - // usage: [input_file] [process_name] [wait_for_module1,[wait_for_module2,...]] + // usage: [input_file] [process_name] [wait_for_module1,[wait_for_module2,...]] [output_file] std::string input_file_name = [argc, argv]() { - std::cout << "Input file (DLL): "; - if (argc > 1) { - std::cout << argv[1] << std::endl; + if (argc > 1) return std::string(argv[1]); - } + std::cout << "Input file (DLL): "; std::string input_file_name; std::getline(std::cin, input_file_name); return input_file_name; }(); std::string process_name = [argc, argv]() { - std::cout << "Target process name: "; - if (argc > 2) { - std::cout << argv[2] << std::endl; + if (argc > 2) return std::string(argv[2]); - } + std::cout << "Target process name: "; std::string process_name; std::getline(std::cin, process_name); return process_name; }(); std::string wait_for_modules = [argc, argv]() { - std::cout << "Wait for modules (comma separated): "; - if (argc > 3) { - std::cout << argv[3] << std::endl; + if (argc > 3) return std::string(argv[3]); - } + std::cout << "Wait for modules (comma separated): "; std::string wait_for_modules; std::getline(std::cin, wait_for_modules); return wait_for_modules; }(); + std::string output_file_name = [argc, argv, input_file_name]() { + if (argc > 4) + return std::string(argv[4]); + return std::filesystem::path(input_file_name).replace_extension(".fumo").string(); + }(); if (process_name.length() == 0) { std::cerr << "No process name specified" << std::endl; @@ -54,9 +53,6 @@ int main(int argc, char** argv) { wait_for_modules = "kernel32.dll"; } - // get output file name - std::string output_file_name = std::filesystem::path(input_file_name).replace_extension(".fumo").string(); - // read input file std::ifstream input_file(input_file_name, std::ios::binary); if (!input_file.is_open()) {