diff --git a/.gitignore b/.gitignore index a9dd6874..2b2110b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,14 @@ -/dist -/swiss_r* - -cube/swiss/build/ -cube/swiss/dist/ - -cube/swiss/source/patches/*.s -cube/patches/disassembly - -cube/actionreplay/SDLOADER.BIN - -pc/usbgecko/swissserver -pc/usbgecko/swissserver.exe -pc/usbgecko/core -pc/usbgecko/core.* - +*.d *.dol *.elf -*.o -*.d *.map -*.gcm +*.o +/cube/packer/SDLOADER.BIN +/cube/patches/disassembly +/cube/swiss/source/patches/*.bin.s +/cube/swiss/source/patches/*_bin.h +/pc/usbgecko/swissserver +/pc/usbgecko/swissserver.exe +/swiss_r* +build +dist diff --git a/cube/patches/Makefile b/cube/patches/Makefile index 83bddfd1..881c68aa 100644 --- a/cube/patches/Makefile +++ b/cube/patches/Makefile @@ -25,7 +25,7 @@ gcloaderpatch: gcloader-v1.bin gcloader-v1.card.bin gcloader-v2.bin gcloader-v2. clean: @rm -f *.bin *.elf *.o - @rm -f $(DEST)/*.s + @rm -f $(DEST)/*.bin.s $(DEST)/*_bin.h @rm -fr $(DISASM) cpatches: @@ -43,10 +43,10 @@ cpatches: @$(OBJCOPY) -O binary memcpy.o memcpy.bin @$(OBJCOPY) -O binary CheckStatus.elf CheckStatus.bin @$(OBJCOPY) -O binary WriteUARTN.elf WriteUARTN.bin - @$(BIN2S) backwards_memcpy.bin > $(DEST)/backwards_memcpy.s - @$(BIN2S) memcpy.bin > $(DEST)/memcpy.s - @$(BIN2S) CheckStatus.bin > $(DEST)/CheckStatus.s - @$(BIN2S) WriteUARTN.bin > $(DEST)/WriteUARTN.s + @$(BIN2S) -H $(DEST)/backwards_memcpy_bin.h backwards_memcpy.bin > $(DEST)/backwards_memcpy.bin.s + @$(BIN2S) -H $(DEST)/memcpy_bin.h memcpy.bin > $(DEST)/memcpy.bin.s + @$(BIN2S) -H $(DEST)/CheckStatus_bin.h CheckStatus.bin > $(DEST)/CheckStatus.bin.s + @$(BIN2S) -H $(DEST)/WriteUARTN_bin.h WriteUARTN.bin > $(DEST)/WriteUARTN.bin.s @rm -f *.bin *.elf *.o reboot.bin: @@ -62,7 +62,7 @@ reboot.bin: @$(OBJDUMP) -D reboot.elf > $(DISASM)/reboot.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents reboot.elf reboot.bin @truncate -s %32 reboot.bin - @$(BIN2S) reboot.bin > $(DEST)/Reboot.s + @$(BIN2S) -H $(DEST)/reboot_bin.h reboot.bin > $(DEST)/reboot.bin.s @rm -f *.bin *.elf *.o stub.bin: @@ -77,7 +77,7 @@ stub.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D stub.elf > $(DISASM)/stub.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents stub.elf stub.bin - @$(BIN2S) stub.bin > $(DEST)/Stub.s + @$(BIN2S) -H $(DEST)/stub_bin.h stub.bin > $(DEST)/stub.bin.s @rm -f *.bin *.elf *.o sd.bin: @@ -101,7 +101,7 @@ sd.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D sd.elf > $(DISASM)/sd.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents sd.elf sd.bin - @$(BIN2S) sd.bin > $(DEST)/SlotAB-SD.s + @$(BIN2S) -H $(DEST)/sd_bin.h sd.bin > $(DEST)/sd.bin.s @rm -f *.bin *.elf *.o sd.card.bin: @@ -122,7 +122,7 @@ sd.card.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D sd.card.elf > $(DISASM)/sd.card.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents sd.card.elf sd.card.bin - @$(BIN2S) sd.card.bin > $(DEST)/SlotAB-SD.card.s + @$(BIN2S) -H $(DEST)/sd_card_bin.h sd.card.bin > $(DEST)/sd.card.bin.s @rm -f *.bin *.elf *.o sd.dtk.bin: @@ -144,7 +144,7 @@ sd.dtk.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D sd.dtk.elf > $(DISASM)/sd.dtk.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents sd.dtk.elf sd.dtk.bin - @$(BIN2S) sd.dtk.bin > $(DEST)/SlotAB-SD.dtk.s + @$(BIN2S) -H $(DEST)/sd_dtk_bin.h sd.dtk.bin > $(DEST)/sd.dtk.bin.s @rm -f *.bin *.elf *.o ideexi-v1.bin: @@ -168,7 +168,7 @@ ideexi-v1.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D ideexi-v1.elf > $(DISASM)/ideexi-v1.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents ideexi-v1.elf ideexi-v1.bin - @$(BIN2S) ideexi-v1.bin > $(DEST)/SlotAB-IDEEXI_V1.s + @$(BIN2S) -H $(DEST)/ideexi_v1_bin.h ideexi-v1.bin > $(DEST)/ideexi-v1.bin.s @rm -f *.bin *.elf *.o ideexi-v1.card.bin: @@ -189,7 +189,7 @@ ideexi-v1.card.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D ideexi-v1.card.elf > $(DISASM)/ideexi-v1.card.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents ideexi-v1.card.elf ideexi-v1.card.bin - @$(BIN2S) ideexi-v1.card.bin > $(DEST)/SlotAB-IDEEXI_V1.card.s + @$(BIN2S) -H $(DEST)/ideexi_v1_card_bin.h ideexi-v1.card.bin > $(DEST)/ideexi-v1.card.bin.s @rm -f *.bin *.elf *.o ideexi-v1.dtk.bin: @@ -211,7 +211,7 @@ ideexi-v1.dtk.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D ideexi-v1.dtk.elf > $(DISASM)/ideexi-v1.dtk.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents ideexi-v1.dtk.elf ideexi-v1.dtk.bin - @$(BIN2S) ideexi-v1.dtk.bin > $(DEST)/SlotAB-IDEEXI_V1.dtk.s + @$(BIN2S) -H $(DEST)/ideexi_v1_dtk_bin.h ideexi-v1.dtk.bin > $(DEST)/ideexi-v1.dtk.bin.s @rm -f *.bin *.elf *.o ideexi-v2.bin: @@ -235,7 +235,7 @@ ideexi-v2.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D ideexi-v2.elf > $(DISASM)/ideexi-v2.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents ideexi-v2.elf ideexi-v2.bin - @$(BIN2S) ideexi-v2.bin > $(DEST)/SlotAB-IDEEXI_V2.s + @$(BIN2S) -H $(DEST)/ideexi_v2_bin.h ideexi-v2.bin > $(DEST)/ideexi-v2.bin.s @rm -f *.bin *.elf *.o ideexi-v2.card.bin: @@ -256,7 +256,7 @@ ideexi-v2.card.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D ideexi-v2.card.elf > $(DISASM)/ideexi-v2.card.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents ideexi-v2.card.elf ideexi-v2.card.bin - @$(BIN2S) ideexi-v2.card.bin > $(DEST)/SlotAB-IDEEXI_V2.card.s + @$(BIN2S) -H $(DEST)/ideexi_v2_card_bin.h ideexi-v2.card.bin > $(DEST)/ideexi-v2.card.bin.s @rm -f *.bin *.elf *.o ideexi-v2.dtk.bin: @@ -278,7 +278,7 @@ ideexi-v2.dtk.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D ideexi-v2.dtk.elf > $(DISASM)/ideexi-v2.dtk.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents ideexi-v2.dtk.elf ideexi-v2.dtk.bin - @$(BIN2S) ideexi-v2.dtk.bin > $(DEST)/SlotAB-IDEEXI_V2.dtk.s + @$(BIN2S) -H $(DEST)/ideexi_v2_dtk_bin.h ideexi-v2.dtk.bin > $(DEST)/ideexi-v2.dtk.bin.s @rm -f *.bin *.elf *.o dvd.bin: @@ -298,7 +298,7 @@ dvd.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D dvd.elf > $(DISASM)/dvd.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents dvd.elf dvd.bin - @$(BIN2S) dvd.bin > $(DEST)/DVDPatch.s + @$(BIN2S) -H $(DEST)/dvd_bin.h dvd.bin > $(DEST)/dvd.bin.s @rm -f *.bin *.elf *.o dvd.card.bin: @@ -319,7 +319,7 @@ dvd.card.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D dvd.card.elf > $(DISASM)/dvd.card.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents dvd.card.elf dvd.card.bin - @$(BIN2S) dvd.card.bin > $(DEST)/DVDPatch.card.s + @$(BIN2S) -H $(DEST)/dvd_card_bin.h dvd.card.bin > $(DEST)/dvd.card.bin.s @rm -f *.bin *.elf *.o usbgecko.bin: @@ -338,7 +338,7 @@ usbgecko.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D usbgecko.elf > $(DISASM)/usbgecko.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents usbgecko.elf usbgecko.bin - @$(BIN2S) usbgecko.bin > $(DEST)/USBGeckoPatch.s + @$(BIN2S) -H $(DEST)/usbgecko_bin.h usbgecko.bin > $(DEST)/usbgecko.bin.s @rm -f *.bin *.elf *.o wkf.bin: @@ -358,7 +358,7 @@ wkf.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D wkf.elf > $(DISASM)/wkf.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents wkf.elf wkf.bin - @$(BIN2S) wkf.bin > $(DEST)/WKFPatch.s + @$(BIN2S) -H $(DEST)/wkf_bin.h wkf.bin > $(DEST)/wkf.bin.s @rm -f *.bin *.elf *.o wkf.card.bin: @@ -379,7 +379,7 @@ wkf.card.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D wkf.card.elf > $(DISASM)/wkf.card.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents wkf.card.elf wkf.card.bin - @$(BIN2S) wkf.card.bin > $(DEST)/WKFPatch.card.s + @$(BIN2S) -H $(DEST)/wkf_card_bin.h wkf.card.bin > $(DEST)/wkf.card.bin.s @rm -f *.bin *.elf *.o wkf.dtk.bin: @@ -401,7 +401,7 @@ wkf.dtk.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D wkf.dtk.elf > $(DISASM)/wkf.dtk.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents wkf.dtk.elf wkf.dtk.bin - @$(BIN2S) wkf.dtk.bin > $(DEST)/WKFPatch.dtk.s + @$(BIN2S) -H $(DEST)/wkf_dtk_bin.h wkf.dtk.bin > $(DEST)/wkf.dtk.bin.s @rm -f *.bin *.elf *.o fsp.bin: @@ -422,7 +422,7 @@ fsp.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D fsp.elf > $(DISASM)/fsp.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents fsp.elf fsp.bin - @$(BIN2S) fsp.bin > $(DEST)/FSPPatch.s + @$(BIN2S) -H $(DEST)/fsp_bin.h fsp.bin > $(DEST)/fsp.bin.s @rm -f *.bin *.elf *.o fsp.dtk.bin: @@ -443,7 +443,7 @@ fsp.dtk.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D fsp.dtk.elf > $(DISASM)/fsp.dtk.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents fsp.dtk.elf fsp.dtk.bin - @$(BIN2S) fsp.dtk.bin > $(DEST)/FSPPatch.dtk.s + @$(BIN2S) -H $(DEST)/fsp_dtk_bin.h fsp.dtk.bin > $(DEST)/fsp.dtk.bin.s @rm -f *.bin *.elf *.o gcloader-v1.bin: @@ -467,7 +467,7 @@ gcloader-v1.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D gcloader-v1.elf > $(DISASM)/gcloader-v1.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents gcloader-v1.elf gcloader-v1.bin - @$(BIN2S) gcloader-v1.bin > $(DEST)/GCLoaderPatch1.s + @$(BIN2S) -H $(DEST)/gcloader_v1_bin.h gcloader-v1.bin > $(DEST)/gcloader-v1.bin.s @rm -f *.bin *.elf *.o gcloader-v1.card.bin: @@ -488,7 +488,7 @@ gcloader-v1.card.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D gcloader-v1.card.elf > $(DISASM)/gcloader-v1.card.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents gcloader-v1.card.elf gcloader-v1.card.bin - @$(BIN2S) gcloader-v1.card.bin > $(DEST)/GCLoaderPatch1.card.s + @$(BIN2S) -H $(DEST)/gcloader_v1_card_bin.h gcloader-v1.card.bin > $(DEST)/gcloader-v1.card.bin.s @rm -f *.bin *.elf *.o gcloader-v2.bin: @@ -510,7 +510,7 @@ gcloader-v2.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D gcloader-v2.elf > $(DISASM)/gcloader-v2.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents gcloader-v2.elf gcloader-v2.bin - @$(BIN2S) gcloader-v2.bin > $(DEST)/GCLoaderPatch2.s + @$(BIN2S) -H $(DEST)/gcloader_v2_bin.h gcloader-v2.bin > $(DEST)/gcloader-v2.bin.s @rm -f *.bin *.elf *.o gcloader-v2.card.bin: @@ -529,5 +529,5 @@ gcloader-v2.card.bin: @mkdir -p $(DISASM) @$(OBJDUMP) -D gcloader-v2.card.elf > $(DISASM)/gcloader-v2.card.txt @$(OBJCOPY) -O binary --set-section-flags .bss.*=alloc,load,contents gcloader-v2.card.elf gcloader-v2.card.bin - @$(BIN2S) gcloader-v2.card.bin > $(DEST)/GCLoaderPatch2.card.s + @$(BIN2S) -H $(DEST)/gcloader_v2_card_bin.h gcloader-v2.card.bin > $(DEST)/gcloader-v2.card.bin.s @rm -f *.bin *.elf *.o diff --git a/cube/swiss/include/patcher.h b/cube/swiss/include/patcher.h index 60b627ff..ae8a0291 100644 --- a/cube/swiss/include/patcher.h +++ b/cube/swiss/include/patcher.h @@ -11,69 +11,43 @@ typedef struct FuncPattern u32 FCalls; u32 Branch; u32 Moves; - u8 *Patch; + const void *Patch; u32 PatchLength; - char *Name; + const char *Name; u32 offsetFoundAt; } FuncPattern; /* the SDGecko/IDE-EXI patches */ -extern u8 reboot_bin[]; -extern u32 reboot_bin_size; -extern u8 stub_bin[]; -extern u32 stub_bin_size; -extern u8 ideexi_v1_bin[]; -extern u32 ideexi_v1_bin_size; -extern u8 ideexi_v1_card_bin[]; -extern u32 ideexi_v1_card_bin_size; -extern u8 ideexi_v1_dtk_bin[]; -extern u32 ideexi_v1_dtk_bin_size; -extern u8 ideexi_v2_bin[]; -extern u32 ideexi_v2_bin_size; -extern u8 ideexi_v2_card_bin[]; -extern u32 ideexi_v2_card_bin_size; -extern u8 ideexi_v2_dtk_bin[]; -extern u32 ideexi_v2_dtk_bin_size; -extern u8 sd_bin[]; -extern u32 sd_bin_size; -extern u8 sd_card_bin[]; -extern u32 sd_card_bin_size; -extern u8 sd_dtk_bin[]; -extern u32 sd_dtk_bin_size; -extern u8 usbgecko_bin[]; -extern u32 usbgecko_bin_size; -extern u8 wkf_bin[]; -extern u32 wkf_bin_size; -extern u8 wkf_card_bin[]; -extern u32 wkf_card_bin_size; -extern u8 wkf_dtk_bin[]; -extern u32 wkf_dtk_bin_size; -extern u8 dvd_bin[]; -extern u32 dvd_bin_size; -extern u8 dvd_card_bin[]; -extern u32 dvd_card_bin_size; -extern u8 fsp_bin[]; -extern u32 fsp_bin_size; -extern u8 fsp_dtk_bin[]; -extern u32 fsp_dtk_bin_size; -extern u8 gcloader_v1_bin[]; -extern u32 gcloader_v1_bin_size; -extern u8 gcloader_v1_card_bin[]; -extern u32 gcloader_v1_card_bin_size; -extern u8 gcloader_v2_bin[]; -extern u32 gcloader_v2_bin_size; -extern u8 gcloader_v2_card_bin[]; -extern u32 gcloader_v2_card_bin_size; +#include "reboot_bin.h" +#include "stub_bin.h" +#include "sd_bin.h" +#include "sd_card_bin.h" +#include "sd_dtk_bin.h" +#include "ideexi_v1_bin.h" +#include "ideexi_v1_card_bin.h" +#include "ideexi_v1_dtk_bin.h" +#include "ideexi_v2_bin.h" +#include "ideexi_v2_card_bin.h" +#include "ideexi_v2_dtk_bin.h" +#include "dvd_bin.h" +#include "dvd_card_bin.h" +#include "usbgecko_bin.h" +#include "wkf_bin.h" +#include "wkf_card_bin.h" +#include "wkf_dtk_bin.h" +#include "fsp_bin.h" +#include "fsp_dtk_bin.h" +#include "gcloader_v1_bin.h" +#include "gcloader_v1_card_bin.h" +#include "gcloader_v2_bin.h" +#include "gcloader_v2_card_bin.h" /* SDK patches */ -extern u8 backwards_memcpy_bin[]; -extern u32 backwards_memcpy_bin_size; -extern u8 memcpy_bin[]; -extern u32 memcpy_bin_size; +#include "backwards_memcpy_bin.h" +#include "memcpy_bin.h" extern u8 DVDLowTestAlarmHook[]; extern u32 DVDLowTestAlarmHook_length; -extern u8 WriteUARTN_bin[]; -extern u32 WriteUARTN_bin_size; +#include "WriteUARTN_bin.h" extern u8 GXAdjustForOverscanPatch[]; extern u32 GXAdjustForOverscanPatch_length; extern u8 GXCopyDispHook[]; @@ -118,8 +92,7 @@ extern u8 MTXOrthoHook[]; extern u32 MTXOrthoHook_length; extern u8 MTXPerspectiveHook[]; extern u32 MTXPerspectiveHook_length; -extern u8 CheckStatus_bin[]; -extern u32 CheckStatus_bin_size; +#include "CheckStatus_bin.h" extern u8 getTimingPatch[]; extern u32 getTimingPatch_length; extern u8 VIConfigure240p[]; @@ -236,7 +209,7 @@ void *Calc_Address(void *data, int dataType, u32 properAddress); int Patch_CheatsHook(u8 *data, u32 length, u32 type); int Patch_ExecutableFile(void **buffer, u32 *sizeToRead, const char *gameID, int type); void *installPatch(int patchId); -void *installPatch2(void *patchLocation, u32 patchSize); +void *installPatch2(const void *patch, u32 patchSize); void *getPatchAddr(int patchId); void setTopAddr(u32 addr); u32 getTopAddr(); diff --git a/cube/swiss/source/devices/deviceHandler.h b/cube/swiss/source/devices/deviceHandler.h index cec42e1a..73fb13e1 100644 --- a/cube/swiss/source/devices/deviceHandler.h +++ b/cube/swiss/source/devices/deviceHandler.h @@ -80,7 +80,7 @@ typedef s32 (* _fn_makeDir)(file_handle*); typedef s32 (* _fn_readDir)(file_handle*, file_handle**, u32); typedef s64 (* _fn_seekFile)(file_handle*, s64, u32); typedef s32 (* _fn_readFile)(file_handle*, void*, u32); -typedef s32 (* _fn_writeFile)(file_handle*, void*, u32); +typedef s32 (* _fn_writeFile)(file_handle*, const void*, u32); typedef s32 (* _fn_closeFile)(file_handle*); typedef s32 (* _fn_deleteFile)(file_handle*); typedef s32 (* _fn_renameFile)(file_handle*, char*); diff --git a/cube/swiss/source/devices/fat/deviceHandler-FAT.c b/cube/swiss/source/devices/fat/deviceHandler-FAT.c index 1a0aec01..90814112 100644 --- a/cube/swiss/source/devices/fat/deviceHandler-FAT.c +++ b/cube/swiss/source/devices/fat/deviceHandler-FAT.c @@ -176,7 +176,7 @@ s32 deviceHandler_FAT_readFile(file_handle* file, void* buffer, u32 length) { return bytes_read; } -s32 deviceHandler_FAT_writeFile(file_handle* file, void* buffer, u32 length) { +s32 deviceHandler_FAT_writeFile(file_handle* file, const void* buffer, u32 length) { if(!file->ffsFp) { file->ffsFp = malloc(sizeof(FIL)); if(f_open(file->ffsFp, file->name, FA_CREATE_ALWAYS | FA_WRITE ) != FR_OK) { diff --git a/cube/swiss/source/devices/fat/deviceHandler-FAT.h b/cube/swiss/source/devices/fat/deviceHandler-FAT.h index 9a3b5f8c..86c1804b 100644 --- a/cube/swiss/source/devices/fat/deviceHandler-FAT.h +++ b/cube/swiss/source/devices/fat/deviceHandler-FAT.h @@ -21,7 +21,7 @@ extern s32 deviceHandler_FAT_makeDir(file_handle* dir); extern s32 deviceHandler_FAT_readDir(file_handle* ffile, file_handle** dir, u32 type); extern s64 deviceHandler_FAT_seekFile(file_handle* file, s64 where, u32 type); extern s32 deviceHandler_FAT_readFile(file_handle* file, void* buffer, u32 length); -extern s32 deviceHandler_FAT_writeFile(file_handle* file, void* buffer, u32 length); +extern s32 deviceHandler_FAT_writeFile(file_handle* file, const void* buffer, u32 length); extern s32 deviceHandler_FAT_closeFile(file_handle* file); extern s32 deviceHandler_FAT_deleteFile(file_handle* file); extern s32 deviceHandler_FAT_renameFile(file_handle* file, char* name); diff --git a/cube/swiss/source/devices/fsp/deviceHandler-FSP.c b/cube/swiss/source/devices/fsp/deviceHandler-FSP.c index 1994263e..2eb009d4 100644 --- a/cube/swiss/source/devices/fsp/deviceHandler-FSP.c +++ b/cube/swiss/source/devices/fsp/deviceHandler-FSP.c @@ -111,7 +111,7 @@ s32 deviceHandler_FSP_readFile(file_handle* file, void* buffer, u32 length) { return bytes_read; } -s32 deviceHandler_FSP_writeFile(file_handle* file, void* buffer, u32 length) { +s32 deviceHandler_FSP_writeFile(file_handle* file, const void* buffer, u32 length) { if(!file->fp) { file->fp = fsp_fopen(fsp_session, getDevicePath(file->name), "wb"); } diff --git a/cube/swiss/source/devices/ftp/deviceHandler-FTP.c b/cube/swiss/source/devices/ftp/deviceHandler-FTP.c index dbfd75c8..38e7f78e 100644 --- a/cube/swiss/source/devices/ftp/deviceHandler-FTP.c +++ b/cube/swiss/source/devices/ftp/deviceHandler-FTP.c @@ -152,7 +152,7 @@ s32 deviceHandler_FTP_readFile(file_handle* file, void* buffer, u32 length){ return bytes_read; } -s32 deviceHandler_FTP_writeFile(file_handle* file, void* buffer, u32 length){ +s32 deviceHandler_FTP_writeFile(file_handle* file, const void* buffer, u32 length){ if(!file->fp) { file->fp = fopen(file->name, "wb"); } diff --git a/cube/swiss/source/devices/memcard/deviceHandler-CARD.c b/cube/swiss/source/devices/memcard/deviceHandler-CARD.c index b8ca7237..64230e14 100644 --- a/cube/swiss/source/devices/memcard/deviceHandler-CARD.c +++ b/cube/swiss/source/devices/memcard/deviceHandler-CARD.c @@ -315,7 +315,7 @@ s32 deviceHandler_CARD_readFile(file_handle* file, void* buffer, u32 length){ } // This function should always be called for the FULL length cause CARD is lame like that. -s32 deviceHandler_CARD_writeFile(file_handle* file, void* data, u32 length) { +s32 deviceHandler_CARD_writeFile(file_handle* file, const void* data, u32 length) { if(gciInfo == NULL) { // Swiss ID for this CARD_SetGameAndCompany(); diff --git a/cube/swiss/source/devices/qoob/deviceHandler-Qoob.c b/cube/swiss/source/devices/qoob/deviceHandler-Qoob.c index 4a4ccf36..72da43c8 100644 --- a/cube/swiss/source/devices/qoob/deviceHandler-Qoob.c +++ b/cube/swiss/source/devices/qoob/deviceHandler-Qoob.c @@ -271,7 +271,7 @@ int write_qoob_rom(unsigned char *src, u32 dest, int len) // Assumes a single call to write a file. -s32 deviceHandler_Qoob_writeFile(file_handle* file, void* buffer, u32 length) { +s32 deviceHandler_Qoob_writeFile(file_handle* file, const void* buffer, u32 length) { if(!length) return 0; if(!file->fileBase) { diff --git a/cube/swiss/source/devices/smb/deviceHandler-SMB.c b/cube/swiss/source/devices/smb/deviceHandler-SMB.c index 47b0f605..9c56eb40 100644 --- a/cube/swiss/source/devices/smb/deviceHandler-SMB.c +++ b/cube/swiss/source/devices/smb/deviceHandler-SMB.c @@ -156,7 +156,7 @@ s32 deviceHandler_SMB_readFile(file_handle* file, void* buffer, u32 length){ return bytes_read; } -s32 deviceHandler_SMB_writeFile(file_handle* file, void* buffer, u32 length){ +s32 deviceHandler_SMB_writeFile(file_handle* file, const void* buffer, u32 length){ if(!file->fp) { file->fp = fopen(file->name, "wb"); } diff --git a/cube/swiss/source/devices/usbgecko/deviceHandler-usbgecko.c b/cube/swiss/source/devices/usbgecko/deviceHandler-usbgecko.c index 8965e4b3..40a70c6f 100644 --- a/cube/swiss/source/devices/usbgecko/deviceHandler-usbgecko.c +++ b/cube/swiss/source/devices/usbgecko/deviceHandler-usbgecko.c @@ -94,7 +94,7 @@ s32 deviceHandler_USBGecko_readFile(file_handle* file, void* buffer, u32 length) return bytes_read; } -s32 deviceHandler_USBGecko_writeFile(file_handle* file, void* buffer, u32 length) { +s32 deviceHandler_USBGecko_writeFile(file_handle* file, const void* buffer, u32 length) { s32 bytes_written = usbgecko_write_file(buffer, length, file->offset, file->name); if(bytes_written > 0) file->offset += bytes_written; diff --git a/cube/swiss/source/devices/usbgecko/usbgecko.c b/cube/swiss/source/devices/usbgecko/usbgecko.c index 32d54f0e..ed09768b 100644 --- a/cube/swiss/source/devices/usbgecko/usbgecko.c +++ b/cube/swiss/source/devices/usbgecko/usbgecko.c @@ -110,7 +110,7 @@ s32 usbgecko_read_file(void *buffer, u32 length, u32 offset, char* filename) { } // Write to the remote file, returns amount written -s32 usbgecko_write_file(void *buffer, u32 length, u32 offset, char* filename) { +s32 usbgecko_write_file(const void *buffer, u32 length, u32 offset, char* filename) { return 0; } diff --git a/cube/swiss/source/devices/usbgecko/usbgecko.h b/cube/swiss/source/devices/usbgecko/usbgecko.h index 8056af52..f8df29a6 100644 --- a/cube/swiss/source/devices/usbgecko/usbgecko.h +++ b/cube/swiss/source/devices/usbgecko/usbgecko.h @@ -18,7 +18,7 @@ s32 usbgecko_pc_ready(); s32 usbgecko_read_file(void *buffer, u32 length, u32 offset, char* filename); // Write to the remote file, returns amount written -s32 usbgecko_write_file(void *buffer, u32 length, u32 offset, char* filename); +s32 usbgecko_write_file(const void *buffer, u32 length, u32 offset, char* filename); // Opens a directory on the PC end s32 usbgecko_open_dir(char *filename); diff --git a/cube/swiss/source/patcher.c b/cube/swiss/source/patcher.c index f313c128..f393f47c 100644 --- a/cube/swiss/source/patcher.c +++ b/cube/swiss/source/patcher.c @@ -27,90 +27,91 @@ static void *patch_locations[PATCHES_MAX]; // Returns where the ASM patch has been copied to void *installPatch(int patchId) { - u32 patchSize = 0; void *patchLocation = NULL; + const void *patch = NULL; u32 patchSize = 0; switch(patchId) { case BACKWARDS_MEMCPY: - patchSize = backwards_memcpy_bin_size; patchLocation = backwards_memcpy_bin; break; + patch = backwards_memcpy_bin; patchSize = backwards_memcpy_bin_size; break; case DVD_LOWTESTALARMHOOK: - patchSize = DVDLowTestAlarmHook_length; patchLocation = DVDLowTestAlarmHook; break; + patch = DVDLowTestAlarmHook; patchSize = DVDLowTestAlarmHook_length; break; case GX_COPYDISPHOOK: - patchSize = GXCopyDispHook_length; patchLocation = GXCopyDispHook; break; + patch = GXCopyDispHook; patchSize = GXCopyDispHook_length; break; case GX_INITTEXOBJLODHOOK: - patchSize = GXInitTexObjLODHook_length; patchLocation = GXInitTexObjLODHook; break; + patch = GXInitTexObjLODHook; patchSize = GXInitTexObjLODHook_length; break; case GX_SETPROJECTIONHOOK: - patchSize = GXSetProjectionHook_length; patchLocation = GXSetProjectionHook; break; + patch = GXSetProjectionHook; patchSize = GXSetProjectionHook_length; break; case GX_SETSCISSORHOOK: - patchSize = GXSetScissorHook_length; patchLocation = GXSetScissorHook; break; + patch = GXSetScissorHook; patchSize = GXSetScissorHook_length; break; case MTX_FRUSTUMHOOK: - patchSize = MTXFrustumHook_length; patchLocation = MTXFrustumHook; break; + patch = MTXFrustumHook; patchSize = MTXFrustumHook_length; break; case MTX_LIGHTFRUSTUMHOOK: - patchSize = MTXLightFrustumHook_length; patchLocation = MTXLightFrustumHook; break; + patch = MTXLightFrustumHook; patchSize = MTXLightFrustumHook_length; break; case MTX_LIGHTPERSPECTIVEHOOK: - patchSize = MTXLightPerspectiveHook_length; patchLocation = MTXLightPerspectiveHook; break; + patch = MTXLightPerspectiveHook; patchSize = MTXLightPerspectiveHook_length; break; case MTX_ORTHOHOOK: - patchSize = MTXOrthoHook_length; patchLocation = MTXOrthoHook; break; + patch = MTXOrthoHook; patchSize = MTXOrthoHook_length; break; case MTX_PERSPECTIVEHOOK: - patchSize = MTXPerspectiveHook_length; patchLocation = MTXPerspectiveHook; break; + patch = MTXPerspectiveHook; patchSize = MTXPerspectiveHook_length; break; case OS_RESERVED: patchSize = 0x1800; break; case PAD_CHECKSTATUS: - patchSize = CheckStatus_bin_size; patchLocation = CheckStatus_bin; break; + patch = CheckStatus_bin; patchSize = CheckStatus_bin_size; break; case VI_CONFIGURE240P: - patchSize = VIConfigure240p_length; patchLocation = VIConfigure240p; break; + patch = VIConfigure240p; patchSize = VIConfigure240p_length; break; case VI_CONFIGURE288P: - patchSize = VIConfigure288p_length; patchLocation = VIConfigure288p; break; + patch = VIConfigure288p; patchSize = VIConfigure288p_length; break; case VI_CONFIGURE480I: - patchSize = VIConfigure480i_length; patchLocation = VIConfigure480i; break; + patch = VIConfigure480i; patchSize = VIConfigure480i_length; break; case VI_CONFIGURE480P: - patchSize = VIConfigure480p_length; patchLocation = VIConfigure480p; break; + patch = VIConfigure480p; patchSize = VIConfigure480p_length; break; case VI_CONFIGURE540P50: - patchSize = VIConfigure540p50_length; patchLocation = VIConfigure540p50; break; + patch = VIConfigure540p50; patchSize = VIConfigure540p50_length; break; case VI_CONFIGURE540P60: - patchSize = VIConfigure540p60_length; patchLocation = VIConfigure540p60; break; + patch = VIConfigure540p60; patchSize = VIConfigure540p60_length; break; case VI_CONFIGURE576I: - patchSize = VIConfigure576i_length; patchLocation = VIConfigure576i; break; + patch = VIConfigure576i; patchSize = VIConfigure576i_length; break; case VI_CONFIGURE576P: - patchSize = VIConfigure576p_length; patchLocation = VIConfigure576p; break; + patch = VIConfigure576p; patchSize = VIConfigure576p_length; break; case VI_CONFIGURE960I: - patchSize = VIConfigure960i_length; patchLocation = VIConfigure960i; break; + patch = VIConfigure960i; patchSize = VIConfigure960i_length; break; case VI_CONFIGURE1080I50: - patchSize = VIConfigure1080i50_length; patchLocation = VIConfigure1080i50; break; + patch = VIConfigure1080i50; patchSize = VIConfigure1080i50_length; break; case VI_CONFIGURE1080I60: - patchSize = VIConfigure1080i60_length; patchLocation = VIConfigure1080i60; break; + patch = VIConfigure1080i60; patchSize = VIConfigure1080i60_length; break; case VI_CONFIGURE1152I: - patchSize = VIConfigure1152i_length; patchLocation = VIConfigure1152i; break; + patch = VIConfigure1152i; patchSize = VIConfigure1152i_length; break; case VI_CONFIGUREAUTOP: - patchSize = VIConfigureAutop_length; patchLocation = VIConfigureAutop; break; + patch = VIConfigureAutop; patchSize = VIConfigureAutop_length; break; case VI_CONFIGUREHOOK1: - patchSize = VIConfigureHook1_length; patchLocation = VIConfigureHook1; break; + patch = VIConfigureHook1; patchSize = VIConfigureHook1_length; break; case VI_CONFIGUREHOOK1_GCVIDEO: - patchSize = VIConfigureHook1GCVideo_length; patchLocation = VIConfigureHook1GCVideo; break; + patch = VIConfigureHook1GCVideo; patchSize = VIConfigureHook1GCVideo_length; break; case VI_CONFIGUREHOOK2: - patchSize = VIConfigureHook2_length; patchLocation = VIConfigureHook2; break; + patch = VIConfigureHook2; patchSize = VIConfigureHook2_length; break; case VI_CONFIGUREPANHOOK: - patchSize = VIConfigurePanHook_length; patchLocation = VIConfigurePanHook; break; + patch = VIConfigurePanHook; patchSize = VIConfigurePanHook_length; break; case VI_CONFIGUREPANHOOKD: - patchSize = VIConfigurePanHookD_length; patchLocation = VIConfigurePanHookD; break; + patch = VIConfigurePanHookD; patchSize = VIConfigurePanHookD_length; break; case VI_GETRETRACECOUNTHOOK: - patchSize = VIGetRetraceCountHook_length; patchLocation = VIGetRetraceCountHook; break; + patch = VIGetRetraceCountHook; patchSize = VIGetRetraceCountHook_length; break; case VI_RETRACEHANDLERHOOK: - patchSize = VIRetraceHandlerHook_length; patchLocation = VIRetraceHandlerHook; break; + patch = VIRetraceHandlerHook; patchSize = VIRetraceHandlerHook_length; break; default: break; } - patchLocation = installPatch2(patchLocation, patchSize); + patchLocation = installPatch2(patch, patchSize); print_gecko("Installed patch %i to %08X\r\n", patchId, patchLocation); return patchLocation; } -void *installPatch2(void *patchLocation, u32 patchSize) { +void *installPatch2(const void *patch, u32 patchSize) { + void *patchLocation = NULL; if (top_addr == 0x81800000) top_addr -= 8; top_addr -= patchSize; - if (patchLocation) { + if (patch) { top_addr &= ~3; - patchLocation = memcpy((void*)top_addr, patchLocation, patchSize); + patchLocation = memcpy((void*)top_addr, patch, patchSize); } else { top_addr &= ~31; patchLocation = memset((void*)top_addr, 0, patchSize); @@ -147,7 +148,7 @@ u32 getTopAddr() { int install_code(int final) { u32 location = LO_RESERVE; - u8 *patch = NULL; u32 patchSize = 0; + const void *patch = NULL; u32 patchSize = 0; // Reload Stub if (GCMDisk.DVDMagicWord != DVD_MAGIC) {