# Step 05 -- COFF Loader with Symbol Resolution
#
# Builds:
#   COFFLoader.exe  -- the loader (links kernel32 for VirtualAlloc,
#                      LoadLibraryA, GetProcAddress)
#   hello_bof.o     -- test BOF to load
#
# Usage:
#   make            -- build everything
#   make run        -- build and run the loader on hello_bof.o
#   make clean      -- remove compiled files

CC_MINGW = x86_64-w64-mingw32-gcc
CFLAGS   = -c

all: COFFLoader.exe hello_bof.o

COFFLoader.exe: COFFLoader.c beacon_compatibility.c COFFLoader.h beacon_compatibility.h
	$(CC_MINGW) COFFLoader.c beacon_compatibility.c -o COFFLoader.exe -lkernel32

hello_bof.o: hello_bof.c beacon.h
	$(CC_MINGW) $(CFLAGS) hello_bof.c -o hello_bof.o

run: COFFLoader.exe hello_bof.o
	./COFFLoader.exe hello_bof.o

clean:
	rm -f COFFLoader.exe *.o *.obj
