mirror of
https://github.com/upx/upx
synced 2025-10-05 19:20:23 +08:00
PE: Make imports in decompressor stub optional
This commit is contained in:
parent
76ddf6b8da
commit
1d9c211eed
|
@ -168,7 +168,7 @@ void PackW32Pe::buildLoader(const Filter *ft)
|
|||
addLoader("CLEARSTACK", nullptr);
|
||||
addLoader("PEMAIN21", nullptr);
|
||||
//NEW: last loader sections split up to insert TLS callback handler - Stefan Widmann
|
||||
addLoader(ih.entry ? "PEDOJUMP" : "PERETURN", nullptr);
|
||||
addLoader(ih.entry || !ilinker ? "PEDOJUMP" : "PERETURN", nullptr);
|
||||
|
||||
//NEW: TLS callback support PART 2, the callback handler - Stefan Widmann
|
||||
if(use_tls_callbacks)
|
||||
|
@ -232,16 +232,19 @@ void PackW32Pe::defineSymbols(unsigned ncsection, unsigned upxsection,
|
|||
}
|
||||
linker->defineSymbol("reloc_delt", 0u - (unsigned) ih.imagebase - rvamin);
|
||||
linker->defineSymbol("start_of_relocs", crelocs);
|
||||
if (!isdll)
|
||||
linker->defineSymbol("ExitProcess", 0u-rvamin +
|
||||
ilinkerGetAddress("kernel32.dll", "ExitProcess"));
|
||||
linker->defineSymbol("GetProcAddress", 0u-rvamin +
|
||||
ilinkerGetAddress("kernel32.dll", "GetProcAddress"));
|
||||
linker->defineSymbol("kernel32_ordinals", myimport);
|
||||
linker->defineSymbol("LoadLibraryA", 0u-rvamin +
|
||||
ilinkerGetAddress("kernel32.dll", "LoadLibraryA"));
|
||||
linker->defineSymbol("start_of_imports", myimport);
|
||||
linker->defineSymbol("compressed_imports", cimports);
|
||||
|
||||
if (ilinker) {
|
||||
if (!isdll)
|
||||
linker->defineSymbol("ExitProcess", 0u-rvamin +
|
||||
ilinkerGetAddress("kernel32.dll", "ExitProcess"));
|
||||
linker->defineSymbol("GetProcAddress", 0u-rvamin +
|
||||
ilinkerGetAddress("kernel32.dll", "GetProcAddress"));
|
||||
linker->defineSymbol("kernel32_ordinals", myimport);
|
||||
linker->defineSymbol("LoadLibraryA", 0u-rvamin +
|
||||
ilinkerGetAddress("kernel32.dll", "LoadLibraryA"));
|
||||
linker->defineSymbol("start_of_imports", myimport);
|
||||
linker->defineSymbol("compressed_imports", cimports);
|
||||
}
|
||||
|
||||
defineDecompressorSymbols();
|
||||
linker->defineSymbol("filter_buffer_start", ih.codebase - rvamin);
|
||||
|
|
|
@ -167,7 +167,7 @@ void PackW64Pep::buildLoader(const Filter *ft)
|
|||
|
||||
if (ih.entry && isdll)
|
||||
addLoader("PEISDLL9");
|
||||
addLoader(ih.entry ? "PEDOJUMP" : "PERETURN", nullptr);
|
||||
addLoader(ih.entry || !ilinker ? "PEDOJUMP" : "PERETURN", nullptr);
|
||||
|
||||
//NEW: TLS callback support PART 2, the callback handler - Stefan Widmann
|
||||
if(use_tls_callbacks)
|
||||
|
@ -227,16 +227,19 @@ void PackW64Pep::defineSymbols(unsigned ncsection, unsigned upxsection,
|
|||
ilinkerGetAddress("kernel32.dll", "VirtualProtect"));
|
||||
}
|
||||
linker->defineSymbol("start_of_relocs", crelocs);
|
||||
if (!isdll)
|
||||
linker->defineSymbol("ExitProcess",
|
||||
ilinkerGetAddress("kernel32.dll", "ExitProcess"));
|
||||
linker->defineSymbol("GetProcAddress",
|
||||
ilinkerGetAddress("kernel32.dll", "GetProcAddress"));
|
||||
linker->defineSymbol("kernel32_ordinals", myimport);
|
||||
linker->defineSymbol("LoadLibraryA",
|
||||
ilinkerGetAddress("kernel32.dll", "LoadLibraryA"));
|
||||
linker->defineSymbol("start_of_imports", myimport);
|
||||
linker->defineSymbol("compressed_imports", cimports);
|
||||
|
||||
if (ilinker) {
|
||||
if (!isdll)
|
||||
linker->defineSymbol("ExitProcess",
|
||||
ilinkerGetAddress("kernel32.dll", "ExitProcess"));
|
||||
linker->defineSymbol("GetProcAddress",
|
||||
ilinkerGetAddress("kernel32.dll", "GetProcAddress"));
|
||||
linker->defineSymbol("kernel32_ordinals", myimport);
|
||||
linker->defineSymbol("LoadLibraryA",
|
||||
ilinkerGetAddress("kernel32.dll", "LoadLibraryA"));
|
||||
linker->defineSymbol("start_of_imports", myimport);
|
||||
linker->defineSymbol("compressed_imports", cimports);
|
||||
}
|
||||
|
||||
if (M_IS_LZMA(ph.method))
|
||||
{
|
||||
|
|
|
@ -867,6 +867,9 @@ void PeFile::processImports2(unsigned myimport, unsigned) // pass 2
|
|||
{
|
||||
COMPILE_TIME_ASSERT(sizeof(import_desc) == 20);
|
||||
|
||||
if (!ilinker)
|
||||
return;
|
||||
|
||||
ilinker->relocate_import(myimport);
|
||||
int len;
|
||||
oimpdlls = ilinker->getLoader(&len);
|
||||
|
@ -2540,7 +2543,7 @@ void PeFile::pack0(OutputFile *fo, ht &ih, ht &oh,
|
|||
callProcessRelocs(rel, ic);
|
||||
|
||||
processImports2(ic, getProcessImportParam(upxsection));
|
||||
ODADDR(PEDIR_IMPORT) = ic;
|
||||
ODADDR(PEDIR_IMPORT) = soimpdlls ? ic : 0;
|
||||
ODSIZE(PEDIR_IMPORT) = soimpdlls;
|
||||
ic += soimpdlls;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user