Simple Object Loader
This project demonstrates a PIC loader applied to a COFF capability.
Project Files
Notes
The loader.c file is similar to what we've seen before. It's the same stuff. Except, instead of running a DLL capability, we're running a Crystal Palace PICO (COFF).
COFF as a capability container has several benefits over DLLs:
- You know exactly what's in the program and have full control over it
- They're small
- It's possible to separate the .text section (code) and data into disparate parts of memory
- And, you can apply Crystal Palace binary transformations like +mutate, +optimize, and +disco to your COFF capability too!
Use the ./link
program to load the test.x86.o or test.x64.o demonstration programs:
./link /path/to/simpleobj/loader.spec demo/test.x64.o out.bin
Note that when a .o file is provided to ./link
(or the Crystal Palace Java API), the capability content is in the $OBJECT
variable.
This project is also a good playground for Crystal Palace's binary transformations. Here, I've applied +optimize
to our loader PIC. This transform removes any unused functions from our program. This is especially handy here, as we don't need all of the Reflective DLL loading code. We need SOME (to walk the Export Address table and resolve GetProcAddress/LoaderLibraryA). But, we don't need all of it.
loader.spec also shows the disassemble "out.txt"
command. This is an optional command and it's meant for debugging and awareness of what Crystal Palace is doing. It disassemble the COFF/PIC on the top of the program stack and outputs that information to a file (out.txt in this case).
Other binary transforms you can apply include +disco
which randomizes function order and +mutate
which is Crystal Palace's code mutator. You're welcome to use any combination of these transforms with the make pic
, make pic64
, and make object
commands.
License
This project is licensed under the GNU General Public License version 2 (GPLv2) or later..