Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| adcb357242 | |||
| 1e1a078808 | |||
| 7d652fa42b | |||
| a42e72094a | |||
| 97ff8042b4 |
@@ -2,7 +2,7 @@
|
|||||||
User visible changes for UPX
|
User visible changes for UPX
|
||||||
==================================================================
|
==================================================================
|
||||||
|
|
||||||
Changes in 1.10 beta (20 Dec 2000):
|
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!!! REALLY.
|
||||||
* vmlinuz/386: new format - UPX now supports bootable linux kernels
|
* vmlinuz/386: new format - UPX now supports bootable linux kernels
|
||||||
* linux/386: added the new direct-to-memory executable formats - no
|
* linux/386: added the new direct-to-memory executable formats - no
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
- The UCL license is GPL, this will cause problems for the antivirus
|
NOTE: this TODO list is completely out of date (~ Dec 1999)
|
||||||
programs which can't use the uncompressor because of this. Or am I wrong?
|
|
||||||
|
===================================================================
|
||||||
|
|
||||||
- Rearrange this TODO list, sort by categories, add a priority (1-5)
|
- Rearrange this TODO list, sort by categories, add a priority (1-5)
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -97,7 +97,7 @@ void PackCom::patchLoader(OutputFile *fo,
|
|||||||
unsigned calls, unsigned overlapoh)
|
unsigned calls, unsigned overlapoh)
|
||||||
{
|
{
|
||||||
const int filter_id = ph.filter;
|
const int filter_id = ph.filter;
|
||||||
const int e_len = getLoaderSection("COMCUTPO");
|
const int e_len = getLoaderSectionStart("COMCUTPO");
|
||||||
const int d_len = lsize - e_len;
|
const int d_len = lsize - e_len;
|
||||||
assert(e_len > 0 && e_len < 256);
|
assert(e_len > 0 && e_len < 256);
|
||||||
assert(d_len > 0 && d_len < 256);
|
assert(d_len > 0 && d_len < 256);
|
||||||
@@ -234,7 +234,7 @@ void PackCom::pack(OutputFile *fo)
|
|||||||
|
|
||||||
int PackCom::canUnpack()
|
int PackCom::canUnpack()
|
||||||
{
|
{
|
||||||
if (!readPackHeader(128, 0))
|
if (!readPackHeader(128))
|
||||||
return false;
|
return false;
|
||||||
if (file_size <= (off_t) ph.c_len)
|
if (file_size <= (off_t) ph.c_len)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+2
-1
@@ -378,7 +378,8 @@ int PackDjgpp2::canUnpack()
|
|||||||
return false;
|
return false;
|
||||||
if (is_dlm(fi,coff_offset))
|
if (is_dlm(fi,coff_offset))
|
||||||
throwCantUnpack("can't handle DLM");
|
throwCantUnpack("can't handle DLM");
|
||||||
return readPackHeader(1024, coff_offset) ? 1 : -1;
|
fi->seek(coff_offset, SEEK_SET);
|
||||||
|
return readPackHeader(1024) ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -264,7 +264,7 @@ void PackExe::pack(OutputFile *fo)
|
|||||||
fi->seek(ih.headsize16*16,SEEK_SET);
|
fi->seek(ih.headsize16*16,SEEK_SET);
|
||||||
fi->readx(ibuf,imagesize);
|
fi->readx(ibuf,imagesize);
|
||||||
|
|
||||||
if (find_le32(ibuf, UPX_MAX(imagesize, 127u), UPX_MAGIC_LE32) >= 0)
|
if (find_le32(ibuf, UPX_MIN(imagesize, 127u), UPX_MAGIC_LE32) >= 0)
|
||||||
throwAlreadyPacked();
|
throwAlreadyPacked();
|
||||||
|
|
||||||
// relocations
|
// relocations
|
||||||
@@ -413,7 +413,7 @@ void PackExe::pack(OutputFile *fo)
|
|||||||
//OutputFile::dump("xxloader.dat", loader, lsize);
|
//OutputFile::dump("xxloader.dat", loader, lsize);
|
||||||
|
|
||||||
// patch loader
|
// patch loader
|
||||||
const unsigned e_len = getLoaderSection("EXECUTPO");
|
const unsigned e_len = getLoaderSectionStart("EXECUTPO");
|
||||||
const unsigned d_len = lsize - e_len;
|
const unsigned d_len = lsize - e_len;
|
||||||
assert((e_len&15) == 0);
|
assert((e_len&15) == 0);
|
||||||
|
|
||||||
@@ -532,7 +532,8 @@ int PackExe::canUnpack()
|
|||||||
if (!readFileHeader())
|
if (!readFileHeader())
|
||||||
return false;
|
return false;
|
||||||
const off_t off = ih.headsize16 * 16;
|
const off_t off = ih.headsize16 * 16;
|
||||||
bool b = readPackHeader(128, off);
|
fi->seek(off, SEEK_SET);
|
||||||
|
bool b = readPackHeader(128);
|
||||||
return b && (off + (off_t) ph.c_len <= file_size);
|
return b && (off + (off_t) ph.c_len <= file_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -69,7 +69,7 @@ void PackSys::patchLoader(OutputFile *fo,
|
|||||||
unsigned calls, unsigned overlapoh)
|
unsigned calls, unsigned overlapoh)
|
||||||
{
|
{
|
||||||
const int filter_id = ph.filter;
|
const int filter_id = ph.filter;
|
||||||
const int e_len = getLoaderSection("SYSCUTPO");
|
const int e_len = getLoaderSectionStart("SYSCUTPO");
|
||||||
const int d_len = lsize - e_len;
|
const int d_len = lsize - e_len;
|
||||||
assert(e_len > 0 && e_len < 256);
|
assert(e_len > 0 && e_len < 256);
|
||||||
assert(d_len > 0 && d_len < 256);
|
assert(d_len > 0 && d_len < 256);
|
||||||
@@ -88,6 +88,7 @@ void PackSys::patchLoader(OutputFile *fo,
|
|||||||
assert(calls > 0);
|
assert(calls > 0);
|
||||||
patch_le16(loader,lsize,"CT",calls);
|
patch_le16(loader,lsize,"CT",calls);
|
||||||
}
|
}
|
||||||
|
patchPackHeader(loader,e_len);
|
||||||
|
|
||||||
const unsigned jmp_pos = find_le16(loader,e_len,get_le16("JM"));
|
const unsigned jmp_pos = find_le16(loader,e_len,get_le16("JM"));
|
||||||
patch_le16(loader,e_len,"JM",ph.u_len+overlapoh+2-jmp_pos-2);
|
patch_le16(loader,e_len,"JM",ph.u_len+overlapoh+2-jmp_pos-2);
|
||||||
|
|||||||
+3
-2
@@ -217,7 +217,7 @@ void PackTmt::pack(OutputFile *fo)
|
|||||||
memcpy(loader,getLoader(),lsize);
|
memcpy(loader,getLoader(),lsize);
|
||||||
|
|
||||||
const unsigned s_point = getLoaderSection("TMTMAIN1");
|
const unsigned s_point = getLoaderSection("TMTMAIN1");
|
||||||
int e_len = getLoaderSection("TMTCUTPO");
|
int e_len = getLoaderSectionStart("TMTCUTPO");
|
||||||
const unsigned d_len = lsize - e_len;
|
const unsigned d_len = lsize - e_len;
|
||||||
assert(e_len > 0 && s_point > 0);
|
assert(e_len > 0 && s_point > 0);
|
||||||
|
|
||||||
@@ -265,7 +265,8 @@ int PackTmt::canUnpack()
|
|||||||
{
|
{
|
||||||
if (!PackTmt::readFileHeader())
|
if (!PackTmt::readFileHeader())
|
||||||
return false;
|
return false;
|
||||||
return readPackHeader(512,adam_offset) ? 1 : -1;
|
fi->seek(adam_offset, SEEK_SET);
|
||||||
|
return readPackHeader(512) ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -558,7 +558,7 @@ int PackTos::canUnpack()
|
|||||||
{
|
{
|
||||||
if (!readFileHeader())
|
if (!readFileHeader())
|
||||||
return false;
|
return false;
|
||||||
if (!readPackHeader(512, 0))
|
if (!readPackHeader(512))
|
||||||
return false;
|
return false;
|
||||||
// check header as set by packer
|
// check header as set by packer
|
||||||
if ((ih.fh_text & 3) != 0 || (ih.fh_data & 3) != 0 || (ih.fh_bss & 3) != 0
|
if ((ih.fh_text & 3) != 0 || (ih.fh_data & 3) != 0 || (ih.fh_bss & 3) != 0
|
||||||
|
|||||||
+2
-1
@@ -212,7 +212,8 @@ int PackUnix::canUnpack()
|
|||||||
const int bufsize = sizeof(buf);
|
const int bufsize = sizeof(buf);
|
||||||
|
|
||||||
fi->seek(-bufsize, SEEK_END);
|
fi->seek(-bufsize, SEEK_END);
|
||||||
if (!readPackHeader(128, -1, buf))
|
fi->readx(buf, bufsize);
|
||||||
|
if (!getPackHeader(buf, bufsize))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int l = ph.buf_offset + ph.getPackHeaderSize();
|
int l = ph.buf_offset + ph.getPackHeaderSize();
|
||||||
|
|||||||
+4
-1
@@ -345,7 +345,10 @@ void PackBvmlinuzI386::pack(OutputFile *fo)
|
|||||||
|
|
||||||
int PackVmlinuzI386::canUnpack()
|
int PackVmlinuzI386::canUnpack()
|
||||||
{
|
{
|
||||||
return readFileHeader() == getFormat();
|
if (readFileHeader() != getFormat())
|
||||||
|
return false;
|
||||||
|
fi->seek(setup_size, SEEK_SET);
|
||||||
|
return readPackHeader(1024) ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+9
-2
@@ -1925,8 +1925,15 @@ int PackW32Pe::canUnpack()
|
|||||||
bool found_ph = false;
|
bool found_ph = false;
|
||||||
if (memcmp(isection[0].name,"UPX",3) == 0)
|
if (memcmp(isection[0].name,"UPX",3) == 0)
|
||||||
{
|
{
|
||||||
found_ph = readPackHeader(1024, isection[1].rawdataptr - 64) // current version
|
// current version
|
||||||
|| readPackHeader(1024, isection[2].rawdataptr); // old versions
|
fi->seek(isection[1].rawdataptr - 64, SEEK_SET);
|
||||||
|
found_ph = readPackHeader(1024);
|
||||||
|
if (!found_ph)
|
||||||
|
{
|
||||||
|
// old versions
|
||||||
|
fi->seek(isection[2].rawdataptr, SEEK_SET);
|
||||||
|
found_ph = readPackHeader(1024);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (is_packed && found_ph)
|
if (is_packed && found_ph)
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+3
-2
@@ -481,7 +481,7 @@ void PackWcle::pack(OutputFile *fo)
|
|||||||
|
|
||||||
const unsigned lsize = getLoaderSize();
|
const unsigned lsize = getLoaderSize();
|
||||||
neweip = getLoaderSection("WCLEMAIN");
|
neweip = getLoaderSection("WCLEMAIN");
|
||||||
int e_len = getLoaderSection("WCLECUTP");
|
int e_len = getLoaderSectionStart("WCLECUTP");
|
||||||
const unsigned d_len = lsize - e_len;
|
const unsigned d_len = lsize - e_len;
|
||||||
assert(e_len > 0);
|
assert(e_len > 0);
|
||||||
|
|
||||||
@@ -745,8 +745,9 @@ int PackWcle::canUnpack()
|
|||||||
{
|
{
|
||||||
if (!LeFile::readFileHeader())
|
if (!LeFile::readFileHeader())
|
||||||
return false;
|
return false;
|
||||||
|
fi->seek(exe_offset + ih.data_pages_offset, SEEK_SET);
|
||||||
// FIXME: 1024 could be too large for some files
|
// FIXME: 1024 could be too large for some files
|
||||||
return readPackHeader(1024, ih.data_pages_offset+exe_offset) ? 1 : -1;
|
return readPackHeader(1024) ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+13
-19
@@ -594,26 +594,9 @@ int Packer::patchPackHeader(void *b, int blen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Packer::readPackHeader(unsigned len, off_t seek_offset, upx_byte *buf)
|
bool Packer::getPackHeader(void *b, int blen)
|
||||||
{
|
{
|
||||||
assert((int)len > 0);
|
if (!ph.fillPackHeader((unsigned char *)b, blen))
|
||||||
|
|
||||||
MemBuffer hbuf;
|
|
||||||
if (buf == NULL)
|
|
||||||
{
|
|
||||||
hbuf.alloc(len);
|
|
||||||
buf = hbuf;
|
|
||||||
}
|
|
||||||
memset(buf, 0, len);
|
|
||||||
|
|
||||||
if (seek_offset != -1)
|
|
||||||
{
|
|
||||||
if (seek_offset >= 0)
|
|
||||||
fi->seek(seek_offset, SEEK_SET);
|
|
||||||
}
|
|
||||||
len = fi->read(buf,len);
|
|
||||||
|
|
||||||
if (!ph.fillPackHeader(buf, len))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (ph.version > getVersion())
|
if (ph.version > getVersion())
|
||||||
@@ -649,6 +632,17 @@ bool Packer::readPackHeader(unsigned len, off_t seek_offset, upx_byte *buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Packer::readPackHeader(int len)
|
||||||
|
{
|
||||||
|
assert((int)len > 0);
|
||||||
|
MemBuffer buf(len);
|
||||||
|
len = fi->read(buf, len);
|
||||||
|
if (len <= 0)
|
||||||
|
return false;
|
||||||
|
return getPackHeader(buf, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// patch util for loader
|
// patch util for loader
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|||||||
+2
-2
@@ -180,8 +180,8 @@ protected:
|
|||||||
|
|
||||||
// packheader handling
|
// packheader handling
|
||||||
virtual int patchPackHeader(void *b, int blen);
|
virtual int patchPackHeader(void *b, int blen);
|
||||||
virtual bool readPackHeader(unsigned len, off_t seek_offset,
|
virtual bool getPackHeader(void *b, int blen);
|
||||||
upx_byte *buf=NULL);
|
virtual bool readPackHeader(int len);
|
||||||
|
|
||||||
// filter handling
|
// filter handling
|
||||||
virtual bool isValidFilter(int filter_id) const;
|
virtual bool isValidFilter(int filter_id) const;
|
||||||
|
|||||||
+14
-14
@@ -117,20 +117,15 @@ static const char *mkline(unsigned long fu_len, unsigned long fc_len,
|
|||||||
char r[7+1];
|
char r[7+1];
|
||||||
const char *f;
|
const char *f;
|
||||||
|
|
||||||
#if 0
|
unsigned ratio = get_ratio(fu_len, fc_len);
|
||||||
unsigned ratio = get_ratio(fc_len,fu_len);
|
upx_snprintf(r,sizeof(r),"%3d.%02d%%", ratio / 10000, (ratio % 10000) / 100);
|
||||||
upx_snprintf(r,sizeof(r)," %1d.%03d", ratio / 10000, (ratio % 10000) / 10);
|
|
||||||
#else
|
|
||||||
unsigned ratio = get_ratio(fc_len,fu_len, 1000);
|
|
||||||
upx_snprintf(r,sizeof(r),"%3d.%02d%%", ratio / 1000, (ratio % 1000) / 10);
|
|
||||||
UNUSED(u_len); UNUSED(c_len);
|
|
||||||
#endif
|
|
||||||
if (decompress)
|
if (decompress)
|
||||||
f = "%10ld <-%10ld %7s %13s %s";
|
f = "%10ld <-%10ld %7s %13s %s";
|
||||||
else
|
else
|
||||||
f = "%10ld ->%10ld %7s %13s %s";
|
f = "%10ld ->%10ld %7s %13s %s";
|
||||||
upx_snprintf(buf,sizeof(buf),f,
|
upx_snprintf(buf,sizeof(buf),f,
|
||||||
fu_len, fc_len, r, center_string(format_name,13), filename);
|
fu_len, fc_len, r, center_string(format_name,13), filename);
|
||||||
|
UNUSED(u_len); UNUSED(c_len);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,7 +346,7 @@ void __UPX_ENTRY UiPacker::callback(upx_uint isize, upx_uint osize, int state, v
|
|||||||
|
|
||||||
void UiPacker::doCallback(unsigned isize, unsigned osize)
|
void UiPacker::doCallback(unsigned isize, unsigned osize)
|
||||||
{
|
{
|
||||||
static const char spinner[] = "|\\-/";
|
static const char spinner[] = "|/-\\";
|
||||||
|
|
||||||
if (s->pass < 0) // no callback wanted
|
if (s->pass < 0) // no callback wanted
|
||||||
return;
|
return;
|
||||||
@@ -373,8 +368,13 @@ void UiPacker::doCallback(unsigned isize, unsigned osize)
|
|||||||
|
|
||||||
// compute progress position
|
// compute progress position
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
if (isize > 0)
|
if (isize >= s->u_len)
|
||||||
pos = get_ratio(isize,s->u_len) * s->bar_len / 10000;
|
pos = s->bar_len;
|
||||||
|
else if (isize > 0)
|
||||||
|
{
|
||||||
|
pos = get_ratio(s->u_len, isize) * s->bar_len / 1000000;
|
||||||
|
assert(pos >= 0); assert(pos <= s->bar_len);
|
||||||
|
}
|
||||||
if (pos < s->pos)
|
if (pos < s->pos)
|
||||||
return;
|
return;
|
||||||
if (pos < 0 && pos == s->pos)
|
if (pos < 0 && pos == s->pos)
|
||||||
@@ -397,12 +397,12 @@ void UiPacker::doCallback(unsigned isize, unsigned osize)
|
|||||||
*m++ = ']';
|
*m++ = ']';
|
||||||
|
|
||||||
// compute current compression ratio
|
// compute current compression ratio
|
||||||
unsigned ratio = 100*100;
|
unsigned ratio = 1000000;
|
||||||
if (osize > 0)
|
if (osize > 0)
|
||||||
ratio = get_ratio(osize,isize);
|
ratio = get_ratio(isize, osize);
|
||||||
|
|
||||||
sprintf(m," %3d.%1d%% %c ",
|
sprintf(m," %3d.%1d%% %c ",
|
||||||
ratio / 100, (ratio % 100) / 10,
|
ratio / 10000, (ratio % 10000) / 1000,
|
||||||
spinner[s->counter]);
|
spinner[s->counter]);
|
||||||
assert((int)strlen(s->msg_buf) < 1 + 80);
|
assert((int)strlen(s->msg_buf) < 1 + 80);
|
||||||
|
|
||||||
|
|||||||
+12
-14
@@ -443,23 +443,21 @@ bool isafile(int fd)
|
|||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
//
|
// return compression ratio, where 100% == 1000*1000 == 1e6
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
unsigned get_ratio (unsigned long packedsize, unsigned long size,
|
unsigned get_ratio (unsigned u_len, unsigned c_len)
|
||||||
unsigned long scale)
|
|
||||||
{
|
{
|
||||||
unsigned long n1, n2;
|
#if defined(__GNUC__)
|
||||||
|
const unsigned long long n = 1000000;
|
||||||
n1 = 100 * scale; n2 = 1;
|
#elif defined(_MSC_VER)
|
||||||
if (size <= 0)
|
const unsigned __int64 n = 1000000;
|
||||||
return (unsigned) n1;
|
#else
|
||||||
while (n1 > 1 && packedsize > (ULONG_MAX / n1))
|
#error
|
||||||
{
|
#endif
|
||||||
n1 /= 10;
|
if (u_len <= 0)
|
||||||
n2 *= 10;
|
return (unsigned) n;
|
||||||
}
|
return (unsigned) ((c_len * n) / u_len) + 5;
|
||||||
return (unsigned) ((packedsize * n1) / (size / n2)) + 5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -48,8 +48,7 @@ bool maketempname(char *ofilename, const char *ifilename,
|
|||||||
bool makebakname(char *ofilename, const char *ifilename, bool force=true);
|
bool makebakname(char *ofilename, const char *ifilename, bool force=true);
|
||||||
bool isafile(int fd);
|
bool isafile(int fd);
|
||||||
|
|
||||||
unsigned get_ratio(unsigned long packedsize, unsigned long size,
|
unsigned get_ratio(unsigned u_len, unsigned c_len);
|
||||||
unsigned long scale=100);
|
|
||||||
char *center_string(const char *name, size_t s);
|
char *center_string(const char *name, size_t s);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
#define UPX_VERSION 0x011000 /* 01.10.00 */
|
#define UPX_VERSION 0x011100 /* 01.11.00 */
|
||||||
#define UPX_VERSION_STRING "1.10"
|
#define UPX_VERSION_STRING "1.11"
|
||||||
#define UPX_VERSION_DATE "Dec 20th 2000"
|
#define UPX_VERSION_DATE "Dec 20th 2000"
|
||||||
|
|||||||
Reference in New Issue
Block a user