Hacking [Release] rxTools - Roxas75 3DS Toolkit [fw 2.0 - 9.2]

Status
Not open for further replies.

nastys

ナースティス
Member
Joined
Aug 5, 2014
Messages
1,730
Trophies
0
Age
26
Location
Earth
XP
1,794
Country
Italy
@nastys
Strings in spanish
Iniciar en UI:
Tema seleccionado:
Ver AGB_FIRM BIOS:
Habilitar 3D UI:
Inicio rapido:
Lenguaje:
Si
No
AJUSTES
DECEPTICON (ok no XD) "INICIO AUTOMATICO"
Manten pulsado R para ir al menu...
NO SE ENCUENTRAN LOS ARCHIVOS DEL TEMA
Selecciona una NAND para usar:
Pulsa X: sysNAND
Pulsa Y: emuNAND
Pulsa B: Volver al menu
French:
  • Forcer démarrage UI:
  • Thème choisi:
  • Montrer AGB_FIRM:
  • Activer UI 3D:
  • Démarrage rapide:
  • Language console:
  • Oui
  • Non
  • Options
  • Auto-démarrage
  • Maintenir le bouton R pour accéder le menu
  • FICHIERS DE THÈME MANQUANTS!
  • Choissisez le NAND que vous voulez utilisier
  • Bouton X : SysNAND
  • Bouton Y : EmuNAND
  • Bouton B : Retour
Thank you very much ;)
 

DjoeN

Captain Haddock!
Member
Joined
Oct 21, 2005
Messages
5,489
Trophies
0
Age
54
Location
Somewhere in this potatoland!
Website
djoen.dommel.be
XP
2,857
Country
Belgium
I'm making rxTools multilingual. The language can be set manually or change according to the current theme :)
If you want to help me translate rxTools, here are the strings:

...

Note that only Latin script is supported. There are actually more strings to translate, but maybe later...

@nastys

Nederlands / Vlaams (Dutch/Flemish)
  • Start in UI:
  • Selecteer thema:
  • Toon AGB_FIRM BIOS:
  • Gebruik 3D UI:
  • Snel starten:
  • Taal:
  • Ja
  • Nee
  • INSTELLINGEN
  • AUTOSTART
  • R ingedrukt houden voor menu...
  • THEMA BESTANDEN ONTBREKEN!
  • Kies een NAND voor gebruik
  • Druk X : SysNAND
  • Druk Y : EmuNAND
  • Druk B : Terug naar menu
 
Last edited by DjoeN,
  • Like
Reactions: nastys

MrJason005

√2
Member
Joined
Nov 26, 2014
Messages
2,521
Trophies
0
Location
Κάπου
XP
1,609
Country
Greece
I'm making rxTools multilingual. The language can be set manually or change according to the current theme :)
If you want to help me translate rxTools, here are the strings:
  • Force UI boot: [max 20 characters]
  • Selected theme: [max 20 characters]
  • Show AGB_FIRM BIOS: [max 20 characters]
  • Enable 3D UI: [max 20 characters]
  • Silent/quick boot: [max 20 characters]
  • Console language: [max 20 characters]
  • Yes [max 3 characters]
  • No [max 3 characters]
  • SETTINGS
  • AUTOBOOT
  • Hold R to go to the menu...
  • MISSING THEME FILES!
  • Choose the NAND you want to use
  • Press X : SysNAND
  • Press Y : EmuNAND
  • Press B : Back
Note that only Latin script is supported. There are actually more strings to translate, but maybe later...

I could translate to Greek, but I will need Greek characters. I do not support Greeklish in any way.
 

Intronaut

A star maker
Member
Joined
Nov 18, 2014
Messages
772
Trophies
0
Age
30
XP
1,005
Country
Chile
A strange bug: if you launch smash bros, go to home menu (dont close the app) and then open the settings you will see the firmware like always, without RX
 

VinsCool

Persona Secretiva Felineus
Global Moderator
Joined
Jan 7, 2014
Messages
14,600
Trophies
4
Location
Another World
Website
www.gbatemp.net
XP
25,218
Country
Canada
French:
  • Forcer démarrage UI:
  • Thème choisi:
  • Afficher AGB_FIRM:
  • Activer UI 3D:
  • Démarrage rapide:
  • Langage: <=== removed "console", it is pointless
  • Oui
  • Non
  • Options
  • Démarrage automatique
  • Maintenir le bouton R pour accéder au menu
  • FICHIERS DE THÈME MANQUANTS!
  • Choissisez la NAND que vous voulez utiliser <=== there was a typo in "utiliser", and NAND is better in feminine gender.
  • Bouton X : SysNAND
  • Bouton Y : EmuNAND
  • Bouton B : Retour
Changed some stuff, I hope won't be angry at me :)
 
  • Like
Reactions: nastys

R4ndom

Well-Known Member
Newcomer
Joined
Mar 18, 2012
Messages
63
Trophies
0
XP
157
Country
Norway
  • Strings in Norwegian:

  • Force UI boot: = Tving oppstart av UI
  • Selected theme: = Valgt tema
  • Show AGB_FIRM BIOS: = Vis AGB_FIRM BIOS
  • Enable 3D UI: = Aktiver UI i 3D
  • Silent/quick boot: = Rask oppstart
  • Console language: = Språk
  • Yes = Ja
  • No = Nei
  • SETTINGS = INNSTILLINGER
  • AUTOBOOT = AUTOMATISK OPPSTART
  • Hold R to go to the menu... = Hold R for å gå til menyen...
  • MISSING THEME FILES! = MANGLER TEMAFILER!
  • Choose the NAND you want to use = Velg hvilken NAND du vil bruke
  • Press X : SysNAND = Trykk X: SysNAND
  • Press Y : EmuNAND = Trykk Y: EmuNAND
  • Press B : Back = Trykk B: Tilbake
 
  • Like
Reactions: nastys

guitarheroknight

1.6180339887
Member
Joined
Nov 9, 2014
Messages
2,822
Trophies
1
Age
33
Location
Grand Line
XP
4,418
Country
Norway
@nastys


Language: Croatian.
  • Forsiraj ulazak u UI
  • Izabrana tema
  • Prikazi AGB_FIRM BIOS
  • Ukljuci 3D UI
  • Tiho/Brzo Paljenje
  • Jezik
  • Da
  • Ne
  • Postavke
  • Automatsko pokretanje
  • Pridrzite tipku R da bi ste usli u meni
  • NEDOSTAJU DATOTEKE TEME!
  • Izaberi NAND datoteku koju zelite koristiti
  • Stisni X : SysNAND
  • Stisni Y : EmuNAND
  • PStisni B : Povratak
BTW this can be used for Serbian and Bosnian as well!
 
Last edited by guitarheroknight,
  • Like
Reactions: nastys

Gadorach

Electronics Engineering Technologist
Member
Joined
Jan 22, 2014
Messages
970
Trophies
0
Location
Canada
XP
956
Country
Canada
Welp, I guess I'm going to have to add a lot of case statements to downgradeapp...
That includes the FBI injector.

I'm not looking forward to this.

In other news, I implemented the text/option change requests and fixed some bugs/nuisances.

New build (3.0b8): https://anonfiles.com/file/e713b906347d3802faf16af89575770a

Code:
- Changed MSET downgrade options to X/Y and added B to cancel. (VerseHell's request)
- Fixed check in MSET downgrade to allow for MSET to be installed if installed version is not the version you're trying to install. (Should fix GW downgraded MSET failing both checks, and wrong triggers. Also allows 4.x MSET to upgrade to 6.x, and vice-versa)
- Added option to FBI Injector/ HS Backup Restore to preserve data instead of deleting it. (no more SD flipping to inject on both SYS and EMU)

Code:
#include "downgradeapp.h"
#include "common.h"
#include "screenshot.h"
#include "fs.h"
#include "ff.h"
#include "console.h"
#include "draw.h"
#include "hid.h"
#include "ncch.h"
#include "crypto.h"
#include "TitleKeyDecrypt.h"
#include "NandDumper.h"
#include "aes.h"
#include "polarssl/sha2.h"
#include "stdio.h"
#include "filepack.h"

#define bswap_16(a) ((((a) << 8) & 0xff00) | (((a) >> 8) & 0xff))
#define bswap_32(a) ((((a) << 24) & 0xff000000) | (((a) << 8) & 0xff0000) | (((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff))

typedef struct {
    unsigned int id;
    unsigned short index;
    unsigned short type;
    unsigned int size;
    unsigned char signature[0x20];
} tmd_chunk_struct;

unsigned char region = 0;
char *regions[6] = { "Japan", "USA", "Europe", "China", "Korea", "Taiwan" };

char tmpstr[256];
FILINFO curInfo;
DIR myDir;

char cntpath[256]; // Contains the NAND content path
char tmdpath[256]; // Contains the NAND TMD path

char* getContentAppPath(){
    return (char*)&cntpath;
}

char* getTMDAppPath(){
    return (char*)&tmdpath;
}

void print_sha256(unsigned char hash[32])
{
    int i;
    for (i = 0; i < 32; i++)
    {
        print("%02X", hash[i]);
    
        if (i == 16)
        {
            /* Continue printing the SHA-256 sum in a new line after 34 characters (17 bytes) */
            print("\n"); ConsoleShow();
        }
    }

    ConsoleShow();
}

int FindApp(unsigned int tid_low, unsigned int tid_high, int drive)
{
    char *folder = (char*)&tmpstr;
    memset(folder, 0, 256);

    DIR* curDir = &myDir;
    memset((unsigned char*)curDir, 0, sizeof(DIR));

    FILINFO *myInfo = &curInfo;
    memset((unsigned char*)myInfo, 0, sizeof(FILINFO));
    myInfo->fname[0] = 'A';

    sprintf(folder, "%d:title/%08x/%08x/content", drive, tid_low, tid_high);

    if (f_opendir(curDir, folder) != FR_OK) return 0;

    char path[256];
    unsigned short latest_ver = 0, cur_ver = 0;
    bool is_v0 = false;

    for (int i = 0; myInfo->fname[0] != 0; i++)
    {
        if (f_readdir(curDir, myInfo)) break;
        if (myInfo->fname[0] == '.') continue;
    
        if (strstr(myInfo->fname, ".tmd") || strstr(myInfo->fname, ".TMD"))
        {
            memset(&path, 0, 256);
            sprintf(path, "%s/%s", folder, myInfo->fname);
        
            File tmp;
            if (!FileOpen(&tmp, path, 0)) continue;
        
            unsigned int size = FileGetSize(&tmp);
            if (size < 0xB34)
            {
                FileClose(&tmp);
                continue;
            }
        
            /* Get the TMD version */
            /* There can be some instances in which more than one TMD/content file is available */
            /* Of course, we want to use the latest one */
            if (FileRead(&tmp, &cur_ver, 2, 0x1DC) != 2)
            {
                FileClose(&tmp);
                continue;
            }
        
            /* Change Endianness */
            cur_ver = bswap_16(cur_ver);
        
            /* Verify the version number */
            if ((latest_ver == 0 && !is_v0) || cur_ver > latest_ver)
            {
                tmd_chunk_struct tmd_entry;
                memset(&tmd_entry, 0xFF, 0x30);
            
                int cont = 0;
                unsigned int b_read = 0;
                while (tmd_entry.index != 0)
                {
                    cont++;
                    b_read = FileRead(&tmp, &tmd_entry, 0x30, size - (cont * 0x30));
                    if (b_read != 0x30) break;
                }
            
                FileClose(&tmp);
            
                if (b_read != 0x30) continue;
            
                memset(&path, 0, 256);
                sprintf(path, "%s/%08x.app", folder, bswap_32(tmd_entry.id)); // Change Endianness
            
                if (FileOpen(&tmp, path, 0))
                {
                    FileClose(&tmp);
                    latest_ver = cur_ver;
                    if (cur_ver == 0) is_v0 = true;
                
                    /* Save TMD and content paths */
                    sprintf(tmdpath, "%s/%s", folder, myInfo->fname);
                    sprintf(cntpath, "%s/%08x.app", folder, bswap_32(tmd_entry.id));
                }
            } else {
                FileClose(&tmp);
            }
        } else {
            continue;
        }
    }

    f_closedir(curDir);
    if (latest_ver == 0 && !is_v0) return 0;
    return 1;
}

int CheckRegion(int drive)
{
    File secureinfo;
    print("Opening SecureInfo_A... "); ConsoleShow();
    sprintf(tmpstr, "%d:rw/sys/SecureInfo_A", drive);
    if (!FileOpen(&secureinfo, tmpstr, 0))
    {
        print("Error.\nTrying with SecureInfo_B... "); ConsoleShow();
        memset(&tmpstr, 0, 256);
        sprintf(tmpstr, "%d:rw/sys/SecureInfo_B", drive);
        if (!FileOpen(&secureinfo, tmpstr, 0))
        {
            print("Error.\nProcess failed!\n"); ConsoleShow();
            return -1;
        }
    }

    print("OK!\n"); ConsoleShow();
    FileRead(&secureinfo, &region, 1, 0x100);
    FileClose(&secureinfo);

    if (region > 0x06)
    {
        print("Error: unsupported region.\nProcess failed!\n"); ConsoleShow();
        return -1;
    } else {
        /* Avoid problems with the unused "AUS" region code */
        if (region >= 3) region--;
        print("Region: %s\n", regions[region]); ConsoleShow();
    }

    return 0;
}

int CheckRegionSilent(int drive)
{
    File secureinfo;
    sprintf(tmpstr, "%d:rw/sys/SecureInfo_A", drive);
    if (!FileOpen(&secureinfo, tmpstr, 0))
    {
        memset(&tmpstr, 0, 256);
        sprintf(tmpstr, "%d:rw/sys/SecureInfo_B", drive);
        if (!FileOpen(&secureinfo, tmpstr, 0))
        {
            print("Error.\nProcess failed!\n"); ConsoleShow();
            return -1;
        }
    }

    FileRead(&secureinfo, &region, 1, 0x100);
    FileClose(&secureinfo);

    if (region > 0x06)
    {
        print("Error: unsupported region.\nProcess failed!\n"); ConsoleShow();
        return -1;
    } else {
        /* Avoid problems with the unused "AUS" region code */
        if (region >= 3) region--;
    }

    return 0;
}

int checkDgFile(char* path, unsigned int hash)
{
    unsigned char* buf = (unsigned char*)0x21000000;
    unsigned int rb, fixedsize = 0x00400000;

    File fp;
    if (FileOpen(&fp, path, 0))
    {
        rb = FileRead(&fp, buf, fixedsize, 0);
        FileClose(&fp);
        if (!CheckHash(buf, rb, hash)) return 0;
    } else {
        return 0;
    }

    return 1;
}

void downgradeMSET()
{
    File dg;
    char *dgpath = "0:msetdg.bin";
    unsigned int titleid_low = 0x00040010;
    unsigned int titleid_high[6] = { 0x00020000, 0x00021000, 0x00022000, 0x00026000, 0x00027000, 0x00028000 }; //JPN, USA, EUR, CHN, KOR, TWN
    unsigned int mset_hash[10] = { 0x96AEC379, 0xED315608, 0x3387F2CD, 0xEDAC05D7, 0xACC1BE62, 0xF0FF9F08, 0x565BCF20, 0xA04654C6, 0xAFD07166, 0xD40B12F4 }; //JPN, USA, EUR, CHN, KOR, TWN
    unsigned short mset_ver[10] = { 3074, 5127, 3078, 5128, 3075, 5127, 8, 1026, 2049, 8 };
    unsigned short mset_dg_ver = 0;
    unsigned int buttonInput;
    unsigned int checkLoop = 0;

    ConsoleInit();
    ConsoleSetTitle("         MSET DOWNGRADER");

    CheckRegionSilent(SYS_NAND);

    print("What would you like to\nDowngrade to?\n\n"); ConsoleShow();
    print("[X] 4.x MSET\n[Y] 5.x/6.x MSET\n[B] Cancel\n\n"); ConsoleShow();

    while( checkLoop < 1 )
    {
        buttonInput = GetInput();
        //print("buttonInput is:  %u\n", buttonInput); ConsoleShow(); //debug

        if (buttonInput == 4294964224)
        {
            if (region == 0)
            {
                mset_dg_ver = 0;
            }
            else if (region == 1)
            {
                mset_dg_ver = 2;
            }
            else if (region == 2)
            {
                mset_dg_ver = 4;
            }
            else if (region == 3)
            {
                mset_dg_ver = 6;
            }
            else if (region == 4)
            {
                mset_dg_ver = 7;
            }
            else if (region == 5)
            {
                mset_dg_ver = 9;
            }
            else
            {
                print("region is:  %u\n", region); ConsoleShow();
                print("Unsupported Region!\n"); ConsoleShow();
                mset_dg_ver = 0;
            }
            checkLoop = 1;
        }
        else if (buttonInput == 4294965248)
        {
            if (region == 0)
            {
                mset_dg_ver = 1;
            }
            else if (region == 1)
            {
                mset_dg_ver = 3;
            }
            else if (region == 2)
            {
                mset_dg_ver = 5;
            }
            else if (region == 3)
            {
                mset_dg_ver = 6;
                print("CHN Region Detected!\nFalling back to 4.x MSET\n"); ConsoleShow();
            }
            else if (region == 4)
            {
                mset_dg_ver = 8;
            }
            else if (region == 5)
            {
                mset_dg_ver = 9;
                print("TWN Region Detected!\nFalling back to 4.x MSET\n"); ConsoleShow();
            }
            else
            {
                print("Unsupported Region!\n"); ConsoleShow();
                mset_dg_ver = 0;
            }
            checkLoop = 1;
        }
        else if (buttonInput == 4294963202)
        {
            checkLoop = 1;
            print("Operation Canceled!\n"); ConsoleShow();
        }
    }


    if(buttonInput != 4294963202)
    {

        print("Opening MSET app...\n"); ConsoleShow();
    
        if (CheckRegion(SYS_NAND) == 0)
        {
            if (FindApp(titleid_low, titleid_high[region], SYS_NAND)) // SysNAND only
            {
                if (FileOpen(&dg, tmdpath, 0))
                {
                    /* Get the MSET TMD version */
                    unsigned short tmd_ver;
                    FileRead(&dg, &tmd_ver, 2, 0x1DC);
                    tmd_ver = bswap_16(tmd_ver);
                    FileClose(&dg);
                
                    /* Verify version number */
                    if (tmd_ver != mset_ver[mset_dg_ver])
                    {
                        /* Open MSET content file */
                        if (FileOpen(&dg, cntpath, 0))
                        {
                            unsigned int check_val;
                            FileRead(&dg, &check_val, 4, 0x130);
                            FileClose(&dg);
                        
                            if (check_val != 0)
                            {
                                if (checkDgFile(dgpath, mset_hash[mset_dg_ver]))
                                {
                                    print("Opening downgrade pack... "); ConsoleShow();
                                    if (FileOpen(&dg, dgpath, 0))
                                    {
                                        print("OK!\n"); ConsoleShow();
                                    
                                        unsigned int dgsize = FileGetSize(&dg);
                                        unsigned char *buf = (unsigned char*)0x21000000;
                                        FileRead(&dg, buf, dgsize, 0);
                                    
                                        /* Downgrade pack decryption */
                                        u8 iv[0x10] = {0};
                                        u8 Key[0x10] = {0};
                                    
                                        GetTitleKey(&Key[0], titleid_low, titleid_high[region], SYS_NAND);
                                    
                                        aes_context aes_ctxt;
                                        aes_setkey_dec(&aes_ctxt, Key, 0x80);
                                        aes_crypt_cbc(&aes_ctxt, AES_DECRYPT, dgsize, iv, buf, buf);
                                    
                                        FileWrite(&dg, buf, dgsize, 0);
                                        FileClose(&dg);
                                    
                                        if (*((unsigned int*)(buf + 0x100)) == 0x4843434E) // "NCCH" magic word
                                        {
                                            print("Downgrading... "); ConsoleShow();
                                            if (FSFileCopy(cntpath, dgpath) == 0)
                                            {
                                                print("done!\nRemoving downgrade pack... "); ConsoleShow();
                                                f_unlink(dgpath);
                                                print("done.\n"); ConsoleShow();
                                            } else {
                                                print("\nError downgrading MSET content.\nRemoving downgrade pack... "); ConsoleShow();
                                                f_unlink(dgpath);
                                                print("done.\n"); ConsoleShow();
                                            }
                                        } else {
                                            print("Error: bad downgrade pack.\n"); ConsoleShow();
                                        }
                                    } else {
                                        print("Error.\n"); ConsoleShow();
                                    }
                                } else {
                                    print("Error: bad downgrade pack.\n"); ConsoleShow();
                                }
                            } else {
                                print("Your MSET version is exploitable.\nDowngrade isn't necessary.\n"); ConsoleShow();
                            }
                        } else {
                            print("Error opening MSET content file.\n"); ConsoleShow();
                        }
                    } else {
                        print("Your MSET version is exploitable.\nDowngrade isn't necessary.\n"); ConsoleShow();
                    }
                } else {
                    print("Error opening MSET TMD.\n"); ConsoleShow();
                }
            } else {
                print("Error: couldn't find MSET data.\n"); ConsoleShow();
            }
        }
    }

    print("\nPress A to exit\n\n\n");
    ConsoleShow();
    WaitForButton(BUTTON_A);
}

void manageFBI(bool restore)
{
    int drive;
    unsigned int titleid_low = 0x00040010;
    unsigned int titleid_high[6] = { 0x00020300, 0x00021300, 0x00022300, 0x00026300, 0x00027300, 0x00028300 }; //JPN, USA, EUR, CHN, KOR, TWN
    char *backup_path = "rxTools/h&s_backup";

    File tmp;
    char path[256] = {0};
    char path2[256] = {0};
    unsigned char *buf = (unsigned char *)0x21000000;

    unsigned int size;
    unsigned short tmd_ver;
    unsigned int sd_cntsize;
    unsigned short sd_tmd_ver;

    unsigned char TmdCntInfoRecSum[32] = {0};
    unsigned char CntInfoRecSum[32] = {0};
    unsigned char TmdCntChnkRecSum[32] = {0};
    unsigned char CntChnkRecSum[32] = {0};
    unsigned char TmdCntDataSum[32] = {0};
    unsigned char CntDataSum[32] = {0};

    unsigned int buttonInput;
    unsigned short checkLoop;

    if ((drive = NandSwitch()) == UNK_NAND) return;

    ConsoleInit();
    ConsoleSetTitle(restore ? "     RESTORE HEALTH & SAFETY" : "         FBI INSTALLATION");

    if (CheckRegion(drive) == 0)
    {
        if (FindApp(titleid_low, titleid_high[region], drive))
        {
            /* Open the NAND H&S TMD */
            FileOpen(&tmp, tmdpath, 0);
            FileRead(&tmp, buf, 0xB34, 0);
            FileClose(&tmp);
        
            /* Get the title version from the TMD */
            tmd_ver = (unsigned short)((buf[0x1DC] << 8) | buf[0x1DD]);
            print("TMD Version: v%u.\n", tmd_ver);
        
            if (!restore)
            {
                /* Get the stored content size from the TMD */
                unsigned int cntsize = (unsigned int)((buf[0xB10] << 24) | (buf[0xB11] << 16) | (buf[0xB12] << 8) | buf[0xB13]);
            
                /* Open the NAND H&S content file and read it to the memory buffer */
                FileOpen(&tmp, cntpath, 0);
                FileRead(&tmp, buf + 0x1000, cntsize, 0);
                FileClose(&tmp);
            
                /* Create the Health & Safety data backup directory */
                f_mkdir(backup_path);
            
                memset(&tmpstr, 0, 256);
                sprintf(tmpstr, "%s/%s", backup_path, regions[region]);
                f_mkdir(tmpstr);
            
                memset(&tmpstr, 0, 256);
                sprintf(tmpstr, "%s/%s/v%u", backup_path, regions[region], tmd_ver);
                f_mkdir(tmpstr);
            
                /* Backup the H&S TMD */
                sprintf(path, "0:%s/%.12s", tmpstr, tmdpath+34);
                if (FileOpen(&tmp, path, 1))
                {
                    size = FileWrite(&tmp, buf, 0xB34, 0);
                    FileClose(&tmp);
                    if (size == 0xB34)
                    {
                        print("NAND H&S TMD backup created.\n"); ConsoleShow();
                    
                        /* Backup the H&S content file */
                        memset(&path, 0, 256);
                        sprintf(path, "0:%s/%.12s", tmpstr, cntpath+34);
                        if (FileOpen(&tmp, path, 1))
                        {
                            size = FileWrite(&tmp, buf + 0x1000, cntsize, 0);
                            FileClose(&tmp);
                            if (size == cntsize)
                            {
                                print("NAND H&S content backup created.\n"); ConsoleShow();
                            } else {
                                print("Error writing H&S content backup.\n"); ConsoleShow();
                                goto out;
                            }
                        } else {
                            print("Error creating H&S content backup.\n"); ConsoleShow();
                            goto out;
                        }
                    } else {
                        print("Error writing H&S TMD backup.\n"); ConsoleShow();
                        goto out;
                    }
                } else {
                    print("Error creating H&S TMD backup.\n"); ConsoleShow();
                    goto out;
                }
            
                /* Generate the FBI data paths */
                sprintf(path, "0:fbi_inject.tmd");
                sprintf(path2, "0:fbi_inject.app");
            
                print("Editing H&S Information... "); ConsoleShow();
            } else {
                /* Generate the H&S backup data paths */
                memset(&tmpstr, 0, 256);
                sprintf(tmpstr, "%s/%s/v%u", backup_path, regions[region], tmd_ver);
                sprintf(path, "0:%s/%.12s", tmpstr, tmdpath+34);
                sprintf(path2, "0:%s/%.12s", tmpstr, cntpath+34);
            
                print("Restoring H&S Information... "); ConsoleShow();
            }
        
            /* Open the SD TMD */
            if (FileOpen(&tmp, path, 0))
            {
                size = FileGetSize(&tmp);
                if (size == 0xB34)
                {
                    FileRead(&tmp, buf, 0xB34, 0);
                    FileClose(&tmp);
                
                    /* Get the SD TMD version and stored content size */
                    sd_tmd_ver = (unsigned short)((buf[0x1DC] << 8) | buf[0x1DD]);
                    sd_cntsize = (unsigned int)((buf[0xB10] << 24) | (buf[0xB11] << 16) | (buf[0xB12] << 8) | buf[0xB13]);
                
                    if (sd_tmd_ver == tmd_ver)
                    {
                        /* Get the SHA-256 hashes */
                        memcpy(TmdCntInfoRecSum, buf + 0x1E4, 32);
                        memcpy(TmdCntChnkRecSum, buf + 0x208, 32);
                        memcpy(TmdCntDataSum, buf + 0xB14, 32);
                    
                        /* Verify the Content Info Record hash */
                        sha2(buf + 0x204, 0x900, CntInfoRecSum, 0);
                        if (memcmp(CntInfoRecSum, TmdCntInfoRecSum, 32) == 0)
                        {
                            /* Verify the Content Chunk Record hash */
                            sha2(buf + 0xB04, 0x30, CntChnkRecSum, 0);
                            if (memcmp(CntChnkRecSum, TmdCntChnkRecSum, 32) == 0)
                            {
                                /* Open the SD content file */
                                if (FileOpen(&tmp, path2, 0))
                                {
                                    size = FileGetSize(&tmp);
                                    if (size == sd_cntsize)
                                    {
                                        FileRead(&tmp, buf + 0x1000, sd_cntsize, 0);
                                        FileClose(&tmp);
                                    
                                        /* Verify the Content Data hash */
                                        sha2(buf + 0x1000, sd_cntsize, CntDataSum, 0);
                                        if (memcmp(CntDataSum, TmdCntDataSum, 32) == 0)
                                        {
                                            /* Now we are ready to rock 'n roll */
                                            if (FSFileCopy(tmdpath, path) == 0)
                                            {
                                                if (FSFileCopy(cntpath, path2) == 0)
                                                {
                                                    print("\n\nWhat would you like to do?\n"); ConsoleShow();
                                                    print("[B] Keep %s Data\n", restore ? "backup": "FBI injection"); ConsoleShow();
                                                    print("[X] Delete %s Data\n\n", restore ? "backup": "FBI injection"); ConsoleShow();
                                                    checkLoop = 0;

                                                    while (checkLoop < 1)
                                                    {
                                                        buttonInput = GetInput();

                                                        if (buttonInput == 4294963202)
                                                        {
                                                            print("OK!\n\nKeeping %s data.\n", restore ? "backup" : "FBI injection"); ConsoleShow();
                                                            checkLoop = 1;
                                                        }
                                                        else if (buttonInput == 4294964224)
                                                        {
                                                            print("OK!\n\nDeleting %s data... ", restore ? "backup" : "FBI injection"); ConsoleShow();
                                                            f_unlink(path);
                                                            f_unlink(path2);
                                                            print("OK!\n"); ConsoleShow();
                                                            checkLoop = 1;
                                                        }
                                                    }
                                                } else {
                                                    print("\nError %s content file.\n", restore ? "restoring H&S" : "injecting FBI"); ConsoleShow();
                                                }
                                            } else {
                                                print("\nError %s TMD.\n", restore ? "restoring H&S" : "injecting FBI"); ConsoleShow();
                                            }
                                        } else {
                                            print("\nError: invalid Content Data hash.\nGot:\n"); ConsoleShow();
                                            print_sha256(CntDataSum);
                                            print("\nExpected:\n"); ConsoleShow();
                                            print_sha256(TmdCntDataSum);
                                        }
                                    } else {
                                        FileClose(&tmp);
                                        print("\nInvalid %s content size.\nGot: v%u / Expected: v%u\n", restore ? "backup" : "FBI", size, sd_cntsize); ConsoleShow();
                                    }
                                } else {
                                    print("\nError opening %s content.\n", restore ? "backup" : "FBI");
                                }
                            } else {
                                print("\nError: invalid Content Chunk hash.\nGot:\n"); ConsoleShow();
                                print_sha256(CntChnkRecSum);
                                print("\nExpected:\n"); ConsoleShow();
                                print_sha256(TmdCntChnkRecSum);
                            }
                        } else {
                            print("\nError: invalid Content Info hash.\nGot:\n"); ConsoleShow();
                            print_sha256(CntInfoRecSum);
                            print("\nExpected:\n"); ConsoleShow();
                            print_sha256(TmdCntInfoRecSum);
                        }
                    } else {
                        print("\nError: invalid %s TMD version.\nGot: v%u / Expected: v%u\n", restore ? "backup" : "FBI", sd_tmd_ver, tmd_ver); ConsoleShow();
                    }
                } else {
                    FileClose(&tmp);
                    print("\nError: invalid %s TMD size.\nGot: %u / Expected: %u\n", restore ? "backup" : "FBI", size, 0xB34); ConsoleShow();
                }
            } else {
                print("\nError opening %s TMD.\n", restore ? "backup" : "FBI"); ConsoleShow();
            }
        } else {
            print("Error: couldn't find H&S data.\n"); ConsoleShow();
        }
    }

out:
    print("\nPress A to exit.\n\n\n");
    ConsoleShow();
    WaitForButton(BUTTON_A);
}

void installFBI()
{
    /* Injects FBI TMD and content file to the Health & Safety App */
    manageFBI(false);
}

void restoreHS()
{
    /* Restores original Health & Safety TMD and content file to the NAND */
    manageFBI(true);
}

PS. It adds a bit more text to both FBI's injector and HS Restore, as well as a bit more to MSET DG.

I'll need those translations to implement them.

Prepare for more strings guys. It's not gonna be a fun ride for anybody.

@nastys are you setting up the translation strings as a user-editable txt/bin/whatever, or are you hard-coding them? I'll maintain compatability with you, just let me know what format we're going with.
 
Last edited by Gadorach,
  • Like
Reactions: VerseHell

nastys

ナースティス
Member
Joined
Aug 5, 2014
Messages
1,730
Trophies
0
Age
26
Location
Earth
XP
1,794
Country
Italy
I could translate to Greek, but I will need Greek characters. I do not support Greeklish in any way.
I just checked the font and Greek characters are allowed :lol:
font.png


I'll see if it's possible to do something for 漢字, ひらがな, カタカナ and 한글.
 

nastys

ナースティス
Member
Joined
Aug 5, 2014
Messages
1,730
Trophies
0
Age
26
Location
Earth
XP
1,794
Country
Italy

VinsCool

Persona Secretiva Felineus
Global Moderator
Joined
Jan 7, 2014
Messages
14,600
Trophies
4
Location
Another World
Website
www.gbatemp.net
XP
25,218
Country
Canada
  • Like
Reactions: kactusss

Gadorach

Electronics Engineering Technologist
Member
Joined
Jan 22, 2014
Messages
970
Trophies
0
Location
Canada
XP
956
Country
Canada
Here's the unique string list for downgradeapp.c alone...

(Raw, so newline and switch characters still present. I'll try to clean it up later for easier editing/understanding. Basically, ignore any "\n", "%s", and "%u"s present in the strings.)

Code:
"Japan", "USA", "Europe", "China", "Korea", "Taiwan"
"Opening SecureInfo_A... "
"Error.\nTrying with SecureInfo_B... "
"Error.\nProcess failed!\n"
"OK!\n"
"Error: unsupported region.\nProcess failed!\n"
"Region: %s\n"
"         MSET DOWNGRADER"
"What would you like to\nDowngrade to?\n\n"
"[X] 4.x MSET\n[Y] 5.x/6.x MSET\n[B] Cancel\n\n"
"region is:  %u\n"
"Unsupported Region!\n"
"CHN Region Detected!\nFalling back to 4.x MSET\n"
"TWN Region Detected!\nFalling back to 4.x MSET\n"
"Operation Canceled!\n"
"Opening MSET app...\n"
"Opening downgrade pack... "
"Downgrading... "
"done!\nRemoving downgrade pack... "
"done.\n"
"\nError downgrading MSET content.\nRemoving downgrade pack... "
"done.\n"
"Error: bad downgrade pack.\n"
"Error.\n"
"Your MSET version is exploitable.\nDowngrade isn't necessary.\n"
"Error opening MSET content file.\n"
"Error opening MSET TMD.\n"
"Error: couldn't find MSET data.\n"
"\nPress A to exit\n\n\n"



"     RESTORE HEALTH & SAFETY"
"         FBI INSTALLATION"
"TMD Version: v%u.\n"
"NAND H&S TMD backup created.\n"
"NAND H&S content backup created.\n"
"Error writing H&S content backup.\n"
"Error creating H&S content backup.\n"
"Error writing H&S TMD backup.\n"
"Error creating H&S TMD backup.\n"
"Editing H&S Information... "
"Restoring H&S Information... "
"\n\nWhat would you like to do?\n"
"[B] Keep %s Data\n"
"[X] Delete %s Data\n\n"
"backup"
"FBI injection"

"OK!\n\nKeeping %s data.\n"
"OK!\n\nDeleting %s data... "

"restoring H&S"
"injecting FBI"
"\nError %s content file.\n"
"\nError %s TMD.\n"
"\nError: invalid Content Data hash.\nGot:\n"
"\nExpected:\n"

"FBI"
"\nInvalid %s content size.\nGot: v%u / Expected: v%u\n"
"\nError opening %s content.\n"
"\nError: invalid Content Chunk hash.\nGot:\n"
"\nError: invalid Content Info hash.\nGot:\n"
"\nError: invalid %s TMD version.\nGot: v%u / Expected: v%u\n"
"\nError: invalid %s TMD size.\nGot: %u / Expected: %u\n"
"\nError opening %s TMD.\n"
"Error: couldn't find H&S data.\n"
 

VinsCool

Persona Secretiva Felineus
Global Moderator
Joined
Jan 7, 2014
Messages
14,600
Trophies
4
Location
Another World
Website
www.gbatemp.net
XP
25,218
Country
Canada
I didn't know that :)
Maybe it doesn't apply to Canadian French...
Yeah, or actually we just don't care about that. I will fix the text anyway.

--------------------- MERGED ---------------------------

FIXED NOW :D


French:
  • Forcer démarrage UI :
  • Thème choisi :
  • Afficher AGB_FIRM :
  • Activer UI 3D :
  • Démarrage rapide :
  • Langage :
  • Oui
  • Non
  • OPTIONS
  • DÉMARRAGE AUTOMATIQUE
  • Maintenir le bouton R pour accéder au menu
  • FICHIERS DE THÈME MANQUANTS !
  • Choissisez la NAND que vous voulez utiliser
  • Bouton X : SysNAND
  • Bouton Y : EmuNAND
  • Bouton B : Retour
 
Status
Not open for further replies.

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    BigOnYa @ BigOnYa: I'm starting to sound like a Tck