Skip to content
This repository was archived by the owner on Apr 29, 2020. It is now read-only.

Commit 9c980c4

Browse files
committed
Initial commit
0 parents  commit 9c980c4

File tree

4 files changed

+456
-0
lines changed

4 files changed

+456
-0
lines changed

Makefile

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
#---------------------------------------------------------------------------------
2+
.SUFFIXES:
3+
#---------------------------------------------------------------------------------
4+
5+
ifeq ($(strip $(DEVKITPRO)),)
6+
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
7+
endif
8+
9+
TOPDIR ?= $(CURDIR)
10+
include $(DEVKITPRO)/libnx/switch_rules
11+
12+
#---------------------------------------------------------------------------------
13+
# TARGET is the name of the output
14+
# BUILD is the directory where object files & intermediate files will be placed
15+
# SOURCES is a list of directories containing source code
16+
# DATA is a list of directories containing data files
17+
# INCLUDES is a list of directories containing header files
18+
# EXEFS_SRC is the optional input directory containing data copied into exefs, if anything this normally should only contain "main.npdm".
19+
#
20+
# NO_ICON: if set to anything, do not use icon.
21+
# NO_NACP: if set to anything, no .nacp file is generated.
22+
# APP_TITLE is the name of the app stored in the .nacp file (Optional)
23+
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
24+
# APP_VERSION is the version of the app stored in the .nacp file (Optional)
25+
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
26+
# ICON is the filename of the icon (.jpg), relative to the project folder.
27+
# If not set, it attempts to use one of the following (in this order):
28+
# - <Project name>.jpg
29+
# - icon.jpg
30+
# - <libnx folder>/default_icon.jpg
31+
#---------------------------------------------------------------------------------
32+
TARGET := $(notdir $(CURDIR))
33+
BUILD := build
34+
SOURCES := source
35+
DATA := data
36+
INCLUDES := include
37+
EXEFS_SRC := exefs_src
38+
39+
#---------------------------------------------------------------------------------
40+
# options for code generation
41+
#---------------------------------------------------------------------------------
42+
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE
43+
44+
CFLAGS := -g -Wall -O2 -ffunction-sections \
45+
$(ARCH) $(DEFINES)
46+
47+
CFLAGS += $(INCLUDE) -DSWITCH
48+
49+
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
50+
51+
ASFLAGS := -g $(ARCH)
52+
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
53+
54+
LIBS := -lnx
55+
56+
#---------------------------------------------------------------------------------
57+
# list of directories containing libraries, this must be the top level containing
58+
# include and lib
59+
#---------------------------------------------------------------------------------
60+
LIBDIRS := $(PORTLIBS) $(LIBNX)
61+
62+
63+
#---------------------------------------------------------------------------------
64+
# no real need to edit anything past this point unless you need to add additional
65+
# rules for different file extensions
66+
#---------------------------------------------------------------------------------
67+
ifneq ($(BUILD),$(notdir $(CURDIR)))
68+
#---------------------------------------------------------------------------------
69+
70+
export OUTPUT := $(CURDIR)/$(TARGET)
71+
export TOPDIR := $(CURDIR)
72+
73+
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
74+
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
75+
76+
export DEPSDIR := $(CURDIR)/$(BUILD)
77+
78+
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
79+
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
80+
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
81+
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
82+
83+
#---------------------------------------------------------------------------------
84+
# use CXX for linking C++ projects, CC for standard C
85+
#---------------------------------------------------------------------------------
86+
ifeq ($(strip $(CPPFILES)),)
87+
#---------------------------------------------------------------------------------
88+
export LD := $(CC)
89+
#---------------------------------------------------------------------------------
90+
else
91+
#---------------------------------------------------------------------------------
92+
export LD := $(CXX)
93+
#---------------------------------------------------------------------------------
94+
endif
95+
#---------------------------------------------------------------------------------
96+
97+
export OFILES := $(addsuffix .o,$(BINFILES)) \
98+
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
99+
100+
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
101+
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
102+
-I$(CURDIR)/$(BUILD)
103+
104+
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
105+
106+
export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC)
107+
108+
ifeq ($(strip $(ICON)),)
109+
icons := $(wildcard *.jpg)
110+
ifneq (,$(findstring $(TARGET).jpg,$(icons)))
111+
export APP_ICON := $(TOPDIR)/$(TARGET).jpg
112+
else
113+
ifneq (,$(findstring icon.jpg,$(icons)))
114+
export APP_ICON := $(TOPDIR)/icon.jpg
115+
endif
116+
endif
117+
else
118+
export APP_ICON := $(TOPDIR)/$(ICON)
119+
endif
120+
121+
ifeq ($(strip $(NO_ICON)),)
122+
export NROFLAGS += --icon=$(APP_ICON)
123+
endif
124+
125+
ifeq ($(strip $(NO_NACP)),)
126+
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
127+
endif
128+
129+
ifneq ($(APP_TITLEID),)
130+
export NACPFLAGS += --titleid=$(APP_TITLEID)
131+
endif
132+
133+
.PHONY: $(BUILD) clean all
134+
135+
#---------------------------------------------------------------------------------
136+
all: $(BUILD)
137+
138+
$(BUILD):
139+
@[ -d $@ ] || mkdir -p $@
140+
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
141+
142+
#---------------------------------------------------------------------------------
143+
clean:
144+
@echo clean ...
145+
@rm -fr $(BUILD) $(TARGET).pfs0 $(TARGET).nso $(TARGET).nro $(TARGET).kip $(TARGET).nacp $(TARGET).elf
146+
147+
148+
#---------------------------------------------------------------------------------
149+
else
150+
.PHONY: all
151+
152+
DEPENDS := $(OFILES:.o=.d)
153+
154+
#---------------------------------------------------------------------------------
155+
# main targets
156+
#---------------------------------------------------------------------------------
157+
all : $(OUTPUT).pfs0 $(OUTPUT).nro $(OUTPUT).kip
158+
159+
$(OUTPUT).pfs0 : $(OUTPUT).nso
160+
161+
$(OUTPUT).nso : $(OUTPUT).elf
162+
$(OUTPUT).kip : $(OUTPUT).elf
163+
elf2kip $(OUTPUT).elf $(CURDIR)/../nxldrldr.json $(OUTPUT).kip
164+
165+
ifeq ($(strip $(NO_NACP)),)
166+
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
167+
else
168+
$(OUTPUT).nro : $(OUTPUT).elf
169+
endif
170+
171+
$(OUTPUT).elf : $(OFILES)
172+
173+
#---------------------------------------------------------------------------------
174+
# you need a rule like this for each extension you use as binary data
175+
#---------------------------------------------------------------------------------
176+
%.bin.o : %.bin
177+
#---------------------------------------------------------------------------------
178+
@echo $(notdir $<)
179+
@$(bin2o)
180+
181+
-include $(DEPENDS)
182+
183+
#---------------------------------------------------------------------------------------
184+
endif
185+
#---------------------------------------------------------------------------------------

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# nx-hbloaderloader
2+
A small KIP that:
3+
* patches FS to re-insert nspwn (a vulnerability that was patched in 5.0.0).
4+
* and redirects the Album title to the sdcard path `bootloader/hbl.nsp`
5+
6+
## Usage
7+
With hekate:
8+
9+
* Build nx-hbloader and put it on your sdcard at `bootloader/hbl.nsp`
10+
* Build nx-hbloaderloader and put the resulting kip at `bootloader/nxldrldr.kip`
11+
* Add it to the `bootloader/hekate_ipl.ini` (it needs to have debug-mode):
12+
13+
```
14+
kip1=bootloader/nxldrldr.kip
15+
debugmode=1
16+
```

0 commit comments

Comments
 (0)