Added PackUnix::writePackHeader().

committer: mfx <mfx> 979754833 +0000
This commit is contained in:
Markus F.X.J. Oberhumer
2001-01-17 18:07:13 +00:00
parent 4322931d97
commit d8baf6d1e8
3 changed files with 21 additions and 8 deletions
+1 -4
View File
@@ -401,10 +401,7 @@ void PackLinuxI386elf::pack(OutputFile *fo)
ph.c_len = total_out;
// write packheader
const int hsize = ph.getPackHeaderSize();
set_le32(obuf, UPX_MAGIC_LE32); // note: always le32
patchPackHeader(obuf, hsize);
fo->write(obuf, hsize);
writePackHeader(fo);
// write overlay offset (needed for decompression)
set_native32(obuf, lsize);
+18 -4
View File
@@ -75,6 +75,23 @@ bool PackUnix::canPack()
}
void PackUnix::writePackHeader(OutputFile *fo)
{
unsigned char buf[32];
memset(buf, 0, sizeof(buf));
const int hsize = ph.getPackHeaderSize();
assert((unsigned)hsize <= sizeof(buf));
// note: magic constants are always le32
set_le32(buf+0, UPX_MAGIC_LE32);
set_le32(buf+4, UPX_MAGIC2_LE32);
patchPackHeader(buf, hsize);
fo->write(buf, hsize);
}
/*************************************************************************
// Generic Unix pack(). Subclasses must provide patchLoader().
//
@@ -186,10 +203,7 @@ void PackUnix::pack(OutputFile *fo)
ph.c_len = total_out;
// write packheader
const int hsize = ph.getPackHeaderSize();
set_le32(obuf, UPX_MAGIC_LE32); // note: always le32
patchPackHeader(obuf, hsize);
fo->write(obuf, hsize);
writePackHeader(fo);
// write overlay offset (needed for decompression)
set_native32(obuf, lsize);
+2
View File
@@ -56,6 +56,8 @@ protected:
virtual void patchLoaderChecksum() {}
virtual void updateLoader(OutputFile *) = 0;
virtual void writePackHeader(OutputFile *fo);
// in order too share as much code as possible we introduce
// an endian abstraction here
virtual unsigned get_native32(const void *, int off=0) = 0;