1 /* options.h --
2 
3    This file is part of the UPX executable compressor.
4 
5    Copyright (C) 1996-2020 Markus Franz Xaver Johannes Oberhumer
6    Copyright (C) 1996-2020 Laszlo Molnar
7    All Rights Reserved.
8 
9    UPX and the UCL library are free software; you can redistribute them
10    and/or modify them under the terms of the GNU General Public License as
11    published by the Free Software Foundation; either version 2 of
12    the License, or (at your option) any later version.
13 
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18 
19    You should have received a copy of the GNU General Public License
20    along with this program; see the file COPYING.
21    If not, write to the Free Software Foundation, Inc.,
22    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 
24    Markus F.X.J. Oberhumer              Laszlo Molnar
25    <markus@oberhumer.com>               <ezerotven+github@gmail.com>
26  */
27 
28 
29 #ifndef __UPX_OPTIONS_H
30 #define __UPX_OPTIONS_H 1
31 
32 
33 /*************************************************************************
34 // globals
35 **************************************************************************/
36 
37 // options - command
38 enum {
39     CMD_NONE,
40     CMD_COMPRESS, CMD_DECOMPRESS, CMD_TEST, CMD_LIST, CMD_FILEINFO,
41     CMD_HELP, CMD_LICENSE, CMD_VERSION
42 };
43 
44 
45 struct options_t {
46     int cmd;
47 
48     // mp (meta) options
49     int mp_compress_task;
50     bool mp_query_format;
51     bool mp_query_num_tasks;
52 
53     // compression options
54     int method;
55     bool method_lzma_seen;
56     bool method_nrv2b_seen;
57     bool method_nrv2d_seen;
58     bool method_nrv2e_seen;
59     int level;              // compression level 1..10
60     int filter;             // preferred filter from Packer::getFilters()
61     bool ultra_brute;
62     bool all_methods;       // try all available compression methods ?
63     bool all_methods_use_lzma;
64     bool all_filters;       // try all available filters ?
65     bool no_filter;         // force no filter
66     bool prefer_ucl;        // prefer UCL
67     bool exact;             // user requires byte-identical decompression
68 
69     // other options
70     int backup;
71     int console;
72     int force;
73     int info_mode;
74     bool ignorewarn;
75     bool no_env;
76     bool no_progress;
77     const char *output_name;
78     bool preserve_mode;
79     bool preserve_ownership;
80     bool preserve_timestamp;
81     int small;
82     int verbose;
83     bool to_stdout;
84 
85     // debug options
86     struct {
87         int debug_level;
88         bool disable_random_id;         // for Packer::getRandomId()
89         const char *dump_stub_loader;
90         char fake_stub_version[4+1];    // for internal debugging
91         char fake_stub_year[4+1];       // for internal debugging
92     } debug;
93 
94     // overlay handling
95     enum {
96         SKIP_OVERLAY      = 0,
97         COPY_OVERLAY      = 1,
98         STRIP_OVERLAY     = 2
99     };
100     int overlay;
101 
102     // compression runtime parameters - see struct XXX_compress_config_t
103     struct crp_t {
104         lzma_compress_config_t  crp_lzma;
105         ucl_compress_config_t   crp_ucl;
106         zlib_compress_config_t  crp_zlib;
resetoptions_t::crp_t107         void reset() { crp_lzma.reset(); crp_ucl.reset(); crp_zlib.reset(); }
108     };
109     crp_t crp;
110 
111     // CPU
112     enum {
113         CPU_DEFAULT = 0,
114         CPU_8086    = 1,
115         CPU_286     = 2,
116         CPU_386     = 3,
117         CPU_486     = 4,
118         CPU_586     = 5,
119         CPU_686     = 6
120     };
121     int cpu;
122 
123     // options for various executable formats
124     struct {
125         bool split_segments;
126     } atari_tos;
127     struct {
128         bool coff;
129     } djgpp2_coff;
130     struct {
131         bool force_stub;
132         bool no_reloc;
133     } dos_exe;
134     struct {
135         bool boot_only;
136         bool no_align;
137         bool do_8bit;
138         bool do_8mib;
139     } ps1_exe;
140     struct {
141         unsigned blocksize;
142         bool force_execve;          // force the linux/386 execve format
143         bool is_ptinterp;           // is PT_INTERP, so don't adjust auxv_t
144         bool use_ptinterp;          // use PT_INTERP /opt/upx/run
145         bool make_ptinterp;         // make PT_INTERP [ignore current file!]
146         bool unmap_all_pages;       // thus /proc/self/exe vanishes
147         unsigned char osabi0;       // replacement if 0==.e_ident[EI_OSABI]
148         bool preserve_build_id;     // copy the build-id to the compressed binary
149         bool android_shlib;         // keep some ElfXX_Shdr for dlopen()
150         bool force_pie;             // choose DF_1_PIE instead of is_shlib
151     } o_unix;
152     struct {
153         bool le;
154     } watcom_le;
155     struct {
156         int compress_exports;
157         int compress_icons;
158         int compress_resources;
159         signed char compress_rt[25];    // 25 == RT_LAST
160         int strip_relocs;
161         const char *keep_resource;
162     } win32_pe;
163 
164     void reset();
165 };
166 
167 extern struct options_t *opt;
168 
169 
170 #endif /* already included */
171 
172 /* vim:set ts=4 sw=4 et: */
173