feat: add no banner option
This commit is contained in:
@@ -7,12 +7,13 @@
|
||||
|
||||
#include "ASTree.h"
|
||||
|
||||
const char* VERSION = "v0.2.1";
|
||||
const char* VERSION = "v0.2.1+";
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* infile = nullptr;
|
||||
unsigned disasm_flags = 0;
|
||||
bool banner = true;
|
||||
std::ofstream dc_out_file;
|
||||
std::ofstream das_out_file;
|
||||
|
||||
@@ -26,13 +27,20 @@ int main(int argc, char* argv[])
|
||||
fputs("Options:\n", stderr);
|
||||
fputs(" --pycode-extra Show extra fields in PyCode object dumps\n", stderr);
|
||||
fputs(" --show-caches Don't suprress CACHE instructions in Python 3.11+ disassembly\n", stderr);
|
||||
fputs(" --no-banner Don't output banner\n", stderr);
|
||||
fputs(" --help Show this help text and then exit\n", stderr);
|
||||
return 0;
|
||||
} else if (strcmp(argv[arg], "--no-banner") == 0) {
|
||||
banner = false;
|
||||
} else if (argv[arg][0] == '-') {
|
||||
fprintf(stderr, "Error: Unrecognized argument %s\n", argv[arg]);
|
||||
return 1;
|
||||
} else {
|
||||
} else if (!infile) {
|
||||
infile = argv[arg];
|
||||
} else {
|
||||
fprintf(stderr, "Error: Only one input file allowed, got %s and %s\n",
|
||||
infile, argv[arg]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +87,7 @@ int main(int argc, char* argv[])
|
||||
const char* disp_prefix = strrchr(prefix_name.c_str(), PATHSEP);
|
||||
disp_prefix = (disp_prefix == NULL) ? prefix_name.c_str() : disp_prefix + 1;
|
||||
|
||||
formatted_print(
|
||||
banner && formatted_print(
|
||||
das_out_file,
|
||||
R"(# File: %s (Python %d.%d)
|
||||
# Disassembly generated by Pyarmor-Static-Unpack-1shot (%s), powered by pycdas
|
||||
@@ -111,13 +119,15 @@ int main(int argc, char* argv[])
|
||||
das_out_file);
|
||||
} catch (std::exception& ex) {
|
||||
fprintf(stderr, "Error disassembling %s: %s\n", infile, ex.what());
|
||||
das_out_file.flush();
|
||||
das_out_file.close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
das_out_file.flush();
|
||||
das_out_file.close();
|
||||
|
||||
formatted_print(
|
||||
banner && formatted_print(
|
||||
dc_out_file,
|
||||
R"(# File: %s (Python %d.%d)
|
||||
# Source generated by Pyarmor-Static-Unpack-1shot (%s), powered by Decompyle++ (pycdc)
|
||||
@@ -136,6 +146,8 @@ int main(int argc, char* argv[])
|
||||
decompyle(mod.code(), &mod, dc_out_file);
|
||||
} catch (std::exception& ex) {
|
||||
fprintf(stderr, "Error decompyling %s: %s\n", infile, ex.what());
|
||||
dc_out_file.flush();
|
||||
dc_out_file.close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user