Fix unlaunch being wrongly detected as installed

This commit is contained in:
Edoardo Lolletti 2024-04-25 15:37:31 +02:00
parent a6e2c31c14
commit e8956ae02e
3 changed files with 22 additions and 1 deletions

View File

@ -203,6 +203,7 @@ int main(int argc, char **argv)
const char* hnaaTmdPath = "nand:/title/00030017/484e4141/content/title.tmd";
{
FILE* file = fopen("nand:/sys/HWINFO_S.dat", "rb");
bool mainTmdIsPatched = false;
if (file)
{
fseek(file, 0xA0, SEEK_SET);
@ -224,6 +225,10 @@ int main(int argc, char **argv)
//if size isn't 520 then the tmd either is not present (size 0), or is already invalid, thus no need to patch
retailLauncherTmdPresentAndToBePatched = false;
}
else
{
mainTmdIsPatched = isLauncherTmdPatched(retailLauncherTmdPath);
}
// HWINFO_S may not always exist (PRE_IMPORT). Fill in defaults if that happens.
}
@ -231,7 +236,7 @@ int main(int argc, char **argv)
// These can normally be identified by having the region set to ALL (0x41)
retailConsole = (region != 0x41 && region != 0xFF);
if (!unlaunchFound)
if (!unlaunchFound && (mainTmdIsPatched || !retailConsole))
{
unsigned long long tmdSize = getFileSizePath(hnaaTmdPath);
if (tmdSize > 520)

View File

@ -8,6 +8,20 @@
static char unlaunchInstallerBuffer[0x30000];
static const char* hnaaTmdPath = "nand:/title/00030017/484e4141/content/title.tmd";
bool isLauncherTmdPatched(const char* path)
{
FILE* launcherTmd = fopen(path, "rb");
if(!launcherTmd)
{
return false;
}
fseek(launcherTmd, 0x190, SEEK_SET);
char c;
fread(&c, 1, 1, launcherTmd);
fclose(launcherTmd);
return c == 0x47;
}
static bool restoreMainTmd(const char* path)
{
FILE* launcherTmd = fopen(path, "r+b");

View File

@ -5,4 +5,6 @@
bool uninstallUnlaunch(bool notProto, const char* retailLauncherTmdPath);
bool installUnlaunch(bool retailConsole, const char* retailLauncherTmdPath);
bool isLauncherTmdPatched(const char* path);
#endif