Usability - added stub binary for return to loader and functions to manage the return TID via "return_to_channel" configuration key

Compilation - added all prebuild libraries for old PPC versions
This commit is contained in:
Nitraiolo 2015-01-17 17:50:43 +00:00
parent d28531dae8
commit a7a54c7439
57 changed files with 243 additions and 24 deletions

View File

@ -309,6 +309,10 @@ $(OUTPUT).elf: $(OFILES)
@echo $(notdir $<)
@$(bin2o)
%.bin.o : %.bin
@echo $(notdir $<)
@$(bin2o)
#%.o: %.c
# @echo $(notdir $<)
# $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@

BIN
data/stub.bin Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/jpeg/lib17/libjpeg.a Normal file

Binary file not shown.

BIN
lib/jpeg/lib22/libjpeg.a Normal file

Binary file not shown.

BIN
lib/jpeg/lib24/libjpeg.a Normal file

Binary file not shown.

BIN
lib/jpeg/lib25/libjpeg.a Normal file

Binary file not shown.

BIN
lib/jpeg/lib26/libjpeg.a Normal file

Binary file not shown.

BIN
lib/jpeg/src/libjpeg.a Normal file

Binary file not shown.

BIN
lib/jpeg8a/lib/libjpeg.a Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/libfat/lib17/libfat.a Normal file

Binary file not shown.

BIN
lib/libfat/lib22/libfat.a Normal file

Binary file not shown.

BIN
lib/libfat/lib24/libfat.a Normal file

Binary file not shown.

BIN
lib/libfat/lib25/libfat.a Normal file

Binary file not shown.

BIN
lib/libfat/lib26/libfat.a Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/libntfs/lib17/libntfs.a Normal file

Binary file not shown.

BIN
lib/libntfs/lib22/libntfs.a Normal file

Binary file not shown.

BIN
lib/libntfs/lib24/libntfs.a Normal file

Binary file not shown.

BIN
lib/libntfs/lib25/libntfs.a Normal file

Binary file not shown.

BIN
lib/libntfs/lib26/libntfs.a Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/png-1.2.34/lib/libpng.a Normal file

Binary file not shown.

BIN
lib/png/lib17/libpng.a Normal file

Binary file not shown.

BIN
lib/png/lib22/libpng.a Normal file

Binary file not shown.

BIN
lib/png/lib24/libpng.a Normal file

Binary file not shown.

BIN
lib/png/lib25/libpng.a Normal file

Binary file not shown.

BIN
lib/png/lib26/libpng.a Normal file

Binary file not shown.

BIN
lib/png/src/libpng.a Normal file

Binary file not shown.

BIN
lib/zlib/lib17/libz.a Normal file

Binary file not shown.

BIN
lib/zlib/lib22/libz.a Normal file

Binary file not shown.

BIN
lib/zlib/lib24/libz.a Normal file

Binary file not shown.

BIN
lib/zlib/lib25/libz.a Normal file

Binary file not shown.

BIN
lib/zlib/lib26/libz.a Normal file

Binary file not shown.

BIN
lib/zlib/src/libz.a Normal file

Binary file not shown.

View File

@ -35,6 +35,7 @@ char APPS_DIR[200] = "";
char LAST_CFG_PATH[200];
char direct_start_id_buf[] = "#GAMEID\0\0\0\0\0CFGUSB0000000000";
char DIOS_MIOS_INFO[200] = "";
u32 HBC_LOWER_TID = 0x00000000;
/* configurable fields */

View File

@ -233,6 +233,7 @@ extern char APPS_DIR[];
extern char CFG_VERSION[];
extern char LAST_CFG_PATH[];
extern char DIOS_MIOS_INFO[];
extern u32 HBC_LOWER_TID;
typedef char GAMEID_t[8];

View File

@ -97,7 +97,7 @@ char *read_name_from_banner_app(u64 titleid)
u8 imet[4] = {0x49, 0x4D, 0x45, 0x54};
sprintf(path_buffer, "%s/title/%08x/%08x/content", CFG.nand_emu_path, TITLE_HIGH(titleid), TITLE_LOW(titleid));
sprintf(path_buffer, "%s/title/%08x/%08x/content", CFG.nand_emu_path, TITLE_UPPER(titleid), TITLE_LOWER(titleid));
dbg_printf("opendir(%s)\n", path_buffer);
sdir = opendir(path_buffer);
@ -109,7 +109,7 @@ char *read_name_from_banner_app(u64 titleid)
{
continue;
}
sprintf(path_buffer, "%s/title/%08x/%08x/content/%s", CFG.nand_emu_path, TITLE_HIGH(titleid), TITLE_LOW(titleid), entry->d_name);
sprintf(path_buffer, "%s/title/%08x/%08x/content/%s", CFG.nand_emu_path, TITLE_UPPER(titleid), TITLE_LOWER(titleid), entry->d_name);
dbg_printf("fopen(%s)\n", path_buffer);
fp = fopen(path_buffer, "rb");
@ -159,7 +159,7 @@ char *read_name_from_banner_bin(u64 titleid)
u32 filesize;
FILE *fp;
sprintf(path, "%s/title/%08x/%08x/data/banner.bin", CFG.nand_emu_path, TITLE_HIGH(titleid), TITLE_LOW(titleid));
sprintf(path, "%s/title/%08x/%08x/data/banner.bin", CFG.nand_emu_path, TITLE_UPPER(titleid), TITLE_LOWER(titleid));
fp = fopen(path, "rb");
if (fp == NULL)
@ -189,7 +189,7 @@ char *get_channel_name(u64 titleid, FILE *fp)
{
char *temp = NULL;
u32 low;
low = TITLE_LOW(titleid);
low = TITLE_LOWER(titleid);
// TODO
// dbg_printf("Getting the name for: %08x...\n", titleid);

View File

@ -61,6 +61,7 @@
#include "savegame.h"
#include "channel.h"
#include "RuntimeIOSPatch.h"
#include "titles.h"
void _unstub_start();
@ -70,10 +71,6 @@ u32 dolchunkcount;
extern void __exception_closeall();
#define TITLE_UPPER(x) ((u32)((x) >> 32))
#define TITLE_LOWER(x) ((u32)(x))
#define TITLE_ID(x,y) (((u64)(x) << 32) | (y))
typedef void (*entrypoint) (void);
#define CHANGE(V,M) {V+=change; if(V>(M)) V=(M); if(V<0) V=0;}
@ -397,7 +394,7 @@ s32 get_channel_list(void *outbuf, u32 size)
channel->magic = CHANNEL_MAGIC;
//strncpy(channel->path, path, strlen(path));
u32 title_low = TITLE_LOW(strtol(entry->d_name,NULL,16));
u32 title_low = TITLE_LOWER(strtol(entry->d_name,NULL,16));
memcpy(channel->id, &title_low, sizeof(u32));
char *name = get_channel_name(TITLE_ID(0x00010001, title_low),fp);
strncpy(channel->title, name, sizeof(channel->title));
@ -1061,7 +1058,7 @@ void Menu_GameInfoStr2(struct discHdr *header, char *str, u64 comp_size, u64 rea
}
if (game_tmd.sys_version) {
s += strlen(s);
sprintf(s, " IOS%d\n\n", TITLE_LOW(game_tmd.sys_version));
sprintf(s, " IOS%d\n\n", TITLE_LOWER(game_tmd.sys_version));
} else {
s += strlen(s);
sprintf(s, "\n\n");
@ -4644,7 +4641,7 @@ L_repaint:
}
}
if (game_tmd.sys_version) {
set_recommended_cIOS_idx(TITLE_LOW(game_tmd.sys_version), false);
set_recommended_cIOS_idx(TITLE_LOWER(game_tmd.sys_version), false);
}
}
//dbg_printf("set ios: %d idx: %d\n", CFG.ios, CFG.game.ios_idx);

117
source/rcstub.c Normal file
View File

@ -0,0 +1,117 @@
/* Load the open source "return to channel" stub
*
* Functions for manipulating the HBC stub by giantpune from PostLoader
* Stub from USBLoader GX and FIX94 work
* Adapted to Cfg USB Loader by NiTRo
*/
#include <stdio.h>
#include <ogcsys.h>
#include <stdlib.h>
#include <malloc.h>
#include <unistd.h>
#include <gccore.h>
#include <string.h>
#include <time.h>
#include "rcstub.h"
#include "debug.h"
extern const u8 stub_bin[];
extern const u32 stub_bin_size;
void stub_load ( void )
{
dbg_printf("stub_load()\n");
// Clear potential homebrew channel stub
memset((void*)0x80001800, 0, 0x1800);
// Copy our own stub into memory
memcpy((void*)0x80001800, stub_bin, stub_bin_size);
DCFlushRange((void*)0x80001800, 0x1800);
return;
}
void stub_unload ( void )
{
dbg_printf("stub_unload()\n");
memset((void*)0x80001800, 0, 0x1800);
DCFlushRange((void*)0x80001800, 0x1800);
return;
}
static char* stub_find_tid_addr ( void )
{
u32 *stub_id = (u32*) 0x80001818;
//HBC stub 1.0.6 and lower, and stub.bin
if (stub_id[0] == 0x480004c1 && stub_id[1] == 0x480004f5)
return (char *) 0x800024C6;
//HBC stub changed @ version 1.0.7. this file was last updated for HBC 1.0.8
else if (stub_id[0] == 0x48000859 && stub_id[1] == 0x4800088d)
return (char *) 0x8000286A;
return NULL;
}
s32 stub_set_tid ( u64 new_tid )
{
char *stub_tid_addr = stub_find_tid_addr();
if (!stub_tid_addr) return -68;
stub_tid_addr[0] = TITLE_7( new_tid );
stub_tid_addr[1] = TITLE_6( new_tid );
stub_tid_addr[8] = TITLE_5( new_tid );
stub_tid_addr[9] = TITLE_4( new_tid );
stub_tid_addr[4] = TITLE_3( new_tid );
stub_tid_addr[5] = TITLE_2( new_tid );
stub_tid_addr[12] = TITLE_1( new_tid );
stub_tid_addr[13] = ((u8) (new_tid));
DCFlushRange(stub_tid_addr, 0x10);
return 0;
}
s32 stub_set_splitted_tid ( u32 type, const char* new_lower )
{
const u32 lower = ((u32)new_lower[0] << 24) |
((u32)new_lower[1] << 16) |
((u32)new_lower[2] << 8) |
((u32)new_lower[3]);
return stub_set_tid(TITLE_ID( type, lower ));
}
u8 stub_available ( void )
{
char * sig = (char *) 0x80001804;
return (strncmp(sig, "STUBHAXX", 8) == 0);
}
u64 stub_get_tid ( void )
{
if (!stub_available()) return 0;
char ret[8];
u64 retu = 0;
char *stub = stub_find_tid_addr();
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;
}

21
source/rcstub.h Normal file
View File

@ -0,0 +1,21 @@
/* Load the open source "return to channel" stub
*
* Functions for manipulating the HBC stub by giantpune from PostLoader
* Stub from USBLoader GX and FIX94 work
* Adapted to Cfg USB Loader by NiTRo
*/
#ifndef _STUB_
#define _STUB_
#include "titles.h"
void stub_load ( void );
void stub_unload ( void );
s32 stub_set_tid ( u64 new_tid );
s32 stub_set_splitted_tid ( u32 type, const char* new_lower );
u8 stub_available ( void );
u64 stub_get_tid ( void );
#endif

View File

@ -731,6 +731,7 @@ int ReloadIOS(int subsys, int verbose)
}
}
}
if (is_ios_type(IOS_TYPE_WANIN) && IOS_GetRevision() >= 18) {
//load_dip_249();
mk_mload_version();
@ -853,10 +854,7 @@ void get_title_id()
if (old_title_id <= 2)
{
// HBC reload stub -> assuming boot from HBC
if (strncmp("STUBHAXX", (char *)0x80001804, 8) == 0)
{
old_title_id = 0xAF1BF516;
}
old_title_id = HBC_LOWER_TID;
}
dbg_printf("channel id: %08X\n", old_title_id);
}
@ -1536,7 +1534,7 @@ u8 get_base_ios_from_tmd(int ios_slot, u32 *version) {
t = (tmd*)SIGNATURE_PAYLOAD(TMD);
dbg_printf("\ntmd id: %llx %x-%x t: %x v: %d",
t->title_id, TITLE_HIGH(t->title_id), TITLE_LOW(t->title_id),
t->title_id, TITLE_UPPER(t->title_id), TITLE_LOWER(t->title_id),
t->title_type, t->title_version);
if (version) *version = t->title_version;
@ -1579,7 +1577,7 @@ retry:;
for (mm = 0; mm < 2; mm++) {
for (i = 0; i < ios_info_number; i++)
{
if (ios_info[i].slot != TITLE_LOW(t->title_id)) continue;
if (ios_info[i].slot != TITLE_LOWER(t->title_id)) continue;
if (memcmp((void *)hash, &ios_info[i].hash, sizeof(sha1)) == 0)
{
retValue = atoi(ios_info[i].info);
@ -1658,7 +1656,7 @@ char* get_iosx_info_from_tmd(int ios_slot, u32 *version)
t = (tmd*)SIGNATURE_PAYLOAD(TMD);
dbg_printf("\ntmd id: %llx %x-%x t: %x v: %d",
t->title_id, TITLE_HIGH(t->title_id), TITLE_LOW(t->title_id),
t->title_id, TITLE_UPPER(t->title_id), TITLE_LOWER(t->title_id),
t->title_type, t->title_version);
if (version) *version = t->title_version;
@ -1703,7 +1701,7 @@ retry:;
for (mm = 0; mm < 2; mm++) {
for (i = 0; i < ios_info_number; i++)
{
if (ios_info[i].slot != TITLE_LOW(t->title_id)) continue;
if (ios_info[i].slot != TITLE_LOWER(t->title_id)) continue;
if (memcmp((void *)hash, &ios_info[i].hash, sizeof(sha1)) == 0)
{
info = ios_info[i].info;
@ -1851,7 +1849,7 @@ char* get_ios_tmd_hash_str(char *str)
if (ret != 0) goto out;
t = (tmd*)SIGNATURE_PAYLOAD(TMD);
dbg_printf("\ntmd id: %llx %x-%x t: %x v: %d",
t->title_id, TITLE_HIGH(t->title_id), TITLE_LOW(t->title_id),
t->title_id, TITLE_UPPER(t->title_id), TITLE_LOWER(t->title_id),
t->title_type, t->title_version);
// safety check
if (t->title_id != TITLE_ID(1, IOS_GetVersion())) goto out;

View File

@ -1,9 +1,7 @@
#ifndef _SYS_H_
#define _SYS_H_
#define TITLE_ID(x,y) (((u64)(x) << 32) | (y))
#define TITLE_HIGH(x) ((u32)((x) >> 32))
#define TITLE_LOW(x) ((u32)(x))
#include "titles.h"
/* Prototypes */
void Sys_Init(void);

34
source/titles.h Normal file
View File

@ -0,0 +1,34 @@
/*
* Titles ID functions and defaults
*/
#define TITLE_ID(x,y) (((u64)(x) << 32) | (y))
#define TITLE_UPPER(x) ((u32)((x) >> 32))
#define TITLE_LOWER(x) ((u32)(x))
#define TITLE_1(x) ((u8)((x) >> 8))
#define TITLE_2(x) ((u8)((x) >> 16))
#define TITLE_3(x) ((u8)((x) >> 24))
#define TITLE_4(x) ((u8)((x) >> 32))
#define TITLE_5(x) ((u8)((x) >> 40))
#define TITLE_6(x) ((u8)((x) >> 48))
#define TITLE_7(x) ((u8)((x) >> 56))
#define DOWNLOADED_CHANNELS 0x00010001
#define SYSTEM_CHANNELS 0x00010002
#define GAME_CHANNELS 0x00010004
//Region Free News Channel
#define RF_NEWS_CHANNEL 0x48414741
//Region Free Forecast Channel
#define RF_FORECAST_CHANNEL 0x48414641
//DVDX
#define DVDX_CHANNEL 0x44564458
//HAXX (HBC old)
#define HBC_OLD_CHANNEL 0x48415858
//JODI (HBC new)
#define HBC_NEW_CHANNEL 0x4A4F4449
//.... (HBC 1.0.7+)
#define HBC_107_CHANNEL 0xAF1BF516
//LULZ (HBC 1.1.2)
#define HBC_112_CHANNEL 0x4C554C5A

View File

@ -22,6 +22,8 @@
#include "console.h"
#include "RuntimeIOSPatch.h"
#include "rcstub.h"
// libogc < 1.8.5 can hang if wiimote is initialized multiple times
// (in case ios is reload 2x) so we delay wpad to later
// libogc = 1.8.5 can crash if started with 2+ wiimotes
@ -71,6 +73,8 @@ void print_ios()
int main(int argc, char **argv)
{
s32 ret;
signed_blob *buf = NULL;
u32 filesize;
IOSPATCH_Apply();
@ -247,6 +251,48 @@ int main(int argc, char **argv)
goto out;
}
/* identify HBC lower TID if installed */
// check HBC 1.1.2+ (LULZ) first
ret = GetTMD(TITLE_ID(DOWNLOADED_CHANNELS,HBC_112_CHANNEL), &buf, &filesize);
SAFE_FREE(buf);
if (ret == 0) {
HBC_LOWER_TID = HBC_112_CHANNEL;
} else {
// check old 1.0.7+
ret = GetTMD(TITLE_ID(DOWNLOADED_CHANNELS,HBC_107_CHANNEL), &buf, &filesize);
SAFE_FREE(buf);
if (ret == 0) {
HBC_LOWER_TID = HBC_107_CHANNEL;
} else {
// check older (JODI)
ret = GetTMD(TITLE_ID(DOWNLOADED_CHANNELS,HBC_NEW_CHANNEL), &buf, &filesize);
SAFE_FREE(buf);
if (ret == 0) {
HBC_LOWER_TID = HBC_NEW_CHANNEL;
} else {
// check oldest (HAXX)
ret = GetTMD(TITLE_ID(DOWNLOADED_CHANNELS,HBC_OLD_CHANNEL), &buf, &filesize);
SAFE_FREE(buf);
if (ret == 0) {
HBC_LOWER_TID = HBC_OLD_CHANNEL;
}
}
}
}
dbg_printf("HBC lower TID %08x\n", HBC_LOWER_TID);
if (CFG.return_to > 2)
{
// Check if the title exists
ret = GetTMD(TITLE_ID(DOWNLOADED_CHANNELS,CFG.return_to), &buf, &filesize);
SAFE_FREE(buf);
if (ret == 0) {
stub_load ();
stub_set_splitted_tid(DOWNLOADED_CHANNELS,(char*)&(CFG.return_to));
dbg_printf("stub_return_to_channel %08x\n", CFG.return_to);
}
}
/* Menu loop */
//dbg_printf("Menu_Loop\n"); //Wpad_WaitButtons();
Menu_Loop();
@ -256,7 +302,9 @@ out:
/* Restart */
exit(0);
Restart_Wait();
stub_unload ();
return 0;
}