mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Some more dos/exe updates.
This commit is contained in:
parent
1695096d18
commit
0d5ae77efc
|
@ -553,23 +553,28 @@ static int do_option(int optc, const char *arg)
|
|||
|
||||
// method
|
||||
case 702:
|
||||
opt->method_nrv2b_seen = true;
|
||||
if (!set_method(M_NRV2B_LE32, -1))
|
||||
e_method(M_NRV2B_LE32, opt->level);
|
||||
break;
|
||||
case 704:
|
||||
opt->method_nrv2d_seen = true;
|
||||
if (!set_method(M_NRV2D_LE32, -1))
|
||||
e_method(M_NRV2D_LE32, opt->level);
|
||||
break;
|
||||
case 705:
|
||||
opt->method_nrv2e_seen = true;
|
||||
if (!set_method(M_NRV2E_LE32, -1))
|
||||
e_method(M_NRV2E_LE32, opt->level);
|
||||
break;
|
||||
case 721:
|
||||
opt->method_lzma_seen = true;
|
||||
opt->all_methods_use_lzma = true;
|
||||
if (!set_method(M_LZMA, -1))
|
||||
e_method(M_LZMA, opt->level);
|
||||
break;
|
||||
case 722:
|
||||
opt->method_lzma_seen = false;
|
||||
opt->all_methods_use_lzma = false;
|
||||
if (M_IS_LZMA(opt->method))
|
||||
opt->method = -1;
|
||||
|
|
|
@ -47,6 +47,10 @@ struct options_t {
|
|||
|
||||
// compression options
|
||||
int method;
|
||||
bool method_lzma_seen;
|
||||
bool method_nrv2b_seen;
|
||||
bool method_nrv2d_seen;
|
||||
bool method_nrv2e_seen;
|
||||
int level; // compression level 1..10
|
||||
int filter; // preferred filter from Packer::getFilters()
|
||||
bool ultra_brute;
|
||||
|
|
|
@ -53,11 +53,16 @@ PackExe::PackExe(InputFile *f) :
|
|||
bele = &N_BELE_RTP::le_policy;
|
||||
COMPILE_TIME_ASSERT(sizeof(exe_header_t) == 32);
|
||||
ih_exesize = ih_imagesize = ih_overlay = 0;
|
||||
|
||||
// disable lzma for "--brute" unless explicitly given "--lzma"
|
||||
if (opt->all_methods_use_lzma && !opt->method_lzma_seen)
|
||||
opt->all_methods_use_lzma = false;
|
||||
}
|
||||
|
||||
|
||||
const int *PackExe::getCompressionMethods(int method, int level) const
|
||||
{
|
||||
#if 0
|
||||
static const int m_all[] = { M_NRV2B_8, M_NRV2D_8, M_NRV2E_8, M_END };
|
||||
static const int m_nrv2b[] = { M_NRV2B_8, M_END };
|
||||
static const int m_nrv2d[] = { M_NRV2D_8, M_END };
|
||||
|
@ -68,11 +73,15 @@ const int *PackExe::getCompressionMethods(int method, int level) const
|
|||
if (M_IS_NRV2B(method)) return m_nrv2b;
|
||||
if (M_IS_NRV2D(method)) return m_nrv2d;
|
||||
if (M_IS_NRV2E(method)) return m_nrv2e;
|
||||
if (M_IS_LZMA(method)) return m_lzma;
|
||||
if (M_IS_LZMA(method)) return m_lzma;
|
||||
bool small = ih_imagesize <= 256*1024;
|
||||
if (level == 1 || small)
|
||||
return m_nrv2b;
|
||||
return m_nrv2e;
|
||||
#else
|
||||
bool small = ih_imagesize <= 256*1024;
|
||||
return Packer::getDefaultCompressionMethods_8(method, level, small);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,7 +105,9 @@ int PackExe::fillExeHeader(struct exe_header_t *eh) const
|
|||
oh.ident = 'M' + 'Z' * 256;
|
||||
oh.headsize16 = 2;
|
||||
|
||||
unsigned minsp = M_IS_LZMA(ph.method) ? getDecompressorWrkmemSize() + 0x1100 : 0x200;
|
||||
unsigned minsp = 0x200;
|
||||
if (M_IS_LZMA(ph.method))
|
||||
minsp = getDecompressorWrkmemSize() + 0x1100;
|
||||
assert(minsp < 0xff00);
|
||||
|
||||
oh.sp = ih.sp > minsp ? (unsigned) ih.sp : minsp;
|
||||
|
@ -170,7 +181,7 @@ void PackExe::buildLoader(const Filter *)
|
|||
"NRV2EEX9",
|
||||
NULL
|
||||
);
|
||||
else if (ph.method == M_LZMA)
|
||||
else if M_IS_LZMA(ph.method)
|
||||
addLoader("LZMA_DEC00,LZMA_DEC10,LZMA_DEC99,LZMA_DEC30",
|
||||
ph.u_len > 0xffff ? "LZMA_DEC31" : "",
|
||||
NULL
|
||||
|
@ -439,9 +450,12 @@ void PackExe::pack(OutputFile *fo)
|
|||
// compress (max_match = 8192)
|
||||
upx_compress_config_t cconf; cconf.reset();
|
||||
cconf.conf_ucl.max_match = MAXMATCH;
|
||||
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28KB stack
|
||||
compressWithFilters(&ft, 32, &cconf);
|
||||
if (ph.max_run_found + ph.max_match_found > 0x8000)
|
||||
throwCantPack("decompressor limit exceeded, send a bugreport");
|
||||
|
||||
if (M_IS_NRV2B(ph.method) || M_IS_NRV2D(ph.method) || M_IS_NRV2E(ph.method))
|
||||
if (ph.max_run_found + ph.max_match_found > 0x8000)
|
||||
throwCantPack("decompressor limit exceeded, send a bugreport");
|
||||
|
||||
#ifdef TESTING
|
||||
if (opt->debug.debug_level)
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#ifdef WANT_MACH_HEADER_ENUM /*{*/
|
||||
#undef WANT_MACH_HEADER_ENUM
|
||||
enum { // magic
|
||||
enum { // magic
|
||||
MH_MAGIC = 0xfeedface
|
||||
};
|
||||
enum { // cputype
|
||||
|
|
|
@ -108,7 +108,7 @@ endef
|
|||
# Borland C/C++ 5.02
|
||||
ifneq ($(wildcard $(BC502DIR)/bin/.),)
|
||||
c := tc.method-lzma.bcc
|
||||
$c = @$(WINEENV) CL='$(CL)' wine cmd.exe /c tmp/bcc.bat
|
||||
$c = @$(WINEENV) wine cmd.exe /c tmp/bcc.bat
|
||||
$c += -mc
|
||||
$c += -O1 -1
|
||||
$c += -w
|
||||
|
|
|
@ -139,7 +139,7 @@ def main(argv):
|
|||
if m.group(3): args = m.group(3).strip()
|
||||
#
|
||||
if inst in ["movl",] and re.search(r"\b[de]s\b", args):
|
||||
# correct objdump bug
|
||||
# fix bug in objdump
|
||||
inst = "movw"
|
||||
m = re.search(r"^(.+?)\b0x0\s+(\w+):\s+[12]\s+(__\w+)$", args)
|
||||
if m:
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
; ------------- DECOMPRESSION -------------
|
||||
|
||||
; Input:
|
||||
; si - source
|
||||
; di - dest
|
||||
; ds:si - source
|
||||
; es:di - dest
|
||||
; cld
|
||||
|
||||
; Output:
|
||||
|
@ -111,10 +111,10 @@ __PIA_V03:
|
|||
#else
|
||||
// optimized version
|
||||
inc ax
|
||||
jnes .L1
|
||||
jnes 1f
|
||||
add dh, (__AHINCR >> 8)
|
||||
movw ds, dx
|
||||
.L1:
|
||||
1:
|
||||
mov WORD PTR [bp-12],ax
|
||||
#endif
|
||||
ret
|
||||
|
|
Loading…
Reference in New Issue
Block a user