Skip to content

Commit

Permalink
no more volume str
Browse files Browse the repository at this point in the history
  • Loading branch information
Naim2000 committed Jun 17, 2024
1 parent ffbfc88 commit 381df14
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion source/fatfs/ffconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion source/fsop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 14 additions & 12 deletions source/mset9.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]);
Expand All @@ -404,6 +405,7 @@ bool MSET9Injection(void) {
return false;
}

f_chdir("0:/");
puts(pGood "MSET9 injected, have fun!");
return true;
}
4 changes: 2 additions & 2 deletions source/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 381df14

Please sign in to comment.