📄 loader.txt
字号:
This documentation is written for those brave souls who want tounderstand and/or modify the UPX assembly stubs - the small snippetsthat do the runtime decompression when a compressed program is started.If you look at the C++ source files, you can find code fragments likethis: addLoader("PEMAIN20", ih.entry ? "PEDOJUMP" : "PERETURN", "IDENTSTR""UPX1HEAD", NULL ); linker->defineSymbol("original_entry", ih.entry);and in the assembly files fragments like this: section PEISDLL1 cmpb [esp + 8], 1 jnz reloc_end_jmp section PEMAIN21 reloc_end_jmp: section PERETURN xor eax, eax inc eax ret 0x0C section PEDOJUMP jmp original_entryEverything works as you would expect. If you want to add the codefragment which is in `section PERETURN' to the runtime stub, thensimply use `addLoader("PERETURN")' in the C++ source.That's nice, you could say, but how cross section jumps and calls arehandled? Well, that is the nicest part of this stuff - they are handledautomatically. All you have to do is to add the required sections to theloader using `addLoader()' and the rest is done by upx. It will resolveevery conditional or unconditional jumps or subroutine calls for you.You can also use (undefined) symbols in the assembly for values thatcan only be computed during compression time (like `original_entry').These symbols can be defined later in C++ using linker->defineSymbol("xx", yy)This functionality (we could say it's a simple linker) is achieved bycompiling the assembly into an ELF object file which a little C++module (src/linker.cpp) can interpret and work with.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -