diff --git a/source/fatfs/ffconf.h b/source/fatfs/ffconf.h index 66e6829..bd82ae8 100644 --- a/source/fatfs/ffconf.h +++ b/source/fatfs/ffconf.h @@ -170,7 +170,7 @@ /* Number of volumes (logical drives) to be used. (1-10) */ -#define FF_STR_VOLUME_ID 1 +#define FF_STR_VOLUME_ID 0 #define FF_VOLUME_STRS "sdmc" /* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings. / When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive diff --git a/source/fsop.c b/source/fsop.c index 189c3a7..d71bb2c 100644 --- a/source/fsop.c +++ b/source/fsop.c @@ -79,13 +79,26 @@ static UINT sha256hash_cb(const BYTE* data, UINT size) { static FRESULT hashfile(FIL* fp, FSIZE_t offset, UINT size, unsigned char out[SHA256_BLOCK_SIZE]) { FRESULT fres; - UINT forwarded; + UINT left = size; fres = f_lseek(fp, offset); if (fres) return fres; sha256_init(&sha256ctx); + /* + ok this thing seems really slow + fres = f_forward(fp, sha256hash_cb, size, &forwarded); + */ + while (left) + { + UINT btr = (left > sizeof(buffer)) ? sizeof(buffer) : left; + UINT read; + fres = f_read(fp, buffer, btr, &read); + if (fres || !read) break; + left -= sha256hash_cb(buffer, read); + } + sha256_final(&sha256ctx, out); return fres; diff --git a/source/mset9.c b/source/mset9.c index c0755ab..c49611c 100644 --- a/source/mset9.c +++ b/source/mset9.c @@ -83,7 +83,7 @@ static bool isHaxID1(const char* name) { } int MSET9Start() { - char path[256] = "sdmc:/Nintendo 3DS"; + char path[256] = "0:/Nintendo 3DS"; FRESULT fres = 0; DIR dp = {}; FILINFO fl = {}; @@ -180,7 +180,7 @@ int MSET9Start() { if ((fres = f_rename(backupID1name, mset9.ID[1])) != FR_OK) { printf(pWarn "Failed to restore backed up ID1 ..? (%i)\n", fres); } - f_chdir("sdmc:/"); + f_chdir("0:/"); } if (injectedConsoleVer >= 0) { @@ -189,7 +189,7 @@ int MSET9Start() { if ((fres = f_rmdir_r(curhaxID1)) != FR_OK) { printf(pWarn "Failed to remove hax ID1 ..? (%i)\n", fres); } - f_chdir("sdmc:/"); + f_chdir("0:/"); puts(pGood "MSET9 has been removed!"); return 2; @@ -221,13 +221,14 @@ bool MSET9SanityCheck(void) { || !CheckFile("/SafeB9S.bin", 0, false)) { puts(pBad "Error #08: One or more files are missing or malformed!"); - puts(pInfo "Please re-extract the MSET9 zip file, overwriting any files when prompted."); + puts(pInfo "Please re-extract the MSET9 zip file, \n" + pInfo "overwriting any files when prompted."); return false; } puts(pGood "Extracted files look good!"); - sprintf(path, "sdmc:/Nintendo 3DS/%.32s/%.32s/", mset9.ID[0], mset9.ID[1]); + sprintf(path, "0:/Nintendo 3DS/%.32s/%.32s/", mset9.ID[0], mset9.ID[1]); FRESULT fres = f_chdir(path); if (fres != FR_OK) { printf("f_chdir failed? (%i)\n", fres); @@ -301,20 +302,20 @@ bool MSET9SanityCheck(void) { } puts(pGood "Found Mii Maker extdata!"); - f_chdir("sdmc:/"); + f_chdir("0:/"); return true; } bool MSET9Injection(void) { char path[256], path2[256]; FRESULT fres; - FIL fp; +// FIL fp; if (!mset9.ready || !mset9.consoleVer) return false; puts(pNote "Performing injection..."); - sprintf(path, "sdmc:/Nintendo 3DS/%.32s/", mset9.ID[0]); + sprintf(path, "0:/Nintendo 3DS/%.32s/", mset9.ID[0]); f_chdir(path); // 1. Create hax ID1 @@ -382,16 +383,16 @@ bool MSET9Injection(void) { // 4. Create trigger file (002F003A.txt) puts(pInfo "Injecting trigger file..."); strcpy(strchr(path, '/'), "/extdata/002F003A.txt"); - fres = f_open(&fp, path, FA_CREATE_NEW | FA_WRITE); + fres = f_dummy(path, false); if (fres != FR_OK) { - printf(pBad "f_open failed! (%i)\n", fres); + printf(pBad "f_dummy failed! (%i)\n", fres); return false; } - +/* UINT written; fres = f_write(&fp, "arm9 \"security\" processor vs. text file in extdata:", 52, &written); f_close(&fp); - +*/ // 5. Back up original ID1 puts(pInfo "Backing up original ID1..."); strcpy(path, mset9.ID[1]); @@ -404,6 +405,7 @@ bool MSET9Injection(void) { return false; } + f_chdir("0:/"); puts(pGood "MSET9 injected, have fun!"); return true; } diff --git a/source/sd.c b/source/sd.c index 38dfa25..a986839 100644 --- a/source/sd.c +++ b/source/sd.c @@ -45,7 +45,7 @@ bool SDMount(void) { printf(pInfo "Mounting SD card ...\r"); // usleep(1000000); sdmc->startup(); - FRESULT fres = f_mount(&fs, "sdmc:/", true); + FRESULT fres = f_mount(&fs, "0:/", true); if (fres == FR_OK) { unsigned long freeSpace = (fs.free_clst * fs.csize); unsigned long totalSpace = ((fs.n_fatent - 2) * fs.csize); @@ -79,7 +79,7 @@ bool SDMount(void) { void SDUnmount(void) { if (sdMounted) { - f_unmount("sdmc:/"); + f_unmount("0:/"); // sdmc->shutdown(); puts(pInfo "Unmounted SD card."); sdMounted = false;