diff --git a/src/p_com.cpp b/src/p_com.cpp index ce294c02..df8b599d 100644 --- a/src/p_com.cpp +++ b/src/p_com.cpp @@ -97,7 +97,7 @@ void PackCom::patchLoader(OutputFile *fo, unsigned calls, unsigned overlapoh) { 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; assert(e_len > 0 && e_len < 256); assert(d_len > 0 && d_len < 256); diff --git a/src/p_exe.cpp b/src/p_exe.cpp index 78914c7d..8ee7f493 100644 --- a/src/p_exe.cpp +++ b/src/p_exe.cpp @@ -264,7 +264,7 @@ void PackExe::pack(OutputFile *fo) fi->seek(ih.headsize16*16,SEEK_SET); 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(); // relocations @@ -413,7 +413,7 @@ void PackExe::pack(OutputFile *fo) //OutputFile::dump("xxloader.dat", loader, lsize); // patch loader - const unsigned e_len = getLoaderSection("EXECUTPO"); + const unsigned e_len = getLoaderSectionStart("EXECUTPO"); const unsigned d_len = lsize - e_len; assert((e_len&15) == 0); diff --git a/src/p_sys.cpp b/src/p_sys.cpp index eab94382..14ea1383 100644 --- a/src/p_sys.cpp +++ b/src/p_sys.cpp @@ -69,7 +69,7 @@ void PackSys::patchLoader(OutputFile *fo, unsigned calls, unsigned overlapoh) { 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; assert(e_len > 0 && e_len < 256); assert(d_len > 0 && d_len < 256); @@ -88,6 +88,7 @@ void PackSys::patchLoader(OutputFile *fo, assert(calls > 0); patch_le16(loader,lsize,"CT",calls); } + patchPackHeader(loader,e_len); 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); diff --git a/src/p_tmt.cpp b/src/p_tmt.cpp index a4c696f9..a574a6ea 100644 --- a/src/p_tmt.cpp +++ b/src/p_tmt.cpp @@ -217,7 +217,7 @@ void PackTmt::pack(OutputFile *fo) memcpy(loader,getLoader(),lsize); const unsigned s_point = getLoaderSection("TMTMAIN1"); - int e_len = getLoaderSection("TMTCUTPO"); + int e_len = getLoaderSectionStart("TMTCUTPO"); const unsigned d_len = lsize - e_len; assert(e_len > 0 && s_point > 0); diff --git a/src/p_wcle.cpp b/src/p_wcle.cpp index 6e24c6e5..cbea80a6 100644 --- a/src/p_wcle.cpp +++ b/src/p_wcle.cpp @@ -481,7 +481,7 @@ void PackWcle::pack(OutputFile *fo) const unsigned lsize = getLoaderSize(); neweip = getLoaderSection("WCLEMAIN"); - int e_len = getLoaderSection("WCLECUTP"); + int e_len = getLoaderSectionStart("WCLECUTP"); const unsigned d_len = lsize - e_len; assert(e_len > 0);