mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-16 00:15:08 +01:00
Cleanup and improve StartUpProcess
This commit is contained in:
parent
e25c4e4342
commit
9cabf089ec
@ -235,41 +235,33 @@ int StartUpProcess::Run(int argc, char *argv[])
|
||||
int StartUpProcess::Execute()
|
||||
{
|
||||
Settings.EntryIOS = IOS_GetVersion();
|
||||
gprintf("Current IOS: %i - have AHB access: %s\n", Settings.EntryIOS, AHBPROT_DISABLED ? "yes" : "no");
|
||||
|
||||
// Reloading to cIOS 249 fixes compatibility issues with old forwarders
|
||||
s32 ret = IosLoader::ReloadIosSafe(249);
|
||||
|
||||
// Reload to the IOS set in meta.xml
|
||||
if(Settings.UseArgumentIOS)
|
||||
// Only reload the IOS if the XML requests it, we don't have full HW access or the entry IOS isn't 58
|
||||
if(Settings.UseArgumentIOS || !AHBPROT_DISABLED || IOS_GetVersion() != 58)
|
||||
{
|
||||
SetTextf("Loading %sIOS %i requested in meta.xml\n", Settings.LoaderIOS >= 200 ? "c" : "", Settings.LoaderIOS);
|
||||
if(IosLoader::ReloadIosSafe(Settings.LoaderIOS) < 0)
|
||||
if (Settings.UseArgumentIOS)
|
||||
SetTextf("Reloading to %sIOS %i requested in meta.xml\n", Settings.LoaderIOS >= 200 ? "c" : "", Settings.LoaderIOS);
|
||||
else
|
||||
SetTextf("Reloading to %sIOS %i\n", Settings.LoaderIOS >= 200 ? "c" : "", Settings.LoaderIOS);
|
||||
// Reload to the default loader IOS or the IOS set in meta.xml
|
||||
// And on failure try cIOS 249, 250, 222, 223, 245, 246, 247 and 248
|
||||
if(IosLoader::LoadAppCios(Settings.LoaderIOS) < 0)
|
||||
{
|
||||
SetTextf("Failed to load %sIOS %i requested in meta.xml. Exiting...\n", Settings.LoaderIOS >= 200 ? "c" : "", Settings.LoaderIOS);
|
||||
SetTextf("Failed to load an IOS. USB Loader GX requires a cIOS or IOS58 with AHB access. Exiting...\n");
|
||||
sleep(5);
|
||||
Sys_BackToLoader();
|
||||
}
|
||||
}
|
||||
// This prevents an unnecessary IOS reload
|
||||
else if(BUILD_IOS != 249 || ret < 0)
|
||||
{
|
||||
// Reload to the default IOS (58) or a cIOS if nothing is set in meta.xml
|
||||
if(IosLoader::LoadAppCios(BUILD_IOS) < 0)
|
||||
{
|
||||
SetTextf("Failed to load a cIOS or IOS58 with AHB access. Exiting...\n");
|
||||
sleep(5);
|
||||
Sys_BackToLoader();
|
||||
}
|
||||
}
|
||||
|
||||
if(!AHBPROT_DISABLED && IOS_GetVersion() < 200)
|
||||
{
|
||||
SetTextf("Failed loading IOS %i. USB Loader GX requires a cIOS or IOS58 with AHB access. Exiting...\n", IOS_GetVersion());
|
||||
SetTextf("Failed to load into IOS %i. USB Loader GX requires a cIOS or IOS58 with AHB access. Exiting...\n", IOS_GetVersion());
|
||||
sleep(5);
|
||||
Sys_BackToLoader();
|
||||
}
|
||||
}
|
||||
|
||||
SetupPads();
|
||||
gprintf("Current IOS: %i - have AHB access: %s\n", IOS_GetVersion(), AHBPROT_DISABLED ? "yes" : "no");
|
||||
|
||||
SetTextf("Initializing sd card\n");
|
||||
DeviceHandler::Instance()->MountSD();
|
||||
@ -299,16 +291,17 @@ int StartUpProcess::Execute()
|
||||
if(Settings.USBAutoMount == ON)
|
||||
USBStorage2_Deinit();
|
||||
|
||||
// Shut down pads
|
||||
// Shutdown pads
|
||||
Wpad_Disconnect();
|
||||
|
||||
// Loading now the cIOS setup in the settings
|
||||
// Now load the cIOS that was set in the settings menu
|
||||
if(IosLoader::LoadAppCios(Settings.LoaderIOS) > -1)
|
||||
{
|
||||
SetTextf("Reloaded into cIOS %i R%i\n", IOS_GetVersion(), IOS_GetRevision());
|
||||
// Re-Mount devices
|
||||
SetTextf("Reinitializing devices\n");
|
||||
}
|
||||
gprintf("Current IOS: %i - have AHB access: %s\n", IOS_GetVersion(), AHBPROT_DISABLED ? "yes" : "no");
|
||||
DeviceHandler::Instance()->MountSD();
|
||||
if(Settings.USBAutoMount == ON)
|
||||
{
|
||||
@ -352,6 +345,8 @@ int StartUpProcess::Execute()
|
||||
NandTitles.Get(); // get NAND channel's titles
|
||||
}
|
||||
|
||||
gprintf("Current IOS: %i - have AHB access: %s\n", IOS_GetVersion(), AHBPROT_DISABLED ? "yes" : "no");
|
||||
|
||||
// We only initialize once for the whole session
|
||||
ISFS_Initialize();
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "mload/modules/ehcmodule_5.h"
|
||||
#include "mload/modules/dip_plugin_249.h"
|
||||
#include "mload/modules/odip_frag.h"
|
||||
#include "libs/libruntimeiospatch/runtimeiospatch.h"
|
||||
#include "utils/tools.h"
|
||||
#include "gecko.h"
|
||||
|
||||
@ -108,7 +107,6 @@ s32 IosLoader::LoadAppCios(u8 ios)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Loads a CIOS before a game start.
|
||||
* @return 0 if a cios has been successfully loaded. Else a value below 0 is returned.
|
||||
@ -178,7 +176,35 @@ s32 IosLoader::ReloadIosSafe(s32 ios)
|
||||
*/
|
||||
s32 IosLoader::ReloadIosKeepingRights(s32 ios)
|
||||
{
|
||||
IosPatch_AHBPROT(false);
|
||||
if (CheckAHBPROT())
|
||||
{
|
||||
static const u16 ticket_check[] = {
|
||||
0x685B, // ldr r3, [r3, #4] ; Get TMD pointer
|
||||
0x22EC, 0x0052, // movs r2, 0x1D8 ; Set offset of access rights field in TMD
|
||||
0x189B, // adds r3, r3, r2 ; Add offset to TMD pointer
|
||||
0x681B, // ldr r3, [r3] ; Load access rights. We'll hack it with full access rights!!!
|
||||
0x4698, // mov r8, r3 ; Store it for the DVD video bitcheck later
|
||||
0x07DB // lsls r3, r3, 0x1F ; check AHBPROT bit
|
||||
};
|
||||
|
||||
/* Disable MEM 2 protection */
|
||||
write16(MEM2_PROT, 2);
|
||||
|
||||
for (u16 *patchme = ES_MODULE_START; patchme < ES_MODULE_END; patchme++)
|
||||
{
|
||||
if (!memcmp(patchme, ticket_check, sizeof(ticket_check)))
|
||||
{
|
||||
gprintf("ReloadIos: Found TMD access rights check at %p\n", patchme);
|
||||
|
||||
/* Apply patch */
|
||||
patchme[ES_HACK_OFFSET] = 0x23FF; // li r3, 0xFF ; Set full access rights
|
||||
|
||||
/* Flush cache */
|
||||
DCFlushRange(patchme+ES_HACK_OFFSET, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Reload IOS. MEM2 protection is implicitly re-enabled
|
||||
return IOS_ReloadIOS(ios);
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include <gccore.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
|
||||
#define CheckAHBPROT() (read32(0x0D800064) == 0xFFFFFFFF)
|
||||
|
||||
enum MiosInfo
|
||||
{
|
||||
DEFAULT_MIOS,
|
||||
|
@ -810,7 +810,7 @@ int GameBooter::BootDevolution(struct discHdr *gameHdr)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!AHBPROT_DISABLED)
|
||||
if(!CheckAHBPROT())
|
||||
{
|
||||
WindowPrompt(tr("Error:"), fmt(tr("%s requires AHB access! Please launch USBLoaderGX from HBC or from an updated channel or forwarder."),LoaderName), tr("OK"));
|
||||
return -1;
|
||||
@ -1053,7 +1053,7 @@ int GameBooter::BootNintendont(struct discHdr *gameHdr)
|
||||
const char *ninLoaderPath = game_cfg->NINLoaderPath.size() == 0 ? Settings.NINLoaderPath : game_cfg->NINLoaderPath.c_str();
|
||||
|
||||
|
||||
if(!AHBPROT_DISABLED)
|
||||
if(!CheckAHBPROT())
|
||||
{
|
||||
WindowPrompt(tr("Error:"), fmt(tr("%s requires AHB access! Please launch USBLoaderGX from HBC or from an updated channel or forwarder."),LoaderName), tr("OK"));
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user