2010-12-12 17:31:13 +01:00
|
|
|
//functions for manipulating the HBC stub by giantpune
|
2023-01-01 18:00:08 +01:00
|
|
|
//updated by blackb0x April 2022
|
2010-12-12 17:31:13 +01:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <ogcsys.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "lstub.h"
|
|
|
|
#include "wad/nandtitle.h"
|
|
|
|
|
2011-06-14 19:53:19 +02:00
|
|
|
extern const u8 stub_bin[];
|
|
|
|
extern const u32 stub_bin_size;
|
|
|
|
|
2010-12-12 17:31:13 +01:00
|
|
|
s32 Set_Stub(u64 reqID)
|
|
|
|
{
|
2021-08-01 19:00:15 +02:00
|
|
|
if (!hbcStubAvailable())
|
|
|
|
return 0;
|
|
|
|
if (NandTitles.IndexOf(reqID) < 0)
|
|
|
|
return WII_EINSTALL;
|
2010-12-12 17:31:13 +01:00
|
|
|
|
2023-01-01 18:00:08 +01:00
|
|
|
char *stub = (char *)0x80002662;
|
2021-08-01 19:00:15 +02:00
|
|
|
|
|
|
|
stub[0] = TITLE_7(reqID);
|
|
|
|
stub[1] = TITLE_6(reqID);
|
|
|
|
stub[8] = TITLE_5(reqID);
|
|
|
|
stub[9] = TITLE_4(reqID);
|
|
|
|
stub[4] = TITLE_3(reqID);
|
|
|
|
stub[5] = TITLE_2(reqID);
|
|
|
|
stub[12] = TITLE_1(reqID);
|
|
|
|
stub[13] = ((u8)(reqID));
|
2010-12-12 17:31:13 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
DCFlushRange(stub, 0x10);
|
|
|
|
return 1;
|
2010-12-12 17:31:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void loadStub()
|
|
|
|
{
|
2021-08-01 19:00:15 +02:00
|
|
|
char *stubLoc = (char *)0x80001800;
|
2011-07-26 00:28:22 +02:00
|
|
|
memcpy(stubLoc, stub_bin, stub_bin_size);
|
|
|
|
DCFlushRange(stubLoc, stub_bin_size);
|
2010-12-12 17:31:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 hbcStubAvailable()
|
|
|
|
{
|
2021-08-01 19:00:15 +02:00
|
|
|
char *sig = (char *)0x80001804;
|
2012-05-06 12:59:58 +02:00
|
|
|
return (strncmp(sig, "STUBHAXX", 8) == 0);
|
2010-12-12 17:31:13 +01:00
|
|
|
}
|
|
|
|
|
2023-01-01 18:00:08 +01:00
|
|
|
u64 returnTo(bool onlyHBC)
|
2021-08-01 19:00:15 +02:00
|
|
|
{
|
2023-01-01 18:00:08 +01:00
|
|
|
if (!onlyHBC)
|
|
|
|
{
|
|
|
|
// UNEO
|
|
|
|
if (NandTitles.IndexOf(0x00010001554E454FULL) >= 0)
|
|
|
|
return 0x00010001554E454FULL;
|
|
|
|
// ULNR
|
|
|
|
if (NandTitles.IndexOf(0x00010001554C4E52ULL) >= 0)
|
|
|
|
return 0x00010001554C4E52ULL;
|
|
|
|
// IDCL
|
|
|
|
if (NandTitles.IndexOf(0x000100014944434CULL) >= 0)
|
|
|
|
return 0x000100014944434CULL;
|
|
|
|
}
|
2021-08-01 19:00:15 +02:00
|
|
|
// OHBC
|
2023-01-01 18:00:08 +01:00
|
|
|
if (NandTitles.IndexOf(0x000100014F484243ULL) >= 0)
|
2021-08-01 19:00:15 +02:00
|
|
|
return 0x000100014F484243ULL;
|
|
|
|
// LULZ
|
2023-01-01 18:00:08 +01:00
|
|
|
if (NandTitles.IndexOf(0x000100014C554C5AULL) >= 0)
|
2021-08-01 19:00:15 +02:00
|
|
|
return 0x000100014C554C5AULL;
|
|
|
|
// 1.0.7
|
2023-01-01 18:00:08 +01:00
|
|
|
if (NandTitles.IndexOf(0x00010001AF1BF516ULL) >= 0)
|
2021-08-01 19:00:15 +02:00
|
|
|
return 0x00010001AF1BF516ULL;
|
|
|
|
// JODI
|
2023-01-01 18:00:08 +01:00
|
|
|
if (NandTitles.IndexOf(0x000100014A4F4449ULL) >= 0)
|
2021-08-01 19:00:15 +02:00
|
|
|
return 0x000100014A4F4449ULL;
|
|
|
|
// HAXX
|
2023-01-01 18:00:08 +01:00
|
|
|
if (NandTitles.IndexOf(0x0001000148415858ULL) >= 0)
|
2021-08-01 19:00:15 +02:00
|
|
|
return 0x0001000148415858ULL;
|
|
|
|
// System menu
|
2023-01-01 18:00:08 +01:00
|
|
|
return 0x100000002ULL;
|
2021-08-01 19:00:15 +02:00
|
|
|
}
|