diff --git a/src/Makefile b/src/Makefile index 3a9f9f9b..ce14d4b3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -64,7 +64,7 @@ OBJECTS1 = \ p_com$o p_djgpp2$o p_elks$o p_exe$o \ p_lx_elf$o p_lx_exc$o p_lx_sep$o p_lx_sh$o \ p_sys$o p_tmt$o p_tos$o \ - p_unix$o p_vmlinz$o p_w32pe$o p_wcle$o + p_unix$o p_vmlinz$o p_w16ne$o p_w32pe$o p_wcle$o # no exceptions or RTTI OBJECTS2 = \ diff --git a/src/p_w16ne.cpp b/src/p_w16ne.cpp new file mode 100644 index 00000000..80d3d703 --- /dev/null +++ b/src/p_w16ne.cpp @@ -0,0 +1,133 @@ +/* p_w16ne.cpp -- + + This file is part of the UPX executable compressor. + + Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2000 Laszlo Molnar + All Rights Reserved. + + UPX and the UCL library are free software; you can redistribute them + and/or modify them under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. + If not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Markus F.X.J. Oberhumer Laszlo Molnar + markus.oberhumer@jk.uni-linz.ac.at ml1050@cdata.tvnet.hu + */ + + +#include "conf.h" +#include "file.h" +#include "filter.h" +#include "packer.h" +#include "p_w16ne.h" + + +/************************************************************************* +// +**************************************************************************/ + +PackW16Ne::PackW16Ne(InputFile *f) : + super(f) +{ +} + + +int PackW16Ne::getCompressionMethod() const +{ + if (M_IS_NRV2B(opt->method)) + return M_NRV2B_8; + if (M_IS_NRV2D(opt->method)) + return M_NRV2D_8; + return opt->level > 1 && file_size >= 512*1024 ? M_NRV2D_8 : M_NRV2B_8; +} + + +const int *PackW16Ne::getFilters() const +{ + return NULL; +} + + +int PackW16Ne::buildLoader(const Filter *ft) +{ + // prepare loader +// initLoader(nrv_loader,sizeof(nrv_loader)); +// addLoader("..."); + if (ft->id) + { + assert(ft->calls > 0); +// addLoader("..."); + } +// + return getLoaderSize(); +} + + +/************************************************************************* +// +**************************************************************************/ + +bool PackW16Ne::readFileHeader() +{ + // FIXME: identify a win16/ne executable, so that the call + // for contribution below will get thrown + return false; +} + + +bool PackW16Ne::canPack() +{ + if (!readFileHeader()) + return false; + throwCantPack("win16/ne is not supported yet; your contribution is welcome"); + return false; +} + + +/************************************************************************* +// +**************************************************************************/ + +void PackW16Ne::pack(OutputFile *) +{ + throwCantPack("not yet implemented"); +} + + +/************************************************************************* +// +**************************************************************************/ + +int PackW16Ne::canUnpack() +{ + if (!readFileHeader()) + return false; + return false; +} + + +/************************************************************************* +// +**************************************************************************/ + +void PackW16Ne::unpack(OutputFile *) +{ + throwCantUnpack("not yet implemented"); +} + + +/* +vi:ts=4:et +*/ + diff --git a/src/p_w16ne.h b/src/p_w16ne.h new file mode 100644 index 00000000..44ee8a4e --- /dev/null +++ b/src/p_w16ne.h @@ -0,0 +1,66 @@ +/* p_w16ne.h -- + + This file is part of the UPX executable compressor. + + Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2000 Laszlo Molnar + All Rights Reserved. + + UPX and the UCL library are free software; you can redistribute them + and/or modify them under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. + If not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Markus F.X.J. Oberhumer Laszlo Molnar + markus.oberhumer@jk.uni-linz.ac.at ml1050@cdata.tvnet.hu + */ + + +#ifndef __UPX_P_W16NE_H +#define __UPX_P_W16NE_H + + +/************************************************************************* +// win16/ne +**************************************************************************/ + +class PackW16Ne : public Packer +{ + typedef Packer super; +public: + PackW16Ne(InputFile *f); + virtual int getVersion() const { return 11; } + virtual int getFormat() const { return UPX_F_WIN16_NE; } + virtual const char *getName() const { return "win16/ne"; } + virtual int getCompressionMethod() const; + virtual const int *getFilters() const; + + virtual void pack(OutputFile *fo); + virtual void unpack(OutputFile *fo); + + virtual bool canPack(); + virtual int canUnpack(); + +protected: + virtual bool readFileHeader(void); + virtual int buildLoader(const Filter *ft); +}; + + +#endif /* already included */ + + +/* +vi:ts=4:et +*/ + diff --git a/src/p_w32pe.h b/src/p_w32pe.h index 499458e4..c08fbbdd 100644 --- a/src/p_w32pe.h +++ b/src/p_w32pe.h @@ -48,7 +48,7 @@ public: PackW32Pe(InputFile *f); ~PackW32Pe(); virtual int getVersion() const { return 12; } - virtual int getFormat() const { return UPX_F_W32_PE; } + virtual int getFormat() const { return UPX_F_WIN32_PE; } virtual const char *getName() const { return isrtm ? "rtm32/pe" : "win32/pe"; } virtual int getCompressionMethod() const; virtual const int *getFilters() const; diff --git a/src/packmast.cpp b/src/packmast.cpp index 54d61c42..ef934ae2 100644 --- a/src/packmast.cpp +++ b/src/packmast.cpp @@ -46,6 +46,7 @@ #include "p_wcle.h" #include "p_tmt.h" #include "p_vxd.h" +#include "p_w16ne.h" #include "p_w32pe.h" #include "p_vmlinz.h" @@ -162,6 +163,8 @@ static Packer* try_packers(InputFile *f, try_function func) if ((p = func(new PackVxd(f),f)) != NULL) return p; #endif + if ((p = func(new PackW16Ne(f),f)) != NULL) + return p; if ((p = func(new PackW32Pe(f),f)) != NULL) return p; } diff --git a/src/unupx.h b/src/unupx.h index b5656844..570b1a95 100644 --- a/src/unupx.h +++ b/src/unupx.h @@ -74,9 +74,9 @@ typedef unsigned upx_uint32; #define UPX_F_VXD_LE 6 #define UPX_F_DOS_EXEH 7 /* OBSOLETE */ #define UPX_F_TMT_ADAM 8 -#define UPX_F_W32_PE 9 +#define UPX_F_WIN32_PE 9 #define UPX_F_LINUX_i386 10 - /* UNUSED */ +#define UPX_F_WIN16_NE 11 #define UPX_F_LINUX_ELF_i386 12 #define UPX_F_LINUX_SEP_i386 13 #define UPX_F_LINUX_SH_i386 14