From 5bc9cee195ff005ae53b61f766114b448facd9ab Mon Sep 17 00:00:00 2001 From: giantpune Date: Thu, 16 Sep 2010 10:22:24 +0000 Subject: [PATCH] updated lstub to work with newer HBC stub ( fixes "return to loader" ) --- HBC/META.XML | 4 ++-- source/gecko.c | 41 ++++++++++++++++++++++++++++++++++++++++- source/gecko.h | 2 ++ source/lstub.c | 34 ++++++++++++++++++++++++++++++---- 4 files changed, 74 insertions(+), 7 deletions(-) diff --git a/HBC/META.XML b/HBC/META.XML index 05227f5d..3fba8986 100644 --- a/HBC/META.XML +++ b/HBC/META.XML @@ -2,8 +2,8 @@ USB Loader GX USB Loader GX Team - 1.0 r940 - 201009151816 + 1.0 r941 + 201009160837 Loads games from USB-devices USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times. The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller. diff --git a/source/gecko.c b/source/gecko.c index 2362454a..9007fce3 100644 --- a/source/gecko.c +++ b/source/gecko.c @@ -23,7 +23,8 @@ void gprintf( const char *str, ... ) va_end(ap); - usb_sendbuffer( 1, astr, strlen(astr) ); + //usb_sendbuffer( 1, astr, strlen(astr) ); + usb_sendbuffer_safe( 1, astr, strlen(astr) ); } bool InitGecko() @@ -37,5 +38,43 @@ bool InitGecko() else return false; } +static char ascii(char s) +{ + if(s < 0x20) + return '.'; + if(s > 0x7E) + return '.'; + return s; +} + +void hexdump(void *d, int len) +{ + u8 *data; + int i, off; + data = (u8*)d; + + gprintf("\n 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF"); + gprintf("\n==== =============================================== ================\n"); + + for (off=0; off=len) + gprintf(" "); + else + gprintf("%02x ",data[off+i]); + + gprintf(" "); + for(i=0; i<16; i++) + if((i+off)>=len) + gprintf(" "); + else + gprintf("%c",ascii(data[off+i])); + gprintf("\n"); + } +} + + #endif /* NO_DEBUG */ diff --git a/source/gecko.h b/source/gecko.h index 83b55311..d416ab4c 100644 --- a/source/gecko.h +++ b/source/gecko.h @@ -11,9 +11,11 @@ extern "C" { //use this just like printf(); void gprintf(const char *str, ...); bool InitGecko(); + void hexdump(void *d, int len); #else #define gprintf(...) #define InitGecko() false + #define hexdump( x, y ) #endif /* NO_DEBUG */ diff --git a/source/lstub.c b/source/lstub.c index b00d1f8f..860d161c 100644 --- a/source/lstub.c +++ b/source/lstub.c @@ -8,6 +8,7 @@ #include "lstub.h" #include "stub_bin.h" +#include "gecko.h" #define TITLE_1(x) ((u8)((x) >> 8)) #define TITLE_2(x) ((u8)((x) >> 16)) @@ -18,6 +19,23 @@ #define TITLE_7(x) ((u8)((x) >> 56)) #define TITLE_ID(x,y) (((u64)(x) << 32) | (y)) +static char* determineStubTIDLocation() +{ + u32 *stubID = (u32*)0x80001818; + + //HBC stub 1.0.6 and lower, and stub.bin + if( stubID[ 0 ] == 0x480004c1 && stubID[ 1 ] == 0x480004f5 ) + return (char *)0x800024C6; + + //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; + + //hexdump( stubID, 0x20 ); + return NULL; + +} + s32 Set_Stub(u64 reqID) { u32 tmdsize; @@ -54,7 +72,9 @@ s32 Set_Stub(u64 reqID) if(ES_GetStoredTMDSize(tid, &tmdsize) < 0) return WII_EINSTALL; - char *stub = (char *)0x800024C6; + char *stub = determineStubTIDLocation(); + if( !stub ) + return -68; stub[0] = TITLE_7(reqID); stub[1] = TITLE_6(reqID); @@ -64,6 +84,8 @@ s32 Set_Stub(u64 reqID) stub[5] = TITLE_2(reqID); stub[12] = TITLE_1(reqID); stub[13] = ((u8)(reqID)); + + DCFlushRange( stub, 0x10 ); return 1; @@ -84,6 +106,7 @@ void loadStub() { char *stubLoc = (char *)0x80001800; memcpy(stubLoc, stub_bin, stub_bin_size); + DCFlushRange( stubLoc, stub_bin_size ); } u64 getStubDest() @@ -91,10 +114,13 @@ u64 getStubDest() if (!hbcStubAvailable()) return 0; + char ret[ 8 ]; + u64 retu = 0; + + char *stub = determineStubTIDLocation(); + if( !stub ) + return 0; - char *stub = (char *)0x800024C6; - char ret[9]; - u64 retu =0; ret[0] = stub[0]; ret[1] = stub[1];