From f23f035554d0a76a60ef1d6baba536a4df29846f Mon Sep 17 00:00:00 2001 From: "C. Masloch" Date: Thu, 26 May 2022 10:41:43 +0200 Subject: [PATCH] exeflat: allow to force either DOS/EXE or DOS/SYS compression format --- utils/exeflat.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/utils/exeflat.c b/utils/exeflat.c index 171a893..8243e93 100644 --- a/utils/exeflat.c +++ b/utils/exeflat.c @@ -102,7 +102,7 @@ static int exeflat(const char *srcfile, const char *dstfile, UWORD curbufoffset; FILE *src, *dest; short silentdone = 0; - int compress_sys_file; + int compress_sys_file = 0; UWORD stubsize = 0; if ((src = fopen(srcfile, "rb")) == NULL) @@ -221,9 +221,18 @@ static int exeflat(const char *srcfile, const char *dstfile, } /* The biggest .sys file that UPX accepts seems to be 65419 bytes long */ - compress_sys_file = (size - (0x20 - 0x10)) < 65420; if (UPX) { - printf("Compressing kernel - %s format\n", (compress_sys_file)?"sys":"exe"); + if (stubdevsize && stubexesize) + compress_sys_file = (size - (0x20 - 0x10)) < 65420; + else if (stubexesize) + compress_sys_file = 0; + else if (stubdevsize) + compress_sys_file = 1; + else { + printf("Error: Entry file must be specified\n"); + exit(1); + } + printf("Compressing kernel - %s format\n", (compress_sys_file)?"sys":"exe"); if (!compress_sys_file) { stubsize = stubexesize; ULONG realsize;