Big re-sync with UPX 1.2 branch.
committer: mfx <mfx> 1026835258 +0000
This commit is contained in:
+29
-12
@@ -2,8 +2,8 @@
|
||||
|
||||
This file is part of the UPX executable compressor.
|
||||
|
||||
Copyright (C) 1996-2001 Markus Franz Xaver Johannes Oberhumer
|
||||
Copyright (C) 1996-2001 Laszlo Molnar
|
||||
Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
|
||||
Copyright (C) 1996-2002 Laszlo Molnar
|
||||
All Rights Reserved.
|
||||
|
||||
UPX and the UCL library are free software; you can redistribute them
|
||||
@@ -21,8 +21,8 @@
|
||||
If not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||
markus@oberhumer.com ml1050@cdata.tvnet.hu
|
||||
Markus F.X.J. Oberhumer Laszlo Molnar
|
||||
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
|
||||
@@ -32,8 +32,13 @@
|
||||
#include "lefile.h"
|
||||
|
||||
|
||||
LeFile::LeFile(InputFile *f) : fif(f)
|
||||
LeFile::LeFile(InputFile *f) :
|
||||
fif(f), fof(NULL),
|
||||
le_offset(0), exe_offset(0)
|
||||
{
|
||||
COMPILE_TIME_ASSERT(sizeof(le_header_t) == 196);
|
||||
COMPILE_TIME_ASSERT(sizeof(le_object_table_entry_t) == 24);
|
||||
COMPILE_TIME_ASSERT(sizeof(le_pagemap_entry_t) == 4);
|
||||
memset(&ih,0,sizeof ih);
|
||||
memset(&oh,0,sizeof oh);
|
||||
iobject_table = oobject_table = NULL;
|
||||
@@ -43,7 +48,6 @@ LeFile::LeFile(InputFile *f) : fif(f)
|
||||
ifixups = ofixups = NULL;
|
||||
inonres_names = ononres_names = NULL;
|
||||
ientries = oentries = NULL;
|
||||
le_offset = exe_offset = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -168,6 +172,18 @@ void LeFile::writeFixups()
|
||||
}
|
||||
|
||||
|
||||
unsigned LeFile::getImageSize() const
|
||||
{
|
||||
unsigned n = 0;
|
||||
if (ih.memory_pages > 0)
|
||||
{
|
||||
n = (ih.memory_pages - 1) * ih.memory_page_size;
|
||||
n += ih.bytes_on_last_page;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
void LeFile::readImage()
|
||||
{
|
||||
soimage = pages*mps;
|
||||
@@ -295,7 +311,8 @@ void LeFile::writeFile(OutputFile *f, bool le)
|
||||
|
||||
void LeFile::countFixups(unsigned *counts) const
|
||||
{
|
||||
memset(counts,0,sizeof(unsigned)*(objects+2));
|
||||
const unsigned o = objects;
|
||||
memset(counts,0,sizeof(unsigned)*(o+2));
|
||||
// counts[0..objects-1] - # of 32-bit offset relocations in for that objects
|
||||
// counts[objects] - # of selector fixups
|
||||
// counts[objects+1] - # of self-relative fixups
|
||||
@@ -311,7 +328,7 @@ void LeFile::countFixups(unsigned *counts) const
|
||||
switch (*fix)
|
||||
{
|
||||
case 2: // selector fixup
|
||||
counts[objects] += 9;
|
||||
counts[o] += 9;
|
||||
fix += 5;
|
||||
break;
|
||||
case 0x12: // alias selector
|
||||
@@ -320,7 +337,7 @@ void LeFile::countFixups(unsigned *counts) const
|
||||
fix += (fix[1] & 0x10) ? 9 : 7;
|
||||
break;
|
||||
case 6: // 16:32 pointer
|
||||
counts[objects] += 9;
|
||||
counts[o] += 9;
|
||||
case 7: // 32-bit offset
|
||||
counts[fix[4]-1] += 4;
|
||||
fix += (fix[1] & 0x10) ? 9 : 7;
|
||||
@@ -332,15 +349,15 @@ void LeFile::countFixups(unsigned *counts) const
|
||||
fix += ll*2;
|
||||
break;
|
||||
case 8: // 32-bit self relative fixup
|
||||
counts[objects+1] += 4;
|
||||
counts[o+1] += 4;
|
||||
fix += (fix[1] & 0x10) ? 9 : 7;
|
||||
break;
|
||||
default:
|
||||
throwCantPack("unsupported fixup record");
|
||||
}
|
||||
}
|
||||
counts[objects]++; // extra space for 'ret'
|
||||
counts[objects+1] += 4; // extra space for 0xFFFFFFFF
|
||||
counts[o]++; // extra space for 'ret'
|
||||
counts[o+1] += 4; // extra space for 0xFFFFFFFF
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user