Skip to content
This repository has been archived by the owner on May 24, 2018. It is now read-only.

Commit

Permalink
Add a script
Browse files Browse the repository at this point in the history
  • Loading branch information
hax0kartik committed Sep 12, 2017
1 parent 5fefe8b commit 1c5054a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
41 changes: 32 additions & 9 deletions source/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,37 @@ Result checkFileExists(const char *location)
}
Result fsOpenAndWriteNAND(const char *location, void *data, size_t size)
{
Handle file;
Result ret;
FS_Path archivePath = fsMakePath(PATH_EMPTY, "");
FS_Path filePath = fsMakePath(PATH_ASCII, location);
ret = FSUSER_OpenFileDirectly(&file, ARCHIVE_NAND_CTR_FS, archivePath, filePath, FS_OPEN_WRITE|FS_OPEN_CREATE, 0x0);
if(ret > 0) return ret;
ret = FSFILE_Write(file, NULL, 0x0, data, size, FS_WRITE_FLUSH);
if(ret > 0) return ret;
FSFILE_Close(file);
Handle log;
fsInit();
FS_Archive ctrArchive;
FS_Path path = fsMakePath (PATH_EMPTY,"");
Result ret = FSUSER_OpenArchive(&ctrArchive, ARCHIVE_NAND_CTR_FS,path);
if(ret != 0)
{
printf("FATAL\nCouldn't open CTR-NAND for writing");
fsExit();
return ret;
}
FS_Path path2 = fsMakePath(PATH_ASCII, location);
ret = FSUSER_OpenFile(&log,ctrArchive,path2,FS_OPEN_WRITE|FS_OPEN_CREATE,0x0);
if(ret != 0)
{
printf("FATAL\nCouldn't open boot.firm for writing");
fsExit();
FSUSER_CloseArchive (ctrArchive);
return ret;
}
ret = FSFILE_Write(log,NULL,0x0,data,size,FS_WRITE_FLUSH);
if(ret != 0)
{
printf("FATAL\nCouldn't write boot.firm");
FSFILE_Close(log);
FSUSER_CloseArchive (ctrArchive);
fsExit();
return ret;
}
FSFILE_Close(log);
FSUSER_CloseArchive (ctrArchive);
fsExit();
return ret;
}
14 changes: 8 additions & 6 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ char *parseApi(const char *url, const char *format)
sprintf(downloadUrl, "%.*s", t[i+1].end-t[i+1].start, apiReqData + t[i+1].start);
if(strstr(downloadUrl, format) != NULL)
strcpy(returnDownloadUrl, downloadUrl);
printf("Downloading the latest release\n");
}
}
}
Expand Down Expand Up @@ -165,25 +166,26 @@ void downloadExtractStep2()
mkdir("/luma/payloads", 0777);
archiveExtractFile(httpRetrieveData(), httpBufSize(), "GodMode9.firm", "GodMode9.firm", "/luma/payloads/");
printf("Downloading godmode9 sd card cleaup script\n");
Result ret = httpDownloadData("http://3ds.guide/gm9_scripts/cleanup_sd_card.gm9"); //By d0k3
ret = httpDownloadData("http://3ds.guide/gm9_scripts/cleanup_sd_card.gm9"); //By d0k3
result("Download", ret, 9, 7);
mkdir("/gm9",0777);
mkdir("/gm9/scripts", 0777);
fsOpenAndWrite("/gm9/scripts/cleanup_sd_card.gm9", httpRetrieveData(), httpBufSize());
printf("Downloading godmode9 ctr-nand luma script\n");
ret = httpDownloadData("http://3ds.guide/gm9_scripts/setup_ctrnand_luma3ds.gm9"); //By d0k3
result("Download", ret, 9, 8);
fsOpenAndWrite("/gm9/scripts/setup_ctrnand_luma3ds.gm9", httpRetrieveData(), httpBufSize());
//Best time to install hblauncher_loader
printf("Downloading hblauncher_loader\n");
ret = httpDownloadData(parseApi("https://api.github.com/repos/yellows8/hblauncher_loader/releases/latest", ".zip"));//hblauncher_loader by yellows8
result("Download", ret, 9, 8);
result("Download", ret, 9, 9);
archiveExtractFile(httpRetrieveData(), httpBufSize(), "hblauncher_loader.cia", "hblauncher_loader.cia", "/");
httpFree();
u32 size;
u8 *data = fsOpenAndRead("/hblauncher_loader.cia", &size);
printf("Trying to install hblauncher_loader.cia\n");
ciaInstall(data, size);
free(data);
data = fsOpenAndRead("/boot.firm", &size);
Result ret = fsOpenAndWriteNAND("/boot.firm", data, size);
result("Luma_On_CTRNAND", ret, 9, 9);
free(data);
}

int main()
Expand Down

0 comments on commit 1c5054a

Please sign in to comment.