patchFilter32 added.
committer: ml1050 <ml1050> 976877022 +0000
This commit is contained in:
+1
-8
@@ -329,14 +329,7 @@ void PackDjgpp2::pack(OutputFile *fo)
|
|||||||
// patch loader
|
// patch loader
|
||||||
patchPackHeader(loader,lsize);
|
patchPackHeader(loader,lsize);
|
||||||
patch_le32(loader,lsize,"ENTR",coff_hdr.a_entry);
|
patch_le32(loader,lsize,"ENTR",coff_hdr.a_entry);
|
||||||
if (ft.id)
|
patchFilter32(ft, loader, lsize);
|
||||||
{
|
|
||||||
assert(ft.calls > 0);
|
|
||||||
if (ft.id > 0x20)
|
|
||||||
patch_le16(loader,lsize,"??",'?' + (ft.cto << 8));
|
|
||||||
patch_le32(loader,lsize,"TEXL",(ft.id & 0xf) % 3 == 0 ? ft.calls :
|
|
||||||
ft.lastcall - ft.calls * 4);
|
|
||||||
}
|
|
||||||
patch_le32(loader,lsize,"BSSL",overlapoh/4);
|
patch_le32(loader,lsize,"BSSL",overlapoh/4);
|
||||||
assert(bss->vaddr == ((size + 0x1ff) &~ 0x1ff) + (text->vaddr &~ 0x1ff));
|
assert(bss->vaddr == ((size + 0x1ff) &~ 0x1ff) + (text->vaddr &~ 0x1ff));
|
||||||
patch_le32(loader,lsize,"OUTP",text->vaddr &~ 0x1ff);
|
patch_le32(loader,lsize,"OUTP",text->vaddr &~ 0x1ff);
|
||||||
|
|||||||
+1
-10
@@ -223,16 +223,7 @@ void PackTmt::pack(OutputFile *fo)
|
|||||||
|
|
||||||
// patch loader
|
// patch loader
|
||||||
patch_le32(loader,lsize,"JMPO",ih.entry-(ph.u_len+overlapoh+d_len));
|
patch_le32(loader,lsize,"JMPO",ih.entry-(ph.u_len+overlapoh+d_len));
|
||||||
|
patchFilter32(ft, loader, lsize);
|
||||||
if (ft.id)
|
|
||||||
{
|
|
||||||
assert(ft.calls > 0);
|
|
||||||
if (ft.id > 0x20)
|
|
||||||
patch_le16(loader,lsize,"??",'?'+(ph.filter_cto << 8));
|
|
||||||
patch_le32(loader,lsize,"TEXL",(ft.id & 0xf) % 3 == 0 ? ft.calls :
|
|
||||||
ft.lastcall - ft.calls * 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
patchPackHeader(loader,e_len);
|
patchPackHeader(loader,e_len);
|
||||||
|
|
||||||
const unsigned jmp_pos = find_le32(loader,e_len,get_le32("JMPD"));
|
const unsigned jmp_pos = find_le32(loader,e_len,get_le32("JMPD"));
|
||||||
|
|||||||
+3
-7
@@ -1720,16 +1720,12 @@ void PackW32Pe::pack(OutputFile *fo)
|
|||||||
patch_le32(loader,codesize,"IMPS",myimport);
|
patch_le32(loader,codesize,"IMPS",myimport);
|
||||||
patch_le32(loader,codesize,"BIMP",cimports);
|
patch_le32(loader,codesize,"BIMP",cimports);
|
||||||
}
|
}
|
||||||
if (ft.id)
|
|
||||||
|
if (patchFilter32(ft, loader, lsize))
|
||||||
{
|
{
|
||||||
assert(ft.calls > 0);
|
|
||||||
if (ft.id > 0x20)
|
|
||||||
patch_le16(loader,codesize,"??",'?' + (ft.cto << 8));
|
|
||||||
patch_le32(loader,lsize,"TEXL",(ft.id & 0xf) % 3 == 0 ? ft.calls :
|
|
||||||
ft.lastcall - ft.calls * 4);
|
|
||||||
const unsigned texv = ih.codebase - rvamin;
|
const unsigned texv = ih.codebase - rvamin;
|
||||||
if (texv)
|
if (texv)
|
||||||
patch_le32(loader,codesize,"TEXV",texv);
|
patch_le32(loader, codesize, "TEXV", texv);
|
||||||
}
|
}
|
||||||
if (tlsindex)
|
if (tlsindex)
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-11
@@ -432,7 +432,6 @@ void PackWcle::pack(OutputFile *fo)
|
|||||||
// filter
|
// filter
|
||||||
Filter ft(opt->level);
|
Filter ft(opt->level);
|
||||||
tryFilters(&ft, iimage+text_vaddr, text_size, text_vaddr);
|
tryFilters(&ft, iimage+text_vaddr, text_size, text_vaddr);
|
||||||
const unsigned calltrickoffset = ft.cto << 24;
|
|
||||||
|
|
||||||
// attach some useful data at the end of preprocessed fixups
|
// attach some useful data at the end of preprocessed fixups
|
||||||
ifixups[sofixups++] = (unsigned char) ih.automatic_data_object;
|
ifixups[sofixups++] = (unsigned char) ih.automatic_data_object;
|
||||||
@@ -514,16 +513,8 @@ void PackWcle::pack(OutputFile *fo)
|
|||||||
upx_byte *p = oimage+soimage-d_len;
|
upx_byte *p = oimage+soimage-d_len;
|
||||||
patch_le32(p,d_len,"JMPO",ih.init_eip_offset+text_vaddr-(ic+d_len));
|
patch_le32(p,d_len,"JMPO",ih.init_eip_offset+text_vaddr-(ic+d_len));
|
||||||
patch_le32(p,d_len,"ESP0",ih.init_esp_offset+IOT(ih.init_ss_object-1,my_base_address));
|
patch_le32(p,d_len,"ESP0",ih.init_esp_offset+IOT(ih.init_ss_object-1,my_base_address));
|
||||||
if (ft.id)
|
if (patchFilter32(ft, p, d_len) && text_vaddr)
|
||||||
{
|
patch_le32(p, d_len, "TEXV", text_vaddr);
|
||||||
assert(ft.calls > 0);
|
|
||||||
if (ft.id > 0x20)
|
|
||||||
patch_le16(p,d_len,"??",'?'+(calltrickoffset>>16));
|
|
||||||
patch_le32(p,d_len,"TEXL",(ft.id & 0xf) % 3 == 0 ? ft.calls :
|
|
||||||
ft.lastcall - ft.calls * 4);
|
|
||||||
if (text_vaddr)
|
|
||||||
patch_le32(p,d_len,"TEXV",text_vaddr);
|
|
||||||
}
|
|
||||||
patch_le32(p,d_len,"RELO",mps*pages);
|
patch_le32(p,d_len,"RELO",mps*pages);
|
||||||
|
|
||||||
patchPackHeader(oimage,e_len);
|
patchPackHeader(oimage,e_len);
|
||||||
|
|||||||
@@ -1301,6 +1301,19 @@ void Packer::scanFilters(Filter *ft, const upx_byte *buf, unsigned buf_len,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Packer::patchFilter32(const Filter &ft, void *loader, unsigned lsize)
|
||||||
|
{
|
||||||
|
if (ft.id == 0)
|
||||||
|
return false;
|
||||||
|
assert(ft.calls > 0);
|
||||||
|
if (ft.id > 0x20)
|
||||||
|
patch_le16(loader, lsize, "??", '?' + (ft.cto << 8));
|
||||||
|
patch_le32(loader, lsize, "TEXL", (ft.id & 0xf) % 3 == 0 ? ft.calls :
|
||||||
|
ft.lastcall - ft.calls * 4);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
vi:ts=4:et:nowrap
|
vi:ts=4:et:nowrap
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ protected:
|
|||||||
unsigned addvalue=0) const;
|
unsigned addvalue=0) const;
|
||||||
virtual void optimizeFilter(Filter *, const upx_byte *, unsigned) const
|
virtual void optimizeFilter(Filter *, const upx_byte *, unsigned) const
|
||||||
{ }
|
{ }
|
||||||
|
virtual bool patchFilter32(const Filter &, void *, unsigned);
|
||||||
|
|
||||||
// loader util
|
// loader util
|
||||||
virtual int buildLoader(const Filter *) { return getLoaderSize(); }
|
virtual int buildLoader(const Filter *) { return getLoaderSize(); }
|
||||||
|
|||||||
Reference in New Issue
Block a user