diff --git a/BUGS b/BUGS index e2e49fa9..63118845 100644 --- a/BUGS +++ b/BUGS @@ -8,7 +8,7 @@ The Ultimate Packer for eXecutables - Copyright (c) 1996-2000 Markus Oberhumer & Laszlo Molnar + Copyright (c) 1996-2001 Markus Oberhumer & Laszlo Molnar http://wildsau.idv.uni-linz.ac.at/mfx/upx.html http://upx.tsx.org diff --git a/Makefile b/Makefile index 359b4c13..20cfb358 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,10 @@ mostlyclean clean distclean maintainer-clean: dist: distclean false +zip: + cd .. && rm -f upx-currenz.zip && zip -r upx-current.zip upx + + cvs-admin-ko: cvs admin -ko . cvs update diff --git a/NEWS b/NEWS index c0b75a20..a68b001a 100644 --- a/NEWS +++ b/NEWS @@ -2,8 +2,14 @@ User visible changes for UPX ================================================================== +Changes in 1.12 beta (XX Jan 2001): + * UNSTABLE BETA VERSION - DO NOT USE EXCEPT FOR TESTING + * implemented several new options for finer compression control: + `--all-methods', `--all-filters' and `--brute' + * linux/386: added the option `--force-execve' + Changes in 1.11 beta (20 Dec 2000): - * UNSTABLE BETA VERSION - DO NOT USE EXCEPT FOR TESTING!!! REALLY. + * UNSTABLE BETA VERSION - DO NOT USE EXCEPT FOR TESTING * vmlinuz/386: new format - UPX now supports bootable linux kernels * linux/386: added the new direct-to-memory executable formats - no more temp files are needed for decompression! @@ -188,7 +194,7 @@ Changes in 0.60 (06 Mar 1999) * fixed a bug which could make UPX hang when an exe header contained an illegal value * added some compression flags for the win32/pe format - * added support for Atari ST executables (atari/tos) + * added support for Atari ST/TT executables (atari/tos) * improved compression ratio * improved compression speed diff --git a/PROJECTS b/PROJECTS index 5b0074a1..8043cc9e 100644 --- a/PROJECTS +++ b/PROJECTS @@ -8,7 +8,7 @@ The Ultimate Packer for eXecutables - Copyright (c) 1996-2000 Markus Oberhumer & Laszlo Molnar + Copyright (c) 1996-2001 Markus Oberhumer & Laszlo Molnar http://wildsau.idv.uni-linz.ac.at/mfx/upx.html http://upx.tsx.org diff --git a/README b/README index 2668fa9e..37fa482f 100644 --- a/README +++ b/README @@ -8,7 +8,7 @@ The Ultimate Packer for eXecutables - Copyright (c) 1996-2000 Markus Oberhumer & Laszlo Molnar + Copyright (c) 1996-2001 Markus Oberhumer & Laszlo Molnar http://wildsau.idv.uni-linz.ac.at/mfx/upx.html http://upx.tsx.org @@ -126,8 +126,8 @@ THE FUTURE COPYRIGHT ========= -Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -Copyright (C) 1996-2000 Laszlo Molnar +Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +Copyright (C) 1996-2001 Laszlo Molnar This program may be used freely, and you are welcome to redistribute it under certain conditions. diff --git a/THANKS b/THANKS index e042ebef..d9861f86 100644 --- a/THANKS +++ b/THANKS @@ -8,7 +8,7 @@ The Ultimate Packer for eXecutables - Copyright (c) 1996-2000 Markus Oberhumer & Laszlo Molnar + Copyright (c) 1996-2001 Markus Oberhumer & Laszlo Molnar http://wildsau.idv.uni-linz.ac.at/mfx/upx.html http://upx.tsx.org diff --git a/TODO b/TODO index d831ffb2..fcf573b5 100644 --- a/TODO +++ b/TODO @@ -64,8 +64,6 @@ FORMAT TMT/ADAM - the decompressors are already aligned, no need for an extra alignment -- verify that compressWithFilters() works - FORMAT WATCOM/LE ================ diff --git a/doc/Makefile b/doc/Makefile index c7aaa139..b2f31796 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -3,14 +3,14 @@ SHELL = /bin/sh top_srcdir = .. PACKAGE = upx -VERSION_DATE = 30 Dec 2000 +VERSION_DATE = 02 Jan 2001 VERSION := $(shell sed -n 's/^.*UPX_VERSION_STRING.*"\(.*\)".*/\1/p' $(top_srcdir)/src/version.h) TRIMSPACE = cat TRIMSPACE = sed -e 's/ *$$//' BUILT_SOURCES = upx.1 upx.doc upx.html upx.man upx.ps upx.tex -BUILT_SOURCES = upx.1 upx.doc upx.html upx.man +BUILT_SOURCES = upx.1 upx.doc upx.html ### diff --git a/doc/upx.pod b/doc/upx.pod index 0aecc67a..8535090c 100644 --- a/doc/upx.pod +++ b/doc/upx.pod @@ -12,11 +12,11 @@ B S<[ I ]> S<[ I ]> I... =head1 ABSTRACT - The Ultimate Packer for eXecutables - Copyright (c) 1996, 1997, 1998, 1999, 2000 + The Ultimate Packer for eXecutables + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Markus F.X.J. Oberhumer, Laszlo Molnar & John F. Reiser - http://wildsau.idv.uni-linz.ac.at/mfx/upx.html - http://upx.tsx.org + http://wildsau.idv.uni-linz.ac.at/mfx/upx.html + http://upx.tsx.org B is a portable, extendable, high-performance executable packer for @@ -178,17 +178,24 @@ squeezes out even some more compression ratio. While it is usually fine to use this option with your favorite .com file it may take a long time to compress a multi-megabyte program. You have been warned. -Tips for even better compression: +Tips for achieving the best compression ratio: =over 4 =item * -Try if B<--overlay=strip> works. +Use the compression level B<--best>. =item * -Try B<--all-filters>. +Try one or both of the options B<--all-methods> and B<--all-filters>. + +Info: the option B<--brute> is an abbrevation for all the options +B S<--all-methods> S<--all-filters>>. + +=item * + +Try if B<--overlay=strip> works. =item * @@ -277,6 +284,16 @@ Extra options available for this executable format: --8086 Create an executable that works on any 8086 CPU. + --all-methods Compress the program several times, using all + available compression methods. This may improve + the compression ratio in some cases, but usually + the default method gives the best results anyway. + + --all-filters Compress the program several times, using all + available preprocessing filters. This may improve + the compression ratio in some cases, but usually + the default filter gives the best results anyway. + =head2 NOTES FOR DOS/EXE @@ -294,6 +311,11 @@ Extra options available for this executable format: --no-reloc Use no relocation records in the exe header. + --all-methods Compress the program several times, using all + available compression methods. This may improve + the compression ratio in some cases, but usually + the default method gives the best results anyway. + =head2 NOTES FOR DOS/SYS @@ -311,6 +333,16 @@ Extra options available for this executable format: --8086 Create an executable that works on any 8086 CPU. + --all-methods Compress the program several times, using all + available compression methods. This may improve + the compression ratio in some cases, but usually + the default method gives the best results anyway. + + --all-filters Compress the program several times, using all + available preprocessing filters. This may improve + the compression ratio in some cases, but usually + the default filter gives the best results anyway. + =head2 NOTES FOR DJGPP2/COFF @@ -338,10 +370,15 @@ Extra options available for this executable format: --coff Produce COFF output instead of EXE. By default UPX keeps your current stub. - --all-filters Compress the program several times, using different - preprocessing filters. This may improve the compression - ratio in some cases, but usually the default filter - gives the best results anyway. + --all-methods Compress the program several times, using all + available compression methods. This may improve + the compression ratio in some cases, but usually + the default method gives the best results anyway. + + --all-filters Compress the program several times, using all + available preprocessing filters. This may improve + the compression ratio in some cases, but usually + the default filter gives the best results anyway. @@ -649,10 +686,15 @@ This format is used by the TMT Pascal compiler - see http://www.tmt.com/ . Extra options available for this executable format: - --all-filters Compress the program several times, using different - preprocessing filters. This may improve the compression - ratio in some cases, but usually the default filter - gives the best results anyway. + --all-methods Compress the program several times, using all + available compression methods. This may improve + the compression ratio in some cases, but usually + the default method gives the best results anyway. + + --all-filters Compress the program several times, using all + available preprocessing filters. This may improve + the compression ratio in some cases, but usually + the default filter gives the best results anyway. @@ -691,10 +733,15 @@ Drawbacks: Extra options available for this executable format: - --all-filters Compress the program several times, using different - preprocessing filters. This may improve the compression - ratio in some cases, but usually the default filter - gives the best results anyway. + --all-methods Compress the program several times, using all + available compression methods. This may improve + the compression ratio in some cases, but usually + the default method gives the best results anyway. + + --all-filters Compress the program several times, using all + available preprocessing filters. This may improve + the compression ratio in some cases, but usually + the default filter gives the best results anyway. @@ -770,10 +817,15 @@ Extra options available for this executable format: UPX never strips relocations from a DLL regardless of this option. - --all-filters Compress the program several times, using different - preprocessing filters. This may improve the compression - ratio in some cases, but usually the default filter - gives the best results anyway. + --all-methods Compress the program several times, using all + available compression methods. This may improve + the compression ratio in some cases, but usually + the default method gives the best results anyway. + + --all-filters Compress the program several times, using all + available preprocessing filters. This may improve + the compression ratio in some cases, but usually + the default filter gives the best results anyway. @@ -805,11 +857,11 @@ Please report all bugs immediately to the authors. =head1 COPYRIGHT -Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer +Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer -Copyright (C) 1996-2000 Laszlo Molnar +Copyright (C) 1996-2001 Laszlo Molnar -Copyright (C) 2000 John Reiser +Copyright (C) 2000-2001 John F. Reiser This program may be used freely, and you are welcome to redistribute it under certain conditions. diff --git a/src/Makefile b/src/Makefile index ce14d4b3..c7683da7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -178,7 +178,8 @@ ifeq (1,2) # checkergcc else ifeq ($(DEBUG),1) ##CFLAGS += -O0 -gstabs+3 - CFLAGS += -O0 -gdwarf-2 + ##CFLAGS += -O0 -gdwarf-2 + CFLAGS += -O0 -g else ##LDFLAGS += -static STUBEDIT_EXE = objcopy -S -R .comment -R .note $@ && perl $(srcdir)/stub/scripts/brandelf.pl $@ && chmod 755 $@ diff --git a/src/bele.h b/src/bele.h index 9e9d35d4..ea4b25f3 100644 --- a/src/bele.h +++ b/src/bele.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/c_file.cpp b/src/c_file.cpp index f2d076b8..9e02bd53 100644 --- a/src/c_file.cpp +++ b/src/c_file.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/c_init.cpp b/src/c_init.cpp index 1362607d..8ecf18eb 100644 --- a/src/c_init.cpp +++ b/src/c_init.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/c_none.cpp b/src/c_none.cpp index 60923020..966d6538 100644 --- a/src/c_none.cpp +++ b/src/c_none.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/c_screen.cpp b/src/c_screen.cpp index 67399945..3786cdf8 100644 --- a/src/c_screen.cpp +++ b/src/c_screen.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/compress.cpp b/src/compress.cpp index 5bfb7197..53480eda 100644 --- a/src/compress.cpp +++ b/src/compress.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/conf.h b/src/conf.h index 8484cc65..7b178d0b 100644 --- a/src/conf.h +++ b/src/conf.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -459,9 +459,9 @@ struct options_t { // compression options int method; int level; // compression level 1..10 - int mem_level; // memory level 1..9 int filter; // preferred filter from Packer::getFilters() - bool all_filters; // try all filters ? + bool all_methods; // try all available compression methods ? + bool all_filters; // try all available filters ? // other options int backup; diff --git a/src/console.h b/src/console.h index c1bddfc3..b5a113a3 100644 --- a/src/console.h +++ b/src/console.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/except.cpp b/src/except.cpp index 50390b12..a4f68906 100644 --- a/src/except.cpp +++ b/src/except.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -135,10 +135,14 @@ void throwEOFException(const char *msg, int e) const char *prettyName(const char *n) { - while (*n >= '0' && *n <= '9') // gcc / egcs +#if defined(__GNUC__) + while (*n >= '0' && *n <= '9') // gcc n++; +#endif +#if defined(_MSC_VER) if (strncmp(n, "class ", 6) == 0) // Visual C++ n += 6; +#endif return n; } diff --git a/src/except.h b/src/except.h index 7a4a593a..f848134b 100644 --- a/src/except.h +++ b/src/except.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/fcto_ml.ch b/src/fcto_ml.ch index ecad6aec..88942786 100644 --- a/src/fcto_ml.ch +++ b/src/fcto_ml.ch @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/fcto_ml2.ch b/src/fcto_ml2.ch index 49d0a286..e088f42c 100644 --- a/src/fcto_ml2.ch +++ b/src/fcto_ml2.ch @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/fcto_ml3.ch b/src/fcto_ml3.ch index 0683bfb1..b213d5af 100644 --- a/src/fcto_ml3.ch +++ b/src/fcto_ml3.ch @@ -2,9 +2,9 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar - Copyright (C) 2000 John F. Reiser + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar + Copyright (C) 2000-2001 John F. Reiser All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/file.cpp b/src/file.cpp index c08af3bc..cbb2b160 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -171,7 +171,11 @@ void FileBase::write(const void *buf, int len) void FileBase::seek(off_t off, int whence) { if (!isOpen()) - throwIOException("bad seek"); + throwIOException("bad seek 1"); + if (whence == SEEK_SET && off < 0) + throwIOException("bad seek 2"); + if (whence == SEEK_END && off > 0) + throwIOException("bad seek 3"); if (::lseek(_fd,off,whence) < 0) throwIOException("seek error",errno); } diff --git a/src/file.h b/src/file.h index c0a5fff1..2806126a 100644 --- a/src/file.h +++ b/src/file.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/filter.cpp b/src/filter.cpp index d2182988..59f4c1a3 100644 --- a/src/filter.cpp +++ b/src/filter.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -129,7 +129,7 @@ bool Filter::filter(upx_byte *buf_, unsigned buf_len_) } -bool Filter::unfilter(upx_byte *buf_, unsigned buf_len_, bool verify_checksum) +void Filter::unfilter(upx_byte *buf_, unsigned buf_len_, bool verify_checksum) { initFilter(this, buf_, buf_len_); @@ -137,11 +137,11 @@ bool Filter::unfilter(upx_byte *buf_, unsigned buf_len_, bool verify_checksum) if (fe == NULL) throwInternalError("unfilter-1"); if (fe->id == 0) - return true; + return; if (buf_len < fe->min_buf_len) - return false; + return; if (fe->max_buf_len && buf_len > fe->max_buf_len) - return false; + return; if (!fe->do_unfilter) throwInternalError("unfilter-2"); @@ -158,12 +158,10 @@ bool Filter::unfilter(upx_byte *buf_, unsigned buf_len_, bool verify_checksum) if (this->adler != upx_adler32(a, this->buf, this->buf_len)) throwInternalError("unfilter-4"); } - - return true; } -bool Filter::verifyUnfilter() +void Filter::verifyUnfilter() { // Note: // This verify is just because of complete paranoia that there @@ -175,9 +173,8 @@ bool Filter::verifyUnfilter() // Packer::verifyOverlappingDecompression() //printf("verifyUnfilter: %02x %p %d\n", this->id, this->buf, this->buf_len); - if (clevel == 1) - return true; - return unfilter(this->buf, this->buf_len, true); + if (clevel != 1) + unfilter(this->buf, this->buf_len, true); } diff --git a/src/filter.h b/src/filter.h index 4ed896e0..3535a6da 100644 --- a/src/filter.h +++ b/src/filter.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -44,8 +44,7 @@ class FilterImp; // call throwFilterException() - this will cause the compression // to fail. // -// The return value of unfilters can/should be ignored. They throw -// exceptions in case of errors. +// Unfilters throw exceptions in case of errors. // // The main idea behind filters is to convert relative jumps and calls // to absolute addresses so that the buffer compresses better. @@ -58,8 +57,8 @@ public: void init(int id=0, unsigned addvalue=0); bool filter(upx_byte *buf, unsigned buf_len); - bool unfilter(upx_byte *buf, unsigned buf_len, bool verify_checksum=false); - bool verifyUnfilter(); + void unfilter(upx_byte *buf, unsigned buf_len, bool verify_checksum=false); + void verifyUnfilter(); bool scan(const upx_byte *buf, unsigned buf_len); public: diff --git a/src/filteri.cpp b/src/filteri.cpp index 7b07c143..d6e81705 100644 --- a/src/filteri.cpp +++ b/src/filteri.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/help.cpp b/src/help.cpp index 06c4951e..4b1ef94c 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -48,7 +48,7 @@ void show_head(void) fg = con_fg(f,FG_GREEN); con_fprintf(f, " Ultimate Packer for eXecutables\n" - " Copyright (C) 1996, 1997, 1998, 1999, 2000\n" + " Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001\n" "UPX v%-12sMarkus F.X.J. Oberhumer & Laszlo Molnar%21s\n\n", UPX_VERSION_STRING, UPX_VERSION_DATE); fg = con_fg(f,fg); @@ -137,12 +137,16 @@ void show_help(int x) fg = con_fg(f,fg); con_fprintf(f, " --coff produce COFF output [default: EXE]\n" + " --all-methods try all available compression methods\n" + " --all-filters try all available preprocessing filters\n" "\n"); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Options for dos/com:\n"); fg = con_fg(f,fg); con_fprintf(f, " --8086 make compressed com work on any 8086\n" + " --all-methods try all available compression methods\n" + " --all-filters try all available preprocessing filters\n" "\n"); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Options for dos/exe:\n"); @@ -150,13 +154,43 @@ void show_help(int x) con_fprintf(f, " --8086 make compressed exe work on any 8086\n" " --no-reloc put no relocations in to the exe header\n" + " --all-methods try all available compression methods\n" "\n"); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Options for dos/sys:\n"); fg = con_fg(f,fg); con_fprintf(f, " --8086 make compressed sys work on any 8086\n" + " --all-methods try all available compression methods\n" + " --all-filters try all available preprocessing filters\n" "\n"); +#if 0 + fg = con_fg(f,FG_YELLOW); + con_fprintf(f,"Options for linux/386\n"); + fg = con_fg(f,fg); + con_fprintf(f, + " --script use /usr/local/lib/upx/upx[bd] as decompressor\n" + " --script=/path/upxX use path/upxX as decompressor\n" + "\n"); +#endif +#if 1 + fg = con_fg(f,FG_YELLOW); + con_fprintf(f,"Options for tmt/adam:\n"); + fg = con_fg(f,fg); + con_fprintf(f, + " --all-methods try all available compression methods\n" + " --all-filters try all available preprocessing filters\n" + "\n"); +#endif +#if 1 + fg = con_fg(f,FG_YELLOW); + con_fprintf(f,"Options for [b]vmlinuz/386\n"); + fg = con_fg(f,fg); + con_fprintf(f, + " --all-methods try all available compression methods\n" + " --all-filters try all available preprocessing filters\n" + "\n"); +#endif fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Options for watcom/le:\n"); fg = con_fg(f,fg); @@ -175,28 +209,25 @@ void show_help(int x) " --compress-resources=0 do not compress any resources at all\n" " --strip-relocs=0 do not strip relocations\n" " --strip-relocs=1 strip relocations [default]\n" + " --all-methods try all available compression methods\n" + " --all-filters try all available preprocessing filters\n" "\n"); -#if 0 - fg = con_fg(f,FG_YELLOW); - con_fprintf(f,"Options for linux/386\n"); - fg = con_fg(f,fg); - con_fprintf(f, - " --script use /usr/local/lib/upx/upx[bd] as decompressor\n" - " --script=/path/upxX use path/upxX as decompressor\n" - "\n"); -#endif } con_fprintf(f, - " file.. executables to (de)compress\n" - "\n" - "This version supports:\n " + "file.. executables to (de)compress\n" + "\n"); + fg = con_fg(f,FG_YELLOW); + con_fprintf(f,"This version supports:\n"); + fg = con_fg(f,fg); + con_fprintf(f," " "atari/tos, " "bvmlinuz/386, " "djgpp2/coff, " "dos/com, " "dos/exe, " "dos/sys,\n " + //"elks/8086, " "linux/386, " "linux/elf386, " "linux/sh386, " @@ -204,6 +235,7 @@ void show_help(int x) "tmt/adam, " "vmlinuz/386,\n " "watcom/le, " + //"win16/ne, " "win32/pe" "\n\nUPX comes with ABSOLUTELY NO WARRANTY; for details visit http://upx.tsx.org\n" //"\n\nUPX comes with ABSOLUTELY NO WARRANTY; for details type `upx -L'.\n" @@ -280,9 +312,9 @@ void show_version(int x) #if defined(WITH_UCL) fprintf(f,"UCL data compression library %s\n", ucl_version_string()); #endif - fprintf(f,"Copyright (C) 1996,1997,1998,1999,2000 Markus Franz Xaver Johannes Oberhumer\n"); - fprintf(f,"Copyright (C) 1996,1997,1998,1999,2000 Laszlo Molnar\n"); - fprintf(f,"Copyright (C) 2000 John F. Reiser\n"); + fprintf(f,"Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer\n"); + fprintf(f,"Copyright (C) 1996-2001 Laszlo Molnar\n"); + fprintf(f,"Copyright (C) 2000-2001 John F. Reiser\n"); fprintf(f,"UPX comes with ABSOLUTELY NO WARRANTY; for details type `%s -L'.\n", progname); } diff --git a/src/lefile.cpp b/src/lefile.cpp index bb5dbd85..95ddf08b 100644 --- a/src/lefile.cpp +++ b/src/lefile.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/lefile.h b/src/lefile.h index b2e53839..eae6250c 100644 --- a/src/lefile.h +++ b/src/lefile.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/linker.cpp b/src/linker.cpp index 43859b02..f6965e01 100644 --- a/src/linker.cpp +++ b/src/linker.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/linker.h b/src/linker.h index 13f08f60..b48c6eee 100644 --- a/src/linker.h +++ b/src/linker.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/main.cpp b/src/main.cpp index c78f583a..8ff43113 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -30,6 +30,7 @@ #include "version.h" #include "mygetopt.h" #include "file.h" +#include "packer.h" /************************************************************************* @@ -44,7 +45,6 @@ void init_options(struct options_t *o) o->cmd = CMD_NONE; o->method = -1; o->level = -1; - o->mem_level = -1; o->filter = -1; o->backup = -1; @@ -271,7 +271,12 @@ static void set_cmd(int cmd) static bool set_method(int m, int l) { if (m > 0) + { + if (!Packer::isValidCompressionMethod(m)) + return false; opt->method = m; + opt->all_methods = false; + } if (l > 0) opt->level = l; set_cmd(CMD_COMPRESS); @@ -417,7 +422,7 @@ static int do_option(int optc, const char *arg) case 'f': opt->force++; break; - case 901: + case 902: set_cmd(CMD_FILEINFO); break; case 'h': @@ -426,9 +431,11 @@ static int do_option(int optc, const char *arg) set_cmd(CMD_HELP); break; case 'h'+256: +#if 0 /* according to GNU standards */ set_term(stdout); opt->console = CON_FILE; +#endif show_help(1); e_exit(EXIT_OK); break; @@ -487,16 +494,18 @@ static int do_option(int optc, const char *arg) if (!set_method(-1, optc - '0')) e_method(opt->method, optc); break; - case 900: + + case 901: // --brute + opt->all_methods = true; + opt->method = -1; + opt->all_filters = true; + opt->filter = -1; + /* fallthrough */ + case 900: // --best if (!set_method(-1, 10)) e_method(opt->method, 10); break; - // compression memory level - case 902: - getoptvar(&opt->mem_level, 1, 9); - break; - // misc case 512: opt->console = CON_FILE; @@ -525,6 +534,9 @@ static int do_option(int optc, const char *arg) opt->all_filters = true; opt->filter = -1; break; + case 528: + opt->all_methods = true; + opt->method = -1; // compression parms case 531: getoptvar(&opt->crp.c_flags, 0, 3); @@ -665,10 +677,11 @@ static int get_options(int argc, char **argv) static const struct mfx_option longopts[] = { // commands - {"best", 0, 0, 900}, // compress best + {"best", 0x10, 0, 900}, // compress best + {"brute", 0x10, 0, 901}, // compress best, brute force {"decompress", 0, 0, 'd'}, // decompress - {"fast", 0, 0, '1'}, // compress faster - {"fileinfo", 0x10, 0, 901}, // display info about file + {"fast", 0x10, 0, '1'}, // compress faster + {"fileinfo", 0x10, 0, 902}, // 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 @@ -722,8 +735,8 @@ static const struct mfx_option longopts[] = {"nrv2d", 0x10, 0, 704}, // --nrv2d // compression settings {"all-filters", 0x10, 0, 527}, + {"all-methods", 0x10, 0, 528}, {"filter", 0x31, 0, 526}, // --filter= - {"mem", 0x31, 0, 902}, // --mem= {"small", 0x10, 0, 525}, // compression runtime parameters {"crp-cf", 0x31, 0, 531}, @@ -785,8 +798,9 @@ static void get_envoptions(int argc, char **argv) static const struct mfx_option longopts[] = { // commands - {"best", 0, 0, 900}, // compress best - {"fast", 0, 0, '1'}, // compress faster + {"best", 0x10, 0, 900}, // compress best + {"brute", 0x10, 0, 901}, // compress best, brute force + {"fast", 0x10, 0, '1'}, // compress faster // options {"info", 0, 0, 'i'}, // info mode @@ -1111,7 +1125,6 @@ int main(int argc, char *argv[]) // invalidate compression options opt->method = 0; opt->level = 0; - opt->mem_level = 0; memset(&opt->crp, 0xff, sizeof(opt->crp)); } diff --git a/src/mem.cpp b/src/mem.cpp index 72f138d9..1dd1d9ec 100644 --- a/src/mem.cpp +++ b/src/mem.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/mem.h b/src/mem.h index 77453aec..1fb1a800 100644 --- a/src/mem.h +++ b/src/mem.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/msg.cpp b/src/msg.cpp index c104e9d6..272a53e6 100644 --- a/src/msg.cpp +++ b/src/msg.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/p_com.cpp b/src/p_com.cpp index 9c24104b..883f25b1 100644 --- a/src/p_com.cpp +++ b/src/p_com.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -44,16 +44,19 @@ static const // **************************************************************************/ -int PackCom::getCompressionMethod() const +const int *PackCom::getCompressionMethods(int method, int level) const { - if (M_IS_NRV2B(opt->method)) - return M_NRV2B_LE16; + static const int m_nrv2b[] = { M_NRV2B_LE16, -1 }; + if (M_IS_NRV2B(method)) + return m_nrv2b; #if 0 // NOT IMPLEMENTED - if (M_IS_NRV2D(opt->method)) - return M_NRV2D_LE16; + static const int m_nrv2d[] = { M_NRV2D_LE16, -1 }; + if (M_IS_NRV2D(method)) + return m_nrv2d; #endif - return M_NRV2B_LE16; + UNUSED(level); + return m_nrv2b; } @@ -191,23 +194,12 @@ void PackCom::pack(OutputFile *fo) // prepare packheader ph.u_len = file_size; - ph.filter = 0; // prepare filter - Filter ft(opt->level); + Filter ft(ph.level); ft.addvalue = getCallTrickOffset(); - - int strategy = -1; // try the first working filter - if (opt->filter >= 0 && isValidFilter(opt->filter)) - // try opt->filter or 0 if that fails - strategy = -2; - else if (opt->all_filters || opt->level > 9) - // choose best from all available filters - strategy = 0; - else if (opt->level == 9) - // choose best from the first 4 filters - strategy = 4; + // compress const unsigned overlap_range = ph.u_len < 0xFE00 - ft.addvalue ? 32 : 0; - compressWithFilters(&ft, overlap_range, strategy); + compressWithFilters(&ft, overlap_range); const int lsize = getLoaderSize(); MemBuffer loader(lsize); diff --git a/src/p_com.h b/src/p_com.h index 10ffbeca..0af6b681 100644 --- a/src/p_com.h +++ b/src/p_com.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -42,7 +42,7 @@ public: virtual int getVersion() const { return 11; } virtual int getFormat() const { return UPX_F_DOS_COM; } virtual const char *getName() const { return "dos/com"; } - virtual int getCompressionMethod() const; + virtual const int *getCompressionMethods(int method, int level) const; virtual const int *getFilters() const; virtual void pack(OutputFile *fo); diff --git a/src/p_djgpp2.cpp b/src/p_djgpp2.cpp index bc468fda..4ab703c5 100644 --- a/src/p_djgpp2.cpp +++ b/src/p_djgpp2.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -50,15 +50,21 @@ PackDjgpp2::PackDjgpp2(InputFile *f) : } -int PackDjgpp2::getCompressionMethod() const +const int *PackDjgpp2::getCompressionMethods(int method, int level) const { - if (M_IS_NRV2B(opt->method)) - return M_NRV2B_LE32; - if (M_IS_NRV2D(opt->method)) - return M_NRV2D_LE32; - return opt->level > 1 && file_size >= 512*1024 ? M_NRV2D_LE32 : M_NRV2B_LE32; + static const int m_nrv2b[] = { M_NRV2B_LE32, M_NRV2D_LE32, -1 }; + static const int m_nrv2d[] = { M_NRV2D_LE32, M_NRV2B_LE32, -1 }; + + if (M_IS_NRV2B(method)) + return m_nrv2b; + if (M_IS_NRV2D(method)) + return m_nrv2d; + if (level == 1 || file_size <= 512*1024) + return m_nrv2b; + return m_nrv2d; } + const int *PackDjgpp2::getFilters() const { static const int filters[] = { 0x26, 0x24, 0x11, 0x14, 0x13, 0x16, @@ -277,43 +283,14 @@ void PackDjgpp2::pack(OutputFile *fo) fi->seek(coff_offset+tpos,SEEK_SET); fi->readx(ibuf + (tpos & 0x1ff),size); -#if 0 - // filter - Filter ft(opt->level); - tryFilters(&ft, ibuf, usize - data->size, text->vaddr & ~0x1ff); - - // compress - ph.filter = ft.id; - ph.filter_cto = ft.cto; - ph.u_len = usize; - if (!compress(ibuf,obuf)) - throwNotCompressible(); - - ph.overlap_overhead = findOverlapOverhead(obuf,ibuf,512); - buildLoader(&ft); - - // verify filter - ft.verifyUnfilter(); -#else - // new version using compressWithFilters() - // prepare packheader ph.u_len = usize; - ph.filter = 0; // prepare filter - Filter ft(opt->level); + Filter ft(ph.level); ft.buf_len = usize - data->size; ft.addvalue = text->vaddr & ~0x1ff; - - int strategy = -1; // try the first working filter - if (opt->filter >= 0 && isValidFilter(opt->filter)) - // try opt->filter or 0 if that fails - strategy = -2; - else if (opt->all_filters) - // choose best from all available filters - strategy = 0; - compressWithFilters(&ft, 512, strategy); -#endif + // compress + compressWithFilters(&ft, 512); // patch coff header #2 const unsigned lsize = getLoaderSize(); diff --git a/src/p_djgpp2.h b/src/p_djgpp2.h index 227716c7..120f820b 100644 --- a/src/p_djgpp2.h +++ b/src/p_djgpp2.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -43,7 +43,7 @@ public: virtual int getVersion() const { return 11; } virtual int getFormat() const { return UPX_F_DJGPP2_COFF; } virtual const char *getName() const { return "djgpp2/coff"; } - virtual int getCompressionMethod() const; + virtual const int *getCompressionMethods(int method, int level) const; virtual const int *getFilters() const; virtual void pack(OutputFile *fo); diff --git a/src/p_elf.h b/src/p_elf.h index 9e0b0880..2415f971 100644 --- a/src/p_elf.h +++ b/src/p_elf.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/p_elks.cpp b/src/p_elks.cpp index 25657170..d47bc69f 100644 --- a/src/p_elks.cpp +++ b/src/p_elks.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -49,13 +49,13 @@ static const unsigned zimage_offset = 0x1000; // **************************************************************************/ -int PackElks8086::getCompressionMethod() const +const int *PackElks8086::getCompressionMethods(int method, int level) const { - if (M_IS_NRV2B(opt->method)) + if (M_IS_NRV2B(method)) return M_NRV2B_8; - if (M_IS_NRV2D(opt->method)) + if (M_IS_NRV2D(method)) return M_NRV2D_8; - return opt->level > 1 ? M_NRV2D_8 : M_NRV2B_8; + return level > 1 ? M_NRV2D_8 : M_NRV2B_8; } @@ -113,18 +113,11 @@ void PackElks8086::pack(OutputFile *fo) readKernel(); // prepare filter - Filter ft(opt->level); + Filter ft(ph.level); ft.buf_len = ph.u_len; ft.addvalue = kernel_entry; - - int strategy = -1; // try the first working filter - if (opt->filter >= 0 && isValidFilter(opt->filter)) - // try opt->filter or 0 if that fails - strategy = -2; - else if (opt->all_filters) - // choose best from all available filters - strategy = 0; - compressWithFilters(&ft, overlap_range, strategy); + // compress + compressWithFilters(&ft, overlap_range); const unsigned lsize = getLoaderSize(); MemBuffer loader(lsize); diff --git a/src/p_exe.cpp b/src/p_exe.cpp index 316e5625..1935daf2 100644 --- a/src/p_exe.cpp +++ b/src/p_exe.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -54,13 +54,18 @@ PackExe::PackExe(InputFile *f) : } -int PackExe::getCompressionMethod() const +const int *PackExe::getCompressionMethods(int method, int level) 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 && ih_imagesize >= 300000 ? M_NRV2D_8 : M_NRV2B_8; + static const int m_nrv2b[] = { M_NRV2B_8, M_NRV2D_8, -1 }; + static const int m_nrv2d[] = { M_NRV2D_8, M_NRV2B_8, -1 }; + + if (M_IS_NRV2B(method)) + return m_nrv2b; + if (M_IS_NRV2D(method)) + return m_nrv2d; + if (level == 1 || ih_imagesize <= 256*1024) + return m_nrv2b; + return m_nrv2d; } @@ -390,11 +395,12 @@ void PackExe::pack(OutputFile *fo) relocsize = 0; } - Filter ft(opt->level); - + // prepare packheader ph.u_len = ih_imagesize + relocsize; - if (!compress(ibuf,obuf,0,MAXMATCH)) - throwNotCompressible(); + // prepare filter + Filter ft(ph.level); + // compress + compressWithFilters(&ft, 32, 0, NULL, 0, MAXMATCH); if (ph.max_run_found + ph.max_match_found > 0x8000) throwCantPack("decompressor limit exceeded, send a bugreport"); @@ -409,10 +415,9 @@ void PackExe::pack(OutputFile *fo) } #endif - ph.overlap_overhead = findOverlapOverhead(obuf,32); - const unsigned lsize = buildLoader(&ft); int flag = fillExeHeader(&oh); + const unsigned lsize = getLoaderSize(); MemBuffer loader(lsize); memcpy(loader,getLoader(),lsize); //OutputFile::dump("xxloader.dat", loader, lsize); diff --git a/src/p_exe.h b/src/p_exe.h index 6dcc8eb5..7e4f8220 100644 --- a/src/p_exe.h +++ b/src/p_exe.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -42,7 +42,7 @@ public: virtual int getVersion() const { return 11; } virtual int getFormat() const { return UPX_F_DOS_EXE; } virtual const char *getName() const { return "dos/exe"; } - virtual int getCompressionMethod() const; + virtual const int *getCompressionMethods(int method, int level) const; virtual const int *getFilters() const; virtual void pack(OutputFile *fo); diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index eea5540a..100daa17 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -2,9 +2,9 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar - Copyright (C) 2000 John F. Reiser + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar + Copyright (C) 2000-2001 John F. Reiser All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -64,9 +64,9 @@ PackLinuxI386elf::~PackLinuxI386elf() const upx_byte *PackLinuxI386elf::getLoader() const { - if (M_IS_NRV2B(opt->method)) + if (M_IS_NRV2B(ph.method)) return linux_i386elf_nrv2b_loader; - if (M_IS_NRV2D(opt->method)) + if (M_IS_NRV2D(ph.method)) return linux_i386elf_nrv2d_loader; return NULL; } @@ -76,9 +76,9 @@ int PackLinuxI386elf::getLoaderSize() const if (0 != lsize) { return lsize; } - if (M_IS_NRV2B(opt->method)) + if (M_IS_NRV2B(ph.method)) return sizeof(linux_i386elf_nrv2b_loader); - if (M_IS_NRV2D(opt->method)) + if (M_IS_NRV2D(ph.method)) return sizeof(linux_i386elf_nrv2d_loader); return 0; } @@ -117,7 +117,7 @@ void PackLinuxI386elf::patchLoader() upx_uint const uncLsize = lsize - fold_begin; upx_uint cprLsize; int r = upx_compress(loader + fold_begin, uncLsize, cprLoader, &cprLsize, - NULL, opt->method, 10, NULL, NULL); + NULL, ph.method, 10, NULL, NULL); if (r != UPX_E_OK || cprLsize >= uncLsize) throwInternalError("loaded compression failed"); diff --git a/src/p_lx_elf.h b/src/p_lx_elf.h index 0662796b..6f01b549 100644 --- a/src/p_lx_elf.h +++ b/src/p_lx_elf.h @@ -2,9 +2,9 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar - Copyright (C) 2000 John F. Reiser + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar + Copyright (C) 2000-2001 John F. Reiser All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/p_lx_exc.cpp b/src/p_lx_exc.cpp index 941e5f4a..ed4962b7 100644 --- a/src/p_lx_exc.cpp +++ b/src/p_lx_exc.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -47,21 +47,26 @@ static const #include "stub/l_lx_n2d.h" -int PackLinuxI386::getCompressionMethod() const +const int *PackLinuxI386::getCompressionMethods(int method, int level) const { - if (M_IS_NRV2B(opt->method)) - return M_NRV2B_LE32; - if (M_IS_NRV2D(opt->method)) - return M_NRV2D_LE32; - return opt->level > 1 && file_size >= 512*1024 ? M_NRV2D_LE32 : M_NRV2B_LE32; + static const int m_nrv2b[] = { M_NRV2B_LE32, M_NRV2D_LE32, -1 }; + static const int m_nrv2d[] = { M_NRV2D_LE32, M_NRV2B_LE32, -1 }; + + if (M_IS_NRV2B(method)) + return m_nrv2b; + if (M_IS_NRV2D(method)) + return m_nrv2d; + if (level == 1 || file_size <= 512*1024) + return m_nrv2b; + return m_nrv2d; } const upx_byte *PackLinuxI386::getLoader() const { - if (M_IS_NRV2B(opt->method)) + if (M_IS_NRV2B(ph.method)) return linux_i386exec_nrv2b_loader; - if (M_IS_NRV2D(opt->method)) + if (M_IS_NRV2D(ph.method)) return linux_i386exec_nrv2d_loader; return NULL; } @@ -72,9 +77,9 @@ int PackLinuxI386::getLoaderSize() const if (0!=lsize) { return lsize; } - if (M_IS_NRV2B(opt->method)) + if (M_IS_NRV2B(ph.method)) return sizeof(linux_i386exec_nrv2b_loader); - if (M_IS_NRV2D(opt->method)) + if (M_IS_NRV2D(ph.method)) return sizeof(linux_i386exec_nrv2d_loader); return 0; } @@ -206,7 +211,7 @@ void PackLinuxI386::patchLoader() upx_uint const uncLsize = lsize - fold_begin; upx_uint cprLsize; int r = upx_compress(loader + fold_begin, uncLsize, cprLoader, &cprLsize, - NULL, opt->method, 10, NULL, NULL); + NULL, ph.method, 10, NULL, NULL); if (r != UPX_E_OK || cprLsize >= uncLsize) throwInternalError("loaded compression failed"); diff --git a/src/p_lx_exc.h b/src/p_lx_exc.h index 3ac537b6..650ba68e 100644 --- a/src/p_lx_exc.h +++ b/src/p_lx_exc.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -41,7 +41,7 @@ public: PackLinuxI386(InputFile *f) : super(f) { } virtual int getFormat() const { return UPX_F_LINUX_i386; } virtual const char *getName() const { return "linux/386"; } - virtual int getCompressionMethod() const; + virtual const int *getCompressionMethods(int method, int level) const; virtual bool canPack(); diff --git a/src/p_lx_sep.cpp b/src/p_lx_sep.cpp index 17f1a769..82f1f779 100644 --- a/src/p_lx_sep.cpp +++ b/src/p_lx_sep.cpp @@ -2,9 +2,9 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar - Copyright (C) 2000 John F. Reiser + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar + Copyright (C) 2000-2001 John F. Reiser All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -57,11 +57,11 @@ const upx_byte *PackLinuxI386sep::getLoader() const name = "/usr/local/lib/upxX"; } sprintf(script, "#!%s\n", name); - if (M_IS_NRV2B(opt->method)) { + if (M_IS_NRV2B(ph.method)) { script[strlen(script)-2] = 'b'; return (upx_byte const *)script; } - if (M_IS_NRV2D(opt->method)) { + if (M_IS_NRV2D(ph.method)) { script[strlen(script)-2] = 'd'; return (upx_byte const *)script; } @@ -70,9 +70,9 @@ const upx_byte *PackLinuxI386sep::getLoader() const int PackLinuxI386sep::getLoaderSize() const { - if (M_IS_NRV2B(opt->method)) + if (M_IS_NRV2B(ph.method)) return SCRIPT_SIZE; - if (M_IS_NRV2D(opt->method)) + if (M_IS_NRV2D(ph.method)) return SCRIPT_SIZE; return 0; } diff --git a/src/p_lx_sep.h b/src/p_lx_sep.h index 6b396614..3dc34bd8 100644 --- a/src/p_lx_sep.h +++ b/src/p_lx_sep.h @@ -2,9 +2,9 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar - Copyright (C) 2000 John F. Reiser + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar + Copyright (C) 2000-2001 John F. Reiser All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/p_lx_sh.cpp b/src/p_lx_sh.cpp index cfdee4ae..d96261cc 100644 --- a/src/p_lx_sh.cpp +++ b/src/p_lx_sh.cpp @@ -2,9 +2,9 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar - Copyright (C) 2000 John F. Reiser + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar + Copyright (C) 2000-2001 John F. Reiser All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -63,9 +63,9 @@ PackLinuxI386sh::~PackLinuxI386sh() const upx_byte *PackLinuxI386sh::getLoader() const { - if (M_IS_NRV2B(opt->method)) + if (M_IS_NRV2B(ph.method)) return linux_i386sh_nrv2b_loader; - if (M_IS_NRV2D(opt->method)) + if (M_IS_NRV2D(ph.method)) return linux_i386sh_nrv2d_loader; return NULL; } @@ -75,9 +75,9 @@ int PackLinuxI386sh::getLoaderSize() const if (0 != lsize) { return lsize; } - if (M_IS_NRV2B(opt->method)) + if (M_IS_NRV2B(ph.method)) return sizeof(linux_i386sh_nrv2b_loader); - if (M_IS_NRV2D(opt->method)) + if (M_IS_NRV2D(ph.method)) return sizeof(linux_i386sh_nrv2d_loader); return 0; } @@ -102,7 +102,7 @@ void PackLinuxI386sh::patchLoader() upx_uint const uncLsize = lsize - fold_begin; upx_uint cprLsize; int r = upx_compress(loader + fold_begin, uncLsize, cprLoader, &cprLsize, - NULL, opt->method, 10, NULL, NULL); + NULL, ph.method, 10, NULL, NULL); if (r != UPX_E_OK || cprLsize >= uncLsize) throwInternalError("loaded compression failed"); diff --git a/src/p_lx_sh.h b/src/p_lx_sh.h index 4bc1b181..051736f1 100644 --- a/src/p_lx_sh.h +++ b/src/p_lx_sh.h @@ -2,9 +2,9 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar - Copyright (C) 2000 John F. Reiser + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar + Copyright (C) 2000-2001 John F. Reiser All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/p_sys.cpp b/src/p_sys.cpp index b7b4d483..2f8a06b9 100644 --- a/src/p_sys.cpp +++ b/src/p_sys.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/p_sys.h b/src/p_sys.h index 69607321..805dbc46 100644 --- a/src/p_sys.h +++ b/src/p_sys.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/p_tmt.cpp b/src/p_tmt.cpp index a0f10fbf..aabf1eb2 100644 --- a/src/p_tmt.cpp +++ b/src/p_tmt.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -47,13 +47,18 @@ PackTmt::PackTmt(InputFile *f) : super(f) } -int PackTmt::getCompressionMethod() const +const int *PackTmt::getCompressionMethods(int method, int level) const { - if (M_IS_NRV2B(opt->method)) - return M_NRV2B_LE32; - if (M_IS_NRV2D(opt->method)) - return M_NRV2D_LE32; - return opt->level > 1 && file_size >= 512*1024 ? M_NRV2D_LE32 : M_NRV2B_LE32; + static const int m_nrv2b[] = { M_NRV2B_LE32, M_NRV2D_LE32, -1 }; + static const int m_nrv2d[] = { M_NRV2D_LE32, M_NRV2B_LE32, -1 }; + + if (M_IS_NRV2B(method)) + return m_nrv2b; + if (M_IS_NRV2D(method)) + return m_nrv2d; + if (level == 1 || file_size <= 512*1024) + return m_nrv2b; + return m_nrv2d; } @@ -103,7 +108,7 @@ int PackTmt::buildLoader(const Filter *ft) /************************************************************************* -// util +// **************************************************************************/ int PackTmt::readFileHeader() @@ -171,7 +176,9 @@ int PackTmt::readFileHeader() bool PackTmt::canPack() { - return readFileHeader(); + if (!readFileHeader()) + return false; + return true; } @@ -221,41 +228,13 @@ void PackTmt::pack(OutputFile *fo) relocsize += 4; memcpy(ibuf+usize,wrkmem,relocsize); -#if 0 - // filter - Filter ft(opt->level); - tryFilters(&ft, ibuf, usize); - - ph.filter = ft.id; - ph.filter_cto = ft.cto; - ph.u_len = usize + relocsize; - if (!compress(ibuf,obuf)) - throwNotCompressible(); - - ph.overlap_overhead = findOverlapOverhead(obuf,512); - buildLoader(&ft); - - // verify filter - ft.verifyUnfilter(); -#else - // new version using compressWithFilters() - // prepare packheader ph.u_len = usize + relocsize; - ph.filter = 0; // prepare filter - Filter ft(opt->level); + Filter ft(ph.level); ft.buf_len = usize; - - int strategy = -1; // try the first working filter - if (opt->filter >= 0 && isValidFilter(opt->filter)) - // try opt->filter or 0 if that fails - strategy = -2; - else if (opt->all_filters) - // choose best from all available filters - strategy = 0; - compressWithFilters(&ft, 512, strategy); -#endif + // compress + compressWithFilters(&ft, 512); const unsigned lsize = getLoaderSize(); MemBuffer loader(lsize); diff --git a/src/p_tmt.h b/src/p_tmt.h index 86edda7b..6bf8f3f4 100644 --- a/src/p_tmt.h +++ b/src/p_tmt.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -42,7 +42,7 @@ public: virtual int getVersion() const { return 11; } virtual int getFormat() const { return UPX_F_TMT_ADAM; } virtual const char *getName() const { return "tmt/adam"; } - virtual int getCompressionMethod() const; + virtual const int *getCompressionMethods(int method, int level) const; virtual const int *getFilters() const; virtual void pack(OutputFile *fo); diff --git a/src/p_tos.cpp b/src/p_tos.cpp index 262e3033..61d22d96 100644 --- a/src/p_tos.cpp +++ b/src/p_tos.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -29,6 +29,7 @@ #include "conf.h" #include "file.h" +#include "filter.h" #include "packer.h" #include "p_tos.h" @@ -57,13 +58,18 @@ PackTos::PackTos(InputFile *f) : } -int PackTos::getCompressionMethod() const +const int *PackTos::getCompressionMethods(int method, int level) 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; + static const int m_nrv2b[] = { M_NRV2B_8, M_NRV2D_8, -1 }; + static const int m_nrv2d[] = { M_NRV2D_8, M_NRV2B_8, -1 }; + + if (M_IS_NRV2B(method)) + return m_nrv2b; + if (M_IS_NRV2D(method)) + return m_nrv2d; + if (level == 1 || ih.fh_text + ih.fh_data <= 256*1024) + return m_nrv2b; + return m_nrv2d; } @@ -75,9 +81,9 @@ const int *PackTos::getFilters() const const upx_byte *PackTos::getLoader() const { - if (M_IS_NRV2B(opt->method)) + if (M_IS_NRV2B(ph.method)) return opt->small ? nrv2b_loader_small : nrv2b_loader; - if (M_IS_NRV2D(opt->method)) + if (M_IS_NRV2D(ph.method)) return opt->small ? nrv2d_loader_small : nrv2d_loader; return NULL; } @@ -85,9 +91,9 @@ const upx_byte *PackTos::getLoader() const int PackTos::getLoaderSize() const { - if (M_IS_NRV2B(opt->method)) + if (M_IS_NRV2B(ph.method)) return opt->small ? sizeof(nrv2b_loader_small) : sizeof(nrv2b_loader); - if (M_IS_NRV2D(opt->method)) + if (M_IS_NRV2D(ph.method)) return opt->small ? sizeof(nrv2d_loader_small) : sizeof(nrv2d_loader); return 0; } @@ -406,13 +412,14 @@ void PackTos::pack(OutputFile *fo) // alloc buffer obuf.allocForCompression(t + d_len + 512); - // compress (max_match = 65535) + // prepare packheader ph.u_len = t; - if (!compress(ibuf,obuf,0,65535)) - throwNotCompressible(); + // prepare filter + Filter ft(ph.level); + // compress (max_match = 65535) + compressWithFilters(&ft, 512, 0, NULL, 0, 65535); // The decompressed data will now get placed at this offset: - ph.overlap_overhead = findOverlapOverhead(obuf, 512); unsigned offset = (ph.u_len + ph.overlap_overhead) - ph.c_len; // compute addresses diff --git a/src/p_tos.h b/src/p_tos.h index 803c307c..49d7271f 100644 --- a/src/p_tos.h +++ b/src/p_tos.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -42,7 +42,7 @@ public: virtual int getVersion() const { return 11; } virtual int getFormat() const { return UPX_F_ATARI_TOS; } virtual const char *getName() const { return "atari/tos"; } - virtual int getCompressionMethod() const; + virtual const int *getCompressionMethods(int method, int level) const; virtual const int *getFilters() const; virtual void pack(OutputFile *fo); diff --git a/src/p_unix.cpp b/src/p_unix.cpp index b3e2bd2c..0316c181 100644 --- a/src/p_unix.cpp +++ b/src/p_unix.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/p_unix.h b/src/p_unix.h index 98108f65..f12d6a55 100644 --- a/src/p_unix.h +++ b/src/p_unix.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/p_vmlinz.cpp b/src/p_vmlinz.cpp index 9b0dfdf5..b1165ca8 100644 --- a/src/p_vmlinz.cpp +++ b/src/p_vmlinz.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -56,13 +56,18 @@ PackVmlinuzI386::PackVmlinuzI386(InputFile *f) : } -int PackVmlinuzI386::getCompressionMethod() const +const int *PackVmlinuzI386::getCompressionMethods(int method, int level) const { - if (M_IS_NRV2B(opt->method)) - return M_NRV2B_LE32; - if (M_IS_NRV2D(opt->method)) - return M_NRV2D_LE32; - return opt->level > 1 ? M_NRV2D_LE32 : M_NRV2B_LE32; + static const int m_nrv2b[] = { M_NRV2B_LE32, M_NRV2D_LE32, -1 }; + static const int m_nrv2d[] = { M_NRV2D_LE32, M_NRV2B_LE32, -1 }; + + if (M_IS_NRV2B(method)) + return m_nrv2b; + if (M_IS_NRV2D(method)) + return m_nrv2d; + if (level == 1) + return m_nrv2b; + return m_nrv2d; } @@ -217,18 +222,11 @@ void PackVmlinuzI386::pack(OutputFile *fo) readKernel(); // prepare filter - Filter ft(opt->level); + Filter ft(ph.level); ft.buf_len = ph.u_len; ft.addvalue = kernel_entry; - - int strategy = -1; // try the first working filter - if (opt->filter >= 0 && isValidFilter(opt->filter)) - // try opt->filter or 0 if that fails - strategy = -2; - else if (opt->all_filters) - // choose best from all available filters - strategy = 0; - compressWithFilters(&ft, 1 << 20, strategy); + // compress + compressWithFilters(&ft, 1 << 20); const unsigned lsize = getLoaderSize(); MemBuffer loader(lsize); @@ -291,18 +289,11 @@ void PackBvmlinuzI386::pack(OutputFile *fo) readKernel(); // prepare filter - Filter ft(opt->level); + Filter ft(ph.level); ft.buf_len = ph.u_len; ft.addvalue = kernel_entry; - - int strategy = -1; // try the first working filter - if (opt->filter >= 0 && isValidFilter(opt->filter)) - // try opt->filter or 0 if that fails - strategy = -2; - else if (opt->all_filters) - // choose best from all available filters - strategy = 0; - compressWithFilters(&ft, 512, strategy); + // compress + compressWithFilters(&ft, 512); // align everything to dword boundary - it is easier to handle unsigned clen = ph.c_len; diff --git a/src/p_vmlinz.h b/src/p_vmlinz.h index 985af910..ef947be9 100644 --- a/src/p_vmlinz.h +++ b/src/p_vmlinz.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -42,7 +42,7 @@ public: virtual int getVersion() const { return 11; } virtual int getFormat() const { return UPX_F_VMLINUZ_i386; } virtual const char *getName() const { return "vmlinuz/386"; } - virtual int getCompressionMethod() const; + virtual const int *getCompressionMethods(int method, int level) const; virtual const int *getFilters() const; virtual void pack(OutputFile *fo); @@ -116,7 +116,7 @@ public: PackElks8086(InputFile *f) : super(f) { } virtual int getFormat() const { return UPX_F_ELKS_8086; } virtual const char *getName() const { return "elks/8086"; } - virtual int getCompressionMethod() const; + virtual const int *getCompressionMethods(int method, int level) const; virtual const int *getFilters() const; virtual void pack(OutputFile *fo); diff --git a/src/p_vxd.h b/src/p_vxd.h index 3f5d8147..1f6e4a1b 100644 --- a/src/p_vxd.h +++ b/src/p_vxd.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -43,7 +43,7 @@ public: virtual int getVersion() const { return 11; } virtual int getFormat() const { return UPX_F_VXD_LE; } virtual const char *getName() const { return "vxd/le"; } - virtual int getCompressionMethod() const; + virtual const int *getCompressionMethods(int method, int level) const; virtual const int *getFilters() const; virtual void pack(OutputFile *fo); diff --git a/src/p_w16ne.cpp b/src/p_w16ne.cpp index 84222a2b..088c69e2 100644 --- a/src/p_w16ne.cpp +++ b/src/p_w16ne.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -43,13 +43,18 @@ PackW16Ne::PackW16Ne(InputFile *f) : } -int PackW16Ne::getCompressionMethod() const +const int *PackW16Ne::getCompressionMethods(int method, int level) 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; + static const int m_nrv2b[] = { M_NRV2B_8, M_NRV2D_8, -1 }; + static const int m_nrv2d[] = { M_NRV2D_8, M_NRV2B_8, -1 }; + + if (M_IS_NRV2B(method)) + return m_nrv2b; + if (M_IS_NRV2D(method)) + return m_nrv2d; + if (level == 1) + return m_nrv2b; + return m_nrv2d; } diff --git a/src/p_w16ne.h b/src/p_w16ne.h index 7222d8e0..dfc590c6 100644 --- a/src/p_w16ne.h +++ b/src/p_w16ne.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -42,7 +42,7 @@ public: 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 *getCompressionMethods(int method, int level) const; virtual const int *getFilters() const; virtual void pack(OutputFile *fo); diff --git a/src/p_w32pe.cpp b/src/p_w32pe.cpp index 1ba284f1..a1270170 100644 --- a/src/p_w32pe.cpp +++ b/src/p_w32pe.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -98,13 +98,18 @@ PackW32Pe::~PackW32Pe() } -int PackW32Pe::getCompressionMethod() const +const int *PackW32Pe::getCompressionMethods(int method, int level) const { - if (M_IS_NRV2B(opt->method)) - return M_NRV2B_LE32; - if (M_IS_NRV2D(opt->method)) - return M_NRV2D_LE32; - return opt->level > 1 && file_size >= 512*1024 ? M_NRV2D_LE32 : M_NRV2B_LE32; + static const int m_nrv2b[] = { M_NRV2B_LE32, M_NRV2D_LE32, -1 }; + static const int m_nrv2d[] = { M_NRV2D_LE32, M_NRV2B_LE32, -1 }; + + if (M_IS_NRV2B(method)) + return m_nrv2b; + if (M_IS_NRV2D(method)) + return m_nrv2d; + if (level == 1 || ih.codesize + ih.datasize <= 256*1024) + return m_nrv2b; + return m_nrv2d; } @@ -1377,7 +1382,9 @@ unsigned PackW32Pe::stripDebug(unsigned overlaystart) bool PackW32Pe::canPack() { - return readFileHeader(); + if (!readFileHeader()) + return false; + return true; } @@ -1528,9 +1535,8 @@ void PackW32Pe::pack(OutputFile *fo) } // check for NeoLite - for (ic = 0; ic < 64; ic++) - if (memcmp(ibuf + ih.entry + ic,"NeoLite",7) == 0) - throwCantPack("file is already compressed with another packer"); + if (find(ibuf + ih.entry, 64+7, "NeoLite", 7) >= 0) + throwCantPack("file is already compressed with another packer"); unsigned overlay = file_size - stripDebug(overlaystart); if (overlay >= (unsigned) file_size) @@ -1612,48 +1618,16 @@ void PackW32Pe::pack(OutputFile *fo) s += 4; ph.u_len += s; obuf.allocForCompression(ph.u_len); - ph.u_len -= rvamin; - -#if 0 - // filter - Filter ft(opt->level); - if (allow_filter) - tryFilters(&ft, ibuf + ih.codebase, ih.codesize); - - // compress - ph.filter = ft.id; - ph.filter_cto = ft.cto; - if (!compress(ibuf + rvamin,obuf)) - throwNotCompressible(); - - ph.overlap_overhead = findOverlapOverhead(obuf, 2048); - buildLoader(&ft); - - // verify filter - ft.verifyUnfilter(); -#else - // new version using compressWithFilters() // prepare packheader - ph.filter = 0; + ph.u_len -= rvamin; // prepare filter - Filter ft(opt->level); + Filter ft(ph.level); ft.buf_len = ih.codesize; - ft.addvalue = 0; - - int strategy = -1; // try the first working filter - if (!allow_filter) - // no filter - strategy = -3; - else if (opt->filter >= 0 && isValidFilter(opt->filter)) - // try opt->filter or 0 if that fails - strategy = -2; - else if (opt->all_filters) - // choose best from all available filters - strategy = 0; + // compress + int strategy = allow_filter ? 0 : -3; compressWithFilters(&ft, 2048, strategy, NULL, 0, 0, ih.codebase, rvamin); -#endif newvsize = (ph.u_len + rvamin + ph.overlap_overhead + oam1) &~ oam1; if (tlsindex && ((newvsize - ph.c_len - 1024 + oam1) &~ oam1) > tlsindex + 4) diff --git a/src/p_w32pe.h b/src/p_w32pe.h index 48dd7d56..96ad36da 100644 --- a/src/p_w32pe.h +++ b/src/p_w32pe.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -50,7 +50,7 @@ public: virtual int getVersion() const { return 12; } 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 *getCompressionMethods(int method, int level) const; virtual const int *getFilters() const; virtual void pack(OutputFile *fo); diff --git a/src/p_wcle.cpp b/src/p_wcle.cpp index 110a06a6..c11b04fc 100644 --- a/src/p_wcle.cpp +++ b/src/p_wcle.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -66,13 +66,18 @@ static const // **************************************************************************/ -int PackWcle::getCompressionMethod() const +const int *PackWcle::getCompressionMethods(int method, int level) const { - if (M_IS_NRV2B(opt->method)) - return M_NRV2B_LE32; - if (M_IS_NRV2D(opt->method)) - return M_NRV2D_LE32; - return opt->level > 1 && file_size >= 512*1024 ? M_NRV2D_LE32 : M_NRV2B_LE32; + static const int m_nrv2b[] = { M_NRV2B_LE32, M_NRV2D_LE32, -1 }; + static const int m_nrv2d[] = { M_NRV2D_LE32, M_NRV2B_LE32, -1 }; + + if (M_IS_NRV2B(method)) + return m_nrv2b; + if (M_IS_NRV2D(method)) + return m_nrv2d; + if (level == 1 || file_size <= 512*1024) + return m_nrv2b; + return m_nrv2d; } @@ -130,7 +135,9 @@ void PackWcle::handleStub(OutputFile *fo) bool PackWcle::canPack() { - return LeFile::readFileHeader(); + if (!LeFile::readFileHeader()) + return false; + return true; } @@ -479,7 +486,7 @@ void PackWcle::pack(OutputFile *fo) sofixups += 13; // filter - Filter ft(opt->level); + Filter ft(ph.level); tryFilters(&ft, iimage+text_vaddr, text_size, text_vaddr); encodeImage(&ft); diff --git a/src/p_wcle.h b/src/p_wcle.h index 8e7b96df..9757cfde 100644 --- a/src/p_wcle.h +++ b/src/p_wcle.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -42,7 +42,7 @@ public: virtual int getVersion() const { return 12; } virtual int getFormat() const { return UPX_F_WC_LE; } virtual const char *getName() const { return "watcom/le"; } - virtual int getCompressionMethod() const; + virtual const int *getCompressionMethods(int method, int level) const; virtual const int *getFilters() const; virtual void pack(OutputFile *fo); diff --git a/src/packer.cpp b/src/packer.cpp index a67484e0..8020622e 100644 --- a/src/packer.cpp +++ b/src/packer.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -571,16 +571,20 @@ void Packer::initPackHeader() ph.u_file_size = file_size; } + // this is called directly after canPack() from class PackMaster void Packer::updatePackHeader() { - // update our local options - if (opt->level < 0) - opt->level = file_size < 512*1024 ? 8 : 7; - opt->method = getCompressionMethod(); - // set ph + assert(opt->cmd == CMD_COMPRESS); + // + const int *m = getCompressionMethods(opt->method, opt->level); + ph.method = m[0]; ph.level = opt->level; - ph.method = opt->method; + if (ph.level < 0) + ph.level = file_size < 512*1024 ? 8 : 7; + // + assert(isValidCompressionMethod(ph.method)); + assert(1 <= ph.level && ph.level <= 10); } @@ -626,7 +630,7 @@ bool Packer::getPackHeader(void *b, int blen) throwCantUnpack("header size corrupted"); #endif } - if (ph.method < M_NRV2B_LE32 || ph.method > M_NRV2D_LE16) + if (!isValidCompressionMethod(ph.method)) throwCantUnpack("unknown compression method"); // Some formats might be able to unpack "subformats". Ask them. @@ -668,6 +672,12 @@ void Packer::checkAlreadyPacked(void *b, int blen) } +bool Packer::isValidCompressionMethod(int method) +{ + return (method >= M_NRV2B_LE32 && method <= M_NRV2D_LE16); +} + + /************************************************************************* // patch util for loader **************************************************************************/ @@ -924,12 +934,12 @@ void Packer::initLoader(const void *pdata, int plen, int pinfo) "\n\0" "$Info: This file is packed with the UPX executable packer http://upx.tsx.org $" "\n\0" - "$Id: UPX " UPX_VERSION_STRING " Copyright (C) 1996-2000 the UPX Team. All Rights Reserved. $" + "$Id: UPX " UPX_VERSION_STRING " Copyright (C) 1996-2001 the UPX Team. All Rights Reserved. $" "\n"; static const char identsmall[] = "\n" - "$Id: UPX (C) 1996-2000 the UPX Team. All Rights Reserved. http://upx.tsx.org $" + "$Id: UPX (C) 1996-2001 the UPX Team. All Rights Reserved. http://upx.tsx.org $" "\n"; if (opt->small) @@ -1059,8 +1069,8 @@ void Packer::addFilter32(int filter_id) /************************************************************************* -// Try compression with several filters, choose the best or first one. -// Needs buildLoader(). +// Try compression with several methods and filters, choose the best +/ or first working one. Needs buildLoader(). // // Required inputs: // this->ph @@ -1072,18 +1082,18 @@ void Packer::addFilter32(int filter_id) // // - updates this->ph // - updates *ft -// - ibuf[] is restored to unfiltered version +// - ibuf[] is restored to the original unfiltered version // - obuf[] contains the best compressed version // // strategy: -// 0: try all filters, use best one -// n: try the first N filters in parm_filters[], use best one +// n: try the first N filters, use best one // -1: try all filters, use first working one // -2: try only the opt->filter filter // -3: use no filter at all // // This has been prepared for generalization into class Packer so that -// opt->all_filters is available for all executable formats. +// opt->all_methods and/or opt->all_filters are available for all +// executable formats. // // It will replace the tryFilters() / compress() call sequence. **************************************************************************/ @@ -1114,23 +1124,39 @@ void Packer::compressWithFilters(Filter *parm_ft, assert(orig_ft.id == 0); assert(filter_off + filter_len <= compress_buf_off + compress_buf_len); - // setup raw_filters - static const int no_filters[] = { 0, -1 }; - int strategy_filters[] = { 0, -1 }; - - const int *raw_filters = parm_filters; - if (raw_filters == NULL) - raw_filters = getFilters(); - if (raw_filters == NULL) - raw_filters = no_filters; - if (strategy == -2) + // setup filter strategy + if (strategy == 0) { - assert(opt->filter >= 0); - strategy_filters[0] = opt->filter; - raw_filters = strategy_filters; + if (opt->all_filters) + // choose best from all available filters + strategy = INT_MAX; + else if (opt->filter >= 0 && isValidFilter(opt->filter)) + // try opt->filter + strategy = -2; + else + // try the first working filter + strategy = -1; + } + assert(strategy != 0); + + // setup raw_filters + int tmp_filters[] = { 0, -1 }; + const int *raw_filters = NULL; + if (strategy == -3) + raw_filters = tmp_filters; + else if (strategy == -2 && opt->filter >= 0) + { + tmp_filters[0] = opt->filter; + raw_filters = tmp_filters; + } + else + { + raw_filters = parm_filters; + if (raw_filters == NULL) + raw_filters = getFilters(); + if (raw_filters == NULL) + raw_filters = tmp_filters; } - else if (strategy == -3) - raw_filters = no_filters; // first pass - count number of filters int raw_nfilters = 0; @@ -1140,7 +1166,7 @@ void Packer::compressWithFilters(Filter *parm_ft, raw_nfilters++; } - // copy filters, eliminate duplicates, add a 0 + // copy filters, add a 0 int nfilters = 0; bool zero_seen = false; autoheap_array(int, filters, raw_nfilters + 2); @@ -1148,111 +1174,129 @@ void Packer::compressWithFilters(Filter *parm_ft, { if (*f == 0) zero_seen = true; - bool duplicate = false; - for (int i = 0; i < nfilters; i++) - if (filters[i] == *f) - duplicate = true; - if (!duplicate) - filters[nfilters++] = *f; + filters[nfilters++] = *f; + if (nfilters == strategy) + break; } if (!zero_seen) filters[nfilters++] = 0; filters[nfilters] = -1; + // methods + int tmp_methods[] = { ph.method, -1 }; + const int *methods = NULL; + if (opt->all_methods) + methods = getCompressionMethods(-1, ph.level); + if (methods == NULL) + methods = tmp_methods; + int nmethods = 0; + while (methods[nmethods] >= 0) + { + assert(isValidCompressionMethod(methods[nmethods])); + nmethods++; + } + assert(nmethods > 0); + // update total_passes if (strategy < 0) - ui_total_passes += 1; + ui_total_passes += 1 * nmethods; else - { - if (strategy > nfilters) - nfilters = strategy; - ui_total_passes += nfilters; - } + ui_total_passes += nfilters * nmethods; // Working buffer for compressed data. Don't waste memory. upx_byte *otemp = obuf; MemBuffer otemp_buf; - if (nfilters > 1 && strategy >= 0) - { - otemp_buf.allocForCompression(compress_buf_len); - otemp = otemp_buf; - } // compress int nfilters_success = 0; - for (int i = 0; i < nfilters; i++) + for (int m = 0; m < nmethods; m++) // for all methods { - // get fresh packheader - ph = orig_ph; - ph.filter = filters[i]; - // get fresh filter - Filter ft = orig_ft; - ft.init(filters[i], orig_ft.addvalue); - // filter - optimizeFilter(&ft, ibuf + filter_off, filter_len); - bool success = ft.filter(ibuf + filter_off, filter_len); - if (ft.id != 0 && ft.calls == 0) + for (int i = 0; i < nfilters; i++) // for all filters { - // filter did not do anything - no need to call ft.unfilter() - success = false; - } - if (!success) - { - // filter failed or was usesless - if (strategy >= 0) - ui_total_passes -= 1; - continue; - } - // filter success - nfilters_success++; - ph.filter_cto = ft.cto; - // compress - if (compress(ibuf + compress_buf_off, otemp, max_offset, max_match)) - { - unsigned lsize = 0; - if (ph.c_len + lsize < best_ph.c_len + best_ph_lsize) + // get fresh packheader + ph = orig_ph; + ph.method = methods[m]; + ph.filter = filters[i]; + // get fresh filter + Filter ft = orig_ft; + ft.init(ph.filter, orig_ft.addvalue); + // filter + optimizeFilter(&ft, ibuf + filter_off, filter_len); + bool success = ft.filter(ibuf + filter_off, filter_len); + if (ft.id != 0 && ft.calls == 0) { - // get results - ph.overlap_overhead = findOverlapOverhead(otemp, overlap_range); - lsize = buildLoader(&ft); + // filter did not do anything - no need to call ft.unfilter() + success = false; } + if (!success) + { + // filter failed or was usesless + if (strategy > 0) + ui_total_passes -= 1; + continue; + } + // filter success + if (nfilters_success > 0 && otemp == obuf) + { + otemp_buf.allocForCompression(compress_buf_len); + otemp = otemp_buf; + } + nfilters_success++; + ph.filter_cto = ft.cto; + // compress + if (compress(ibuf + compress_buf_off, otemp, max_offset, max_match)) + { + unsigned lsize = 0; + if (ph.c_len + lsize < best_ph.c_len + best_ph_lsize) + { + // get results + ph.overlap_overhead = findOverlapOverhead(otemp, overlap_range); + lsize = buildLoader(&ft); + } #if 0 - printf("\n%02x: %d + %d = %d (best: %d + %d = %d)\n", ft.id, + printf("\n%2d %02x: %d + %d = %d (best: %d + %d = %d)\n", ph.method, ph.filter, ph.c_len, getLoaderSize(), ph.c_len + getLoaderSize(), best_ph.c_len, best_ph_lsize, best_ph.c_len + best_ph_lsize); #endif - bool update = false; - if (ph.c_len + lsize < best_ph.c_len + best_ph_lsize) - update = true; - else if (ph.c_len + lsize == best_ph.c_len + best_ph_lsize) - { - if (ph.overlap_overhead < best_ph.overlap_overhead) + bool update = false; + if (ph.c_len + lsize < best_ph.c_len + best_ph_lsize) update = true; + else if (ph.c_len + lsize == best_ph.c_len + best_ph_lsize) + { + // prefer less overlap_overhead + if (ph.overlap_overhead < best_ph.overlap_overhead) + update = true; + else if (ph.overlap_overhead == best_ph.overlap_overhead) + { + // prefer bigger loaders + if (lsize > best_ph_lsize) + update = true; + } + } + if (update) + { + // update obuf[] with best version + if (otemp != obuf) + memcpy(obuf, otemp, ph.c_len); + // save compression results + best_ph = ph; + best_ph_lsize = lsize; + best_ft = ft; + } } - if (update) - { - // update obuf[] with best version - if (otemp != obuf) - memcpy(obuf, otemp, ph.c_len); - // save compression results - best_ph = ph; - best_ph_lsize = lsize; - best_ft = ft; - } + // restore ibuf[] - unfilter with verify + ft.unfilter(ibuf + filter_off, filter_len, true); + // + if (strategy < 0) + break; } - // restore ibuf[] - unfilter with verify - ft.unfilter(ibuf + filter_off, filter_len, true); - // - if (strategy < 0) - break; } - // postconditions + // postconditions 1) assert(nfilters_success > 0); assert(best_ph.u_len == orig_ph.u_len); assert(best_ph.filter == best_ft.id); assert(best_ph.filter_cto == best_ft.cto); - assert(best_ph.overlap_overhead > 0); // copy back results this->ph = best_ph; @@ -1264,6 +1308,9 @@ void Packer::compressWithFilters(Filter *parm_ft, if (!checkCompressionRatio(best_ph.u_len, best_ph.c_len)) throwNotCompressible(); + // postconditions 2) + assert(best_ph.overlap_overhead > 0); + // convenience buildLoader(&best_ft); } diff --git a/src/packer.h b/src/packer.h index 9604f333..5192c3aa 100644 --- a/src/packer.h +++ b/src/packer.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -107,10 +107,10 @@ public: virtual ~Packer(); virtual int getVersion() const = 0; - // A unique integer ID for this executable format. See conf.h. + // A unique integer ID for this executable format. See unupx.h. virtual int getFormat() const = 0; virtual const char *getName() const = 0; - virtual int getCompressionMethod() const = 0; + virtual const int *getCompressionMethods(int method, int level) const = 0; virtual const int *getFilters() const = 0; // PackMaster entries @@ -163,7 +163,7 @@ protected: // high-level compression drivers void compressWithFilters(Filter *ft, const unsigned overlap_range, - int strategy, + int strategy = 0, const int *filters = NULL, unsigned max_offset = 0, unsigned max_match = 0, unsigned filter_buf_off = 0, @@ -235,6 +235,10 @@ protected: virtual upx_byte *optimizeReloc32(upx_byte *in,unsigned relocnum,upx_byte *out,upx_byte *image,int bs,int *big); virtual unsigned unoptimizeReloc32(upx_byte **in,upx_byte *image,MemBuffer *out,int bs); + // compression method util +public: + static bool isValidCompressionMethod(int method); + protected: InputFile *fi; diff --git a/src/packhead.cpp b/src/packhead.cpp index 419255aa..3cff9373 100644 --- a/src/packhead.cpp +++ b/src/packhead.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/packmast.cpp b/src/packmast.cpp index ef934ae2..cc99dbec 100644 --- a/src/packmast.cpp +++ b/src/packmast.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them @@ -95,7 +95,8 @@ static Packer* try_pack(Packer *p, InputFile *f) f->seek(0,SEEK_SET); if (p->canPack()) { - p->updatePackHeader(); + if (opt->cmd == CMD_COMPRESS) + p->updatePackHeader(); f->seek(0,SEEK_SET); return p; } diff --git a/src/packmast.h b/src/packmast.h index 7c4a8d7e..2d50a16c 100644 --- a/src/packmast.h +++ b/src/packmast.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/s_djgpp2.cpp b/src/s_djgpp2.cpp index 7f77197c..2ad12016 100644 --- a/src/s_djgpp2.cpp +++ b/src/s_djgpp2.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/s_object.cpp b/src/s_object.cpp index 3d7b4b9c..4cd30a11 100644 --- a/src/s_object.cpp +++ b/src/s_object.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/s_vcsa.cpp b/src/s_vcsa.cpp index f1100746..01cd6945 100644 --- a/src/s_vcsa.cpp +++ b/src/s_vcsa.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/s_win32.cpp b/src/s_win32.cpp index 493684e7..31e11730 100644 --- a/src/s_win32.cpp +++ b/src/s_win32.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/screen.h b/src/screen.h index fc7831ee..0b8fccef 100644 --- a/src/screen.h +++ b/src/screen.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/stdcxx.cpp b/src/stdcxx.cpp index 28727d8d..6326768a 100644 --- a/src/stdcxx.cpp +++ b/src/stdcxx.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/stdcxx.h b/src/stdcxx.h index b04d43be..744164c7 100644 --- a/src/stdcxx.h +++ b/src/stdcxx.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/header.ash b/src/stub/header.ash index c2a94e24..b3b5c3e0 100644 --- a/src/stub/header.ash +++ b/src/stub/header.ash @@ -2,8 +2,8 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar ; All Rights Reserved. ; ; UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/ident.ash b/src/stub/ident.ash index e7d6ef74..15ce2845 100644 --- a/src/stub/ident.ash +++ b/src/stub/ident.ash @@ -2,8 +2,8 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar ; All Rights Reserved. ; ; UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/ident_n.ash b/src/stub/ident_n.ash index 94aba2a3..62763d7b 100644 --- a/src/stub/ident_n.ash +++ b/src/stub/ident_n.ash @@ -2,8 +2,8 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar ; All Rights Reserved. ; ; UPX and the UCL library are free software; you can redistribute them @@ -33,7 +33,7 @@ db 10,0 db '$Id: UPX ' db 'UPXV' - db ' Copyright (C) 1996-2000 the UPX Team. All Rights Reserved. $' + db ' Copyright (C) 1996-2001 the UPX Team. All Rights Reserved. $' db 10,0 diff --git a/src/stub/ident_s.ash b/src/stub/ident_s.ash index b7c5b67c..18d65728 100644 --- a/src/stub/ident_s.ash +++ b/src/stub/ident_s.ash @@ -2,8 +2,8 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar ; All Rights Reserved. ; ; UPX and the UCL library are free software; you can redistribute them @@ -29,7 +29,7 @@ ; ------------- COPYRIGHT ------------- db 10 - db '$Id: UPX (C) 1996-2000 the UPX Team. All Rights Reserved. http://upx.tsx.org $' + db '$Id: UPX (C) 1996-2001 the UPX Team. All Rights Reserved. http://upx.tsx.org $' db 10,0 diff --git a/src/stub/l_com.asm b/src/stub/l_com.asm index 664c7bf6..931e9857 100644 --- a/src/stub/l_com.asm +++ b/src/stub/l_com.asm @@ -2,8 +2,8 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar ; All Rights Reserved. ; ; UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/l_djgpp2.asm b/src/stub/l_djgpp2.asm index f642afe4..1b750cce 100644 --- a/src/stub/l_djgpp2.asm +++ b/src/stub/l_djgpp2.asm @@ -2,8 +2,8 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar ; All Rights Reserved. ; ; UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/l_exe.asm b/src/stub/l_exe.asm index 606a269b..915117fd 100644 --- a/src/stub/l_exe.asm +++ b/src/stub/l_exe.asm @@ -2,8 +2,8 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar ; All Rights Reserved. ; ; UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/l_lx_elf.c b/src/stub/l_lx_elf.c index 9f74d3c6..7362ed44 100644 --- a/src/stub/l_lx_elf.c +++ b/src/stub/l_lx_elf.c @@ -2,13 +2,11 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar + Copyright (C) 2000-2001 John F. Reiser All Rights Reserved. - Integration of virtual exec() with decompression is - Copyright (C) 2000 John F. Reiser. 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 diff --git a/src/stub/l_lx_elf86.asm b/src/stub/l_lx_elf86.asm index 52432354..e3e624fe 100644 --- a/src/stub/l_lx_elf86.asm +++ b/src/stub/l_lx_elf86.asm @@ -2,13 +2,11 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar +; Copyright (C) 2000-2001 John F. Reiser ; All Rights Reserved. ; -; Integration of virtual exec() with decompression is -; Copyright (C) 2000 John F. Reiser. 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 diff --git a/src/stub/l_lx_elf86.lds b/src/stub/l_lx_elf86.lds index 07183bed..76ce67c2 100644 --- a/src/stub/l_lx_elf86.lds +++ b/src/stub/l_lx_elf86.lds @@ -2,7 +2,7 @@ This file is part of the UPX executable compressor. - Copyright (C) 2000 John F. Reiser + Copyright (C) 2000-2001 John F. Reiser All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/l_lx_exec.c b/src/stub/l_lx_exec.c index 0e4210f7..a863a75f 100644 --- a/src/stub/l_lx_exec.c +++ b/src/stub/l_lx_exec.c @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/l_lx_exec86.asm b/src/stub/l_lx_exec86.asm index 375e590d..607e7b45 100644 --- a/src/stub/l_lx_exec86.asm +++ b/src/stub/l_lx_exec86.asm @@ -2,13 +2,11 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar +; Copyright (C) 2000-2001 John F. Reiser ; All Rights Reserved. ; -; Integration of virtual exec() with decompression is -; Copyright (C) 2000 John F. Reiser. 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 diff --git a/src/stub/l_lx_exec86.lds b/src/stub/l_lx_exec86.lds index 01bed788..7e849384 100644 --- a/src/stub/l_lx_exec86.lds +++ b/src/stub/l_lx_exec86.lds @@ -2,7 +2,7 @@ This file is part of the UPX executable compressor. - Copyright (C) 2000 John F. Reiser + Copyright (C) 2000-2001 John F. Reiser All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/l_lx_sep.c b/src/stub/l_lx_sep.c index 024fa3ea..791da23b 100644 --- a/src/stub/l_lx_sep.c +++ b/src/stub/l_lx_sep.c @@ -2,13 +2,11 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar + Copyright (C) 2000-2001 John F. Reiser All Rights Reserved. - Integration of virtual exec() with decompression is - Copyright (C) 2000 John F. Reiser. 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 diff --git a/src/stub/l_lx_sep86.asm b/src/stub/l_lx_sep86.asm index d0845226..974ccc70 100644 --- a/src/stub/l_lx_sep86.asm +++ b/src/stub/l_lx_sep86.asm @@ -2,13 +2,11 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar +; Copyright (C) 2000-2001 John F. Reiser ; All Rights Reserved. ; -; Integration of virtual exec() with decompression is -; Copyright (C) 2000 John F. Reiser. 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 diff --git a/src/stub/l_lx_sep86.lds b/src/stub/l_lx_sep86.lds index c4e975e2..929b0a31 100644 --- a/src/stub/l_lx_sep86.lds +++ b/src/stub/l_lx_sep86.lds @@ -2,7 +2,7 @@ This file is part of the UPX executable compressor. - Copyright (C) 2000 John F. Reiser + Copyright (C) 2000-2001 John F. Reiser All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/l_lx_sh.c b/src/stub/l_lx_sh.c index abda233e..eeee88d4 100644 --- a/src/stub/l_lx_sh.c +++ b/src/stub/l_lx_sh.c @@ -2,13 +2,11 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar + Copyright (C) 2000-2001 John F. Reiser All Rights Reserved. - Integration of virtual exec() with decompression is - Copyright (C) 2000 John F. Reiser. 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 diff --git a/src/stub/l_lx_sh86.asm b/src/stub/l_lx_sh86.asm index ec4da041..a9e6c8ba 100644 --- a/src/stub/l_lx_sh86.asm +++ b/src/stub/l_lx_sh86.asm @@ -2,13 +2,11 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar +; Copyright (C) 2000-2001 John F. Reiser ; All Rights Reserved. ; -; Integration of virtual exec() with decompression is -; Copyright (C) 2000 John F. Reiser. 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 diff --git a/src/stub/l_lx_sh86.lds b/src/stub/l_lx_sh86.lds index 6c99ff60..a45f128c 100644 --- a/src/stub/l_lx_sh86.lds +++ b/src/stub/l_lx_sh86.lds @@ -2,7 +2,7 @@ This file is part of the UPX executable compressor. - Copyright (C) 2000 John F. Reiser + Copyright (C) 2000-2001 John F. Reiser All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/l_sys.asm b/src/stub/l_sys.asm index 21735747..b44769ba 100644 --- a/src/stub/l_sys.asm +++ b/src/stub/l_sys.asm @@ -2,8 +2,8 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar ; All Rights Reserved. ; ; UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/l_tmt.asm b/src/stub/l_tmt.asm index ccd0a13e..83c38b6a 100644 --- a/src/stub/l_tmt.asm +++ b/src/stub/l_tmt.asm @@ -2,8 +2,8 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar ; All Rights Reserved. ; ; UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/l_tos.s b/src/stub/l_tos.s index 2f65ec83..f6449646 100644 --- a/src/stub/l_tos.s +++ b/src/stub/l_tos.s @@ -2,8 +2,8 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar ; All Rights Reserved. ; ; UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/l_vmlinz.asm b/src/stub/l_vmlinz.asm index c51eca2a..d725c867 100644 --- a/src/stub/l_vmlinz.asm +++ b/src/stub/l_vmlinz.asm @@ -2,8 +2,8 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar ; All Rights Reserved. ; ; UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/l_w32pe.asm b/src/stub/l_w32pe.asm index c3c939ea..16e45cb9 100644 --- a/src/stub/l_w32pe.asm +++ b/src/stub/l_w32pe.asm @@ -2,8 +2,8 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar ; All Rights Reserved. ; ; UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/l_wcle.asm b/src/stub/l_wcle.asm index e7a8acdc..93969bc8 100644 --- a/src/stub/l_wcle.asm +++ b/src/stub/l_wcle.asm @@ -2,8 +2,8 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar ; All Rights Reserved. ; ; UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/linux.hh b/src/stub/linux.hh index 5059620c..a2e38237 100644 --- a/src/stub/linux.hh +++ b/src/stub/linux.hh @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/macros.ash b/src/stub/macros.ash index d8d7f408..445f61c0 100644 --- a/src/stub/macros.ash +++ b/src/stub/macros.ash @@ -2,8 +2,8 @@ ; ; This file is part of the UPX executable compressor. ; -; Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -; Copyright (C) 1996-2000 Laszlo Molnar +; Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +; Copyright (C) 1996-2001 Laszlo Molnar ; All Rights Reserved. ; ; UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/scripts/app.pl b/src/stub/scripts/app.pl index 73560da0..bfd9ae50 100644 --- a/src/stub/scripts/app.pl +++ b/src/stub/scripts/app.pl @@ -4,8 +4,8 @@ # # This file is part of the UPX executable compressor. # -# Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -# Copyright (C) 1996-2000 Laszlo Molnar +# Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +# Copyright (C) 1996-2001 Laszlo Molnar # All Rights Reserved. # # UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/scripts/bin2h.pl b/src/stub/scripts/bin2h.pl index 2106f804..3cdc2680 100644 --- a/src/stub/scripts/bin2h.pl +++ b/src/stub/scripts/bin2h.pl @@ -4,8 +4,8 @@ # # This file is part of the UPX executable compressor. # -# Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -# Copyright (C) 1996-2000 Laszlo Molnar +# Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +# Copyright (C) 1996-2001 Laszlo Molnar # All Rights Reserved. # # UPX and the UCL library are free software; you can redistribute them @@ -62,8 +62,8 @@ print <<"EOF"; This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/scripts/brandelf.pl b/src/stub/scripts/brandelf.pl index ffa67061..04357962 100644 --- a/src/stub/scripts/brandelf.pl +++ b/src/stub/scripts/brandelf.pl @@ -4,8 +4,8 @@ # # This file is part of the UPX executable compressor. # -# Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -# Copyright (C) 1996-2000 Laszlo Molnar +# Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +# Copyright (C) 1996-2001 Laszlo Molnar # All Rights Reserved. # # UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/scripts/o2bin.pl b/src/stub/scripts/o2bin.pl index a68d887c..55bc7401 100644 --- a/src/stub/scripts/o2bin.pl +++ b/src/stub/scripts/o2bin.pl @@ -4,8 +4,8 @@ # # This file is part of the UPX executable compressor. # -# Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -# Copyright (C) 1996-2000 Laszlo Molnar +# Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +# Copyright (C) 1996-2001 Laszlo Molnar # All Rights Reserved. # # UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/scripts/setfold.pl b/src/stub/scripts/setfold.pl index 22c894c9..5bb1c0b0 100644 --- a/src/stub/scripts/setfold.pl +++ b/src/stub/scripts/setfold.pl @@ -4,7 +4,8 @@ # # This file is part of the UPX executable compressor. # -# Copyright (C) 2000 John F. Reiser. All rights reserved. +# Copyright (C) 2000-2001 John F. Reiser +# 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 diff --git a/src/stub/scripts/stripelf.pl b/src/stub/scripts/stripelf.pl index 225db983..0cad1768 100644 --- a/src/stub/scripts/stripelf.pl +++ b/src/stub/scripts/stripelf.pl @@ -4,8 +4,8 @@ # # This file is part of the UPX executable compressor. # -# Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -# Copyright (C) 1996-2000 Laszlo Molnar +# Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +# Copyright (C) 1996-2001 Laszlo Molnar # All Rights Reserved. # # UPX and the UCL library are free software; you can redistribute them diff --git a/src/stub/scripts/version.pl b/src/stub/scripts/version.pl index c9b2ea66..a888c8d7 100644 --- a/src/stub/scripts/version.pl +++ b/src/stub/scripts/version.pl @@ -4,8 +4,8 @@ # # This file is part of the UPX executable compressor. # -# Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer -# Copyright (C) 1996-2000 Laszlo Molnar +# Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer +# Copyright (C) 1996-2001 Laszlo Molnar # All Rights Reserved. # # UPX and the UCL library are free software; you can redistribute them diff --git a/src/tailor.h b/src/tailor.h index 8f9faf98..0f238127 100644 --- a/src/tailor.h +++ b/src/tailor.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/ui.cpp b/src/ui.cpp index 0bf8be4c..f3f8ab76 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/ui.h b/src/ui.h index 27007255..8a31e2a1 100644 --- a/src/ui.h +++ b/src/ui.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/unupx.h b/src/unupx.h index 570b1a95..ab8d3927 100644 --- a/src/unupx.h +++ b/src/unupx.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/util.cpp b/src/util.cpp index e1d355cb..1a67ac3b 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/util.h b/src/util.h index 836ca224..1db383f8 100644 --- a/src/util.h +++ b/src/util.h @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them diff --git a/src/version.h b/src/version.h index a20a1d67..86c8290f 100644 --- a/src/version.h +++ b/src/version.h @@ -1,3 +1,3 @@ -#define UPX_VERSION 0x011101 /* 01.11.01 */ -#define UPX_VERSION_STRING "1.11.1" -#define UPX_VERSION_DATE "Dec 29th 2000" +#define UPX_VERSION 0x011102 /* 01.11.02 */ +#define UPX_VERSION_STRING "1.11.2" +#define UPX_VERSION_DATE "Jan 2nd 2001" diff --git a/src/work.cpp b/src/work.cpp index a25f1509..b9a08868 100644 --- a/src/work.cpp +++ b/src/work.cpp @@ -2,8 +2,8 @@ This file is part of the UPX executable compressor. - Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2000 Laszlo Molnar + Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996-2001 Laszlo Molnar All Rights Reserved. UPX and the UCL library are free software; you can redistribute them