Backup existing arm9loaderhax.bin

This commit is contained in:
Aurora 2016-11-23 00:03:45 +01:00
parent bccdfe4404
commit 5d1c717cb4
3 changed files with 13 additions and 1 deletions

View File

@ -88,6 +88,11 @@ void fileDelete(const char *path)
f_unlink(path); f_unlink(path);
} }
void fileRename(const char *oldPath, const char *newPath)
{
f_rename(oldPath, newPath);
}
u32 firmRead(void *dest) u32 firmRead(void *dest)
{ {
const char *firmFolders[] = {"00000002", "20000002"}; const char *firmFolders[] = {"00000002", "20000002"};

View File

@ -29,4 +29,5 @@ void unmountCtrNand(void);
u32 fileRead(void *dest, const char *path, u32 maxSize); u32 fileRead(void *dest, const char *path, u32 maxSize);
bool fileWrite(const void *buffer, const char *path, u32 size); bool fileWrite(const void *buffer, const char *path, u32 size);
void fileDelete(const char *path); void fileDelete(const char *path);
void fileRename(const char *oldPath, const char *newPath);
u32 firmRead(void *dest); u32 firmRead(void *dest);

View File

@ -206,6 +206,8 @@ static inline void installer(bool isOtpless)
{ {
magic = 0xDEADCAFE; magic = 0xDEADCAFE;
fileRename("arm9loaderhax.bin", "arm9loaderhax.bak");
if(!fileWrite((void *)0x23F00000, "arm9loaderhax.bin", 0x10000)) if(!fileWrite((void *)0x23F00000, "arm9loaderhax.bin", 0x10000))
shutdown(1, "Error: couldn't write arm9loaderhax.bin"); shutdown(1, "Error: couldn't write arm9loaderhax.bin");
} }
@ -273,7 +275,11 @@ static inline void installer(bool isOtpless)
drawTitle(); drawTitle();
if(sdmmc_sdcard_init(true, false) && mountFs(true)) fileDelete("arm9loaderhax.bin"); if(sdmmc_sdcard_init(true, false) && mountFs(true))
{
fileDelete("arm9loaderhax.bin");
fileRename("arm9loaderhax.bak", "arm9loaderhax.bin");
}
else else
{ {
posY = drawString("Couldn't remove arm9loaderhax.bin!", 10, posY + SPACING_Y, COLOR_RED); posY = drawString("Couldn't remove arm9loaderhax.bin!", 10, posY + SPACING_Y, COLOR_RED);