Cleanups.
committer: mfx <mfx> 1034719891 +0000
This commit is contained in:
+1
-1
@@ -1159,7 +1159,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_NRV)
|
#if defined(WITH_NRV)
|
||||||
if (nrv_init() != NRV_E_OK)
|
if (nrv_init() != NRV_E_OK || NRV_VERSION != nrv_version())
|
||||||
{
|
{
|
||||||
show_head();
|
show_head();
|
||||||
fprintf(stderr,"nrv_init() failed - check your NRV installation !\n");
|
fprintf(stderr,"nrv_init() failed - check your NRV installation !\n");
|
||||||
|
|||||||
+11
-10
@@ -61,8 +61,9 @@ PackPs1::PackPs1(InputFile *f) :
|
|||||||
COMPILE_TIME_ASSERT(sizeof(ps1_exe_t) == 188);
|
COMPILE_TIME_ASSERT(sizeof(ps1_exe_t) == 188);
|
||||||
COMPILE_TIME_ASSERT(IH_BKUP == 40);
|
COMPILE_TIME_ASSERT(IH_BKUP == 40);
|
||||||
|
|
||||||
fdata_size = cfile_size = 0;
|
overlap = 0;
|
||||||
sa_cnt = 0;
|
sa_cnt = 0;
|
||||||
|
fdata_size = cfile_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int *PackPs1::getCompressionMethods(int method, int level) const
|
const int *PackPs1::getCompressionMethods(int method, int level) const
|
||||||
@@ -85,16 +86,16 @@ int PackPs1::patch_mips_le16(void *b, int blen, const void *old, unsigned new_)
|
|||||||
{
|
{
|
||||||
unsigned char w[2];
|
unsigned char w[2];
|
||||||
|
|
||||||
set_le16(&w,get_be16(old));
|
set_le16(w, get_be16(old));
|
||||||
return patch_le16(b, blen, &w, new_);
|
return patch_le16(b, blen, w, new_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PackPs1::patch_mips_le32(void *b, int blen, const void *old, unsigned new_)
|
int PackPs1::patch_mips_le32(void *b, int blen, const void *old, unsigned new_)
|
||||||
{
|
{
|
||||||
unsigned char w[4];
|
unsigned char w[4];
|
||||||
|
|
||||||
set_le32(&w,get_be32(old));
|
set_le32(w, get_be32(old));
|
||||||
return patch_le32(b, blen, &w, new_);
|
return patch_le32(b, blen, w, new_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PackPs1::patch_hi_lo(void *b, int blen, const void *old_hi, const void *old_lo, unsigned new_)
|
int PackPs1::patch_hi_lo(void *b, int blen, const void *old_hi, const void *old_lo, unsigned new_)
|
||||||
@@ -120,7 +121,7 @@ bool PackPs1::canPack()
|
|||||||
if ((memcmp(&ih.id,"PS-X EXE",8) != 0) && (memcmp(&ih.id,"EXE X-SP",8) != 0))
|
if ((memcmp(&ih.id,"PS-X EXE",8) != 0) && (memcmp(&ih.id,"EXE X-SP",8) != 0))
|
||||||
return false;
|
return false;
|
||||||
fi->readx(buf, sizeof(buf));
|
fi->readx(buf, sizeof(buf));
|
||||||
checkAlreadyPacked(&buf, sizeof(buf));
|
checkAlreadyPacked(buf, sizeof(buf));
|
||||||
if (fdata_size != ih.tx_len || (ih.tx_len & 3))
|
if (fdata_size != ih.tx_len || (ih.tx_len & 3))
|
||||||
{
|
{
|
||||||
if (!opt->force)
|
if (!opt->force)
|
||||||
@@ -181,7 +182,7 @@ void PackPs1::pack(OutputFile *fo)
|
|||||||
|
|
||||||
ibuf.alloc(fdata_size);
|
ibuf.alloc(fdata_size);
|
||||||
obuf.allocForCompression(fdata_size);
|
obuf.allocForCompression(fdata_size);
|
||||||
upx_byte *p_scan = ibuf+(fdata_size-1);
|
const upx_byte *p_scan = ibuf+(fdata_size-1);
|
||||||
|
|
||||||
// read file
|
// read file
|
||||||
fi->seek(PS_HDR_SIZE,SEEK_SET);
|
fi->seek(PS_HDR_SIZE,SEEK_SET);
|
||||||
@@ -201,7 +202,7 @@ void PackPs1::pack(OutputFile *fo)
|
|||||||
|
|
||||||
Filter ft(ph.level);
|
Filter ft(ph.level);
|
||||||
// compress (max_match = 65535)
|
// compress (max_match = 65535)
|
||||||
compressWithFilters(&ft, 512, 0, NULL, 0, 65535, 0, 0);
|
compressWithFilters(&ft, 512, 0, NULL, 0, 65535);
|
||||||
|
|
||||||
if (ph.overlap_overhead <= sa_cnt)
|
if (ph.overlap_overhead <= sa_cnt)
|
||||||
overlap = 0;
|
overlap = 0;
|
||||||
@@ -236,10 +237,10 @@ void PackPs1::pack(OutputFile *fo)
|
|||||||
pad = ALIGN_DOWN(pad, 4);
|
pad = ALIGN_DOWN(pad, 4);
|
||||||
pad_code = CHK_ALIGNED(ph.c_len, 4);
|
pad_code = CHK_ALIGNED(ph.c_len, 4);
|
||||||
|
|
||||||
unsigned decomp_data_start = ih.tx_ptr;
|
const unsigned decomp_data_start = ih.tx_ptr;
|
||||||
|
|
||||||
// set the offset for compressed stuff at the very end of file
|
// set the offset for compressed stuff at the very end of file
|
||||||
unsigned comp_data_start = (decomp_data_start+pad)-ph.c_len+(overlap ? overlap : 0);
|
const unsigned comp_data_start = (decomp_data_start+pad)-ph.c_len+(overlap ? overlap : 0);
|
||||||
|
|
||||||
pad = 0;
|
pad = 0;
|
||||||
if (!opt->ps1.no_align)
|
if (!opt->ps1.no_align)
|
||||||
|
|||||||
+1
-1
@@ -110,7 +110,7 @@ void PackHeader::putPackHeader(upx_bytep p)
|
|||||||
assert(get_le32(p) == UPX_MAGIC_LE32);
|
assert(get_le32(p) == UPX_MAGIC_LE32);
|
||||||
if (get_le32(p+4) != UPX_MAGIC2_LE32)
|
if (get_le32(p+4) != UPX_MAGIC2_LE32)
|
||||||
{
|
{
|
||||||
//printf("%x %x\n", get_le32(p+4), UPX_MAGIC2_LE32);
|
//fprintf(stderr, "MAGIC2_LE32: %x %x\n", get_le32(p+4), UPX_MAGIC2_LE32);
|
||||||
throwBadLoader();
|
throwBadLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ void do_one_file(const char *iname, char *oname)
|
|||||||
#endif
|
#endif
|
||||||
if (st.st_size <= 0)
|
if (st.st_size <= 0)
|
||||||
throwIOException("empty file -- skipped");
|
throwIOException("empty file -- skipped");
|
||||||
|
if (st.st_size >= 1024*1024*1024)
|
||||||
|
throwIOException("file is too large -- skipped");
|
||||||
if ((st.st_mode & S_IWUSR) == 0)
|
if ((st.st_mode & S_IWUSR) == 0)
|
||||||
{
|
{
|
||||||
bool skip = true;
|
bool skip = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user