Simple Loader (Resource Masking)

This is a Simple Loader with Free() that uses Crystal Palace's generate and xor instructions to mask the appended DLL and PICO. This project also demonstrates printf-style debugging too.

Project Files

Notes

loader.spec is an important player here. We use generate to generate an arbitrary sized key. We use xor to mask our appended assets before we link them. And, notice after each xor, we make use of preplen. This command prepends the [length] of our data to that data. This length hint is critical for unmasking the right amount of data.

loader.c implements the needed code to unmask the appended resources. The random XOR key is an appended resource too.

And, debug.h is the bonus in this project. This header file includes functions to aid with printf-style debugging when writing PIC using these conventions. The dprintf function uses OutputDebugStringA. You will need DbgView.exe from Microsoft's Sysinternals Suite to view this output.

Here, I've used char foo[] { 's', 't', 'a', 'c', 'k', ' ', 's', 't', 'r', 'i', 'n', 'g', 's', 0 } to make this example work on x86 and x64. This isn't necessary for x64-only builds though. Use make pic64 in your .spec file and "string literals" will work in x64 position-independent code.

License

This project is licensed under the GNU General Public License version 2 (GPLv2) or later..