Upx_Doxygen
https://github.com/upx/upx
p_exe.h
1 /* p_exe.h --
2 
3  This file is part of the UPX executable compressor.
4 
5  Copyright (C) 1996-2016 Markus Franz Xaver Johannes Oberhumer
6  Copyright (C) 1996-2016 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_P_EXE_H
30 #define __UPX_P_EXE_H 1
31 
32 
33 /*************************************************************************
34 // dos/exe
35 **************************************************************************/
36 
37 class PackExe : public Packer
38 {
39  typedef Packer super;
40 public:
41  PackExe(InputFile *f);
42  virtual int getVersion() const { return 13; }
43  virtual int getFormat() const { return UPX_F_DOS_EXE; }
44  virtual const char *getName() const { return "dos/exe"; }
45  //virtual const char *getFullName(const options_t *o) const { return o && o->cpu == o->CPU_8086 ? "i086-dos16.exe" : "i286-dos16.exe"; }
46  virtual const char *getFullName(const options_t *) const { return "i086-dos16.exe"; }
47  virtual const int *getCompressionMethods(int method, int level) const;
48  virtual const int *getFilters() const;
49 
50  virtual void pack(OutputFile *fo);
51  virtual void unpack(OutputFile *fo);
52 
53  virtual bool canPack();
54  virtual int canUnpack();
55 
56  // unpacker capabilities
57  virtual bool canUnpackVersion(int version) const
58  {
59  // NOTE: could adapt p_exe.cpp to support (version >= 8)
60  return (version >= 10);
61  }
62  virtual bool canUnpackFormat(int format) const
63  {
64  return (format == UPX_F_DOS_EXE || format == UPX_F_DOS_EXEH);
65  }
66 
67 protected:
68  struct exe_header_t;
69 
70  virtual int readFileHeader(void);
71 
72  virtual int fillExeHeader(struct exe_header_t *) const;
73  virtual void buildLoader(const Filter *ft);
74  virtual Linker* newLinker() const;
75  void addLoaderEpilogue(int flag);
76 
77  __packed_struct(exe_header_t)
78  LE16 ident;
79  LE16 m512;
80  LE16 p512;
81  LE16 relocs;
82  LE16 headsize16;
83  LE16 min;
84  LE16 max;
85  LE16 ss;
86  LE16 sp;
87  char _[2]; // checksum
88  LE16 ip;
89  LE16 cs;
90  LE16 relocoffs;
91  char __[2]; // overlnum
92  LE32 firstreloc;
93  __packed_struct_end()
94 
95  exe_header_t ih, oh;
96 
97  unsigned ih_exesize;
98  unsigned ih_imagesize;
99  unsigned ih_overlay;
100  unsigned relocsize;
101 
102  bool has_9a;
103  bool device_driver;
104 
105  enum {
106  NORELOC = 1,
107  USEJUMP = 2,
108  SS = 4,
109  SP = 8,
110  MINMEM = 16,
111  MAXMEM = 32
112  };
113 
114  unsigned stack_for_lzma; // stack size required for lzma
115  bool use_clear_dirty_stack;
116 };
117 
118 
119 #endif /* already included */
120 
121 /* vim:set ts=4 sw=4 et: */
Definition: linker.h:35
Definition: options.h:45
Definition: file.h:89
Definition: packer.h:115
Definition: p_exe.h:37
Definition: file.h:121
Definition: filter.h:53