pe: win32/win64 pack/unpack seems to work again
This commit is contained in:
+6
-9
@@ -107,11 +107,7 @@ static void xcheck(size_t poff, size_t plen, const void *b, size_t blen)
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
PackW32Pe::PackW32Pe(InputFile *f) : super(f)
|
PackW32Pe::PackW32Pe(InputFile *f) : super(f)
|
||||||
{
|
{}
|
||||||
isrtm = false;
|
|
||||||
use_dep_hack = true;
|
|
||||||
use_clear_dirty_stack = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PackW32Pe::~PackW32Pe()
|
PackW32Pe::~PackW32Pe()
|
||||||
@@ -297,17 +293,18 @@ void PackW32Pe::defineSymbols(unsigned ncsection, unsigned upxsection,
|
|||||||
linker->defineSymbol("vp_size", ((addr & 0xfff) + 0x28 >= 0x1000) ?
|
linker->defineSymbol("vp_size", ((addr & 0xfff) + 0x28 >= 0x1000) ?
|
||||||
0x2000 : 0x1000); // 2 pages or 1 page
|
0x2000 : 0x1000); // 2 pages or 1 page
|
||||||
linker->defineSymbol("vp_base", addr &~ 0xfff); // page mask
|
linker->defineSymbol("vp_base", addr &~ 0xfff); // page mask
|
||||||
linker->defineSymbol("VirtualProtect", myimport +
|
linker->defineSymbol("VirtualProtect", -rvamin +
|
||||||
ilinkerGetAddress("kernel32.dll", "VirtualProtect"));
|
ilinkerGetAddress("kernel32.dll", "VirtualProtect"));
|
||||||
}
|
}
|
||||||
linker->defineSymbol("reloc_delt", 0u - (unsigned) ih.imagebase - rvamin);
|
linker->defineSymbol("reloc_delt", 0u - (unsigned) ih.imagebase - rvamin);
|
||||||
linker->defineSymbol("start_of_relocs", crelocs);
|
linker->defineSymbol("start_of_relocs", crelocs);
|
||||||
linker->defineSymbol("ExitProcess", myimport +
|
if (!isdll)
|
||||||
|
linker->defineSymbol("ExitProcess", -rvamin +
|
||||||
ilinkerGetAddress("kernel32.dll", "ExitProcess"));
|
ilinkerGetAddress("kernel32.dll", "ExitProcess"));
|
||||||
linker->defineSymbol("GetProcAddress", myimport +
|
linker->defineSymbol("GetProcAddress", -rvamin +
|
||||||
ilinkerGetAddress("kernel32.dll", "GetProcAddress"));
|
ilinkerGetAddress("kernel32.dll", "GetProcAddress"));
|
||||||
linker->defineSymbol("kernel32_ordinals", myimport);
|
linker->defineSymbol("kernel32_ordinals", myimport);
|
||||||
linker->defineSymbol("LoadLibraryA", myimport +
|
linker->defineSymbol("LoadLibraryA", -rvamin +
|
||||||
ilinkerGetAddress("kernel32.dll", "LoadLibraryA"));
|
ilinkerGetAddress("kernel32.dll", "LoadLibraryA"));
|
||||||
linker->defineSymbol("start_of_imports", myimport);
|
linker->defineSymbol("start_of_imports", myimport);
|
||||||
linker->defineSymbol("compressed_imports", cimports);
|
linker->defineSymbol("compressed_imports", cimports);
|
||||||
|
|||||||
+1
-5
@@ -112,11 +112,7 @@ static void xcheck(size_t poff, size_t plen, const void *b, size_t blen)
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
PackW64Pep::PackW64Pep(InputFile *f) : super(f)
|
PackW64Pep::PackW64Pep(InputFile *f) : super(f)
|
||||||
{
|
{}
|
||||||
isrtm = false;
|
|
||||||
use_dep_hack = true;
|
|
||||||
use_clear_dirty_stack = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PackW64Pep::~PackW64Pep()
|
PackW64Pep::~PackW64Pep()
|
||||||
|
|||||||
@@ -59,10 +59,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual void buildLoader(const Filter *ft);
|
virtual void buildLoader(const Filter *ft);
|
||||||
virtual Linker* newLinker() const;
|
virtual Linker* newLinker() const;
|
||||||
|
|
||||||
bool isrtm;
|
|
||||||
bool use_dep_hack;
|
|
||||||
bool use_clear_dirty_stack;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -139,6 +139,10 @@ PeFile::PeFile(InputFile *f) : super(f)
|
|||||||
use_tls_callbacks = false;
|
use_tls_callbacks = false;
|
||||||
oloadconf = NULL;
|
oloadconf = NULL;
|
||||||
soloadconf = 0;
|
soloadconf = 0;
|
||||||
|
|
||||||
|
use_dep_hack = true;
|
||||||
|
use_clear_dirty_stack = true;
|
||||||
|
isrtm = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -763,6 +767,7 @@ public:
|
|||||||
for (unsigned ic = 0; ic < nsections; ic++)
|
for (unsigned ic = 0; ic < nsections; ic++)
|
||||||
osize += sections[ic]->size;
|
osize += sections[ic]->size;
|
||||||
output = new upx_byte[osize];
|
output = new upx_byte[osize];
|
||||||
|
outputlen = 0;
|
||||||
|
|
||||||
// sort the sections by name before adding them all
|
// sort the sections by name before adding them all
|
||||||
qsort(sections, nsections, sizeof (Section*), ImportLinker::compare);
|
qsort(sections, nsections, sizeof (Section*), ImportLinker::compare);
|
||||||
|
|||||||
Reference in New Issue
Block a user