From 4e6fc92d8a322ca8e8c005c1a9a1c6fd1b3a2994 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Sat, 9 Sep 2000 23:17:27 +0000 Subject: [PATCH] Prepared for first GUI version. committer: mfx 968541447 +0000 --- .cvsignore | 3 +++ THANKS | 6 ++++-- doc/Makefile | 2 +- doc/upx.pod | 5 ++--- src/conf.h | 6 +++++- src/console.h | 4 ++++ src/help.cpp | 7 +++---- src/main.cpp | 13 ++++++++----- src/msg.cpp | 16 ++++++++++++++++ src/ui.h | 8 ++++++++ src/version.h | 4 ++-- src/work.cpp | 16 +++++++++++----- 12 files changed, 67 insertions(+), 23 deletions(-) diff --git a/.cvsignore b/.cvsignore index e69de29b..8be6ba02 100644 --- a/.cvsignore +++ b/.cvsignore @@ -0,0 +1,3 @@ +.cvsignore +.mfxcvsup +maint diff --git a/THANKS b/THANKS index cbbf78da..7278b956 100644 --- a/THANKS +++ b/THANKS @@ -23,6 +23,8 @@ Adam Ierymenko for severals ideas for the Linux version Andi Kleen and Jamie Lokier for the /proc/self/fd/X and other Linux suggestions +Andreas Muegge + for the Win32 GUI Atli Mar Gudmundsson for several comments on the win32/pe stub Charles W. Sandmann @@ -31,6 +33,8 @@ Ice for debugging the PE headersize problem down Joergen Ibsen and d'b for the relocation & address optimization ideas +John F. Reiser + for the new Linux executable formats John S. Fine for the new version of the dos/exe decompressor Lukundoo @@ -45,8 +49,6 @@ Salvador Eduardo Tropea for beta testing The WINE project (http://www.winehq.com/) for lots of useful information found in their PE loader sources -DJ Delorie for djgpp -Linus for Linux Natascha Everybody else who was kind enough to spend time testing UPX, use it in diff --git a/doc/Makefile b/doc/Makefile index 725f5b83..73c8bc93 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -3,7 +3,7 @@ SHELL = /bin/sh top_srcdir = .. PACKAGE = upx -VERSION_DATE = 10 May 2000 +VERSION_DATE = 10 Sep 2000 VERSION := $(shell sed -n 's/^.*UPX_VERSION_STRING.*"\(.*\)".*/\1/p' $(top_srcdir)/src/version.h) TRIMSPACE = cat diff --git a/doc/upx.pod b/doc/upx.pod index 9b82dea5..130ceee7 100644 --- a/doc/upx.pod +++ b/doc/upx.pod @@ -15,7 +15,6 @@ B S<[ I ]> S<[ I ]> I... The Ultimate Packer for eXecutables Copyright (c) 1996-2000 Markus Oberhumer & Laszlo Molnar http://wildsau.idv.uni-linz.ac.at/mfx/upx.html - http://www.nexus.hu/upx http://upx.tsx.org @@ -222,7 +221,7 @@ For example: for csh/tcsh: setenv UPX "-9 --compress-icons=1" Under DOS/Windows you must use '#' instead of '=' when setting the -environment variable because of a command.com limitation. +environment variable because of a COMMAND.COM limitation. On Vax/VMS, the name of the environment variable is UPX_OPT, to avoid a conflict with the symbol set for @@ -345,7 +344,7 @@ How it works: May 2000), and transfers control to the program interpreter or the e_entry address of the original executable. - For shell script executables (files beginning with "#!/" or "#! /") + For shell script executables (files beginning with "#!/" or "#! /") where the shell is known to accept "-c ", UPX decompresses the file into low memory, then maps the shell (and its PT_INTERP), and passes control to the shell with the entire decompressed file diff --git a/src/conf.h b/src/conf.h index f45a6d0a..179ddfa6 100644 --- a/src/conf.h +++ b/src/conf.h @@ -50,8 +50,10 @@ #endif // just in case +#undef NDEBUG #undef dos #undef linux +#undef small #undef tos #undef unix @@ -503,7 +505,7 @@ struct options_t { bool le; } wcle; struct { - bool compress_exports; + int compress_exports; int compress_icons; bool compress_resources; int strip_relocs; @@ -515,6 +517,7 @@ extern struct options_t * volatile opt; // main.cpp extern const char *progname; +void init_options(struct options_t *o); bool set_ec(int ec); #if defined(__GNUC__) void e_exit(int ec) __attribute__((noreturn)); @@ -527,6 +530,7 @@ void e_exit(int ec); void printSetNl(int need_nl); void printClearLine(FILE *f = NULL); void printErr(const char *iname, const Throwable *e); +void printUnhandledException(const char *iname, const exception *e); #if defined(__GNUC__) void printErr(const char *iname, const char *format, ...) __attribute__((format(printf,2,3))); diff --git a/src/console.h b/src/console.h index ac4fcfda..4bb16d9f 100644 --- a/src/console.h +++ b/src/console.h @@ -37,6 +37,10 @@ #undef USE_SCREEN_CURSES #undef USE_FRAMES +#if defined(WITH_GUI) && !defined(NO_CONSOLE) +# define NO_CONSOLE +#endif + #if 1 && defined(__linux__) # define USE_SCREEN # define USE_SCREEN_VCSA diff --git a/src/help.cpp b/src/help.cpp index f18685a4..8694afbb 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -238,7 +238,6 @@ con_fprintf(f, con_fprintf(f, " http://upx.tsx.org\n" " http://wildsau.idv.uni-linz.ac.at/mfx/upx.html\n" - " http://www.nexus.hu/upx\n" ); (void)con_fg(f,FG_ORANGE); con_fprintf(f, @@ -260,10 +259,10 @@ void show_version(int x) UNUSED(x); fprintf(f,"upx %s\n",UPX_VERSION_STRING); -#if defined(WITH_UCL) - fprintf(f,"UCL data compression library %s\n", ucl_version_string()); -#elif defined(WITH_NRV) +#if defined(WITH_NRV) fprintf(f,"NRV data compression library %s\n", nrv_version_string()); +#elif 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"); diff --git a/src/main.cpp b/src/main.cpp index e96360cc..b290755a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,7 +34,7 @@ // options **************************************************************************/ -static void init_options(struct options_t *o) +void init_options(struct options_t *o) { memset(o, 0, sizeof(*o)); memset(&o->crp, 0xff, sizeof(o->crp)); @@ -51,7 +51,7 @@ static void init_options(struct options_t *o) o->console = CON_INIT; o->verbose = 2; - o->w32pe.compress_exports = true; + o->w32pe.compress_exports = 1; o->w32pe.compress_icons = 2; o->w32pe.compress_resources = true; o->w32pe.strip_relocs = -1; @@ -608,9 +608,8 @@ static int do_option(int optc, const char *arg) opt->wcle.le = true; break; case 630: - opt->w32pe.compress_exports = true; - if (mfx_optarg && strcmp(mfx_optarg,"0") == 0) - opt->w32pe.compress_exports = false; + opt->w32pe.compress_exports = 1; + getoptvar(&opt->w32pe.compress_exports, 0, 1); //printf("compress_exports: %d\n", opt->w32pe.compress_exports); break; case 631: @@ -977,6 +976,8 @@ void upx_sanity_check(void) // main entry point **************************************************************************/ +#if !defined(WITH_GUI) + int main(int argc, char *argv[]) { int i; @@ -1127,6 +1128,8 @@ int main(int argc, char *argv[]) return exit_code; } +#endif /* !defined(WITH_GUI) */ + /* vi:ts=4:et:nowrap diff --git a/src/msg.cpp b/src/msg.cpp index cc74413c..fa5272db 100644 --- a/src/msg.cpp +++ b/src/msg.cpp @@ -145,6 +145,19 @@ void printWarn(const char *iname, const char *format, ...) } +void printUnhandledException(const char *iname, const exception *e) +{ + if (e) + printErr(iname,"unhandled exception: %s\n", prettyName(e->what())); + else + printErr(iname,"internal error: unhandled exception!\n"); + if (opt->cmd != CMD_COMPRESS) + { + printErr(iname," this file has possibly been modified/hacked; take care!\n"); + } +} + + /************************************************************************* // FIXME: should use colors and a consistent layout here **************************************************************************/ @@ -208,7 +221,10 @@ void info(const char *format, ...) void infoWarning(const char *format, ...) { if (opt->info_mode <= 0) + { + // FIXME - should still print something here return; + } va_list args; char buf[1024]; va_start(args,format); diff --git a/src/ui.h b/src/ui.h index ab2303c6..746391d3 100644 --- a/src/ui.h +++ b/src/ui.h @@ -33,6 +33,10 @@ class OutputFile; class Packer; class UiPacker; +#if defined(WITH_GUI) +class CMainDlg; +#endif + /************************************************************************* // @@ -104,6 +108,10 @@ protected: static long update_u_len; static long update_fc_len; static long update_fu_len; + +#if defined(WITH_GUI) + CMainDlg* pMain; +#endif }; diff --git a/src/version.h b/src/version.h index eac3be8b..a82f2c83 100644 --- a/src/version.h +++ b/src/version.h @@ -1,2 +1,2 @@ -#define UPX_VERSION_STRING "1.09.2" -#define UPX_VERSION_DATE "May 13th 2000" +#define UPX_VERSION_STRING "1.09.3" +#define UPX_VERSION_DATE "Sep 10th 2000" diff --git a/src/work.cpp b/src/work.cpp index d38c8d2a..a3bd2301 100644 --- a/src/work.cpp +++ b/src/work.cpp @@ -65,7 +65,7 @@ void do_one_file(const char *iname, char *oname) if (r == -1) throw FileNotFoundException(iname); - if (!S_ISREG(st.st_mode)) + if (!(S_ISREG(st.st_mode))) throwIOException("not a regular file -- skipped"); #if defined(__unix__) // no special bits may be set @@ -124,7 +124,7 @@ void do_one_file(const char *iname, char *oname) int omode = 0600; fo.sopen(tname,flags,shmode,omode); #endif - // open succeeded - set oname + // open succeeded - now set oname[] strcpy(oname,tname); } } @@ -177,6 +177,8 @@ void do_one_file(const char *iname, char *oname) // make backup char bakname[PATH_MAX+1]; makebakname(bakname,iname); + if (file_exists(bakname)) + maketempname(bakname,iname,".000",1); File::rename(iname,bakname); } File::rename(oname,iname); @@ -213,6 +215,8 @@ void do_one_file(const char *iname, char *oname) // process all files from the commandline **************************************************************************/ +#if !defined(WITH_GUI) + void do_files(int i, int argc, char *argv[]) { if (opt->verbose >= 1) @@ -247,19 +251,19 @@ void do_files(int i, int argc, char *argv[]) e_exit(EXIT_ERROR); //throw; } catch (const exception &e) { - printErr(iname,"unhandled exception: %s\n", prettyName(e.what())); + printUnhandledException(iname,&e); if (oname[0]) (void) ::unlink(oname); e_exit(EXIT_ERROR); //throw; } catch (const exception *e) { - printErr(iname,"unhandled exception: %s\n", prettyName(e->what())); + printUnhandledException(iname,e); if (oname[0]) (void) ::unlink(oname); e_exit(EXIT_ERROR); //throw; } catch (...) { - printErr(iname,"internal error: unhandled exception !\n"); + printUnhandledException(iname,NULL); if (oname[0]) (void) ::unlink(oname); e_exit(EXIT_ERROR); @@ -284,6 +288,8 @@ void do_files(int i, int argc, char *argv[]) UiPacker::uiFileInfoTotal(); } +#endif /* !defined(WITH_GUI) */ + /* vi:ts=4:et