Use raw2c instead of xxd

This commit is contained in:
Maschell 2020-06-27 10:22:22 +02:00
parent 66bcc3861d
commit 3476644ed0
7 changed files with 40 additions and 13 deletions

View File

@ -238,7 +238,7 @@ static const int final_chain[] = {
0x0, // 0x1F0 0x0, // 0x1F0
0x101063db, // 0x1F4 POP {R1,R2,R5,PC} 0x101063db, // 0x1F4 POP {R1,R2,R5,PC}
0x0, // 0x1F8 0x0, // 0x1F8
sizeof(ios_kernel_bin), // 0x1FC our code size sizeof(ios_kernel), // 0x1FC our code size
0x0, // 0x200 0x0, // 0x200
0x10123983, // 0x204 POP {R1,R3,R4,R6,PC} 0x10123983, // 0x204 POP {R1,R3,R4,R6,PC}
0x00140000, // 0x208 our code source location 0x00140000, // 0x208 our code source location
@ -310,15 +310,15 @@ static void uhs_exploit_init(int dev_uhs_0_handle) {
memcpy((char *) (0xF4120000), second_chain, sizeof(second_chain)); memcpy((char *) (0xF4120000), second_chain, sizeof(second_chain));
memcpy((char *) (0xF4130000), final_chain, sizeof(final_chain)); memcpy((char *) (0xF4130000), final_chain, sizeof(final_chain));
memcpy((char *) (0xF4140000), ios_kernel_bin, sizeof(ios_kernel_bin)); memcpy((char *) (0xF4140000), ios_kernel, sizeof(ios_kernel));
payload_info_t *payloads = (payload_info_t *) 0xF4148000; payload_info_t *payloads = (payload_info_t *) 0xF4148000;
payloads->size = sizeof(ios_usb_bin); payloads->size = sizeof(ios_usb);
memcpy(payloads->data, ios_usb_bin, payloads->size); memcpy(payloads->data, ios_usb, payloads->size);
payloads = (payload_info_t *) 0xF4160000; payloads = (payload_info_t *) 0xF4160000;
payloads->size = sizeof(ios_mcp_bin); payloads->size = sizeof(ios_mcp);
memcpy(payloads->data, ios_mcp_bin, payloads->size); memcpy(payloads->data, ios_mcp, payloads->size);
pretend_root_hub[33] = 0x500000; pretend_root_hub[33] = 0x500000;
@ -327,7 +327,7 @@ static void uhs_exploit_init(int dev_uhs_0_handle) {
DCStoreRange(pretend_root_hub + 33, 200); DCStoreRange(pretend_root_hub + 33, 200);
DCStoreRange((void *) 0xF4120000, sizeof(second_chain)); DCStoreRange((void *) 0xF4120000, sizeof(second_chain));
DCStoreRange((void *) 0xF4130000, sizeof(final_chain)); DCStoreRange((void *) 0xF4130000, sizeof(final_chain));
DCStoreRange((void *) 0xF4140000, sizeof(ios_kernel_bin)); DCStoreRange((void *) 0xF4140000, sizeof(ios_kernel));
DCStoreRange((void *) 0xF4148000, ((uint32_t) 0xF4180000) - 0xF4148000); DCStoreRange((void *) 0xF4148000, ((uint32_t) 0xF4180000) - 0xF4148000);
} }

View File

@ -1,4 +1,6 @@
build/ build/
*.bin *.bin
*.bin.h *.bin.h
ios_kernel.c
ios_kernel.h
*.elf *.elf

View File

@ -26,6 +26,12 @@ OFILES += $(SFILES:source/%.s=build/%.o)
PROJECTNAME = ${shell basename "$(CURDIR)"} PROJECTNAME = ${shell basename "$(CURDIR)"}
CWD = "$(CURDIR)"" CWD = "$(CURDIR)""
#---------------------------------------------------------------------------------
# path to tools
#---------------------------------------------------------------------------------
DEVKITPATH=$(shell echo "$(DEVKITPRO)" | sed -e 's/^\([a-zA-Z]\):/\/\1/')
export PATH := $(DEVKITPATH)/tools/bin:$(DEVKITPATH)/devkitPPC/bin:$(PATH)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# canned command sequence for binary data, taken from devkitARM # canned command sequence for binary data, taken from devkitARM
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
@ -49,7 +55,8 @@ $(PROJECTNAME).bin: $(PROJECTNAME).elf
@$(OBJCOPY) -j .text -j .rodata -j .data -O binary $(PROJECTNAME).elf $@ @$(OBJCOPY) -j .text -j .rodata -j .data -O binary $(PROJECTNAME).elf $@
$(PROJECTNAME).bin.h: $(PROJECTNAME).bin $(PROJECTNAME).bin.h: $(PROJECTNAME).bin
@xxd -i $< | sed "s/unsigned/static const unsigned/g;s/$(PROJECTNAME)$*/$(PROJECTNAME)/g" > $@ @raw2c $<
@cp $(PROJECTNAME).c $@
$(PROJECTNAME)_syms.h: $(PROJECTNAME)_syms.h:
@echo "#ifndef $(PROJECTNAME)_SYMS_H" > $@ @echo "#ifndef $(PROJECTNAME)_SYMS_H" > $@
@ -60,7 +67,7 @@ $(PROJECTNAME)_syms.h:
clean: clean:
@rm -f build/*.o build/*.d @rm -f build/*.o build/*.d
@rm -f $(PROJECTNAME).elf $(PROJECTNAME).bin $(PROJECTNAME)_syms.h $(PROJECTNAME).bin $(PROJECTNAME).bin.h @rm -f $(PROJECTNAME).elf $(PROJECTNAME).bin $(PROJECTNAME)_syms.h $(PROJECTNAME).bin $(PROJECTNAME).bin.h $(PROJECTNAME).h $(PROJECTNAME).c
@echo "all cleaned up !" @echo "all cleaned up !"
-include $(DFILES) -include $(DFILES)

View File

@ -1,4 +1,6 @@
build/ build/
*.bin *.bin
*.bin.h *.bin.h
ios_mcp.c
ios_mcp.h
*.elf *.elf

View File

@ -31,6 +31,12 @@ OFILES += $(SFILES:source/%.s=build/%.o)
PROJECTNAME = ${shell basename "$(CURDIR)"} PROJECTNAME = ${shell basename "$(CURDIR)"}
CWD = "$(CURDIR)"" CWD = "$(CURDIR)""
#---------------------------------------------------------------------------------
# path to tools
#---------------------------------------------------------------------------------
DEVKITPATH=$(shell echo "$(DEVKITPRO)" | sed -e 's/^\([a-zA-Z]\):/\/\1/')
export PATH := $(DEVKITPATH)/tools/bin:$(DEVKITPATH)/devkitPPC/bin:$(PATH)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# canned command sequence for binary data, taken from devkitARM # canned command sequence for binary data, taken from devkitARM
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
@ -54,7 +60,8 @@ $(PROJECTNAME).bin: $(PROJECTNAME).elf
@$(OBJCOPY) -j .text -j .rodata -j .data -O binary $(PROJECTNAME).elf $@ @$(OBJCOPY) -j .text -j .rodata -j .data -O binary $(PROJECTNAME).elf $@
$(PROJECTNAME).bin.h: $(PROJECTNAME).bin $(PROJECTNAME).bin.h: $(PROJECTNAME).bin
@xxd -i $< | sed "s/unsigned/static const unsigned/g;s/$(PROJECTNAME)$*/$(PROJECTNAME)/g" > $@ @raw2c $<
@cp $(PROJECTNAME).c $@
$(PROJECTNAME)_syms.h: $(PROJECTNAME)_syms.h:
@echo "#ifndef $(PROJECTNAME)_SYMS_H" > $@ @echo "#ifndef $(PROJECTNAME)_SYMS_H" > $@
@ -65,7 +72,7 @@ $(PROJECTNAME)_syms.h:
clean: clean:
@rm -f build/*.o build/*.d @rm -f build/*.o build/*.d
@rm -f $(PROJECTNAME).elf $(PROJECTNAME).bin $(PROJECTNAME)_syms.h $(PROJECTNAME).bin $(PROJECTNAME).bin.h @rm -f $(PROJECTNAME).elf $(PROJECTNAME).bin $(PROJECTNAME)_syms.h $(PROJECTNAME).bin $(PROJECTNAME).bin.h $(PROJECTNAME).c $(PROJECTNAME).h
@echo "all cleaned up !" @echo "all cleaned up !"
-include $(DFILES) -include $(DFILES)

View File

@ -1,4 +1,6 @@
build/ build/
*.bin *.bin
*.bin.h *.bin.h
ios_usb.c
ios_usb.h
*.elf *.elf

View File

@ -26,6 +26,12 @@ OFILES += $(SFILES:source/%.s=build/%.o)
PROJECTNAME = ${shell basename "$(CURDIR)"} PROJECTNAME = ${shell basename "$(CURDIR)"}
CWD = "$(CURDIR)"" CWD = "$(CURDIR)""
#---------------------------------------------------------------------------------
# path to tools
#---------------------------------------------------------------------------------
DEVKITPATH=$(shell echo "$(DEVKITPRO)" | sed -e 's/^\([a-zA-Z]\):/\/\1/')
export PATH := $(DEVKITPATH)/tools/bin:$(DEVKITPATH)/devkitPPC/bin:$(PATH)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# canned command sequence for binary data, taken from devkitARM # canned command sequence for binary data, taken from devkitARM
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
@ -49,7 +55,8 @@ $(PROJECTNAME).bin: $(PROJECTNAME).elf
@$(OBJCOPY) -j .text -j .rodata -j .data -O binary $(PROJECTNAME).elf $@ @$(OBJCOPY) -j .text -j .rodata -j .data -O binary $(PROJECTNAME).elf $@
$(PROJECTNAME).bin.h: $(PROJECTNAME).bin $(PROJECTNAME).bin.h: $(PROJECTNAME).bin
@xxd -i $< | sed "s/unsigned/static const unsigned/g;s/$(PROJECTNAME)$*/$(PROJECTNAME)/g" > $@ @raw2c $<
@cp $(PROJECTNAME).c $@
$(PROJECTNAME)_syms.h: $(PROJECTNAME)_syms.h:
@echo "#ifndef $(PROJECTNAME)_SYMS_H" > $@ @echo "#ifndef $(PROJECTNAME)_SYMS_H" > $@
@ -60,7 +67,7 @@ $(PROJECTNAME)_syms.h:
clean: clean:
@rm -f build/*.o build/*.d @rm -f build/*.o build/*.d
@rm -f $(PROJECTNAME).elf $(PROJECTNAME).bin $(PROJECTNAME)_syms.h $(PROJECTNAME).bin $(PROJECTNAME).bin.h @rm -f $(PROJECTNAME).elf $(PROJECTNAME).bin $(PROJECTNAME)_syms.h $(PROJECTNAME).bin $(PROJECTNAME).bin.h $(PROJECTNAME).h $(PROJECTNAME).c
@echo "all cleaned up !" @echo "all cleaned up !"
-include $(DFILES) -include $(DFILES)