mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-21 18:59:15 +01:00
Simplify the return to patch
This commit is contained in:
parent
4406ae25bd
commit
ed7daf977c
@ -140,9 +140,8 @@ static int RunAppbooter()
|
|||||||
|
|
||||||
DCFlushRange(ARGS_ADDR, sizeof(struct __argv) + args.length);
|
DCFlushRange(ARGS_ADDR, sizeof(struct __argv) + args.length);
|
||||||
|
|
||||||
u64 currentStub = getStubDest();
|
|
||||||
loadStub();
|
loadStub();
|
||||||
Set_Stub(returnTo(currentStub));
|
Set_Stub(returnTo(false));
|
||||||
|
|
||||||
gprintf("Exiting USBLoaderGX...\n\n");
|
gprintf("Exiting USBLoaderGX...\n\n");
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//functions for manipulating the HBC stub by giantpune
|
//functions for manipulating the HBC stub by giantpune
|
||||||
//updated by blackb0x August 2021
|
//updated by blackb0x April 2022
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ogcsys.h>
|
#include <ogcsys.h>
|
||||||
@ -7,29 +7,11 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "lstub.h"
|
#include "lstub.h"
|
||||||
#include "gecko.h"
|
|
||||||
#include "wad/nandtitle.h"
|
#include "wad/nandtitle.h"
|
||||||
|
|
||||||
extern const u8 stub_bin[];
|
extern const u8 stub_bin[];
|
||||||
extern const u32 stub_bin_size;
|
extern const u32 stub_bin_size;
|
||||||
|
|
||||||
static char *determineStubTIDLocation()
|
|
||||||
{
|
|
||||||
u32 *stubID = (u32 *)0x80001818;
|
|
||||||
|
|
||||||
// HBC stub 1.1.4
|
|
||||||
if (stubID[0] == 0x548406B0 && stubID[1] == 0x7C800124)
|
|
||||||
return (char *)0x80002662;
|
|
||||||
// HBC stub changed @ version 1.0.7. this file was last updated for HBC 1.0.8
|
|
||||||
else if (stubID[0] == 0x48000859 && stubID[1] == 0x4800088d)
|
|
||||||
return (char *)0x8000286A;
|
|
||||||
// HBC stub 1.0.6 and lower, and stub.bin
|
|
||||||
else if (stubID[0] == 0x480004c1 && stubID[1] == 0x480004f5)
|
|
||||||
return (char *)0x800024C6;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 Set_Stub(u64 reqID)
|
s32 Set_Stub(u64 reqID)
|
||||||
{
|
{
|
||||||
if (!hbcStubAvailable())
|
if (!hbcStubAvailable())
|
||||||
@ -37,9 +19,7 @@ s32 Set_Stub(u64 reqID)
|
|||||||
if (NandTitles.IndexOf(reqID) < 0)
|
if (NandTitles.IndexOf(reqID) < 0)
|
||||||
return WII_EINSTALL;
|
return WII_EINSTALL;
|
||||||
|
|
||||||
char *stub = determineStubTIDLocation();
|
char *stub = (char *)0x80002662;
|
||||||
if (!stub)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
stub[0] = TITLE_7(reqID);
|
stub[0] = TITLE_7(reqID);
|
||||||
stub[1] = TITLE_6(reqID);
|
stub[1] = TITLE_6(reqID);
|
||||||
@ -61,66 +41,41 @@ void loadStub()
|
|||||||
DCFlushRange(stubLoc, stub_bin_size);
|
DCFlushRange(stubLoc, stub_bin_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 getStubDest()
|
|
||||||
{
|
|
||||||
if (!hbcStubAvailable())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
char ret[8];
|
|
||||||
u64 retu = 0;
|
|
||||||
|
|
||||||
char *stub = determineStubTIDLocation();
|
|
||||||
if (!stub)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ret[0] = stub[0];
|
|
||||||
ret[1] = stub[1];
|
|
||||||
ret[2] = stub[8];
|
|
||||||
ret[3] = stub[9];
|
|
||||||
ret[4] = stub[4];
|
|
||||||
ret[5] = stub[5];
|
|
||||||
ret[6] = stub[12];
|
|
||||||
ret[7] = stub[13];
|
|
||||||
|
|
||||||
memcpy(&retu, ret, 8);
|
|
||||||
return retu;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8 hbcStubAvailable()
|
u8 hbcStubAvailable()
|
||||||
{
|
{
|
||||||
char *sig = (char *)0x80001804;
|
char *sig = (char *)0x80001804;
|
||||||
return (strncmp(sig, "STUBHAXX", 8) == 0);
|
return (strncmp(sig, "STUBHAXX", 8) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 returnTo(u64 currentStub)
|
u64 returnTo(bool onlyHBC)
|
||||||
{
|
{
|
||||||
// UNEO
|
if (!onlyHBC)
|
||||||
if (NandTitles.IndexOf(0x00010001554E454FULL) > 0)
|
{
|
||||||
return 0x00010001554E454FULL;
|
// UNEO
|
||||||
// ULNR
|
if (NandTitles.IndexOf(0x00010001554E454FULL) >= 0)
|
||||||
else if (NandTitles.IndexOf(0x00010001554C4E52ULL) > 0)
|
return 0x00010001554E454FULL;
|
||||||
return 0x00010001554C4E52ULL;
|
// ULNR
|
||||||
// IDCL
|
if (NandTitles.IndexOf(0x00010001554C4E52ULL) >= 0)
|
||||||
else if (NandTitles.IndexOf(0x000100014944434CULL) > 0)
|
return 0x00010001554C4E52ULL;
|
||||||
return 0x000100014944434CULL;
|
// IDCL
|
||||||
|
if (NandTitles.IndexOf(0x000100014944434CULL) >= 0)
|
||||||
|
return 0x000100014944434CULL;
|
||||||
|
}
|
||||||
// OHBC
|
// OHBC
|
||||||
else if (NandTitles.IndexOf(0x000100014F484243ULL) > 0)
|
if (NandTitles.IndexOf(0x000100014F484243ULL) >= 0)
|
||||||
return 0x000100014F484243ULL;
|
return 0x000100014F484243ULL;
|
||||||
// LULZ
|
// LULZ
|
||||||
else if (NandTitles.IndexOf(0x000100014C554C5AULL) > 0)
|
if (NandTitles.IndexOf(0x000100014C554C5AULL) >= 0)
|
||||||
return 0x000100014C554C5AULL;
|
return 0x000100014C554C5AULL;
|
||||||
// 1.0.7
|
// 1.0.7
|
||||||
else if (NandTitles.IndexOf(0x00010001AF1BF516ULL) > 0)
|
if (NandTitles.IndexOf(0x00010001AF1BF516ULL) >= 0)
|
||||||
return 0x00010001AF1BF516ULL;
|
return 0x00010001AF1BF516ULL;
|
||||||
// JODI
|
// JODI
|
||||||
else if (NandTitles.IndexOf(0x000100014A4F4449ULL) > 0)
|
if (NandTitles.IndexOf(0x000100014A4F4449ULL) >= 0)
|
||||||
return 0x000100014A4F4449ULL;
|
return 0x000100014A4F4449ULL;
|
||||||
// HAXX
|
// HAXX
|
||||||
else if (NandTitles.IndexOf(0x0001000148415858ULL) > 0)
|
if (NandTitles.IndexOf(0x0001000148415858ULL) >= 0)
|
||||||
return 0x0001000148415858ULL;
|
return 0x0001000148415858ULL;
|
||||||
// System menu
|
// System menu
|
||||||
else if (!currentStub)
|
return 0x100000002ULL;
|
||||||
return 0x100000002ULL;
|
|
||||||
// Current stub
|
|
||||||
return currentStub;
|
|
||||||
}
|
}
|
||||||
|
@ -12,18 +12,13 @@
|
|||||||
s32 Set_Stub(u64 reqID);
|
s32 Set_Stub(u64 reqID);
|
||||||
|
|
||||||
//load the default HBC stub into memory. as long as nothing writes to the 0x80001800
|
//load the default HBC stub into memory. as long as nothing writes to the 0x80001800
|
||||||
// +0xDC7 memory block it will stay there. by default it has 0x00010001/JODI.
|
// +0xDC7 memory block it will stay there. by default it has 0x00010001/UNEO.
|
||||||
void loadStub();
|
void loadStub();
|
||||||
|
|
||||||
//get whatever ID the stub is set to load
|
|
||||||
//!returns 0 if no stub is loaded into memory (must be the HBC stub at 0x800018000)
|
|
||||||
//!otherwise returns the ID set to return to
|
|
||||||
u64 getStubDest();
|
|
||||||
|
|
||||||
//returns 0 or 1 depending on wether the stub is available
|
//returns 0 or 1 depending on wether the stub is available
|
||||||
u8 hbcStubAvailable();
|
u8 hbcStubAvailable();
|
||||||
|
|
||||||
//returns a valid title to return to
|
//returns a valid title to return to
|
||||||
u64 returnTo(u64 currentStub);
|
u64 returnTo(bool onlyHBC = false);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -712,9 +712,8 @@ int WindowExitPrompt()
|
|||||||
|
|
||||||
int choice = -1;
|
int choice = -1;
|
||||||
|
|
||||||
u64 oldstub = getStubDest();
|
|
||||||
loadStub();
|
loadStub();
|
||||||
if (oldstub != 0x00010001554c4e52ll && oldstub != 0x00010001554e454fll) Set_Stub(oldstub);
|
Set_Stub(returnTo(true)); // Reset the stub back to the HBC
|
||||||
|
|
||||||
GuiWindow promptWindow(640, 480);
|
GuiWindow promptWindow(640, 480);
|
||||||
promptWindow.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
promptWindow.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||||
|
Loading…
Reference in New Issue
Block a user