mirror of
https://github.com/rvtr/unlaunch-installer_dev.git
synced 2026-01-26 13:43:08 -05:00
Mark launcher's tmd as read only on install
This commit is contained in:
parent
8b19184921
commit
739a5ab467
@ -273,6 +273,7 @@ int main(int argc, char **argv)
|
|||||||
//check for unlaunch and region
|
//check for unlaunch and region
|
||||||
u8 region = 0xff;
|
u8 region = 0xff;
|
||||||
char retailLauncherTmdPath[64];
|
char retailLauncherTmdPath[64];
|
||||||
|
char retailLauncherPath[64];
|
||||||
const char* hnaaTmdPath = "nand:/title/00030017/484e4141/content/title.tmd";
|
const char* hnaaTmdPath = "nand:/title/00030017/484e4141/content/title.tmd";
|
||||||
{
|
{
|
||||||
FILE* file = fopen("nand:/sys/HWINFO_S.dat", "rb");
|
FILE* file = fopen("nand:/sys/HWINFO_S.dat", "rb");
|
||||||
@ -296,7 +297,6 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned long long tmdSize = getFileSize(tmd);
|
|
||||||
if (tmdSize > 520)
|
if (tmdSize > 520)
|
||||||
{
|
{
|
||||||
unlaunchFound = true;
|
unlaunchFound = true;
|
||||||
@ -305,15 +305,15 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
mainTmdIsPatched = isLauncherTmdPatched(retailLauncherTmdPath);
|
mainTmdIsPatched = isLauncherTmdPatched(retailLauncherTmdPath);
|
||||||
}
|
}
|
||||||
fseek(tmd, 0x1E4, SEEK_SET);
|
fseek(tmd, 0x1DC, SEEK_SET);
|
||||||
unsigned int contentId;
|
unsigned short launcherVersion;
|
||||||
fread(&contentId, sizeof(contentId), 1, tmd);
|
fread(&launcherVersion, sizeof(launcherVersion), 1, tmd);
|
||||||
// Launcher v4, build v1024 (shipped with firmware 1.4.2 (not sure about J, and 1.4.3 for china)
|
// Launcher v4, build v1024 (shipped with firmware 1.4.2 (not sure about J, and 1.4.3 for china)
|
||||||
// will fail to launch if another tmd withouth appropriate application, or an invalid
|
// will fail to launch if another tmd withouth appropriate application, or an invalid
|
||||||
// tmd (in our case the one installed from unlaunch) is found in the HNAA launcher folder
|
// tmd (in our case the one installed from unlaunch) is found in the HNAA launcher folder
|
||||||
// there's really no workaround to that, so that specific version is blacklisted and only uninstalling
|
// there's really no workaround to that, so that specific version is blacklisted and only uninstalling
|
||||||
// an "officially" installed unlaunch without leaving any backup behind will be allowed
|
// an "officially" installed unlaunch without leaving any backup behind will be allowed
|
||||||
if(contentId == 0x04000000)
|
if(launcherVersion == 4)
|
||||||
{
|
{
|
||||||
isLauncherVersionSupported = false;
|
isLauncherVersionSupported = false;
|
||||||
messageBox("\x1B[41mWARNING:\x1B[47m This system version\n"
|
messageBox("\x1B[41mWARNING:\x1B[47m This system version\n"
|
||||||
@ -322,6 +322,18 @@ int main(int argc, char **argv)
|
|||||||
"unaunch without backups will\n"
|
"unaunch without backups will\n"
|
||||||
"be possible");
|
"be possible");
|
||||||
}
|
}
|
||||||
|
else if (launcherVersion > 7)
|
||||||
|
{
|
||||||
|
char messageBoxError[128];
|
||||||
|
sprintf(messageBoxError, "\x1B[41mWARNING:\x1B[47m This system version (%d)\n"
|
||||||
|
"is unknown\n"
|
||||||
|
"nothing will be done", (int)launcherVersion);
|
||||||
|
messageBox("\x1B[41mWARNING:\x1B[47m This system version\n"
|
||||||
|
"is unknown\n"
|
||||||
|
"nothing will be done");
|
||||||
|
goto abort;
|
||||||
|
}
|
||||||
|
sprintf(retailLauncherPath, "nand:/title/00030017/%08lx/content/0000000%d.app", launcherTid, (int)launcherVersion);
|
||||||
}
|
}
|
||||||
if(tmd)
|
if(tmd)
|
||||||
{
|
{
|
||||||
@ -381,7 +393,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
needsNocashFooterToBeWritten = false;
|
needsNocashFooterToBeWritten = false;
|
||||||
}
|
}
|
||||||
if(uninstallUnlaunch(retailConsole, hnaaUnlaunchFound, retailLauncherTmdPath, unsafeUninstall))
|
if(uninstallUnlaunch(retailConsole, hnaaUnlaunchFound, retailLauncherTmdPath, retailLauncherPath, unsafeUninstall))
|
||||||
{
|
{
|
||||||
messageBox("Uninstall successful!\n");
|
messageBox("Uninstall successful!\n");
|
||||||
unlaunchFound = false;
|
unlaunchFound = false;
|
||||||
@ -477,6 +489,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if(installUnlaunch(retailConsole,
|
if(installUnlaunch(retailConsole,
|
||||||
retailLauncherTmdPresentAndToBePatched ? retailLauncherTmdPath : NULL,
|
retailLauncherTmdPresentAndToBePatched ? retailLauncherTmdPath : NULL,
|
||||||
|
retailLauncherTmdPresentAndToBePatched ? retailLauncherPath : NULL,
|
||||||
disableAllPatches,
|
disableAllPatches,
|
||||||
enableSoundAndSplash ? splashSoundBinaryPatchPath : NULL,
|
enableSoundAndSplash ? splashSoundBinaryPatchPath : NULL,
|
||||||
customBgPath))
|
customBgPath))
|
||||||
@ -511,6 +524,8 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abort:
|
||||||
|
|
||||||
clearScreen(&bottomScreen);
|
clearScreen(&bottomScreen);
|
||||||
printf("Unmounting NAND...\n");
|
printf("Unmounting NAND...\n");
|
||||||
|
|||||||
@ -225,11 +225,11 @@ static bool restoreProtoTmd(const char* path)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool uninstallUnlaunch(bool retailConsole, bool hasHNAABackup, const char* retailLauncherTmdPath, bool removeHNAABackup)
|
bool uninstallUnlaunch(bool retailConsole, bool hasHNAABackup, const char* retailLauncherTmdPath, const char* retailLauncherPath, bool removeHNAABackup)
|
||||||
{
|
{
|
||||||
// TODO: handle retailLauncherTmdPresentAndToBePatched = false on retail consoles
|
// TODO: handle retailLauncherTmdPresentAndToBePatched = false on retail consoles
|
||||||
if (retailConsole) {
|
if (retailConsole) {
|
||||||
if (!toggleFileReadOnly(retailLauncherTmdPath, false))
|
if (!toggleFileReadOnly(retailLauncherTmdPath, false) || !toggleFileReadOnly(retailLauncherPath, false))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -312,7 +312,7 @@ static bool writeUnlaunchToHNAAFolder()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool installUnlaunchRetailConsole(const char* retailLauncherTmdPath)
|
static bool installUnlaunchRetailConsole(const char* retailLauncherTmdPath, const char* retailLauncherPath)
|
||||||
{
|
{
|
||||||
if(!writeUnlaunchToHNAAFolder())
|
if(!writeUnlaunchToHNAAFolder())
|
||||||
return false;
|
return false;
|
||||||
@ -328,7 +328,7 @@ static bool installUnlaunchRetailConsole(const char* retailLauncherTmdPath)
|
|||||||
removeHnaaLauncher();
|
removeHnaaLauncher();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!toggleFileReadOnly(retailLauncherTmdPath, true))
|
if (!toggleFileReadOnly(retailLauncherTmdPath, true) || !toggleFileReadOnly(retailLauncherPath, true))
|
||||||
{
|
{
|
||||||
messageBox("\x1B[31mError:\x1B[33m Failed to mark default launcher's title.tmd\nas read only, install might be unstable\n");
|
messageBox("\x1B[31mError:\x1B[33m Failed to mark default launcher's title.tmd\nas read only, install might be unstable\n");
|
||||||
}
|
}
|
||||||
@ -569,7 +569,7 @@ const char* getUnlaunchVersionString(UNLAUNCH_VERSION version)
|
|||||||
return unlaunchVersionStrings[version];
|
return unlaunchVersionStrings[version];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool installUnlaunch(bool retailConsole, const char* retailLauncherTmdPath, bool disableAllPatches, const char* splashSoundBinaryPatchPath, const char* customBackgroundPath)
|
bool installUnlaunch(bool retailConsole, const char* retailLauncherTmdPath, const char* retailLauncherPath, bool disableAllPatches, const char* splashSoundBinaryPatchPath, const char* customBackgroundPath)
|
||||||
{
|
{
|
||||||
if (installerVersion == INVALID || !patchUnlaunchInstaller(disableAllPatches, splashSoundBinaryPatchPath, customBackgroundPath))
|
if (installerVersion == INVALID || !patchUnlaunchInstaller(disableAllPatches, splashSoundBinaryPatchPath, customBackgroundPath))
|
||||||
return false;
|
return false;
|
||||||
@ -580,5 +580,5 @@ bool installUnlaunch(bool retailConsole, const char* retailLauncherTmdPath, bool
|
|||||||
return installUnlaunchProtoConsole();
|
return installUnlaunchProtoConsole();
|
||||||
}
|
}
|
||||||
// Do things normally for production units
|
// Do things normally for production units
|
||||||
return installUnlaunchRetailConsole(retailLauncherTmdPath);
|
return installUnlaunchRetailConsole(retailLauncherTmdPath, retailLauncherPath);
|
||||||
}
|
}
|
||||||
@ -15,8 +15,8 @@ typedef enum UNLAUNCH_VERSION {
|
|||||||
|
|
||||||
const char* getUnlaunchVersionString(UNLAUNCH_VERSION);
|
const char* getUnlaunchVersionString(UNLAUNCH_VERSION);
|
||||||
|
|
||||||
bool uninstallUnlaunch(bool notProto, bool hasHNAABackup, const char* retailLauncherTmdPath, bool removeHNAABackup);
|
bool uninstallUnlaunch(bool notProto, bool hasHNAABackup, const char* retailLauncherTmdPath, const char* retailLauncherPath, bool removeHNAABackup);
|
||||||
bool installUnlaunch(bool retailConsole, const char* retailLauncherTmdPath, bool disableAllPatches, const char* splashSoundBinaryPatchPath, const char* customBackgroundPath);
|
bool installUnlaunch(bool retailConsole, const char* retailLauncherTmdPath, const char* retailLauncherPath, bool disableAllPatches, const char* splashSoundBinaryPatchPath, const char* customBackgroundPath);
|
||||||
|
|
||||||
bool isLauncherTmdPatched(const char* path);
|
bool isLauncherTmdPatched(const char* path);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user