Reintroduce the CakeBrah patch to avoid having the Luma3DS.dat file on *hax/menuhax
This commit is contained in:
parent
185ea86284
commit
c1f55735fc
4
Makefile
4
Makefile
@ -34,8 +34,8 @@ objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
||||
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
|
||||
$(call rwildcard, $(dir_source), *.s *.c)))
|
||||
|
||||
bundled = $(dir_build)/reboot.bin.o $(dir_build)/emunand.bin.o $(dir_build)/svcGetCFWInfo.bin.o $(dir_build)/injector.bin.o \
|
||||
$(dir_build)/loader.bin.o $(dir_build)/k11modules.bin.o $(dir_build)/arm9_exceptions.bin.o $(dir_build)/arm11_exceptions.bin.o
|
||||
bundled = $(dir_build)/reboot.bin.o $(dir_build)/emunand.bin.o $(dir_build)/svcGetCFWInfo.bin.o $(dir_build)/k11modules.bin.o \
|
||||
$(dir_build)/injector.bin.o $(dir_build)/loader.bin.o $(dir_build)/arm9_exceptions.bin.o $(dir_build)/arm11_exceptions.bin.o
|
||||
|
||||
define bin2o
|
||||
bin2s $< | $(AS) -o $(@)
|
||||
|
@ -12,6 +12,7 @@ LD := arm-none-eabi-ld
|
||||
OC := arm-none-eabi-objcopy
|
||||
|
||||
dir_source := source
|
||||
dir_diffs := diffs
|
||||
dir_cakebrah := CakeBrah
|
||||
dir_cakehax := CakeHax
|
||||
dir_cakesrop := CakesROP
|
||||
@ -29,7 +30,7 @@ objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
||||
$(call rwildcard, $(dir_source), *.s *.c)))
|
||||
|
||||
.PHONY: all
|
||||
all: $(dir_out)/$(name).dat $(dir_out)/hax/3ds/$(name) $(dir_out)/menuhax/boot.3dsx $(dir_out)/mset/$(name).nds
|
||||
all: $(dir_out)/mset-spider/$(name).dat $(dir_out)/hax/3ds/$(name) $(dir_out)/menuhax/boot.3dsx $(dir_out)/mset/$(name).nds
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@ -38,18 +39,20 @@ clean:
|
||||
@$(MAKE) $(ROPFLAGS) -C $(dir_cakesrop) clean
|
||||
@rm -rf $(dir_build)
|
||||
|
||||
$(dir_out)/$(name).dat: $(dir_build)/main.bin
|
||||
$(dir_out)/mset-spider/$(name).dat: $(dir_build)/main.bin
|
||||
@mkdir -p "$(@D)"
|
||||
@$(MAKE) $(FLAGS) -C $(dir_cakehax) launcher
|
||||
@dd if=$(dir_build)/main.bin of=$@ bs=512 seek=144
|
||||
@dd if=$(dir_build)/main.bin of=$(dir_out)/$(name).dat bs=512 seek=144
|
||||
@mv $(dir_out)/$(name).dat $@
|
||||
|
||||
$(dir_out)/hax/3ds/$(name):
|
||||
@mkdir -p "$@"
|
||||
@$(MAKE) $(FLAGS) -C $(dir_cakebrah)
|
||||
@cd $(dir_cakebrah); patch -p1 < ../$(dir_diffs)/1.diff; $(MAKE) $(FLAGS); git reset --hard
|
||||
@mv $(dir_out)/$(name).3dsx $(dir_out)/$(name).smdh $@
|
||||
|
||||
$(dir_out)/menuhax/boot.3dsx: $(dir_out)/hax/3ds/$(name)
|
||||
@mkdir -p "$(@D)"
|
||||
@cd $(dir_cakebrah); patch -p1 < ../menuhax.diff; $(MAKE) $(FLAGS); git reset --hard
|
||||
@cd $(dir_cakebrah); patch -p1 < ../$(dir_diffs)/1.diff; patch -p1 < ../$(dir_diffs)/2.diff; $(MAKE) $(FLAGS); git reset --hard
|
||||
@mv $(dir_out)/$(name).3dsx $@
|
||||
@rm $(dir_out)/$(name).smdh
|
||||
|
||||
|
116
haxloader/diffs/1.diff
Normal file
116
haxloader/diffs/1.diff
Normal file
@ -0,0 +1,116 @@
|
||||
diff -uNr a/include/brahma.h b/include/brahma.h
|
||||
--- a/include/brahma.h 2016-09-21 16:18:56.246840000 +0200
|
||||
+++ b/include/brahma.h 2016-09-21 16:20:28.975957322 +0200
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
u32 brahma_init (void);
|
||||
u32 brahma_exit (void);
|
||||
-s32 load_arm9_payload_offset (char *filename, u32 offset, u32 max_psize);
|
||||
+s32 load_arm9_payload_offset (void);
|
||||
s32 load_arm9_payload_from_mem (u8* data, u32 dsize);
|
||||
void redirect_codeflow (u32 *dst_addr, u32 *src_addr);
|
||||
s32 map_arm9_payload (void);
|
||||
@@ -13,8 +13,6 @@
|
||||
s32 get_exploit_data (struct exploit_data *data);
|
||||
s32 firm_reboot ();
|
||||
|
||||
-#define load_arm9_payload(filename) load_arm9_payload_offset(filename, 0, 0)
|
||||
-
|
||||
#define BRAHMA_NETWORK_PORT 80
|
||||
|
||||
#define ARM_JUMPOUT 0xE51FF004 // LDR PC, [PC, -#04]
|
||||
diff -uNr a/source/brahma.c b/source/brahma.c
|
||||
--- a/source/brahma.c 2016-09-21 16:18:56.246840000 +0200
|
||||
+++ b/source/brahma.c 2016-09-21 16:21:33.240730777 +0200
|
||||
@@ -179,39 +179,56 @@
|
||||
return g_ext_arm9_loaded;
|
||||
}
|
||||
|
||||
-/* reads ARM9 payload from a given path.
|
||||
- filename: full path of payload
|
||||
- offset: offset of the payload in the file
|
||||
- max_psize: the maximum size of the payload that should be loaded (if 0, ARM9_MAX_PAYLOAD_SIZE. Should be smaller than ARM9_MAX_PAYLOAD_SIZE)
|
||||
+/* reads Luma payload
|
||||
returns: 0 on failure, 1 on success */
|
||||
-s32 load_arm9_payload_offset (char *filename, u32 offset, u32 max_psize) {
|
||||
+s32 load_arm9_payload_offset (void) {
|
||||
s32 result = 0;
|
||||
u32 fsize = 0;
|
||||
u32 psize = 0;
|
||||
+ bool use_default = true;
|
||||
+ FILE *f;
|
||||
|
||||
- if (max_psize == 0 || max_psize > ARM9_PAYLOAD_MAX_SIZE)
|
||||
- max_psize = ARM9_PAYLOAD_MAX_SIZE;
|
||||
+ FILE *p = fopen("/luma/path.txt", "r");
|
||||
|
||||
- if (!filename)
|
||||
- return result;
|
||||
+ if (p) {
|
||||
+ fseek(p , 0, SEEK_END);
|
||||
+ psize = ftell(p);
|
||||
+ if (psize > 5 && psize < 40) {
|
||||
+ char path[psize + 1];
|
||||
+
|
||||
+ fseek(p, 0, SEEK_SET);
|
||||
+ u32 bytes_read = fread(path, 1, psize, p);
|
||||
+
|
||||
+ if (bytes_read == psize) {
|
||||
+ if (path[psize - 1] == 0xA) psize--;
|
||||
+ if (path[psize - 1] == 0xD) psize--;
|
||||
+ if (psize > 5 && psize < 38 && path[0] == '/' && memcmp(&path[psize - 4], ".bin", 4)) {
|
||||
+ path[psize] = 0;
|
||||
+ f = fopen(path, "rb");
|
||||
+ use_default = false;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ fclose(p);
|
||||
+ }
|
||||
+
|
||||
+ if (use_default) f = fopen("/arm9loaderhax.bin", "rb");
|
||||
+
|
||||
+ u32 max_size = ARM9_PAYLOAD_MAX_SIZE;
|
||||
|
||||
- FILE *f = fopen(filename, "rb");
|
||||
if (f) {
|
||||
- fseek(f , 0, SEEK_END);
|
||||
+ fseek(f, 0, SEEK_END);
|
||||
fsize = ftell(f);
|
||||
|
||||
- if (offset < fsize) {
|
||||
- psize = fsize - offset;
|
||||
- if (psize > max_psize)
|
||||
- psize = max_psize;
|
||||
-
|
||||
- g_ext_arm9_size = psize;
|
||||
-
|
||||
- fseek(f, offset, SEEK_SET);
|
||||
- if (psize >= 8) {
|
||||
- u32 bytes_read = fread(g_ext_arm9_buf, 1, psize, f);
|
||||
- result = (g_ext_arm9_loaded = (bytes_read == psize));
|
||||
- }
|
||||
+ if (fsize > max_size)
|
||||
+ fsize = max_size;
|
||||
+
|
||||
+ g_ext_arm9_size = fsize;
|
||||
+
|
||||
+ fseek(f, 0, SEEK_SET);
|
||||
+ if (fsize >= 8) {
|
||||
+ u32 bytes_read = fread(g_ext_arm9_buf, 1, fsize, f);
|
||||
+ result = (g_ext_arm9_loaded = (bytes_read == fsize));
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
diff -uNr a/source/main.c b/source/main.c
|
||||
--- a/source/main.c 2016-09-21 16:18:56.246840000 +0200
|
||||
+++ b/source/main.c 2016-09-21 16:20:28.979957377 +0200
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
int main (void) {
|
||||
if (brahma_init()) {
|
||||
- if (load_arm9_payload_offset("/" LAUNCHER_PATH, 0x12000, 0x10000) != 1)
|
||||
+ if (load_arm9_payload_offset() != 1)
|
||||
goto error;
|
||||
firm_reboot();
|
||||
brahma_exit();
|
@ -7,5 +7,5 @@ diff -uNr a/source/main.c b/source/main.c
|
||||
int main (void) {
|
||||
+ svcSleepThread(2500 * 1000000ULL);
|
||||
if (brahma_init()) {
|
||||
if (load_arm9_payload_offset("/" LAUNCHER_PATH, 0x12000, 0x10000) != 1)
|
||||
if (load_arm9_payload_offset() != 1)
|
||||
goto error;
|
@ -92,7 +92,7 @@ void configMenu(bool oldPinStatus, u32 oldPinMode)
|
||||
|
||||
"Enable splash screen support.\n\n"
|
||||
"\t* 'Before payloads' displays it\n"
|
||||
"before booting payloads.\n"
|
||||
"before booting payloads\n"
|
||||
"(intended for splashes that display\n"
|
||||
"button hints).\n\n"
|
||||
"\t* 'After payloads' displays it\n"
|
||||
|
Reference in New Issue
Block a user