Upx_Doxygen
https://github.com/upx/upx
p_ps1.h
1 /* p_ps1.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  Copyright (C) 2002-2016 Jens Medoch
8  All Rights Reserved.
9 
10  UPX and the UCL library are free software; you can redistribute them
11  and/or modify them under the terms of the GNU General Public License as
12  published by the Free Software Foundation; either version 2 of
13  the License, or (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; see the file COPYING.
22  If not, write to the Free Software Foundation, Inc.,
23  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 
25  Markus F.X.J. Oberhumer Laszlo Molnar
26  <markus@oberhumer.com> <ezerotven+github@gmail.com>
27 
28  Jens Medoch
29  <jssg@users.sourceforge.net>
30  */
31 
32 
33 #ifndef __UPX_P_PS1_H
34 #define __UPX_P_PS1_H 1
35 
36 
37 /*************************************************************************
38 // ps1/exe
39 **************************************************************************/
40 
41 class PackPs1 : public Packer
42 {
43  typedef Packer super;
44 public:
45  PackPs1(InputFile *f);
46  virtual int getVersion() const { return 13; }
47  virtual int getFormat() const { return UPX_F_PS1_EXE; }
48  virtual const char *getName() const { return "ps1/exe"; }
49  virtual const char *getFullName(const options_t *) const { return "mipsel.r3000-ps1"; }
50  virtual const int *getCompressionMethods(int method, int level) const;
51  virtual const int *getFilters() const;
52 
53  virtual void pack(OutputFile *fo);
54  virtual void unpack(OutputFile *fo);
55 
56  virtual bool canPack();
57  virtual int canUnpack();
58 
59 protected:
60  virtual void putBkupHeader(const unsigned char *src, unsigned char *dst, unsigned *len);
61  virtual bool getBkupHeader(unsigned char *src, unsigned char * dst);
62  virtual bool readBkupHeader();
63  virtual void buildLoader(const Filter *ft);
64  virtual bool findBssSection();
65  virtual Linker* newLinker() const;
66 
67  virtual int readFileHeader();
68  virtual bool checkFileHeader();
69 
70  __packed_struct(ps1_exe_t)
71  // ident string
72  char id[8];
73  // is NULL
74  LE32 text;
75  // is NULL
76  LE32 data;
77  // initial program counter
78  LE32 epc;
79  // initial gp register value
80  LE32 gp;
81  // load offset of binary data
82  LE32 tx_ptr, tx_len;
83  LE32 da_ptr, da_len;
84  LE32 bs_ptr, bs_len;
85  // initial stack params
86  LE32 is_ptr, is_len;
87  // saved regs on execution
88  LE32 sp, fp, gp0, ra, k0;
89  // origin Jap/USA/Europe
90  char origin[60];
91  // backup of the original header (epc - is_len)
92  // id & the upx header ...
93  __packed_struct_end()
94 
95  // for unpack
96  __packed_struct(ps1_exe_hb_t)
97  LE32 ih_bkup[10];
98  // plus checksum for the backup
99  LE32 ih_csum;
100  __packed_struct_end()
101 
102  __packed_struct(ps1_exe_chb_t)
103  unsigned char id;
104  unsigned char len;
105  LE16 ih_csum;
106  unsigned char ih_bkup;
107  __packed_struct_end()
108 
109  __packed_struct(bss_nfo)
110  LE16 hi1, op1, lo1, op2;
111  LE16 hi2, op3, lo2, op4;
112  __packed_struct_end()
113 
114  ps1_exe_t ih, oh;
115  ps1_exe_hb_t bh;
116 
117  bool isCon;
118  bool is32Bit;
119  bool buildPart2;
120  bool foundBss;
121  unsigned ram_size;
122  unsigned sa_cnt, overlap;
123  unsigned sz_lunc, sz_lcpr;
124  unsigned pad_code;
125  unsigned bss_start, bss_end;
126  // filesize-PS_HDR_SIZE
127  unsigned fdata_size;
128 };
129 
130 
131 #endif /* already included */
132 
133 /* vim:set ts=4 sw=4 et: */
Definition: linker.h:35
Definition: options.h:45
Definition: file.h:89
Definition: p_ps1.h:41
Definition: packer.h:115
Definition: file.h:121
Definition: filter.h:53