📄 main.cpp
字号:
break; case 'h'+256:#if 1 if (!acc_isatty(STDOUT_FILENO)) { /* according to GNU standards */ set_term(stdout); opt->console = CON_FILE; }#endif show_help(1); e_exit(EXIT_OK); break; case 'i': opt->info_mode++; break; case 'l': set_cmd(CMD_LIST); break; case 'L': set_cmd(CMD_LICENSE); break; case 'o': set_output_name(mfx_optarg,1); break; case 'q': opt->verbose = (opt->verbose > 1 ? 1 : opt->verbose - 1); break; case 't': set_cmd(CMD_TEST); break; case 'v': opt->verbose = (opt->verbose < 3 ? 3 : opt->verbose + 1); break; case 'V': set_cmd(CMD_VERSION); break; case 'V'+256: /* according to GNU standards */ set_term(stdout); opt->console = CON_FILE; show_version(0); e_exit(EXIT_OK); break; // method case 702: opt->method_nrv2b_seen = true; if (!set_method(M_NRV2B_LE32, -1)) e_method(M_NRV2B_LE32, opt->level); break; case 704: opt->method_nrv2d_seen = true; if (!set_method(M_NRV2D_LE32, -1)) e_method(M_NRV2D_LE32, opt->level); break; case 705: opt->method_nrv2e_seen = true; if (!set_method(M_NRV2E_LE32, -1)) e_method(M_NRV2E_LE32, opt->level); break; case 721: opt->method_lzma_seen = true; opt->all_methods_use_lzma = true; if (!set_method(M_LZMA, -1)) e_method(M_LZMA, opt->level); break; case 722: opt->method_lzma_seen = false; opt->all_methods_use_lzma = false; if (M_IS_LZMA(opt->method)) opt->method = -1; break; // compression level case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (!set_method(-1, optc - '0')) e_method(opt->method, optc); break; case 902: // --ultra-brute opt->ultra_brute = true; /* fallthrough */ case 901: // --brute opt->all_methods = true; opt->all_methods_use_lzma = true; opt->method = -1; opt->all_filters = true; opt->filter = -1; opt->crp.crp_ucl.m_size = 999999; /* fallthrough */ case 900: // --best if (!set_method(-1, 10)) e_method(opt->method, 10); break; // debug case 542: if (!mfx_optarg || strlen(mfx_optarg) != 4) e_optarg(arg); memcpy(opt->debug.fake_stub_version, mfx_optarg, 4); break; case 543: if (!mfx_optarg || strlen(mfx_optarg) != 4) e_optarg(arg); memcpy(opt->debug.fake_stub_year, mfx_optarg, 4); break; case 544: if (!mfx_optarg || !mfx_optarg[0]) e_optarg(arg); opt->debug.dump_stub_loader = mfx_optarg; break; case 545: opt->debug.disable_random_id = true; break; // misc case 512: opt->console = CON_FILE; break; case 513: opt->console = CON_ANSI_MONO; break; case 514: opt->console = CON_ANSI_COLOR; break; case 516: opt->no_progress = true; break; case 519: opt->no_env = true; break; case 526: opt->preserve_mode = false; break; case 527: opt->preserve_ownership = false; break; case 528: opt->preserve_timestamp = false; break; // compression settings case 520: // --small if (opt->small < 0) opt->small = 0; opt->small++; break; case 521: // --filter= getoptvar(&opt->filter, 0, 255, arg); opt->all_filters = false; break; case 522: // --no-filter opt->filter = 0; opt->all_filters = false; opt->no_filter = true; break; case 523: // --all-filters opt->all_filters = true; opt->filter = -1; break; case 524: // --all-methods opt->all_methods = true; opt->all_methods_use_lzma = true; opt->method = -1; break; case 525: // --exact opt->exact = true; break; // compression runtime parameters case 801: getoptvar(&opt->crp.crp_ucl.c_flags, 0, 3, arg); break; case 802: getoptvar(&opt->crp.crp_ucl.s_level, 0, 2, arg); break; case 803: getoptvar(&opt->crp.crp_ucl.h_level, 0, 1, arg); break; case 804: getoptvar(&opt->crp.crp_ucl.p_level, 0, 7, arg); break; case 805: getoptvar(&opt->crp.crp_ucl.max_offset, 256u, ~0u, arg); break; case 806: getoptvar(&opt->crp.crp_ucl.max_match, 16u, ~0u, arg); break; case 807: getoptvar(&opt->crp.crp_ucl.m_size, 10000u, 999999u, arg); break; case 811: getoptvar(&opt->crp.crp_lzma.pos_bits, arg); break; case 812: getoptvar(&opt->crp.crp_lzma.lit_pos_bits, arg); break; case 813: getoptvar(&opt->crp.crp_lzma.lit_context_bits, arg); break; case 814: getoptvar(&opt->crp.crp_lzma.dict_size, arg); break; case 816: getoptvar(&opt->crp.crp_lzma.num_fast_bytes, arg); break; case 821: getoptvar(&opt->crp.crp_zlib.mem_level, arg); break; case 822: getoptvar(&opt->crp.crp_zlib.window_bits, arg); break; case 823: getoptvar(&opt->crp.crp_zlib.strategy, arg); break; // backup case 'k': opt->backup = 1; break; case 541: if (opt->backup != 1) // do not overide '--backup' opt->backup = 0; break; // overlay case 551: if (mfx_optarg && strcmp(mfx_optarg,"skip") == 0) opt->overlay = opt->SKIP_OVERLAY; else if (mfx_optarg && strcmp(mfx_optarg,"copy") == 0) opt->overlay = opt->COPY_OVERLAY; else if (mfx_optarg && strcmp(mfx_optarg,"strip") == 0) opt->overlay = opt->STRIP_OVERLAY; else e_optarg(arg); break; case 552: opt->overlay = opt->SKIP_OVERLAY; break; case 553: opt->overlay = opt->COPY_OVERLAY; break; case 554: opt->overlay = opt->STRIP_OVERLAY; break; // CPU case 560: if (mfx_optarg && strcmp(mfx_optarg,"8086") == 0) opt->cpu = opt->CPU_8086; else if (mfx_optarg && strcmp(mfx_optarg,"386") == 0) opt->cpu = opt->CPU_386; else if (mfx_optarg && strcmp(mfx_optarg,"486") == 0) opt->cpu = opt->CPU_486; else e_optarg(arg); break; case 561: opt->cpu = opt->CPU_8086; break; case 563: opt->cpu = opt->CPU_386; break; case 564: opt->cpu = opt->CPU_486; break; // case 600: opt->dos_exe.force_stub = true; break; case 601: opt->dos_exe.no_reloc = true; break; case 610: opt->djgpp2_coff.coff = true; break; case 620: opt->watcom_le.le = true; break; case 630: opt->win32_pe.compress_exports = 1; if (mfx_optarg && mfx_optarg[0]) getoptvar(&opt->win32_pe.compress_exports, 0, 1, arg); //printf("compress_exports: %d\n", opt->win32_pe.compress_exports); break; case 631: opt->win32_pe.compress_icons = 1; if (mfx_optarg && mfx_optarg[0]) getoptvar(&opt->win32_pe.compress_icons, 0, 3, arg); //printf("compress_icons: %d\n", opt->win32_pe.compress_icons); break; case 632: opt->win32_pe.compress_resources = 1; if (mfx_optarg && mfx_optarg[0]) getoptvar(&opt->win32_pe.compress_resources, 0, 1, arg); //printf("compress_resources: %d\n", opt->win32_pe.compress_resources); break; case 633: // opt->win32_pe.strip_loadconf - OBSOLETE - IGNORED break; case 634: opt->win32_pe.strip_relocs = 1; if (mfx_optarg && mfx_optarg[0]) getoptvar(&opt->win32_pe.strip_relocs, 0, 1, arg); //printf("strip_relocs: %d\n", opt->win32_pe.strip_relocs); break; case 635: if (!mfx_optarg || !mfx_optarg[0]) e_optarg(arg); opt->win32_pe.keep_resource = mfx_optarg; break; case 650: opt->atari_tos.split_segments = true; break; case 660: getoptvar(&opt->o_unix.blocksize, 8192u, ~0u, arg); break; case 661: opt->o_unix.force_execve = true; break; case 662: opt->o_unix.script_name = "/usr/local/lib/upx/upxX"; if (mfx_optarg && mfx_optarg[0]) set_script_name(mfx_optarg, 1); break; case 663: opt->o_unix.is_ptinterp = true; break; case 664: opt->o_unix.use_ptinterp = true; break; case 665: opt->o_unix.make_ptinterp = true; break; case 666: // Linux opt->o_unix.osabi0 = Elf32_Ehdr::ELFOSABI_LINUX; break; case 667: // FreeBSD opt->o_unix.osabi0 = Elf32_Ehdr::ELFOSABI_FREEBSD; break; case 668: // NetBSD opt->o_unix.osabi0 = Elf32_Ehdr::ELFOSABI_NETBSD; break; case 669: // OpenBSD opt->o_unix.osabi0 = Elf32_Ehdr::ELFOSABI_OPENBSD; break; case 670: opt->ps1_exe.boot_only = true; break; case 671: opt->ps1_exe.no_align = true; opt->ps1_exe.boot_only = false; break; case 672: opt->ps1_exe.do_8bit = true; break; case 673: opt->ps1_exe.do_8mb = false; break; case '\0': return -1; case ':': return -2; default: fprintf(stderr,"%s: internal error in getopt (%d)\n", argv0, optc); return -3; } UNUSED(i); return 0;}static int get_options(int argc, char **argv){static const struct mfx_option longopts[] ={ // commands {"best", 0x10, 0, 900}, // compress best {"brute", 0x10, 0, 901}, // compress best, brute force {"ultra-brute", 0x10, 0, 902}, // compress best, brute force {"decompress", 0, 0, 'd'}, // decompress {"fast", 0x10, 0, '1'}, // compress faster {"fileinfo", 0x10, 0, 909}, // display info about file {"file-info", 0x10, 0, 909}, // display info about file {"help", 0, 0, 'h'+256}, // give help {"license", 0, 0, 'L'}, // display software license {"list", 0, 0, 'l'}, // list compressed exe {"test", 0, 0, 't'}, // test compressed file integrity {"uncompress", 0, 0, 'd'}, // decompress {"version", 0, 0, 'V'+256}, // display version number // options {"force", 0, 0, 'f'}, // force overwrite of output files {"force-compress", 0, 0, 'f'}, // and compression of suspicious files {"info", 0, 0, 'i'}, // info mode {"no-env", 0x10, 0, 519}, // no environment var {"no-mode", 0x10, 0, 526}, // do not preserve mode (permissions) {"no-owner", 0x10, 0, 527}, // do not preserve ownership {"no-progress", 0, 0, 516}, // no progress bar {"no-time", 0x10, 0, 528}, // do not preserve timestamp {"output", 0x21, 0, 'o'}, {"quiet", 0, 0, 'q'}, // quiet mode {"silent", 0, 0, 'q'}, // quiet mode#if 0 // FIXME: to_stdout doesn't work because of console code mess {"stdout", 0x10, 0, 517}, // write output on standard output {"to-stdout", 0x10, 0, 517}, // write output on standard output#endif {"verbose", 0, 0, 'v'}, // verbose mode // debug options {"debug", 0x10, 0, 'D'}, {"dump-stub-loader" ,0x31, 0, 544}, // for internal debugging {"fake-stub-version",0x31, 0, 542}, // for internal debugging {"fake-stub-year" ,0x31, 0, 543}, // for internal debugging {"disable-random-id",0x10, 0, 545}, // for internal debugging // backup options {"backup", 0x10, 0, 'k'}, {"keep", 0x10, 0, 'k'}, {"no-backup", 0x10, 0, 541}, // overlay options {"overlay", 0x31, 0, 551}, // --overlay= {"skip-overlay", 0x10, 0, 552}, {"no-overlay", 0x10, 0, 552}, // old name {"copy-overlay", 0x10, 0, 553}, {"strip-overlay", 0x10, 0, 554}, // CPU options {"cpu", 0x31, 0, 560}, // --cpu= {"8086", 0x10, 0, 561}, {"386", 0x10, 0, 563}, {"486", 0x10, 0, 564}, // color options {"no-color", 0x10, 0, 512}, {"mono", 0x10, 0, 513}, {"color", 0x10, 0, 514}, // compression method {"nrv2b", 0x10, 0, 702}, // --nrv2b {"nrv2d", 0x10, 0, 704}, // --nrv2d {"nrv2e", 0x10, 0, 705}, // --nrv2e {"lzma", 0x10, 0, 721}, // --lzma {"no-lzma", 0x10, 0, 722}, // (disable all_methods_use_lzma) // compression settings {"all-filters", 0x10, 0, 523}, {"all-methods", 0x10, 0, 524}, {"exact", 0x10, 0, 525}, // user requires byte-identical decompression {"filter", 0x31, 0, 521}, // --filter= {"no-filter", 0x10, 0, 522}, {"small", 0x10, 0, 520}, // compression runtime parameters {"crp-nrv-cf", 0x31, 0, 801}, {"crp-nrv-sl", 0x31, 0, 802}, {"crp-nrv-hl", 0x31, 0, 803}, {"crp-nrv-pl", 0x31, 0, 804}, {"crp-nrv-mo", 0x31, 0, 805}, {"crp-nrv-mm", 0x31, 0, 806}, {"crp-nrv-ms", 0x31, 0, 807}, {"crp-ucl-cf", 0x31, 0, 801}, {"crp-ucl-sl", 0x31, 0, 802}, {"crp-ucl-hl", 0x31, 0, 803}, {"crp-ucl-pl", 0x31, 0, 804}, {"crp-ucl-mo", 0x31, 0, 805}, {"crp-ucl-mm", 0x31, 0, 806}, {"crp-ucl-ms", 0x31, 0, 807}, {"crp-lzma-pb", 0x31, 0, 811}, {"crp-lzma-lp", 0x31, 0, 812}, {"crp-lzma-lc", 0x31, 0, 813}, {"crp-lzma-ds", 0x31, 0, 814}, {"crp-lzma-fb", 0x31, 0, 816}, {"crp-zlib-ml", 0x31, 0, 821}, {"crp-zlib-wb", 0x31, 0, 822}, {"crp-zlib-st", 0x31, 0, 823}, // [deprecated - only for compatibility with UPX 2.0x] {"crp-ms", 0x31, 0, 807}, // atari/tos {"split-segments", 0x10, 0, 650}, // djgpp2/coff {"coff", 0x10, 0, 610}, // produce COFF output // dos/com // dos/exe //{"force-stub", 0x10, 0, 600}, {"no-reloc", 0x10, 0, 601}, // no reloc. record into packer dos/exe // dos/sys // unix {"blocksize", 0x31, 0, 660}, // --blocksize= {"force-execve", 0x10, 0, 661}, // force linux/386 execve format#if 0 {"script", 0x31, 0, 662}, // --script=#endif {"is_ptinterp", 0x10, 0, 663}, // linux/elf386 PT_INTERP program {"use_ptinterp", 0x10, 0, 664}, // linux/elf386 PT_INTERP program {"make_ptinterp", 0x10, 0, 665}, // linux/elf386 PT_INTERP program {"Linux", 0x10, 0, 666}, {"linux", 0x10, 0, 666}, {"FreeBSD", 0x10, 0, 667}, {"freebsd", 0x10, 0, 667}, {"NetBSD", 0x10, 0, 668}, {"netbsd", 0x10, 0, 668}, {"OpenBSD", 0x10, 0, 669},
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -