patchFilter32 added.

committer: ml1050 <ml1050> 976877022 +0000
This commit is contained in:
László Molnár 2000-12-15 10:43:42 +00:00
parent 4b8385856e
commit afcbf46519
6 changed files with 21 additions and 36 deletions

View File

@ -329,14 +329,7 @@ void PackDjgpp2::pack(OutputFile *fo)
// patch loader
patchPackHeader(loader,lsize);
patch_le32(loader,lsize,"ENTR",coff_hdr.a_entry);
if (ft.id)
{
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);
}
patchFilter32(ft, loader, lsize);
patch_le32(loader,lsize,"BSSL",overlapoh/4);
assert(bss->vaddr == ((size + 0x1ff) &~ 0x1ff) + (text->vaddr &~ 0x1ff));
patch_le32(loader,lsize,"OUTP",text->vaddr &~ 0x1ff);

View File

@ -223,16 +223,7 @@ void PackTmt::pack(OutputFile *fo)
// patch loader
patch_le32(loader,lsize,"JMPO",ih.entry-(ph.u_len+overlapoh+d_len));
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);
}
patchFilter32(ft, loader, lsize);
patchPackHeader(loader,e_len);
const unsigned jmp_pos = find_le32(loader,e_len,get_le32("JMPD"));

View File

@ -1720,16 +1720,12 @@ void PackW32Pe::pack(OutputFile *fo)
patch_le32(loader,codesize,"IMPS",myimport);
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;
if (texv)
patch_le32(loader,codesize,"TEXV",texv);
patch_le32(loader, codesize, "TEXV", texv);
}
if (tlsindex)
{

View File

@ -432,7 +432,6 @@ void PackWcle::pack(OutputFile *fo)
// filter
Filter ft(opt->level);
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
ifixups[sofixups++] = (unsigned char) ih.automatic_data_object;
@ -514,16 +513,8 @@ void PackWcle::pack(OutputFile *fo)
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,"ESP0",ih.init_esp_offset+IOT(ih.init_ss_object-1,my_base_address));
if (ft.id)
{
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);
}
if (patchFilter32(ft, p, d_len) && text_vaddr)
patch_le32(p, d_len, "TEXV", text_vaddr);
patch_le32(p,d_len,"RELO",mps*pages);
patchPackHeader(oimage,e_len);

View File

@ -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
*/

View File

@ -192,6 +192,7 @@ protected:
unsigned addvalue=0) const;
virtual void optimizeFilter(Filter *, const upx_byte *, unsigned) const
{ }
virtual bool patchFilter32(const Filter &, void *, unsigned);
// loader util
virtual int buildLoader(const Filter *) { return getLoaderSize(); }