├── source ├── ios.h ├── fsop │ ├── fsop.c │ └── fsop.h ├── grlib │ ├── grlib_menu.c │ ├── grlib_ui.c │ ├── grlib_theme.c │ └── grlib_icon.c ├── stub.h ├── wad.h ├── bits.h ├── language.h ├── debug.h ├── dns.h ├── sha1.h ├── mem2.h ├── isfs.h ├── title.h ├── mp3player.h ├── libwupc-helper │ └── libwupc-helper.h ├── gui.h ├── devices.h ├── http.h ├── mystring.h ├── usbstorage.h ├── stub.c ├── plneek.h ├── identify.h ├── bits.c ├── channels.h ├── wiiload │ └── wiiload.h ├── sicksaxis-wrapper │ ├── sicksaxis-wrapper.h │ └── sicksaxis-wrapper.c ├── zip │ ├── infdef.h │ ├── ioapi.h │ ├── ioapi.c │ └── crypt.h ├── language.c ├── browser.h ├── neek.h ├── cfg.h ├── uneek_fs.h ├── priiloader.c ├── themes.c ├── ios.c ├── mem2.c ├── plneek.c ├── runloader.c ├── io.c ├── dns.c ├── sound.c ├── ioConfig.c ├── screensaver.c └── autoupdate.c ├── addon ├── nandbooter │ ├── data │ │ └── put your cert.sys here.txt │ └── source │ │ ├── main.h │ │ ├── codes │ │ ├── codes.h │ │ ├── multidol.h │ │ ├── patchcode.h │ │ ├── multidol.c │ │ └── patchcode.c │ │ ├── stub.s │ │ ├── isfs.h │ │ ├── usbstorage.h │ │ ├── nand.h │ │ ├── lz77.h │ │ ├── patch.h │ │ ├── tools.h │ │ ├── isfs.c │ │ └── nand.c ├── forwarder │ ├── source │ │ ├── ios.h │ │ ├── hbcstub.h │ │ ├── debug.h │ │ ├── hbcstub.c │ │ ├── ios.c │ │ ├── debug.c │ │ └── main.c │ └── data │ │ └── booter.dol ├── priibooter_gui │ ├── source │ │ ├── ios.h │ │ ├── cfg.h │ │ ├── common.h │ │ ├── debug.h │ │ ├── usbstorage.h │ │ ├── devices.h │ │ ├── cfg.c │ │ ├── fsop.h │ │ ├── bootfile.c │ │ ├── neek2o.c │ │ ├── ios.c │ │ ├── grlib │ │ │ ├── grlib_theme.c │ │ │ ├── grlib_ui.c │ │ │ └── grlib_icon.c │ │ └── debug.c │ └── data │ │ ├── fnorm.bmf │ │ ├── hdd.png │ │ ├── armboot.bin │ │ ├── booter.dol │ │ ├── fsmall.bmf │ │ ├── background.png │ │ └── wiicursor.png ├── di │ ├── source │ │ ├── disc.c │ │ ├── videopatch.h │ │ ├── debug.h │ │ ├── apploader.h │ │ ├── wdvd.h │ │ ├── patchcode.h │ │ ├── disc.h │ │ ├── utils.c │ │ ├── main.c │ │ └── debug.c │ └── data │ │ └── booter.dol ├── neekbooter │ ├── data │ │ ├── di.dol │ │ ├── booter.dol │ │ └── nandbooter.dol │ └── source │ │ ├── neek.h │ │ ├── bootfile.c │ │ └── utils.c └── priibooter │ ├── data │ └── booter.dol │ └── source │ ├── common.h │ ├── bootfile.c │ ├── io.c │ ├── ios.c │ └── utils.c ├── data ├── di.dol ├── dvd.png ├── hdd.png ├── run.png ├── booter.dol ├── cat_hb.png ├── certs.dat ├── chip.png ├── folder.png ├── font.ttf ├── gecko.png ├── ghost.png ├── ico_se.png ├── ico_wm.png ├── icon.png ├── minisd.png ├── noicon.png ├── star.png ├── stub.bin ├── wifi.png ├── wifigk.png ├── anim_rot.png ├── armboot.bin ├── bk_lines.png ├── cat_emul.png ├── cat_wii.png ├── checked.png ├── folderup.png ├── ico_dvd.png ├── ico_exit.png ├── ico_neek.png ├── miniusb.png ├── background.png ├── cat_wiiware.png ├── exclamation.png ├── hourglass.png ├── ico_about.png ├── ico_config.png ├── nandbooter.dol ├── wiicursor.png ├── cat_gamecube.png ├── fake_su_ticket.dat ├── fake_su_tmd.dat └── english.txt ├── compiling.txt └── meta.xml /source/ios.h: -------------------------------------------------------------------------------- 1 | int ios_ReloadIOS(int ios, int *ahbprot); -------------------------------------------------------------------------------- /addon/nandbooter/data/put your cert.sys here.txt: -------------------------------------------------------------------------------- 1 | dummy 2 | -------------------------------------------------------------------------------- /addon/forwarder/source/ios.h: -------------------------------------------------------------------------------- 1 | int ios_ReloadIOS(int ios, int *ahbprot); -------------------------------------------------------------------------------- /addon/priibooter_gui/source/ios.h: -------------------------------------------------------------------------------- 1 | int ios_ReloadIOS(int ios, int *ahbprot); -------------------------------------------------------------------------------- /data/di.dol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/di.dol -------------------------------------------------------------------------------- /data/dvd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/dvd.png -------------------------------------------------------------------------------- /data/hdd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/hdd.png -------------------------------------------------------------------------------- /data/run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/run.png -------------------------------------------------------------------------------- /addon/nandbooter/source/main.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | u32 entryPoint; 4 | -------------------------------------------------------------------------------- /data/booter.dol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/booter.dol -------------------------------------------------------------------------------- /data/cat_hb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/cat_hb.png -------------------------------------------------------------------------------- /data/certs.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/certs.dat -------------------------------------------------------------------------------- /data/chip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/chip.png -------------------------------------------------------------------------------- /data/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/folder.png -------------------------------------------------------------------------------- /data/font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/font.ttf -------------------------------------------------------------------------------- /data/gecko.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/gecko.png -------------------------------------------------------------------------------- /data/ghost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/ghost.png -------------------------------------------------------------------------------- /data/ico_se.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/ico_se.png -------------------------------------------------------------------------------- /data/ico_wm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/ico_wm.png -------------------------------------------------------------------------------- /data/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/icon.png -------------------------------------------------------------------------------- /data/minisd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/minisd.png -------------------------------------------------------------------------------- /data/noicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/noicon.png -------------------------------------------------------------------------------- /data/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/star.png -------------------------------------------------------------------------------- /data/stub.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/stub.bin -------------------------------------------------------------------------------- /data/wifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/wifi.png -------------------------------------------------------------------------------- /data/wifigk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/wifigk.png -------------------------------------------------------------------------------- /data/anim_rot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/anim_rot.png -------------------------------------------------------------------------------- /data/armboot.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/armboot.bin -------------------------------------------------------------------------------- /data/bk_lines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/bk_lines.png -------------------------------------------------------------------------------- /data/cat_emul.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/cat_emul.png -------------------------------------------------------------------------------- /data/cat_wii.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/cat_wii.png -------------------------------------------------------------------------------- /data/checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/checked.png -------------------------------------------------------------------------------- /data/folderup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/folderup.png -------------------------------------------------------------------------------- /data/ico_dvd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/ico_dvd.png -------------------------------------------------------------------------------- /data/ico_exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/ico_exit.png -------------------------------------------------------------------------------- /data/ico_neek.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/ico_neek.png -------------------------------------------------------------------------------- /data/miniusb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/miniusb.png -------------------------------------------------------------------------------- /data/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/background.png -------------------------------------------------------------------------------- /data/cat_wiiware.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/cat_wiiware.png -------------------------------------------------------------------------------- /data/exclamation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/exclamation.png -------------------------------------------------------------------------------- /data/hourglass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/hourglass.png -------------------------------------------------------------------------------- /data/ico_about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/ico_about.png -------------------------------------------------------------------------------- /data/ico_config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/ico_config.png -------------------------------------------------------------------------------- /data/nandbooter.dol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/nandbooter.dol -------------------------------------------------------------------------------- /data/wiicursor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/wiicursor.png -------------------------------------------------------------------------------- /source/fsop/fsop.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/source/fsop/fsop.c -------------------------------------------------------------------------------- /addon/di/source/disc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/addon/di/source/disc.c -------------------------------------------------------------------------------- /data/cat_gamecube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/cat_gamecube.png -------------------------------------------------------------------------------- /addon/di/data/booter.dol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/addon/di/data/booter.dol -------------------------------------------------------------------------------- /data/fake_su_ticket.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/data/fake_su_ticket.dat -------------------------------------------------------------------------------- /source/grlib/grlib_menu.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/source/grlib/grlib_menu.c -------------------------------------------------------------------------------- /source/grlib/grlib_ui.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/source/grlib/grlib_ui.c -------------------------------------------------------------------------------- /addon/neekbooter/data/di.dol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/addon/neekbooter/data/di.dol -------------------------------------------------------------------------------- /addon/forwarder/data/booter.dol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/addon/forwarder/data/booter.dol -------------------------------------------------------------------------------- /addon/neekbooter/data/booter.dol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/addon/neekbooter/data/booter.dol -------------------------------------------------------------------------------- /addon/priibooter/data/booter.dol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/addon/priibooter/data/booter.dol -------------------------------------------------------------------------------- /addon/forwarder/source/hbcstub.h: -------------------------------------------------------------------------------- 1 | s32 Set_Stub(u64 reqID); 2 | 3 | void StubLoad ( void ); 4 | void StubUnload ( void ); -------------------------------------------------------------------------------- /addon/priibooter_gui/data/fnorm.bmf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/addon/priibooter_gui/data/fnorm.bmf -------------------------------------------------------------------------------- /addon/priibooter_gui/data/hdd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/addon/priibooter_gui/data/hdd.png -------------------------------------------------------------------------------- /addon/neekbooter/data/nandbooter.dol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/addon/neekbooter/data/nandbooter.dol -------------------------------------------------------------------------------- /addon/priibooter_gui/data/armboot.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/addon/priibooter_gui/data/armboot.bin -------------------------------------------------------------------------------- /addon/priibooter_gui/data/booter.dol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/addon/priibooter_gui/data/booter.dol -------------------------------------------------------------------------------- /addon/priibooter_gui/data/fsmall.bmf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/addon/priibooter_gui/data/fsmall.bmf -------------------------------------------------------------------------------- /addon/priibooter_gui/data/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/addon/priibooter_gui/data/background.png -------------------------------------------------------------------------------- /addon/priibooter_gui/data/wiicursor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedax/postloader/HEAD/addon/priibooter_gui/data/wiicursor.png -------------------------------------------------------------------------------- /source/stub.h: -------------------------------------------------------------------------------- 1 | #ifndef _STUB_ 2 | #define _STUB_ 3 | 4 | void StubLoad ( void ); 5 | void StubUnload ( void ); 6 | 7 | #endif -------------------------------------------------------------------------------- /addon/nandbooter/source/codes/codes.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define gecko_channel 1 4 | 5 | void do_codes(u64 titleid); 6 | 7 | void preload_codes (u64 titleid); -------------------------------------------------------------------------------- /source/wad.h: -------------------------------------------------------------------------------- 1 | #ifndef _WAD_H_ 2 | #define _WAD_H_ 3 | 4 | /* Prototypes */ 5 | s32 Wad_Install(char *filename, bool compact); 6 | s32 Wad_Uninstall(char *filename); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /addon/priibooter_gui/source/cfg.h: -------------------------------------------------------------------------------- 1 | char *cfg_FindTag (char *buff, char *tag); 2 | int cfg_GetString (char *buff, char *tag, char *string); 3 | int cfg_GetInt (char *buff, char *tag, int *ival); -------------------------------------------------------------------------------- /source/bits.h: -------------------------------------------------------------------------------- 1 | #define SBIA bits_SetInArray 2 | #define GBFA bits_GetFromArray 3 | 4 | void bits_SetInArray (size_t bit, bool value, u8 *buff); 5 | bool bits_GetFromArray (size_t bit, u8 *buff); -------------------------------------------------------------------------------- /source/language.h: -------------------------------------------------------------------------------- 1 | #ifndef _LANGUAGE_ 2 | #define _LANGUAGE_ 3 | 4 | #define GLS GetLanguageString 5 | void SetLangFileBuffer (const char *buff, int size); 6 | char *GetLanguageString (char *tag); 7 | 8 | #endif -------------------------------------------------------------------------------- /addon/di/source/videopatch.h: -------------------------------------------------------------------------------- 1 | #ifndef _VIDEOPATCH_H_ 2 | #define _VIDEOPATCH_H_ 3 | 4 | #include 5 | 6 | void patchVideoModes(void *dst, u32 len, int vidMode, GXRModeObj *vmode, int patchVidModes); 7 | 8 | 9 | #endif // !defined(_VIDEOPATCH_H_) 10 | -------------------------------------------------------------------------------- /addon/di/source/debug.h: -------------------------------------------------------------------------------- 1 | #ifndef _STFDEBUG_ 2 | #define _STFDEBUG_ 3 | 4 | s32 DebugStart (bool gecko, char *fn); 5 | void DebugStop (void); 6 | void Debug (const char *text, ...); 7 | void Debug_hexdump(void *d, int len); 8 | void gprintf (const char *format, ...); 9 | #endif -------------------------------------------------------------------------------- /addon/forwarder/source/debug.h: -------------------------------------------------------------------------------- 1 | #ifndef _STFDEBUG_ 2 | #define _STFDEBUG_ 3 | 4 | s32 DebugStart (bool gecko, char *fn); 5 | void DebugStop (void); 6 | void Debug (const char *text, ...); 7 | void Debug_hexdump(void *d, int len); 8 | void gprintf (const char *format, ...); 9 | #endif -------------------------------------------------------------------------------- /addon/di/source/apploader.h: -------------------------------------------------------------------------------- 1 | #ifndef _APPLOADER_H_ 2 | #define _APPLOADER_H_ 3 | 4 | /* Entry point */ 5 | typedef void (*entry_point)(void); 6 | 7 | /* Prototypes */ 8 | s32 Apploader_Run(entry_point *entry, u8 vidMode, GXRModeObj *vmode, bool vipatch, bool countryString, u8 patchVidModes); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /source/debug.h: -------------------------------------------------------------------------------- 1 | #ifndef _STFDEBUG_ 2 | #define _STFDEBUG_ 3 | 4 | s32 DebugStart (bool gecko, char *fn); 5 | void DebugStop (void); 6 | void Debug (const char *text, ...); 7 | void Debug_hexdump(void *d, int len); 8 | void Debug_hexdumplog (void *d, int len); 9 | void gprintf (const char *format, ...); 10 | #endif -------------------------------------------------------------------------------- /addon/priibooter_gui/source/common.h: -------------------------------------------------------------------------------- 1 | // common.h 2 | 3 | #include "../../../source/plneek.h" 4 | 5 | // utils.c 6 | void printd(const char *text, ...); 7 | u8 *ReadFile2Buffer (char *path, size_t *filesize, int *err); 8 | bool FileExist (char *fn); 9 | bool DirExist (char *path); 10 | int CountObjectsInFolder(char *path); 11 | -------------------------------------------------------------------------------- /addon/priibooter_gui/source/debug.h: -------------------------------------------------------------------------------- 1 | #ifndef _STFDEBUG_ 2 | #define _STFDEBUG_ 3 | 4 | s32 DebugStart (bool gecko, char *fn); 5 | void DebugStop (void); 6 | void Debug (const char *text, ...); 7 | void Debug_hexdump(void *d, int len); 8 | void gprintf (const char *format, ...); 9 | void gprintf_StoreBuff(char *fn); 10 | #endif -------------------------------------------------------------------------------- /addon/nandbooter/source/stub.s: -------------------------------------------------------------------------------- 1 | #define STUB 0x3400 2 | 3 | .text 4 | .section .text 5 | .globl _unstub_start 6 | 7 | _unstub_start: 8 | isync 9 | // set MSR[DR:IR] = 00, jump to STUB 10 | lis 3,STUB@h 11 | ori 3,3,STUB@l 12 | mtsrr0 3 13 | 14 | mfmsr 3 15 | li 4,0x30 16 | andc 3,3,4 17 | mtsrr1 3 18 | rfi 19 | -------------------------------------------------------------------------------- /source/dns.h: -------------------------------------------------------------------------------- 1 | #ifndef _DNS_H_ 2 | #define _DNS_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include //usleep 8 | 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" 13 | { 14 | #endif 15 | 16 | u32 getipbyname(char *domain); 17 | u32 getipbynamecached(char *domain); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif /* _DNS_H_ */ 24 | -------------------------------------------------------------------------------- /addon/nandbooter/source/isfs.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | typedef struct _dirent 5 | { 6 | char name[ISFS_MAXPATH + 1]; 7 | int type; 8 | } dirent_t; 9 | 10 | 11 | 12 | s32 read_full_file_from_nand(char *filepath, u8 **buffer, u32 *filesize); 13 | s32 read_file_from_nand(char *filepath, u8 *buffer, u32 filesize); 14 | s32 getdircount(char *path, u32 *cnt); 15 | s32 getdir(char *path, dirent_t **ent, u32 *cnt); 16 | -------------------------------------------------------------------------------- /source/sha1.h: -------------------------------------------------------------------------------- 1 | typedef struct { 2 | unsigned long state[5]; 3 | unsigned long count[2]; 4 | unsigned char buffer[64]; 5 | } SHA1_CTX; 6 | 7 | void SHA1Transform(unsigned long state[5], unsigned char buffer[64]); 8 | void SHA1Init(SHA1_CTX* context); 9 | void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len); 10 | void SHA1Final(unsigned char digest[20], SHA1_CTX* context); 11 | 12 | void SHA1(unsigned char *ptr, unsigned int size, unsigned char *outbuf); 13 | -------------------------------------------------------------------------------- /data/fake_su_tmd.dat: -------------------------------------------------------------------------------- 1 | Root-CA00000001-CP00000004 -------------------------------------------------------------------------------- /source/mem2.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Visual Boy Advance GX 3 | * 4 | * Tantric 2010 5 | * 6 | * mem2.h 7 | * 8 | * MEM2 memory allocator 9 | ***************************************************************************/ 10 | 11 | #ifdef HW_RVL 12 | 13 | #ifndef _MEM2MANAGER_H_ 14 | #define _MEM2MANAGER_H_ 15 | 16 | u32 InitMem2Manager (); 17 | void* mem2_malloc(u32 size); 18 | bool mem2_free(void *ptr); 19 | u32 mem2_getblocksize (void *ptr); 20 | 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /addon/nandbooter/source/usbstorage.h: -------------------------------------------------------------------------------- 1 | #ifndef _USBSTORAGE_H_ 2 | #define _USBSTORAGE_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | /* Prototypes */ 8 | s32 USBStorage_GetCapacity(u32 *); 9 | s32 USBStorage_Init(void); 10 | void USBStorage_Deinit(void); 11 | s32 USBStorage_Watchdog(u32 on_off); 12 | s32 USBStorage_ReadSectors(u32, u32, void *); 13 | s32 USBStorage_WriteSectors(u32, u32, const void *); 14 | extern const DISC_INTERFACE __io_wiiums; 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /source/isfs.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | typedef struct _dirent 5 | { 6 | char name[ISFS_MAXPATH + 1]; 7 | int type; 8 | } dirent_t; 9 | 10 | 11 | 12 | s32 read_full_file_from_nand(char *filepath, u8 **buffer, u32 *filesize); 13 | s32 read_file_from_nand(char *filepath, u8 *buffer, u32 filesize); 14 | s32 getdircount(char *path, u32 *cnt); 15 | s32 getdir(char *path, dirent_t **ent, u32 *cnt); 16 | 17 | u8 *isfs_ReadFile (char *filepath, s32 *error, size_t bytes2read, size_t *bytesReaded); 18 | bool isfs_WriteFile (char *nandpath, u8 * buff, s32 size); -------------------------------------------------------------------------------- /addon/priibooter_gui/source/usbstorage.h: -------------------------------------------------------------------------------- 1 | #ifndef _UMSSTORAGE_H_ 2 | #define _UMSSTORAGE_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | /* Prototypes */ 8 | s32 UMSStorage_GetCapacity(u32 *); 9 | s32 UMSStorage_Init(void); 10 | void UMSStorage_Deinit(void); 11 | s32 UMSStorage_Watchdog(u32 on_off); 12 | s32 UMSStorage_ReadSectors(u32, u32, void *); 13 | s32 UMSStorage_WriteSectors(u32, u32, const void *); 14 | extern const DISC_INTERFACE __io_wiiums; 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /source/title.h: -------------------------------------------------------------------------------- 1 | #ifndef _TITLE_H_ 2 | #define _TITLE_H_ 3 | 4 | /* Constants */ 5 | #define BLOCK_SIZE 1024 6 | 7 | /* Prototypes */ 8 | s32 Title_ZeroSignature(signed_blob *); 9 | s32 Title_FakesignTik(signed_blob *); 10 | s32 Title_FakesignTMD(signed_blob *); 11 | s32 Title_GetList(u64 **, u32 *); 12 | s32 Title_GetTicketViews(u64, tikview **, u32 *); 13 | s32 Title_GetTMD(u64, signed_blob **, u32 *); 14 | s32 Title_GetVersion(u64, u16 *); 15 | s32 Title_GetSysVersion(u64, u64 *); 16 | s32 Title_GetSize(u64, u32 *); 17 | s32 Title_GetIOSVersions(u8 **, u32 *); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /addon/priibooter_gui/source/devices.h: -------------------------------------------------------------------------------- 1 | #define DEV_SD 0 2 | #define DEV_USB 1 3 | #define DEV_USB1 2 4 | #define DEV_USB2 3 5 | #define DEV_USB3 4 6 | #define DEV_MAX 5 7 | 8 | #define DEVMODE_IOS 0 9 | #define DEVMODE_CIOSX 1 10 | 11 | // This is the devices callback. Return 0 to interrupt the process 12 | typedef int (*devicesCallback)(void); 13 | 14 | void devices_Mount (int devmode, int usbTimeout, devicesCallback cb); 15 | void devices_Unmount (void); 16 | char *devices_Get (int dev); 17 | int devices_PartitionInfo (int dev); 18 | void devices_UsbPreinit (int init); -------------------------------------------------------------------------------- /addon/priibooter/source/common.h: -------------------------------------------------------------------------------- 1 | // common.h 2 | 3 | #include "../../../source/plneek.h" 4 | 5 | #define DEVMAX 2 6 | 7 | #define DEV_SD 0 8 | #define DEV_USB 1 9 | 10 | // Global functions 11 | 12 | // io.c 13 | s32 Fat_Mount(int dev, int *keypressed); 14 | void Fat_Unmount(void); 15 | 16 | // utils.c 17 | void InitVideo (void); 18 | void printd(const char *text, ...); 19 | u8 *ReadFile2Buffer (char *path, size_t *filesize, int *err); 20 | bool FileExist (char *fn); 21 | bool DirExist (char *path); 22 | int CountObjectsInFolder(char *path); 23 | 24 | // Global vars 25 | extern char mount[DEVMAX][16]; 26 | -------------------------------------------------------------------------------- /addon/nandbooter/source/codes/multidol.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file was autogenerated by raw2c. 3 | Visit http://www.devkitpro.org 4 | */ 5 | 6 | //--------------------------------------------------------------------------------- 7 | #ifndef _multidol_h_ 8 | #define _multidol_h_ 9 | //--------------------------------------------------------------------------------- 10 | extern const unsigned char multidol[]; 11 | extern const int multidol_size; 12 | //--------------------------------------------------------------------------------- 13 | #endif //_multidol_h_ 14 | //--------------------------------------------------------------------------------- 15 | -------------------------------------------------------------------------------- /addon/nandbooter/source/nand.h: -------------------------------------------------------------------------------- 1 | #ifndef _NAND_H_ 2 | #define _NAND_H_ 3 | 4 | /* 'NAND Device' structure */ 5 | typedef struct { 6 | /* Device name */ 7 | char *name; 8 | 9 | /* Mode value */ 10 | u32 mode; 11 | 12 | /* Un/mount command */ 13 | u32 mountCmd; 14 | u32 umountCmd; 15 | } nandDevice; 16 | 17 | 18 | #define EMU_SD 1 19 | #define EMU_USB 2 20 | 21 | /* Prototypes */ 22 | s32 Nand_Mount(nandDevice *); 23 | s32 Nand_Unmount(nandDevice *); 24 | s32 Nand_Enable(nandDevice *dev, char *path); 25 | s32 Nand_Disable(void); 26 | s32 Enable_Emu(int selection, char *path); 27 | s32 Disable_Emu(); 28 | s32 get_nand_device(); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /source/mp3player.h: -------------------------------------------------------------------------------- 1 | #ifndef __MP3PLAYER_H__ 2 | #define __MP3PLAYER_H__ 3 | 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif /* __cplusplus */ 10 | 11 | void MP3Player_Init(); 12 | void MP3Player_Stop(); 13 | BOOL MP3Player_IsPlaying(); 14 | void MP3Player_Volume(u32 volume); 15 | s32 MP3Player_PlayBuffer(const void *buffer,s32 len,void (*filterfunc)(struct mad_stream *,struct mad_frame *)); 16 | s32 MP3Player_PlayFile(void *cb_data,s32 (*reader)(void *,void *,s32),void (*filterfunc)(struct mad_stream *,struct mad_frame *)); 17 | s32 MP3Player_PlayFileDirect(char *filename); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif /* __cplusplus */ 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /source/libwupc-helper/libwupc-helper.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBWUPC_HELPER_H 2 | #define LIBWUPC_HELPER_H 3 | 4 | enum ProControllerButtons 5 | { 6 | PRO_CTRL_BUTTON_START = 0x04000000, 7 | PRO_CTRL_BUTTON_SELECT = 0x10000000, 8 | PRO_CTRL_BUTTON_HOME = 0x08000000, 9 | PRO_CTRL_BUTTON_A = 0x00100000, 10 | PRO_CTRL_BUTTON_B = 0x00400000, 11 | PRO_CTRL_BUTTON_Y = 0x00200000, 12 | PRO_CTRL_BUTTON_X = 0x00080000, 13 | PRO_CTRL_BUTTON_L = 0x20000000, 14 | PRO_CTRL_BUTTON_R = 0x02000000, 15 | PRO_CTRL_BUTTON_ZL = 0x00800000, 16 | PRO_CTRL_BUTTON_ZR = 0x00040000, 17 | PRO_CTRL_BUTTON_UP = 0x00010000, 18 | PRO_CTRL_BUTTON_DOWN = 0x40000000, 19 | PRO_CTRL_BUTTON_LEFT = 0x00020000, 20 | PRO_CTRL_BUTTON_RIGHT = 0x80000000, 21 | }; 22 | 23 | #endif -------------------------------------------------------------------------------- /source/gui.h: -------------------------------------------------------------------------------- 1 | #define SPOTSMAX 20 2 | 3 | typedef struct 4 | { 5 | int id; // Look up to application 6 | s_grlib_icon ico; 7 | } 8 | s_spot; 9 | 10 | typedef struct 11 | { 12 | s_spot spots[SPOTSMAX]; 13 | 14 | int spotsIdx; 15 | int spotsXpage; 16 | int spotsXline; 17 | } 18 | s_gui; 19 | 20 | extern s_gui gui; 21 | 22 | void gui_Init (void); 23 | void gui_Clean (void); 24 | 25 | int ChooseDPadReturnMode (u32 btn); 26 | int Menu_SelectBrowsingMode (void); 27 | int GoToPage (int page, int pageMax); 28 | 29 | int DrawTopBar (int *visibleflag, int *browserRet, u32 *btn, int *closed); 30 | int DrawBottomBar (int *visibleflag, u32 *btn, int *closed); 31 | 32 | void DrawInfoWindow (f32 y, char *s1, char *s2, char *s3); -------------------------------------------------------------------------------- /source/devices.h: -------------------------------------------------------------------------------- 1 | #define DEV_SD 0 2 | #define DEV_USB 1 3 | #define DEV_USB1 2 4 | #define DEV_USB2 3 5 | #define DEV_USB3 4 6 | #define DEV_MAX 5 7 | 8 | #define DEVMODE_IOS 0 9 | #define DEVMODE_CIOSX 1 10 | 11 | #define DEV_MN_SD "sd" 12 | #define DEV_MN_USB "usb" 13 | #define DEV_MN_USB1 "ex1" 14 | #define DEV_MN_USB2 "ex2" 15 | #define DEV_MN_USB3 "ex3" 16 | 17 | // This is the devices callback. Return 0 to interrupt the process 18 | typedef int (*devicesCallback)(void); 19 | 20 | void devices_Mount (int devmode, int neek, int usbTimeout, devicesCallback cb); 21 | void devices_Unmount (void); 22 | char *devices_Get (int dev); 23 | int devices_PartitionInfo (int dev); 24 | int devices_TickUSB (void); 25 | bool devices_WakeUSBWrite (void); -------------------------------------------------------------------------------- /source/http.h: -------------------------------------------------------------------------------- 1 | #ifndef _HTTP_H_ 2 | #define _HTTP_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #ifdef __cplusplus 10 | extern "C" 11 | { 12 | #endif 13 | 14 | #include "dns.h" 15 | 16 | extern const struct block emptyblock; 17 | 18 | typedef void (*http_Callback)(void); 19 | 20 | typedef struct 21 | { 22 | size_t headersize; 23 | size_t bytes; 24 | size_t size; 25 | 26 | http_Callback cb; 27 | } 28 | s_http; 29 | 30 | s_http http; 31 | 32 | u8 *downloadfile (const char *url, u32 *size, http_Callback cb); 33 | s32 GetConnection(char * domain); 34 | int network_request(int connection, const char * request, char * filename); 35 | int network_read(int connection, u8 *buf, u32 len); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* _HTTP_H_ */ 42 | -------------------------------------------------------------------------------- /addon/nandbooter/source/lz77.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * lz77.h 3 | * 4 | * Copyright (c) 2009 The Lemon Man 5 | * Copyright (c) 2009 Nicksasa 6 | * Copyright (c) 2009 WiiPower 7 | * 8 | * Distributed under the terms of the GNU General Public License (v2) 9 | * See http://www.gnu.org/licenses/gpl-2.0.txt for more info. 10 | * 11 | * Description: 12 | * ----------- 13 | * 14 | ******************************************************************************/ 15 | 16 | #ifndef _LZ77_MODULE 17 | #define _LZ77_MODULE 18 | 19 | #define LZ77_0x10_FLAG 0x10 20 | #define LZ77_0x11_FLAG 0x11 21 | 22 | int isLZ77compressed(u8 *buffer); 23 | int decompressLZ77content(u8 *buffer, u32 lenght, u8 **output, u32 *outputLen, u32 max_size); 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /source/mystring.h: -------------------------------------------------------------------------------- 1 | #ifndef _MYSTRING_ 2 | #define _MYSTRING_ 3 | char *ms_AllocCopy (char *source, int addbytes); // basically remove/add \n\r, source buffer must contain enought space 4 | void ms_strtoupper(char *str); 5 | void ms_strtolower(char *str); 6 | char *ms_strstr(char *str1, char *str2); 7 | int ms_isequal(char *str1, char *str2); 8 | int ms_strcmp(const char *s1, const char *s2); 9 | char *ms_utf8_to_ascii (char *string); 10 | u8 *ms_FindStringInBuffer (u8 *buffer, size_t size, char *string); 11 | 12 | // This function will return a section of delimited text, ex. "section0;section1;....;sectionn" 13 | char *ms_GetDelimitedString (char *string, char sep, int idx); 14 | 15 | // search "tofind" and replace with "replace" in "string" (slow) 16 | void ms_Subst (char *string, char *tofind, char *replace); 17 | #endif -------------------------------------------------------------------------------- /source/usbstorage.h: -------------------------------------------------------------------------------- 1 | #ifndef _USBSTORAGE2_H_ 2 | #define _USBSTORAGE2_H_ 3 | 4 | #include "ogc/disc_io.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" 8 | { 9 | #endif 10 | 11 | /* Prototypes */ 12 | s32 USBStorage2_Init(u32 port); 13 | void USBStorage2_Deinit(); 14 | s32 USBStorage2_GetCapacity(u32 port, u32 *size); 15 | 16 | s32 USBStorage2_ReadSectors(u32 port, u32 sector, u32 numSectors, void *buffer); 17 | s32 USBStorage2_WriteSectors(u32 port, u32 sector, u32 numSectors, const void *buffer); 18 | s32 USBStorage2_GetSectorSize(); 19 | 20 | s32 USBStorage2_SetPort(u32 port); 21 | s32 USBStorage2_GetPort(); 22 | 23 | #define DEVICE_TYPE_WII_UMS (('W'<<24)|('U'<<16)|('M'<<8)|'S') 24 | 25 | extern const DISC_INTERFACE __io_usbstorage2_port0; 26 | extern const DISC_INTERFACE __io_usbstorage2_port1; 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /source/stub.c: -------------------------------------------------------------------------------- 1 | //Load the open source stub 2 | 3 | #include 4 | #include 5 | #include 6 | #include "stub.h" 7 | #include "debug.h" 8 | #include "globals.h" 9 | 10 | extern const u8 stub_bin[]; 11 | extern const u32 stub_bin_size; 12 | 13 | void StubLoad ( void ) 14 | { 15 | // Clear potential homebrew channel stub 16 | memset((void*)0x80001800, 0, 0x1800); 17 | 18 | // Copy our own stub into memory 19 | memcpy((void*)0x80001800, stub_bin, stub_bin_size); 20 | 21 | DCFlushRange((void*)0x80001800, 0x1800); 22 | 23 | return; 24 | } 25 | 26 | void StubUnload ( void ) 27 | { 28 | Debug ("StubUnload()"); 29 | 30 | // Simple clear the STUBHAXX... some homebrew will try to call it 31 | 32 | *(u32*)0x80001804 = (u32) 0L; 33 | *(u32*)0x80001808 = (u32) 0L; 34 | DCFlushRange((void*)0x80001804,8); 35 | 36 | return; 37 | } 38 | -------------------------------------------------------------------------------- /source/plneek.h: -------------------------------------------------------------------------------- 1 | #ifndef __PLNEEK__ 2 | #define __PLNEEK__ 3 | 4 | #define NAND_MAX 16 5 | 6 | #define PLNEEK_SDDIR "sd://ploader/plneek.dir" 7 | #define PLNEEK_USBDIR "usb://ploader/plneek.dir" 8 | 9 | #define PLNEEK_SDDAT "sd://ploader/plneek.dat" 10 | #define PLNEEK_USBDAT "usb://ploader/plneek.dat" 11 | 12 | #define PLN_BOOT_PL 0 13 | #define PLN_BOOT_NEEK 1 14 | #define PLN_BOOT_SM 2 15 | #define PLN_BOOT_HBC 3 16 | #define PLN_BOOT_NEEK2O 4 17 | #define PLN_BOOT_PLCHANNEL 5 18 | 19 | #define PLN_NAME_LEN 64 20 | 21 | // types 22 | typedef struct 23 | { 24 | char path[64]; // full path to nand 25 | int count; // num of objects inside 26 | } 27 | s_plnNandFolders; 28 | 29 | typedef struct 30 | { 31 | char name[PLN_NAME_LEN]; // this is the name 32 | unsigned char bootMode; 33 | 34 | s_plnNandFolders nands[NAND_MAX]; 35 | int nandsCnt; 36 | } 37 | s_plneek; 38 | 39 | #endif -------------------------------------------------------------------------------- /source/identify.h: -------------------------------------------------------------------------------- 1 | #ifndef _PATCHER_H_ 2 | #define _PATCHER_H_ 3 | 4 | #define PATCH_DI_READLIMIT 0 5 | #define PATCH_ISFS_PERMISSIONS 1 6 | #define PATCH_ES_SETUID 2 7 | #define PATCH_ES_IDENTIFY 3 8 | #define PATCH_HASH_CHECK 4 9 | #define PATCH_NEW_HASH_CHECK 5 10 | 11 | int Patcher_BruteTMD(tmd *ptmd); 12 | void Patcher_ForgeTMD(signed_blob *signedTmd); 13 | 14 | int Patcher_BruteTicket(tik *ticket); 15 | void Patcher_ForgeTicket(signed_blob *signedTicket); 16 | 17 | int Patcher_PatchFakeSign(u8 *buf, u32 size); 18 | int Patcher_PatchEsIdentity(u8 *buf, u32 size); 19 | int Patcher_PatchNandPermissions(u8 *buf, u32 size); 20 | void Patcher_ZeroSignature(signed_blob *sig); 21 | 22 | u32 IOSPATCH_Apply(void); 23 | int IOSTATCH_Get(int id); 24 | 25 | s32 Identify(const u8 *certs, u32 certs_size, const u8 *idtmd, u32 idtmd_size, const u8 *idticket, u32 idticket_size); 26 | s32 Identify_SU(int force); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /source/bits.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "debug.h" 3 | #include "bits.h" 4 | 5 | #define bitRead(value, bit) (((value) >> (bit)) & 0x01) 6 | #define bitSet(value, bit) ((value) |= (1UL << (bit))) 7 | #define bitClear(value, bit) ((value) &= ~(1UL << (bit))) 8 | #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) 9 | 10 | void bits_SetInArray (size_t bit, bool value, u8 *buff) 11 | { 12 | size_t index = bit >> 3; // bit/8 13 | size_t bindex = bit - (index << 3); // index*8 14 | 15 | bitWrite (buff[index], bindex, value); 16 | /* 17 | bool b = bitRead (buff[index], bindex); 18 | Debug ("bit %d (%d %d) = %d (%d)", bit, index, bindex, value, b); 19 | */ 20 | } 21 | 22 | bool bits_GetFromArray (size_t bit, u8 *buff) 23 | { 24 | size_t index = bit >> 3; // bit/8 25 | size_t bindex = bit - (index << 3); // index*8 26 | 27 | return bitRead (buff[index], bindex); 28 | } 29 | -------------------------------------------------------------------------------- /compiling.txt: -------------------------------------------------------------------------------- 1 | To create the required bin2o.h file you should add/modify these lines to /devkitpro/devkitPPC/base_rules 2 | 3 | #--------------------------------------------------------------------------------- 4 | # canned command sequence for binary data 5 | #--------------------------------------------------------------------------------- 6 | define bin2o 7 | bin2s -a 32 $< | $(AS) -o $(@) 8 | echo "extern const u8" `(echo $( `(echo $(> `(echo $(> `(echo $(> bin2o.h 13 | echo "extern const u32" `(echo $(> bin2o.h 14 | endef 15 | -------------------------------------------------------------------------------- /source/channels.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "globals.h" 3 | 4 | #ifndef _NAND_H_ 5 | #define _NAND_H_ 6 | 7 | /* 'NAND Device' structure */ 8 | typedef struct { 9 | /* Device name */ 10 | char *name; 11 | 12 | /* Mode value */ 13 | u32 mode; 14 | 15 | /* Un/mount command */ 16 | u32 mountCmd; 17 | u32 umountCmd; 18 | } nandDevice; 19 | 20 | 21 | #define EMU_SD 1 22 | #define EMU_USB 2 23 | 24 | /* Prototypes */ 25 | s32 Nand_Mount(nandDevice *); 26 | s32 Nand_Unmount(nandDevice *); 27 | s32 Nand_Enable(nandDevice *dev, char *path); 28 | s32 Nand_Disable(void); 29 | s32 Enable_Emu(int selection, char *path); 30 | s32 Disable_Emu(); 31 | s32 get_nand_device(); 32 | 33 | int BootChannel(s_run *run); 34 | s32 get_game_list(u64 **TitleIds, u32 *num, u8 id); 35 | s32 get_game_listEmu(u64 **TitleIds, u32 *num, u8 id, char *nandmountpoint); 36 | char *get_name(u64 titleid, char *nandmountpoint); 37 | 38 | bool RestoreChannelNeek2o (void); 39 | #endif -------------------------------------------------------------------------------- /addon/neekbooter/source/neek.h: -------------------------------------------------------------------------------- 1 | #define NANDCONFIG_MAXNAND 8 2 | #define NANDCONFIG_NANDINFO_SIZE 0xC0 3 | #define NANDCONFIG_CONFIG_SIZE 0x10 4 | 5 | #define PLNANDSTATUS_NONE 0 6 | #define PLNANDSTATUS_BOOTING 1 7 | #define PLNANDSTATUS_BOOTED 2 8 | 9 | 10 | typedef struct 11 | { 12 | u32 NandCnt; 13 | u32 NandSel; 14 | u32 Padding1; 15 | u32 Padding2; 16 | u8 NandInfo[][NANDCONFIG_NANDINFO_SIZE]; 17 | } NandConfig; 18 | 19 | extern NandConfig *nandConfig; 20 | 21 | bool neek_WriteNandConfig (void); 22 | bool neek_GetNandConfig (void); 23 | 24 | void neek_KillDIConfig (void); // Reboot needed after that call 25 | void neek_KillNandConfig (void); // Reboot needed after that call 26 | 27 | bool neek_IsNeek2o (void); 28 | bool neek_NandConfigSelect (char *nand); 29 | 30 | bool neek_PLNandInfo (int mode, u32 *idx, u32 *status, u32 *lo, u32 *hi, u32 *back2real); // mode 0 = read, mode 1 = write; 31 | bool neek_PLNandInfoRemove (void); // mode 0 = read, mode 1 = write -------------------------------------------------------------------------------- /addon/nandbooter/source/patch.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * tools.h 3 | * 4 | * Copyright (c) 2009 The Lemon Man 5 | * Copyright (c) 2009 Nicksasa 6 | * Copyright (c) 2009 WiiPower 7 | * 8 | * Distributed under the terms of the GNU General Public License (v2) 9 | * See http://www.gnu.org/licenses/gpl-2.0.txt for more info. 10 | * 11 | * Description: 12 | * ----------- 13 | * 14 | ******************************************************************************/ 15 | 16 | #include 17 | 18 | extern GXRModeObj TVNtsc480Int; // declared somewhere inside libogc, but missing in the correct .h file 19 | extern GXRModeObj TVMpal480Prog; 20 | 21 | int videomode_interlaced(GXRModeObj* mode); 22 | void search_video_modes(u8 *file, u32 size); 23 | void patch_video_modes_to(GXRModeObj* vmode, u32 videopatchselect); 24 | s32 parser(u8 *file, u32 size, u8 *value, u32 valuesize, u8 *patch, u32 patchsize, u32 offset); 25 | s32 patch_language(u8 *file, u32 size, u32 languageoption); 26 | 27 | -------------------------------------------------------------------------------- /addon/nandbooter/source/tools.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * tools.h 3 | * 4 | * Copyright (c) 2009 The Lemon Man 5 | * Copyright (c) 2009 Nicksasa 6 | * Copyright (c) 2009 WiiPower 7 | * 8 | * Distributed under the terms of the GNU General Public License (v2) 9 | * See http://www.gnu.org/licenses/gpl-2.0.txt for more info. 10 | * 11 | * Description: 12 | * ----------- 13 | * 14 | ******************************************************************************/ 15 | 16 | #define TITLE_UPPER(x) ((u32)((x) >> 32)) 17 | #define TITLE_LOWER(x) ((u32)(x)) 18 | #define TITLE_ID(x,y) (((u64)(x) << 32) | (y)) 19 | 20 | bool Power_Flag; 21 | bool Reset_Flag; 22 | 23 | void Console_SetPosition(u8 row, u8 column); 24 | void ClearScreen (); 25 | void PrintCenter(char *text, int width); 26 | 27 | void *allocate_memory(u32 size); 28 | s32 identify(u64 titleid, u32 *ios); 29 | void debug2Console(bool enable); 30 | void debug(const char *text, ...); 31 | void tell_cIOS_to_return_to_channel(void); 32 | u64 old_title_id; -------------------------------------------------------------------------------- /source/wiiload/wiiload.h: -------------------------------------------------------------------------------- 1 | #define WIILOAD_ZIPFILE "wiiload.zip" 2 | #define WIILOAD_TMPFILE "wiiload.tmp" 3 | 4 | enum 5 | { 6 | WIILOAD_ERROR = -1, 7 | WIILOAD_STOPPED = 0, // Thread stopped 8 | WIILOAD_INITIALIZING, 9 | WIILOAD_IDLE, 10 | WIILOAD_RECEIVING, // Wiiload thread is receiving 11 | WIILOAD_HBREADY, // Homebrew loaded in execute buffer 12 | WIILOAD_HBZREADY, // wiiload.zip written in temp folder and ready to use 13 | }; 14 | 15 | typedef struct 16 | { 17 | char op[128]; // Calling process can set filename or any other info that fit 18 | u32 opUpd; // Every time op is updated, opUpd is incremented 19 | int status; 20 | int gecko; 21 | 22 | char filename[64]; // Filename sended by wiiload protocolo 23 | char fullpath[256]; // full path to temp file on device 24 | char ip[64]; // Filename sended by wiiload protocolo 25 | 26 | char *args; 27 | int argl; 28 | } 29 | s_wiiload; 30 | 31 | extern s_wiiload wiiload; 32 | 33 | void WiiLoad_Start(char *tempPath, int startSleep); 34 | void WiiLoad_Stop (void); 35 | void WiiLoad_Pause (void); 36 | void WiiLoad_Resume (void); -------------------------------------------------------------------------------- /source/sicksaxis-wrapper/sicksaxis-wrapper.h: -------------------------------------------------------------------------------- 1 | // A simple wrapper for libsicksaxis, to make it resemble WPAD/PAD more closely. 2 | // Written by daxtsu/thedax. I'm releasing this code into the public domain, so do whatever you want with it. 3 | 4 | #ifndef _DS3WRAPPER_H_ 5 | #define _DS3WRAPPER_H_ 6 | 7 | #include 8 | 9 | struct ss_device; 10 | 11 | enum 12 | { 13 | DS3_BUTTON_PS = 1, 14 | DS3_BUTTON_START = 2, 15 | DS3_BUTTON_SELECT = 4, 16 | DS3_BUTTON_TRIANGLE = 8, 17 | DS3_BUTTON_CIRCLE = 16, 18 | DS3_BUTTON_CROSS = 32, 19 | DS3_BUTTON_SQUARE = 64, 20 | DS3_BUTTON_UP = 128, 21 | DS3_BUTTON_RIGHT = 256, 22 | DS3_BUTTON_DOWN = 512, 23 | DS3_BUTTON_LEFT = 1024, 24 | DS3_BUTTON_L1 = 2048, 25 | DS3_BUTTON_L2 = 4096, 26 | DS3_BUTTON_L3 = 8192, 27 | DS3_BUTTON_R1 = 16384, 28 | DS3_BUTTON_R2 = 32768, 29 | DS3_BUTTON_R3 = 65536, 30 | }; 31 | 32 | typedef struct ss_device DS3; 33 | bool DS3_Init(); 34 | void DS3_Rumble(); 35 | void DS3_Cleanup(); 36 | uint32_t DS3_ButtonsDown(); 37 | void DS3_ScanPads(); 38 | int32_t DS3_StickX(); 39 | int32_t DS3_SubStickX(); 40 | int32_t DS3_StickY(); 41 | int32_t DS3_SubStickY(); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /source/zip/infdef.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define Z_FOPEN_ERROR (Z_VERSION_ERROR - 1) 4 | #define Z_ALLOC_ERROR (Z_VERSION_ERROR - 2) 5 | #define Z_FILE_ERROR (Z_VERSION_ERROR - 3) 6 | 7 | /* Decompress from file source to file dest until stream ends or EOF. 8 | inf() returns Z_OK on success, Z_MEM_ERROR if memory could not be 9 | allocated for processing, Z_DATA_ERROR if the deflate data is 10 | invalid or incomplete, Z_VERSION_ERROR if the version of zlib.h and 11 | the version of the library linked do not match, or Z_ERRNO if there 12 | is an error reading or writing the files. */ 13 | 14 | int zlib_inf(char *source, char *target); 15 | 16 | /* Compress from file source to file dest until EOF on source. 17 | def() returns Z_OK on success, Z_MEM_ERROR if memory could not be 18 | allocated for processing, Z_STREAM_ERROR if an invalid compression 19 | level is supplied, Z_VERSION_ERROR if the version of zlib.h and the 20 | version of the library linked do not match, or Z_ERRNO if there is 21 | an error reading or writing the files. */ 22 | 23 | int zlib_def(char *source, char *target, int level); 24 | -------------------------------------------------------------------------------- /addon/nandbooter/source/codes/patchcode.h: -------------------------------------------------------------------------------- 1 | #ifndef __PATCHCODE_H__ 2 | #define __PATCHCODE_H__ 3 | 4 | //--------------------------------------------------------------------------------- 5 | extern const u32 viwiihooks[4]; 6 | extern const u32 kpadhooks[4]; 7 | extern const u32 joypadhooks[4]; 8 | extern const u32 gxdrawhooks[4]; 9 | extern const u32 gxflushhooks[4]; 10 | extern const u32 ossleepthreadhooks[4]; 11 | extern const u32 axnextframehooks[4]; 12 | //extern const u32 wpadbuttonsdownhooks[4]; 13 | //extern const u32 wpadbuttonsdown2hooks[4]; 14 | //--------------------------------------------------------------------------------- 15 | //void dogamehooks(void *addr, u32 len); 16 | //void patchmenu(void *addr, u32 len, int patchnum); 17 | //void langpatcher(void *addr, u32 len); 18 | //void vidolpatcher(void *addr, u32 len); 19 | bool dochannelhooks(void *addr, u32 len, bool bootcontentloaded); 20 | //void patch_002(void *addr, u32 len); 21 | //void patchdebug(void *addr, u32 len); 22 | //void determine_libogc_hook(void *addr, u32 len); 23 | //--------------------------------------------------------------------------------- 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /data/english.txt: -------------------------------------------------------------------------------- 1 | This is the default english file 2 | 3 | {Close}Close 4 | 5 | {YesNo}Yes##0|No##-1 6 | {Yes|No}(YES)|(NO) 7 | 8 | {advopt1}Advanced Options!!!\n\n 9 | {advopt2}Important notice: postLoader forwarder channel V4 must be installed to use\nIOS249 option and keep the ability to run homebrews with ahbprot. 10 | 11 | {pwcopying}Please wait: %u%% done|Copying %u of %u Mb (%u kb/sec) 12 | {interruptcopy}This will interrupt the copy process... Are you sure ? 13 | 14 | {clrusbdata}Please wait|clearing old usb data... 15 | {clrsddata}Please wait|clearing old sd data... 16 | 17 | {srcusb}Search USB Dev. 18 | {useciosx}Use cIOSX (249) 19 | {usepl3ch}Use PL3 channel to run homebrews 20 | {usegest}Use wiimotion gestures 21 | {rstrbt}Restart/Reboot... 22 | 23 | {rstrbtcanc1}What do you want to do ?\n 24 | {rstrbtcanc2}Restart ##0~Reboot##1~Cancel##-1 25 | 26 | {n2oopt}Neek(2o) options\n\n 27 | {n2onotice}Important notice: for some options, neek2obooter.app must be installed 28 | {n2obooterstartpl}neek2obooter is configured to start postLoader 29 | {n2obooternostartpl}neek2obooter is configured to start System Menu 30 | 31 | {installDmlWads}Auto Install DML wads -------------------------------------------------------------------------------- /addon/di/source/wdvd.h: -------------------------------------------------------------------------------- 1 | #ifndef _WDVD_H_ 2 | #define _WDVD_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif /* __cplusplus */ 7 | 8 | typedef struct _dirent 9 | { 10 | char name[ISFS_MAXPATH + 1]; 11 | int type; 12 | u32 ownerID; 13 | u16 groupID; 14 | u8 attributes; 15 | u8 ownerperm; 16 | u8 groupperm; 17 | u8 otherperm; 18 | } dirent_t; 19 | 20 | /* Prototypes */ 21 | s32 WDVD_Init(void); 22 | s32 WDVD_Close(void); 23 | s32 WDVD_GetHandle(void); 24 | s32 WDVD_Reset(void); 25 | s32 WDVD_ReadDiskId(void *); 26 | s32 WDVD_Seek(u64); 27 | s32 WDVD_Offset(u64); 28 | s32 WDVD_StopLaser(void); 29 | s32 WDVD_StopMotor(void); 30 | s32 WDVD_OpenPartition(u64 offset, void* Ticket, void* Certificate, unsigned int Cert_Len, void* Out); 31 | s32 WDVD_ClosePartition(void); 32 | s32 WDVD_UnencryptedRead(void *, u32, u64); 33 | s32 WDVD_Read(void *, u32, u64); 34 | s32 WDVD_WaitForDisc(void); 35 | s32 WDVD_GetCoverStatus(u32 *); 36 | s32 WDVD_SetUSBMode(u32, const u8 *, s32); 37 | s32 WDVD_Eject(void); 38 | s32 WDVD_Read_Disc_BCA(void *); 39 | s32 WDVD_SetFragList(int device, void *fraglist, int size); 40 | int WDVD_EnableAudio(int enable); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif /* __cplusplus */ 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /source/language.c: -------------------------------------------------------------------------------- 1 | /* 2 | language.c 3 | 4 | simple language handling routine. This is the format. 5 | 6 | {tag1}string1\n 7 | {tag2}string2\n 8 | etc... 9 | */ 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #define MAXSTRINGS 4 16 | #define MAXSTRINGLEN 512 17 | 18 | static char *langBuff = 0; 19 | static char string[MAXSTRINGS][MAXSTRINGLEN]; 20 | static int stringIdx = 0; 21 | 22 | void SetLangFileBuffer (const char *buff, int size) 23 | { 24 | memset (string, 0, sizeof(string)); 25 | stringIdx = 0; 26 | langBuff = (char*)buff; 27 | langBuff[size-1] = 0; // make sure it is null terminated 28 | } 29 | 30 | char *GetLanguageString (char *tag) 31 | { 32 | int i; 33 | char fulltag[64]; 34 | char *p; 35 | 36 | sprintf (fulltag, "{%s}", tag); 37 | p = strstr(langBuff, fulltag); 38 | 39 | stringIdx++; 40 | if (stringIdx >= MAXSTRINGS) stringIdx = 0; 41 | 42 | if (p == NULL) // not found... copy back the tag 43 | { 44 | strcpy (string[stringIdx], tag); 45 | } 46 | else 47 | { 48 | p += strlen(fulltag); 49 | i = 0; 50 | while (*p != '\r' && *p != '\n' && *p != 0 && i < (MAXSTRINGLEN-1)) 51 | { 52 | if (*p == '\\' && *(p+1) == 'n') 53 | { 54 | string[stringIdx][i++] = '\n'; 55 | p++; 56 | } 57 | else 58 | string[stringIdx][i++] = *p; 59 | p++; 60 | } 61 | string[stringIdx][i++] = 0; 62 | } 63 | 64 | return string[stringIdx]; 65 | } -------------------------------------------------------------------------------- /addon/priibooter_gui/source/cfg.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "cfg.h" 5 | 6 | ///////////////////////////////////////////////////////////////////// 7 | // 8 | // cfg buffer managment routines 9 | // 10 | ///////////////////////////////////////////////////////////////////// 11 | 12 | char *cfg_FindTag (char *buff, char *tag) 13 | { 14 | char b[300]; 15 | char *p; 16 | 17 | sprintf (b, "%s=", tag); 18 | p = strstr (buff, b); 19 | 20 | if (p == NULL) 21 | { 22 | sprintf (b, "%s =", tag); 23 | p = strstr (buff, b); 24 | } 25 | 26 | if (p == NULL) return NULL; 27 | 28 | // move on value 29 | p += strlen (b); 30 | 31 | // strip spaces 32 | while (*p == ' ' && *p != '\0') p++; 33 | if (*p == '\0') return NULL; 34 | 35 | // we should have a value 36 | return p; 37 | } 38 | 39 | int cfg_GetString (char *buff, char *tag, char *string) 40 | { 41 | char *p; 42 | char *ps; 43 | 44 | p = cfg_FindTag (buff, tag); 45 | if (p == NULL) 46 | { 47 | *string = '\0'; 48 | return 0; 49 | } 50 | 51 | ps = string; 52 | 53 | while (*p != '\0' && *p != '\n') 54 | { 55 | *ps++ = *p++; 56 | } 57 | *ps = '\0'; 58 | 59 | return 1; 60 | } 61 | 62 | int cfg_GetInt (char *buff, char *tag, int *ival) 63 | { 64 | char *p; 65 | 66 | p = cfg_FindTag (buff, tag); 67 | if (p == NULL) 68 | { 69 | *ival = 0; 70 | return 0; 71 | } 72 | *ival = atoi (p); 73 | 74 | return 1; 75 | } 76 | -------------------------------------------------------------------------------- /addon/di/source/patchcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Nuke (wiinuke@gmail.com) 3 | * 4 | * this file is part of GeckoOS for USB Gecko 5 | * http://www.usbgecko.com 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef __PATCHCODE_H__ 23 | #define __PATCHCODE_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | // Globals 29 | u32 hooktype; 30 | int patched; 31 | u8 configbytes[2]; 32 | u32 regionfree; 33 | 34 | // Function prototypes 35 | bool dogamehooks(void *addr, u32 len); 36 | void langpatcher(void *addr, u32 len); 37 | void vidolpatcher(void *addr, u32 len); 38 | void patchdebug(void *addr, u32 len); 39 | bool PatchReturnTo(void *Address, int Size, u32 id); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif // __PATCHCODE_H__ 46 | -------------------------------------------------------------------------------- /addon/priibooter_gui/source/fsop.h: -------------------------------------------------------------------------------- 1 | #ifndef _FSOP 2 | #define _FSOP 3 | 4 | typedef void (*fsopCallback)(void); 5 | 6 | typedef struct 7 | { 8 | u64 size, bytes; // for operation that uses more than one file 9 | u32 startms; 10 | u32 elapsed; 11 | } 12 | s_fsopmulty; 13 | 14 | typedef struct 15 | { 16 | char op[256]; // Calling process can set filename or any other info that fit 17 | 18 | u32 size, bytes; 19 | 20 | s_fsopmulty multy; 21 | 22 | int flag1; // user defined flag 23 | bool breakop; // allow to stop a long operation 24 | } 25 | s_fsop; 26 | 27 | extern s_fsop fsop; 28 | 29 | u8 *fsop_ReadFile (char *path, size_t bytes2read, size_t *bytesReaded); 30 | bool fsop_WriteFile (char *path, u8 *buff, size_t len); 31 | u32 fsop_CountDirItems (char *source); 32 | bool fsop_GetFileSizeBytes (char *path, size_t *filesize); // for me stats st_size report always 0 :( 33 | bool fsop_StoreBuffer (char *fn, u8 *buff, int size, fsopCallback vc); 34 | bool fsop_FileExist (char *fn); 35 | bool fsop_DirExist (char *path); 36 | bool fsop_CopyFile (char *source, char *target, fsopCallback vc); 37 | int fsop_MakeFolder (char *path); 38 | bool fsop_CopyFolder (char *source, char *target, fsopCallback vc); 39 | bool fsop_KillFolderTree (char *source, fsopCallback vc); 40 | bool fsop_CreateFolderTree (char *path); 41 | int fsop_CountFolderTree (char *path); 42 | 43 | u32 fsop_GetFolderKb (char *source, fsopCallback vc); 44 | u64 fsop_GetFolderBytes (char *source, fsopCallback vc); 45 | u32 fsop_GetFreeSpaceKb (char *path); 46 | 47 | #endif -------------------------------------------------------------------------------- /source/browser.h: -------------------------------------------------------------------------------- 1 | /* 2 | browser.h contain common code as macro 3 | 4 | */ 5 | 6 | #ifndef _BROWSERCOMMON_ 7 | #define _BROWSERCOMMON_ 8 | 9 | #define REDRAW()\ 10 | {\ 11 | static int ds1,ds2, bbcmd;\ 12 | \ 13 | grlib_PopScreen ();\ 14 | FindSpot ();\ 15 | Overlay ();\ 16 | \ 17 | if (!config.lockCurrentMode)\ 18 | {\ 19 | DrawTopBar (&ds1, &browserRet, &btn, NULL);\ 20 | bbcmd = DrawBottomBar (&ds2, &btn, NULL);\ 21 | }\ 22 | \ 23 | if (ds1 || ds2) disableSpots = 1; else disableSpots = 0;\ 24 | \ 25 | grlib_DrawIRCursor ();\ 26 | grlib_Render();\ 27 | \ 28 | if (!config.lockCurrentMode)\ 29 | {\ 30 | if (bbcmd != -1) redraw = 1;\ 31 | if (bbcmd == 0) ShowAboutPLMenu ();\ 32 | if (bbcmd == 1) ShowAboutMenu ();\ 33 | if (bbcmd == 2 && CheckDisk(NULL) == 1) browserRet = INTERACTIVE_RET_DISC;\ 34 | if (bbcmd == 3) browserRet = ShowExitMenu();\ 35 | if (bbcmd == 4) browserRet = ShowBootmiiMenu();\ 36 | if (bbcmd == 5) browserRet = INTERACTIVE_RET_SE;\ 37 | if (bbcmd == 6) browserRet = INTERACTIVE_RET_WM;\ 38 | }\ 39 | } 40 | 41 | #define CLOSETOPBAR()\ 42 | {\ 43 | int closed;\ 44 | do\ 45 | {\ 46 | grlib_irPos.x = 320;\ 47 | grlib_irPos.y = 240;\ 48 | \ 49 | grlib_PopScreen ();\ 50 | Overlay ();\ 51 | DrawTopBar (&disableSpots, NULL, NULL, &closed);\ 52 | grlib_Render();\ 53 | }\ 54 | while (!closed);\ 55 | } 56 | 57 | #define CLOSEBOTTOMBAR()\ 58 | {\ 59 | int closed;\ 60 | do\ 61 | {\ 62 | grlib_irPos.x = 320;\ 63 | grlib_irPos.y = 240;\ 64 | \ 65 | grlib_PopScreen ();\ 66 | Overlay ();\ 67 | DrawBottomBar (&disableSpots, NULL, &closed);\ 68 | grlib_Render();\ 69 | }\ 70 | while (!closed);\ 71 | } 72 | #endif -------------------------------------------------------------------------------- /source/neek.h: -------------------------------------------------------------------------------- 1 | #define NANDCONFIG_MAXNAND 8 2 | #define NANDCONFIG_NANDINFO_SIZE 0x100 3 | #define NANDCONFIG_CONFIG_SIZE 0x10 4 | 5 | #define PLNANDSTATUS_NONE 0 6 | #define PLNANDSTATUS_BOOTING 1 7 | #define PLNANDSTATUS_BOOTED 2 8 | 9 | #define NEEK2O_NAND "usb://Nands/pln2o" 10 | #define NEEK2O_SNEEK "usb://sneek" 11 | 12 | typedef struct 13 | { 14 | u32 NandCnt; 15 | u32 NandSel; 16 | u32 Padding1; 17 | u32 Padding2; 18 | u8 NandInfo[][NANDCONFIG_NANDINFO_SIZE]; 19 | } NandConfig; 20 | 21 | extern NandConfig *nandConfig; 22 | 23 | s32 neek_SelectGame( u32 SlotID ); 24 | int neek_ReadAndSelectCDIGame(char *gameid); 25 | 26 | bool neek_WriteNandConfig (void); 27 | bool neek_GetNandConfig (void); 28 | 29 | void neek_KillDIConfig (void); // Reboot needed after that call 30 | void neek_KillNandConfig (void); // Reboot needed after that call 31 | 32 | bool neek_IsNeek2o (void); 33 | int neek_NandConfigSelect (char *nand); 34 | 35 | bool neek_PLNandInfoKill (void); // Remove nandcfg.pl... postloader do this when it start 36 | 37 | bool neek_CreateCDIConfig (char *gameid); // gameid must contain ID6 value 38 | 39 | bool neek_PrepareNandForChannel (char *sneekpath, char *nandpath); 40 | bool neek_RestoreNandForChannel (char *sneekpath); 41 | 42 | bool neek_PLNandInfo (int mode, u32 *idx, u32 *status, u32 *lo, u32 *hi, u32 *back2real); // mode 0 = read, mode 1 = write; 43 | 44 | bool neek_UID_Dump (void); 45 | bool neek_UID_Read (void); 46 | bool neek_UID_Write (void); 47 | int neek_UID_Find (u64 title_id); 48 | bool neek_UID_Remove (u64 title_id); 49 | bool neek_UID_Add (u64 title_id); 50 | int neek_UID_Count (void); 51 | int neek_UID_CountHidden (void); 52 | int neek_UID_Clean (void); // return the number of erased items 53 | bool neek_UID_Hide (u64 title_id); 54 | bool neek_UID_Show (u64 title_id); 55 | bool neek_UID_IsHidden (u64 title_id); -------------------------------------------------------------------------------- /source/fsop/fsop.h: -------------------------------------------------------------------------------- 1 | #ifndef _FSOP 2 | #define _FSOP 3 | 4 | typedef void (*fsopCallback)(void); 5 | 6 | typedef struct 7 | { 8 | u64 size, bytes; // for operation that uses more than one file 9 | u32 startms; 10 | u32 elapsed; 11 | } 12 | s_fsopmulty; 13 | 14 | typedef struct 15 | { 16 | char op[256]; // Calling process can set filename or any other info that fit 17 | 18 | u32 size, bytes; 19 | 20 | s_fsopmulty multy; 21 | 22 | int flag1; // user defined flag 23 | bool breakop; // allow to stop a long operation 24 | } 25 | s_fsop; 26 | 27 | extern s_fsop fsop; 28 | 29 | char * fsop_GetExtension (char *path); 30 | char * fsop_GetFilename (char *path, bool killExt); 31 | char * fsop_GetPath (char *path, int killDev); 32 | char * fsop_GetDev (char *path); 33 | 34 | u8 *fsop_ReadFile (char *path, size_t bytes2read, size_t *bytesReaded); 35 | bool fsop_WriteFile (char *path, u8 *buff, size_t len); 36 | u32 fsop_CountDirItems (char *source); 37 | bool fsop_GetFileSizeBytes (char *path, size_t *filesize); // for me stats st_size report always 0 :( 38 | bool fsop_StoreBuffer (char *fn, u8 *buff, int size, fsopCallback vc); 39 | bool fsop_FileExist (char *fn); 40 | bool fsop_DirExist (char *path); 41 | bool fsop_CopyFile (char *source, char *target, fsopCallback vc); 42 | int fsop_MakeFolder (char *path); 43 | bool fsop_CopyFolder (char *source, char *target, fsopCallback vc); 44 | bool fsop_KillFolderTree (char *source, fsopCallback vc); 45 | bool fsop_CreateFolderTree (char *path); 46 | int fsop_CountFolderTree (char *path); 47 | 48 | u32 fsop_GetFolderKb (char *source, fsopCallback vc); 49 | u64 fsop_GetFolderBytes (char *source, fsopCallback vc); 50 | u32 fsop_GetFreeSpaceKb (char *path); 51 | 52 | char * fsop_GetDirAsString (char *path, char sep, int skipfolders, char *ext); 53 | char * fsop_GetDirAsStringWithDirFlag (char *path, char sep); 54 | 55 | #endif -------------------------------------------------------------------------------- /addon/di/source/disc.h: -------------------------------------------------------------------------------- 1 | #ifndef _DISC_H_ 2 | #define _DISC_H_ 3 | 4 | #define ALT_DOL_EXT 1 5 | #define ALT_DOL_DISC 2 6 | #define ALT_DOL_PLUS 3 7 | 8 | /* Disc header structure */ 9 | struct discHdr 10 | { 11 | /* Game ID */ 12 | u8 id[6]; 13 | 14 | /* Game version */ 15 | u16 version; 16 | 17 | /* Audio streaming */ 18 | u8 streaming; 19 | u8 bufsize; 20 | 21 | /* Padding */ 22 | u64 chantitle; // Used for channels 23 | u8 unused1[6]; // Was 14, but removed 8 for chantitle above 24 | 25 | /* Magic word */ 26 | u32 magic; 27 | 28 | /* Padding */ 29 | u8 unused2[4]; 30 | 31 | /* Game title */ 32 | char title[64]; 33 | 34 | /* Encryption/Hashing */ 35 | u8 encryption; 36 | u8 h3_verify; 37 | 38 | /* Padding */ 39 | u8 unused3[30]; 40 | } ATTRIBUTE_PACKED; 41 | 42 | struct dir_discHdr 43 | { 44 | struct discHdr hdr; 45 | char path[256]; 46 | } ATTRIBUTE_PACKED; 47 | 48 | struct gc_discHdr 49 | { 50 | /* Game ID */ 51 | u8 id[6]; 52 | 53 | /* Game version */ 54 | u16 version; 55 | 56 | /* Audio streaming */ 57 | u8 streaming; 58 | u8 bufsize; 59 | 60 | /* Padding */ 61 | u8 unused1[18]; 62 | 63 | /* Magic word */ 64 | u32 magic; 65 | 66 | /* Padding */ 67 | u8 unused2[4]; 68 | 69 | /* Game title */ 70 | char title[124]; 71 | }; 72 | 73 | #ifdef __cplusplus 74 | extern "C" { 75 | #endif /* __cplusplus */ 76 | 77 | /* Prototypes */ 78 | s32 Disc_Init(void); 79 | s32 Disc_Open(void); 80 | s32 Disc_Wait(void); 81 | s32 Disc_SetUSB(const u8 *); 82 | s32 Disc_ReadHeader(void *); 83 | s32 Disc_ReadGCHeader(void *); 84 | s32 Disc_Type(bool); 85 | s32 Disc_IsWii(void); 86 | s32 Disc_IsGC(void); 87 | s32 Disc_BootPartition(u64 offset, u8 vidMode, bool vipatch, bool countryString, u8 patchVidMode); 88 | s32 Disc_WiiBoot(u8 vidMode, bool vipatch, bool countryString, u8 patchVidModes); 89 | s32 Disc_OpenPartition(u8 *); 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif /* __cplusplus */ 94 | 95 | #endif 96 | 97 | -------------------------------------------------------------------------------- /addon/priibooter_gui/source/bootfile.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "../build/bin2o.h" 8 | 9 | #define EXECUTE_ADDR ((u8 *) 0x92000000) 10 | #define BOOTER_ADDR ((u8 *) 0x93000000) 11 | #define ARGS_ADDR ((u8 *) 0x93200000) 12 | #define CMDL_ADDR ((u8 *) 0x93200000+sizeof(struct __argv)) 13 | #define MAXFILESIZE 16777216 // 16mb 14 | 15 | static u32 cookie; 16 | static void *exeBuffer = (void *) EXECUTE_ADDR; 17 | 18 | extern void __exception_closeall(); 19 | typedef void (*entrypoint) (void); 20 | 21 | static entrypoint exeEntryPoint; 22 | 23 | bool LoadExecFile (char *path, char *args) 24 | { 25 | FILE *f; 26 | size_t size; 27 | 28 | f = fopen(path, "rb"); 29 | if (!f) return false; 30 | 31 | size = fread(exeBuffer, 1, MAXFILESIZE, f ); 32 | fclose (f); 33 | 34 | if (size <= 0) return false; 35 | 36 | DCFlushRange(exeBuffer, size); 37 | 38 | struct __argv arg; 39 | memset (&arg, 0, sizeof(struct __argv)); 40 | 41 | if (args != NULL) 42 | { 43 | arg.argvMagic = ARGV_MAGIC; 44 | arg.length = strlen(args) + 1; 45 | arg.commandLine = (char*)CMDL_ADDR; 46 | memset (arg.commandLine, 0, arg.length); 47 | memcpy (arg.commandLine, args, arg.length); 48 | } 49 | 50 | memmove(ARGS_ADDR, &arg, sizeof(arg)); 51 | DCFlushRange(ARGS_ADDR, sizeof(arg) + arg.length); 52 | 53 | memcpy(BOOTER_ADDR, booter_dol, booter_dol_size); 54 | DCFlushRange(BOOTER_ADDR, booter_dol_size); 55 | 56 | exeEntryPoint = (entrypoint) BOOTER_ADDR; 57 | 58 | return true; 59 | } 60 | 61 | bool BootExecFile (void) 62 | { 63 | /* cleaning up and load dol */ 64 | SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); 65 | _CPU_ISR_Disable (cookie); 66 | __exception_closeall (); 67 | exeEntryPoint (); 68 | _CPU_ISR_Restore (cookie); 69 | 70 | return true; 71 | } 72 | -------------------------------------------------------------------------------- /addon/neekbooter/source/bootfile.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "../build/bin2o.h" 8 | 9 | #define EXECUTE_ADDR ((u8 *) 0x92000000) 10 | #define BOOTER_ADDR ((u8 *) 0x93000000) 11 | #define ARGS_ADDR ((u8 *) 0x93200000) 12 | #define CMDL_ADDR ((u8 *) 0x93200000+sizeof(struct __argv)) 13 | #define MAXFILESIZE 16777216 // 16mb 14 | 15 | void green_fix(void); //GREENSCREEN FIX 16 | 17 | static u32 cookie; 18 | static void *exeBuffer = (void *) EXECUTE_ADDR; 19 | 20 | extern void __exception_closeall(); 21 | typedef void (*entrypoint) (void); 22 | 23 | static entrypoint exeEntryPoint; 24 | 25 | bool LoadExecFile (char *path, char *args) 26 | { 27 | FILE *f; 28 | size_t size; 29 | 30 | f = fopen(path, "rb"); 31 | if (!f) return false; 32 | 33 | size = fread(exeBuffer, 1, MAXFILESIZE, f ); 34 | fclose (f); 35 | 36 | if (size <= 0) return false; 37 | 38 | struct __argv arg; 39 | memset (&arg, 0, sizeof(struct __argv)); 40 | 41 | if (args != NULL) 42 | { 43 | arg.argvMagic = ARGV_MAGIC; 44 | arg.length = strlen(args) + 1; 45 | arg.commandLine = (char*)CMDL_ADDR; 46 | memset (arg.commandLine, 0, arg.length); 47 | memcpy (arg.commandLine, args, arg.length); 48 | } 49 | 50 | memmove(ARGS_ADDR, &arg, sizeof(arg)); 51 | DCFlushRange(ARGS_ADDR, sizeof(arg) + arg.length); 52 | 53 | memcpy(BOOTER_ADDR, booter_dol, booter_dol_size); 54 | DCFlushRange(BOOTER_ADDR, booter_dol_size); 55 | 56 | exeEntryPoint = (entrypoint) BOOTER_ADDR; 57 | 58 | return true; 59 | } 60 | 61 | bool BootExecFile (void) 62 | { 63 | green_fix (); 64 | 65 | /* cleaning up and load dol */ 66 | SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); 67 | _CPU_ISR_Disable (cookie); 68 | __exception_closeall (); 69 | exeEntryPoint (); 70 | _CPU_ISR_Restore (cookie); 71 | 72 | return true; 73 | } 74 | -------------------------------------------------------------------------------- /addon/priibooter/source/bootfile.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "../build/bin2o.h" 8 | 9 | #define EXECUTE_ADDR ((u8 *) 0x92000000) 10 | #define BOOTER_ADDR ((u8 *) 0x93000000) 11 | #define ARGS_ADDR ((u8 *) 0x93200000) 12 | #define CMDL_ADDR ((u8 *) 0x93200000+sizeof(struct __argv)) 13 | #define MAXFILESIZE 16777216 // 16mb 14 | 15 | void green_fix(void); //GREENSCREEN FIX 16 | 17 | static u32 cookie; 18 | static void *exeBuffer = (void *) EXECUTE_ADDR; 19 | 20 | extern void __exception_closeall(); 21 | typedef void (*entrypoint) (void); 22 | 23 | static entrypoint exeEntryPoint; 24 | 25 | bool LoadExecFile (char *path, char *args) 26 | { 27 | FILE *f; 28 | size_t size; 29 | 30 | f = fopen(path, "rb"); 31 | if (!f) return false; 32 | 33 | size = fread(exeBuffer, 1, MAXFILESIZE, f ); 34 | fclose (f); 35 | 36 | if (size <= 0) return false; 37 | 38 | struct __argv arg; 39 | memset (&arg, 0, sizeof(struct __argv)); 40 | 41 | if (args != NULL) 42 | { 43 | arg.argvMagic = ARGV_MAGIC; 44 | arg.length = strlen(args) + 1; 45 | arg.commandLine = (char*)CMDL_ADDR; 46 | memset (arg.commandLine, 0, arg.length); 47 | memcpy (arg.commandLine, args, arg.length); 48 | } 49 | 50 | memmove(ARGS_ADDR, &arg, sizeof(arg)); 51 | DCFlushRange(ARGS_ADDR, sizeof(arg) + arg.length); 52 | 53 | memcpy(BOOTER_ADDR, booter_dol, booter_dol_size); 54 | DCFlushRange(BOOTER_ADDR, booter_dol_size); 55 | 56 | exeEntryPoint = (entrypoint) BOOTER_ADDR; 57 | 58 | return true; 59 | } 60 | 61 | bool BootExecFile (void) 62 | { 63 | green_fix (); 64 | 65 | /* cleaning up and load dol */ 66 | SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); 67 | _CPU_ISR_Disable (cookie); 68 | __exception_closeall (); 69 | exeEntryPoint (); 70 | _CPU_ISR_Restore (cookie); 71 | 72 | return true; 73 | } 74 | -------------------------------------------------------------------------------- /addon/forwarder/source/hbcstub.c: -------------------------------------------------------------------------------- 1 | //functions for manipulating the HBC stub by giantpune 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | extern const u8 stub_bin[]; 8 | extern const u32 stub_bin_size; 9 | 10 | static char* determineStubTIDLocation() 11 | { 12 | u32 *stubID = (u32*) 0x80001818; 13 | 14 | //HBC stub 1.0.6 and lower, and stub.bin 15 | if (stubID[0] == 0x480004c1 && stubID[1] == 0x480004f5) 16 | return (char *) 0x800024C6; 17 | 18 | //HBC stub changed @ version 1.0.7. this file was last updated for HBC 1.0.8 19 | else if (stubID[0] == 0x48000859 && stubID[1] == 0x4800088d) return (char *) 0x8000286A; 20 | 21 | //hexdump( stubID, 0x20 ); 22 | return NULL; 23 | 24 | } 25 | 26 | #define TITLE_1(x) ((u8)((x) >> 8)) 27 | #define TITLE_2(x) ((u8)((x) >> 16)) 28 | #define TITLE_3(x) ((u8)((x) >> 24)) 29 | #define TITLE_4(x) ((u8)((x) >> 32)) 30 | #define TITLE_5(x) ((u8)((x) >> 40)) 31 | #define TITLE_6(x) ((u8)((x) >> 48)) 32 | #define TITLE_7(x) ((u8)((x) >> 56)) 33 | 34 | s32 Set_Stub(u64 reqID) 35 | { 36 | char *stub = determineStubTIDLocation(); 37 | if (!stub) return -68; 38 | 39 | stub[0] = TITLE_7( reqID ); 40 | stub[1] = TITLE_6( reqID ); 41 | stub[8] = TITLE_5( reqID ); 42 | stub[9] = TITLE_4( reqID ); 43 | stub[4] = TITLE_3( reqID ); 44 | stub[5] = TITLE_2( reqID ); 45 | stub[12] = TITLE_1( reqID ); 46 | stub[13] = ((u8) (reqID)); 47 | 48 | DCFlushRange(stub, 0x10); 49 | 50 | return 1; 51 | 52 | } 53 | 54 | void StubLoad ( void ) 55 | { 56 | // the offset is 3274 (0xCCA) for the first value 57 | 58 | memcpy((void*)0x80001800, stub_bin, stub_bin_size); 59 | DCFlushRange((void*)0x80001800,stub_bin_size); 60 | return; 61 | } 62 | 63 | void StubUnload ( void ) 64 | { 65 | //some apps apparently dislike it if the stub stays in memory but for some reason isn't active :/ 66 | memset((void*)0x80001800, 0, stub_bin_size); 67 | DCFlushRange((void*)0x80001800,stub_bin_size); 68 | return; 69 | } 70 | -------------------------------------------------------------------------------- /addon/priibooter/source/io.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include //for mkdir 8 | #include 9 | #include 10 | #include "common.h" 11 | 12 | const DISC_INTERFACE* interface[DEVMAX] = {NULL,NULL}; 13 | char mount[DEVMAX][16]; 14 | 15 | s32 Fat_Mount(int dev, int *keypressed) 16 | { 17 | u32 wbtn, gcbtn; 18 | 19 | time_t t, ct, lt = 0; 20 | char m[5]; 21 | 22 | ct = time(NULL); 23 | if (dev == DEV_SD) 24 | { 25 | interface[dev]=(DISC_INTERFACE*)&__io_wiisd; 26 | strcpy (m, "sd"); 27 | t = ct + 1; 28 | } 29 | else if (dev == DEV_USB) 30 | { 31 | interface[dev]=(DISC_INTERFACE*)&__io_usbstorage; 32 | strcpy (m, "usb"); 33 | t = ct + 15; 34 | } 35 | else 36 | return -1; 37 | 38 | printf ("Mounting %s device", m); 39 | 40 | while (t > ct) 41 | { 42 | ct = time(NULL); 43 | 44 | if (ct != lt) 45 | { 46 | printf ("."); // let user know we are live ! 47 | 48 | WPAD_ScanPads(); // Scan the Wiimotes 49 | wbtn = WPAD_ButtonsDown(0); 50 | 51 | PAD_ScanPads(); 52 | gcbtn = PAD_ButtonsDown(0); 53 | 54 | if (wbtn || gcbtn) 55 | { 56 | *keypressed = 1; 57 | printf ("keypress"); 58 | } 59 | 60 | if (interface[dev]->startup() &fatMountSimple(m, interface[dev])) 61 | { 62 | strcpy (mount[dev], m); 63 | printf ("ok\n"); 64 | return 1; // Mounted 65 | } 66 | lt = ct; 67 | } 68 | 69 | if (dev == DEV_SD) break; 70 | 71 | usleep(10 * 1000); // 10 msec 72 | } 73 | 74 | interface[dev]->shutdown(); 75 | 76 | printf ("\n"); 77 | return 0; 78 | } 79 | 80 | // Unmount all mounted devices 81 | void Fat_Unmount(void) 82 | { 83 | int i; 84 | char mnt[64]; 85 | 86 | for (i = 0; i < DEVMAX; i++) 87 | { 88 | if (mount[i][0] != '\0') 89 | { 90 | sprintf (mnt, "%s:/", mount[i]); 91 | fatUnmount(mnt); 92 | interface[i]->shutdown(); 93 | mount[i][0] = '\0'; 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /addon/neekbooter/source/utils.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | static void *xfb = NULL; 11 | static GXRModeObj *rmode = NULL; 12 | 13 | void green_fix(void) //GREENSCREEN FIX 14 | { 15 | if (xfb == NULL) 16 | { 17 | rmode = VIDEO_GetPreferredMode(NULL); 18 | xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); 19 | } 20 | 21 | VIDEO_Configure(rmode); 22 | VIDEO_SetNextFramebuffer(xfb); 23 | VIDEO_SetBlack(TRUE); 24 | VIDEO_Flush(); 25 | VIDEO_WaitVSync(); 26 | } 27 | 28 | void InitVideo (void) 29 | { 30 | // Initialise the video system 31 | VIDEO_Init(); 32 | 33 | // Obtain the preferred video mode from the system 34 | // This will correspond to the settings in the Wii menu 35 | rmode = VIDEO_GetPreferredMode(NULL); 36 | 37 | // Allocate memory for the display in the uncached region 38 | xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); 39 | 40 | VIDEO_Configure(rmode); 41 | VIDEO_SetNextFramebuffer(xfb); 42 | VIDEO_SetBlack(FALSE); 43 | VIDEO_Flush(); 44 | VIDEO_WaitVSync(); 45 | if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); 46 | 47 | int x, y, w, h; 48 | x = 20; 49 | y = 32; 50 | w = rmode->fbWidth - (32); 51 | h = rmode->xfbHeight - (48); 52 | 53 | CON_InitEx(rmode, x, y, w, h); 54 | 55 | VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK); 56 | 57 | CON_InitEx(rmode, x, y, w, h); 58 | 59 | // Set console text color 60 | printf("\x1b[%u;%um", 37, false); 61 | printf("\x1b[%u;%um", 40, false); 62 | } 63 | 64 | void printd(const char *text, ...) 65 | { 66 | static int geckoinit = 0; 67 | 68 | if (!geckoinit) 69 | { 70 | if (usb_isgeckoalive (EXI_CHANNEL_1)) 71 | geckoinit = 1; 72 | else 73 | geckoinit = -1; 74 | } 75 | 76 | if (geckoinit <= 0) return; 77 | 78 | char buff[1024]; 79 | va_list args; 80 | 81 | va_start(args, text); 82 | vsprintf(buff, text, args); 83 | va_end(args); 84 | 85 | strcat (buff, "\n"); 86 | 87 | usb_sendbuffer( EXI_CHANNEL_1, buff, strlen(buff) ); 88 | usb_flush(EXI_CHANNEL_1); 89 | } 90 | -------------------------------------------------------------------------------- /addon/di/source/utils.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | static void *xfb = NULL; 11 | static GXRModeObj *rmode = NULL; 12 | 13 | void green_fix(void) //GREENSCREEN FIX 14 | { 15 | if (rmode == NULL) 16 | { 17 | VIDEO_Init(); 18 | rmode = VIDEO_GetPreferredMode(NULL); 19 | xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); 20 | } 21 | 22 | VIDEO_Configure(rmode); 23 | VIDEO_SetNextFramebuffer(xfb); 24 | VIDEO_SetBlack(TRUE); 25 | VIDEO_Flush(); 26 | VIDEO_WaitVSync(); 27 | } 28 | 29 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 30 | u8 *ReadFile2Buffer (char *path, size_t *filesize, int *err) 31 | { 32 | u8 *buff = NULL; 33 | int size; 34 | int bytes; 35 | int block = 65536; 36 | FILE* f = NULL; 37 | 38 | if (filesize) *filesize = 0; 39 | if (err) *err = 0; 40 | 41 | f = fopen(path, "rb"); 42 | if (!f) 43 | { 44 | if (err != NULL) *err = -1; 45 | return NULL; 46 | } 47 | 48 | //Get file size 49 | fseek( f, 0, SEEK_END); 50 | size = ftell(f); 51 | if (filesize) *filesize = size; 52 | 53 | if (size <= 0) 54 | { 55 | if (err != NULL) *err = -2; 56 | fclose (f); 57 | return NULL; 58 | } 59 | 60 | // Return to beginning.... 61 | fseek( f, 0, SEEK_SET); 62 | 63 | buff = malloc (size); 64 | if (buff == NULL) 65 | { 66 | if (err != NULL) *err = -3; 67 | fclose (f); 68 | return NULL; 69 | } 70 | 71 | bytes = 0; 72 | do 73 | { 74 | bytes += fread(&buff[bytes], 1, block, f ); 75 | } 76 | while (bytes < size); 77 | 78 | fclose (f); 79 | 80 | return buff; 81 | } 82 | 83 | bool FileExist (char *fn) 84 | { 85 | FILE * f; 86 | f = fopen(fn, "rb"); 87 | if (!f) return FALSE; 88 | fclose(f); 89 | return TRUE; 90 | } 91 | 92 | bool DirExist (char *path) 93 | { 94 | DIR *dir; 95 | 96 | dir=opendir(path); 97 | if (dir) 98 | { 99 | closedir(dir); 100 | return TRUE; 101 | } 102 | 103 | return FALSE; 104 | } 105 | -------------------------------------------------------------------------------- /source/cfg.h: -------------------------------------------------------------------------------- 1 | #ifndef _CFG_ 2 | #define _CFG_ 3 | 4 | #ifndef bool 5 | typedef unsigned int bool; 6 | #endif 7 | 8 | #ifndef u32 9 | typedef unsigned int u32; 10 | #endif 11 | 12 | #ifndef u16 13 | typedef unsigned short u16; 14 | #endif 15 | 16 | #ifndef u8 17 | typedef unsigned char u8; 18 | #endif 19 | 20 | /* 21 | #ifndef s8 22 | typedef char s8; 23 | #endif 24 | */ 25 | #ifndef false 26 | #define false 0 27 | #endif 28 | 29 | #ifndef true 30 | #define true 1 31 | #endif 32 | 33 | #define CFG_READ 0 34 | #define CFG_WRITE 1 35 | 36 | enum 37 | { 38 | CFG_INT=0, 39 | CFG_UINT, 40 | CFG_DOUBLE, 41 | CFG_FLOAT, 42 | CFG_STRING, 43 | CFG_LONG, 44 | CFG_CHAR, 45 | CFG_UCHAR, 46 | CFG_SHORT, 47 | CFG_ENCSTRING, 48 | CFG_U32, 49 | CFG_U16, 50 | CFG_U8, 51 | CFG_S8, 52 | CFG_BOOL 53 | }; 54 | 55 | typedef struct cfg 56 | { 57 | char **tags; // it will contain the data 58 | char **items; // it will contain the data 59 | int count; 60 | int maxcount; // allocated number of items 61 | } 62 | s_cfg; 63 | 64 | char *cfg_FindInBuffer (char *buff, char *tag); 65 | int cfg_Section (char *section); 66 | s_cfg *cfg_Alloc (char *fn, int maxcount, int linebuffsize, int skipinvalid); // If fn is null, it return an empty structure, otherwise... 67 | 68 | bool cfg_Store (s_cfg *c, char *fn); 69 | void cfg_Free (s_cfg *c); // Free allocated config. stuct 70 | void cfg_Empty (s_cfg *c); 71 | 72 | int cfg_FindTag (s_cfg *c, char *tag); // return the pointer to an item 73 | bool cfg_RemoveIndex (s_cfg *cfg, int index); 74 | bool cfg_RemoveTag (s_cfg *cfg, char *tag); 75 | int cfg_GetString (s_cfg *cfg, char *tag, char *string); 76 | int cfg_SetString (s_cfg *cfg, char *tag, char *string); 77 | int cfg_CountSepString (char *buff); 78 | 79 | void cfg_CatFmtString (char *buff, int type, void *data); 80 | bool cfg_GetFmtString (char *buff, int type, void *data, int index); 81 | bool cfg_FmtString (char *buff, int mode, int type, void *data, int index); 82 | 83 | int cfg_Value (s_cfg *cfg, int mode, int type, char *item, void *data, int maxbytes); 84 | int cfg_ValueArray (s_cfg *cfg, int mode, int type, char *item, int idx, void *data, int maxbytes); 85 | 86 | char* cfg_TagFromIndex (s_cfg *cfg, int index, char *tag); 87 | #endif 88 | -------------------------------------------------------------------------------- /source/uneek_fs.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------- 2 | 3 | uneek_fs.H -- USB mass storage support, using a modified uneek fs-usb 4 | 5 | rev. 1.00 first draft 6 | rev. 1.01 second draft 7 | added detection and support for SDHC access in SNEEK 8 | added check_uneek_fs_type function to see if it's sneek or uneek 9 | rev. 1.02 third draft 10 | added the UNEEK_FS_BOTH option to the init_uneek_fs function. 11 | when the parameter is set, both sd and usb access are rerouted to the sd card. 12 | it can only be used with sneek. 13 | the exit_uneek_fs function needs to be called when that setup is used. 14 | since I can't disable usb, not knowing if sd access is still needed, and 15 | I can't disable sd if usb access if sd is still needed. 16 | It's probably exceptional that one will be shutdown and the other still used, 17 | but it's better to stay on the safe area. 18 | 19 | 20 | Copyright (C) 2011 Obcd 21 | 22 | This software is provided 'as-is', without any express or implied 23 | warranty. In no event will the authors be held liable for any 24 | damages arising from the use of this software. 25 | 26 | Permission is granted to anyone to use this software for any 27 | purpose, including commercial applications, and to alter it and 28 | redistribute it freely, subject to the following restrictions: 29 | 30 | 1. The origin of this software must not be misrepresented; you 31 | must not claim that you wrote the original software. If you use 32 | this software in a product, an acknowledgment in the product 33 | documentation would be appreciated but is not required. 34 | 35 | 2. Altered source versions must be plainly marked as such, and 36 | must not be misrepresented as being the original software. 37 | 38 | 3. This notice may not be removed or altered from any source 39 | distribution. 40 | 41 | -------------------------------------------------------------*/ 42 | 43 | #ifndef _UNEEK_FS_H_ 44 | #define _UNEEK_FS_H_ 45 | 46 | #include 47 | #include 48 | 49 | 50 | #define UNEEK_FS_NONE 0 51 | #define UNEEK_FS_USB 1 52 | #define UNEEK_FS_SD 2 53 | #define UNEEK_FS_BOTH 4 54 | 55 | #define ISFS_OPEN_ALL 64 56 | 57 | #ifdef __cplusplus 58 | extern "C" { 59 | #endif //__cplusplus 60 | bool init_uneek_fs(u32 mode); 61 | bool check_uneek_fs(void); 62 | s32 check_uneek_fs_type(void); 63 | bool exit_uneek_fs(void); 64 | #ifdef __cplusplus 65 | } 66 | #endif //__cplusplus 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /addon/di/source/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "disc.h" 12 | #include "patchcode.h" 13 | #include "debug.h" 14 | #include "wdvd.h" 15 | 16 | #define VER "[0.5]" 17 | #define BC 0x0000000100000100ULL 18 | static tikview view ATTRIBUTE_ALIGN(32); 19 | 20 | //void green_fix(void); //GREENSCREEN FIX 21 | 22 | //--------------------------------------------------------------------------------- 23 | int main(int argc, char **argv) 24 | { 25 | VIDEO_Init(); 26 | VIDEO_SetBlack(true); // Disable video output during initialisation 27 | 28 | net_wc24cleanup(); 29 | 30 | if (fatMountSimple("sd", &__io_wiisd)) 31 | DebugStart (true, "sd://ploader.log"); 32 | else 33 | DebugStart (true, NULL); 34 | 35 | configbytes[0] = 0xCD; 36 | //configbytes[0] = 0; 37 | 38 | Debug ("---------------------------------------------------------------------------"); 39 | Debug (" di "VER" by stfour"); 40 | Debug (" (part of postLoader project)"); 41 | Debug ("---------------------------------------------------------------------------"); 42 | 43 | struct discHdr *header; 44 | header = (struct discHdr *)memalign(32, sizeof(struct discHdr)); 45 | 46 | s32 rr = Disc_Init(); 47 | Debug("Disc_Init() returned: %d", rr); 48 | 49 | rr = Disc_Open(); 50 | Debug("Disc_Open() returned: %d", rr); 51 | 52 | // Check disc 53 | rr = Disc_IsGC(); 54 | Debug("Disc_IsGC() returned: %d", rr); 55 | 56 | if (rr == 0) 57 | { 58 | rr = WDVD_ReadDiskId ((void*)0x80000000); 59 | Debug("WDVD_ReadDiskId() returned: %d", rr); 60 | 61 | rr = WDVD_EnableAudio(*(u8*)0x80000008); 62 | Debug("WDVD_EnableAudio() returned: %d", rr); 63 | 64 | *(volatile unsigned int *)0xCC003024 |= 7; 65 | 66 | int retval = ES_GetTicketViews(BC, &view, 1); 67 | 68 | if (retval != 0) 69 | { 70 | Debug("ES_GetTicketViews fail %d", retval); 71 | exit (0); 72 | } 73 | 74 | retval = ES_LaunchTitle(BC, &view); 75 | exit (0); 76 | } 77 | 78 | // Check disc 79 | rr = Disc_IsWii(); 80 | Debug("Disc_IsWii() returned: %d", rr); 81 | 82 | if (rr == 0) 83 | { 84 | // Read header 85 | rr = Disc_ReadHeader(header); 86 | Debug("Disc_ReadHeader() returned: %d", rr); 87 | 88 | Disc_WiiBoot (0, FALSE, TRUE, 0); 89 | } 90 | 91 | exit (0); 92 | } 93 | -------------------------------------------------------------------------------- /source/priiloader.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "debug.h" 10 | 11 | void *allocate_memory(u32 size); 12 | 13 | // This is the minimal required structure 14 | typedef struct { 15 | u32 autoboot; 16 | u32 version; 17 | u32 ReturnTo; 18 | } Settings; 19 | 20 | enum { 21 | AUTOBOOT_DISABLED, 22 | AUTOBOOT_HBC, 23 | AUTOBOOT_BOOTMII_IOS, 24 | AUTOBOOT_SYS, 25 | AUTOBOOT_FILE, 26 | AUTOBOOT_ERROR 27 | }; 28 | enum { 29 | RETURNTO_SYSMENU, 30 | RETURNTO_PRIILOADER, 31 | RETURNTO_AUTOBOOT 32 | }; 33 | 34 | #define VERSION 04 35 | 36 | bool CreatePriiloaderSettings (char *nandpath, u8 * iniBuff, s32 iniSize) 37 | { 38 | if (iniBuff == NULL || iniSize == 0) return false; 39 | 40 | s32 fd; 41 | Settings *settings=(Settings *)iniBuff; 42 | 43 | char path[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); 44 | 45 | sprintf (path, "%s/title/00000001/00000002/data/loader.ini", nandpath); 46 | Debug ("CreatePriiloaderSettings: %s", path); 47 | 48 | settings->autoboot = AUTOBOOT_FILE; 49 | settings->ReturnTo = RETURNTO_AUTOBOOT; 50 | 51 | ISFS_CreateFile(path, 0, 3, 3, 3); 52 | fd = ISFS_Open(path, 1|2 ); 53 | if( fd < 0 ) 54 | { 55 | return false; 56 | } 57 | if(ISFS_Write( fd, iniBuff, iniSize )<0) 58 | { 59 | ISFS_Close( fd ); 60 | return false; 61 | } 62 | ISFS_Close (fd); 63 | Debug ("CreatePriiloaderSettings: ok (%d)!", sizeof( Settings )); 64 | 65 | return true; 66 | } 67 | 68 | // The same of above but used in real nand to configure a neek nand on fs 69 | bool CreatePriiloaderSettingsFS (char *nandpath, u8 * iniBuff, s32 iniSize) 70 | { 71 | if (iniBuff == NULL || iniSize == 0) return false; 72 | 73 | FILE *f; 74 | Settings *settings=(Settings *)iniBuff; 75 | 76 | char path[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); 77 | 78 | sprintf (path, "%s/title/00000001/00000002/data/loader.ini", nandpath); 79 | Debug ("CreatePriiloaderSettings: %s", path); 80 | 81 | settings->autoboot = AUTOBOOT_FILE; 82 | settings->ReturnTo = RETURNTO_AUTOBOOT; 83 | 84 | f = fopen (path, "wb"); 85 | if(!f) 86 | { 87 | return false; 88 | } 89 | if(fwrite( iniBuff, 1, iniSize, f) != iniSize) 90 | { 91 | fclose (f); 92 | return false; 93 | } 94 | fclose (f); 95 | Debug ("CreatePriiloaderSettings: ok (%d)!", sizeof( Settings )); 96 | 97 | return true; 98 | } -------------------------------------------------------------------------------- /source/themes.c: -------------------------------------------------------------------------------- 1 | /* 2 | Themes selection menu 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "wiiload/wiiload.h" 12 | #include "globals.h" 13 | #include "devices.h" 14 | 15 | #define MAXTHEMES 24 16 | #define MAXROW 8 17 | 18 | int ThemeSelect (void) 19 | { 20 | int i, j; 21 | DIR *pdir; 22 | struct dirent *pent; 23 | char path[128], targpath[128]; 24 | char menu[2048]; 25 | char files[MAXTHEMES][64]; 26 | char buff[64]; 27 | char *p; 28 | 29 | sprintf (path, "%s://ploader/themes", vars.defMount); 30 | 31 | *menu = '\0'; 32 | i = 0; 33 | j = 0; 34 | 35 | pdir=opendir(path); 36 | 37 | while ((pent=readdir(pdir)) != NULL) 38 | { 39 | if (strstr (pent->d_name, ".zip")) 40 | { 41 | strcpy (buff, pent->d_name); 42 | strcpy (files[i], buff); 43 | 44 | p = strstr (buff, "."); 45 | if (p) *p = '\0'; 46 | grlib_menuAddItem (menu, i, buff); 47 | 48 | i++; 49 | j++; 50 | 51 | if (j == MAXROW) 52 | { 53 | grlib_menuAddColumn (menu); 54 | j = 0; 55 | } 56 | 57 | if (i == MAXTHEMES) 58 | { 59 | break; 60 | } 61 | } 62 | } 63 | 64 | closedir(pdir); 65 | 66 | if (i == 0) 67 | { 68 | grlib_menu (0, "No themes found in ploader/themes folder", "OK"); 69 | return 0; 70 | } 71 | 72 | int ret = grlib_menu (0, "Please select a theme file\n\nPress (B) to close", menu); 73 | Debug ("themes = %d (%s)", ret, files[ret]); 74 | if (ret < 0) return 0; 75 | 76 | sprintf (targpath, "%s://ploader/theme", vars.defMount); 77 | 78 | fsop_KillFolderTree (targpath, NULL); 79 | fsop_MakeFolder (targpath); 80 | 81 | strcat (path, "/"); 82 | strcat (path, files[ret]); 83 | 84 | Debug ("ZipUnpack = %s", path); 85 | ZipUnpack (path, targpath, NULL, NULL); 86 | 87 | sprintf (targpath, "%s://ploader/theme/ploader.png", vars.defMount); 88 | if (fsop_FileExist (targpath) && devices_Get (DEV_SD)) 89 | { 90 | i = grlib_menu (0, "This theme contain a splash screen\n\nDo you want to install it ?", "Yes##1~No##-1~Remove##0"); 91 | if (i != -1) 92 | unlink ("sd://ploader.png"); 93 | if (i == 1) 94 | { 95 | if (!fsop_CopyFile (targpath, "sd://ploader.png", NULL)) 96 | { 97 | grlib_menu (0, "An error occured copying the splash...", " OK "); 98 | } 99 | } 100 | } 101 | 102 | Video_LoadTheme (0); 103 | Video_LoadTheme (1); 104 | 105 | vars.themeReloaded = 1; 106 | 107 | return 1; 108 | } -------------------------------------------------------------------------------- /addon/priibooter_gui/source/neek2o.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "fsop.h" 12 | #include "debug.h" 13 | #include "../build/bin2o.h" 14 | 15 | 16 | static void DoMini(u8* kbuf, size_t kernel_size) 17 | { 18 | kernel_size +=3; 19 | kernel_size &= 0xFFFFFFFC; 20 | 21 | u8* mini = (u8*) memalign( 32, armboot_bin_size + kernel_size + 4 ); 22 | 23 | if( !mini ) 24 | { 25 | Debug( "Cannot allocate mini buffer %d, %d", armboot_bin_size, kernel_size); 26 | return; 27 | } 28 | Debug( "mini buffer: %p", mini ); 29 | 30 | memcpy( mini, kbuf, kernel_size); 31 | DCFlushRange( mini, kernel_size ); 32 | free(kbuf); 33 | 34 | memcpy( mini+kernel_size+4, armboot_bin, armboot_bin_size ); 35 | DCFlushRange( mini+kernel_size+4, armboot_bin_size ); 36 | 37 | Debug( "armboot.bin copied" ); 38 | *(u32*)0xc150f000 = 0x424d454d; 39 | asm volatile( "eieio" ); 40 | 41 | // physical address for armboot.bin. ( virtualToPhysical() ) 42 | *(u32*)0xc150f004 = MEM_VIRTUAL_TO_PHYSICAL( mini+kernel_size+4 ); 43 | 44 | asm volatile( "eieio" ); 45 | 46 | Debug( "physical memory address: %08x", MEM_VIRTUAL_TO_PHYSICAL( mini ) ); 47 | Debug( "loading bootmii IOS" ); 48 | 49 | // pass position of kernel.bin to mini 50 | *(u32*)0x8132FFF0 = MEM_VIRTUAL_TO_PHYSICAL( mini ); 51 | asm volatile( "eieio" ); 52 | DCFlushRange((void*)0x8132FFF0,4); 53 | 54 | // pass length of kernel.bin to mini 55 | *(u32*)0x8132FFF4 = kernel_size; 56 | asm volatile( "eieio" ); 57 | DCFlushRange((void*)0x8132FFF4,4); 58 | 59 | IOS_ReloadIOS( 0xfe ); 60 | 61 | Debug( "well shit. this shouldnt happen" ); 62 | 63 | free( mini ); 64 | } 65 | 66 | static u8 *kernel = NULL; 67 | static size_t kernelsize = 0; 68 | bool Neek2oLoadKernel (void) 69 | { 70 | char path[256]; 71 | 72 | Debug ("Neek2oLoadKernel: begin"); 73 | 74 | *path = '\0'; 75 | sprintf (path, "usb://sneek/kernel.bin"); 76 | kernel = fsop_ReadFile (path, 0, &kernelsize); 77 | 78 | if (!kernel) 79 | { 80 | sprintf (path, "sd://sneek/kernel.bin"); 81 | kernel = fsop_ReadFile (path, 0, &kernelsize); 82 | } 83 | 84 | Debug ("Neek2oLoadKernel: found on %s (size = %d)", path, kernelsize); 85 | Debug ("Neek2oLoadKernel: end (0x%X)", kernel); 86 | 87 | if (!kernel ) return false; 88 | return true; 89 | } 90 | 91 | bool Neek2oBoot (void) 92 | { 93 | if (!kernel ) return false; 94 | DoMini (kernel, kernelsize); 95 | return true; 96 | } 97 | -------------------------------------------------------------------------------- /source/ios.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define HAVE_AHBPROT ((*(vu32*)0xcd800064 == 0xFFFFFFFF) ? 1 : 0) 12 | #define MEM2_PROT 0x0D8B420A 13 | #define ES_MODULE_START (u16*)0x939F0000 14 | #define HW_DIFLAGS 0x0D800180 15 | 16 | static const u16 ticket_check[] = { 17 | 0x685B, // ldr r3,[r3,#4] ; get TMD pointer 18 | 0x22EC, 0x0052, // movls r2, 0x1D8 19 | 0x189B, // adds r3, r3, r2; add offset of access rights field in TMD 20 | 0x681B, // ldr r3, [r3] ; load access rights (haxxme!) 21 | 0x4698, // mov r8, r3 ; store it for the DVD video bitcheck later 22 | 0x07DB // lsls r3, r3, #31; check AHBPROT bit 23 | }; 24 | 25 | int PatchAHB (void) 26 | { 27 | if (HAVE_AHBPROT) 28 | { 29 | u16 *patchme; 30 | 31 | // Disable memory protection 32 | write16(MEM2_PROT, 2); 33 | 34 | for (patchme=ES_MODULE_START; patchme < ES_MODULE_START+0x4000; patchme++) 35 | { 36 | if (!memcmp(patchme, ticket_check, sizeof(ticket_check))) 37 | { 38 | // write16/uncached poke doesn't work for this. Go figure. 39 | patchme[4] = 0x23FF; // li r3, 0xFF 40 | DCFlushRange(patchme+4, 2); 41 | break; 42 | } 43 | } 44 | 45 | return 1; 46 | } 47 | else 48 | return 0; 49 | } 50 | 51 | int ios_ReloadIOS(int ios, int *ahbprot) 52 | { 53 | int ret; 54 | 55 | #ifdef DOLPHINE 56 | return 0; 57 | #endif 58 | 59 | if (ahbprot != NULL) *ahbprot = 0; 60 | 61 | if (ios > 200) //mmm, just reload it 62 | { 63 | IOS_ReloadIOS(ios); 64 | return ios; 65 | } 66 | 67 | if (ios < 0 || ios > 254) // -1 can be passed to auto choose the preferred 68 | { 69 | ios = IOS_GetPreferredVersion(); 70 | 71 | if (ios <= 9) // mmm... maybe something gones wrong 72 | ios = 58; 73 | } 74 | 75 | /* Enable AHBPROT on title launch */ 76 | ret = PatchAHB(); 77 | if (ret) 78 | { 79 | /* Reload current IOS, typically IOS58 */ 80 | IOS_ReloadIOS(ios); 81 | 82 | if (HAVE_AHBPROT) 83 | { 84 | if (ahbprot != NULL) *ahbprot = 1; 85 | 86 | // Disable memory protection 87 | write16(MEM2_PROT, 2); 88 | mask32(HW_DIFLAGS, 0x200000, 0); 89 | } 90 | 91 | return ios; // Wow, it's works 92 | } 93 | 94 | // mmm... anyway re-load, but ahpbrot will be lost 95 | IOS_ReloadIOS(ios); 96 | 97 | return ios; 98 | } -------------------------------------------------------------------------------- /addon/forwarder/source/ios.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define HAVE_AHBPROT ((*(vu32*)0xcd800064 == 0xFFFFFFFF) ? 1 : 0) 12 | #define MEM2_PROT 0x0D8B420A 13 | #define ES_MODULE_START (u16*)0x939F0000 14 | #define HW_DIFLAGS 0x0D800180 15 | 16 | static const u16 ticket_check[] = { 17 | 0x685B, // ldr r3,[r3,#4] ; get TMD pointer 18 | 0x22EC, 0x0052, // movls r2, 0x1D8 19 | 0x189B, // adds r3, r3, r2; add offset of access rights field in TMD 20 | 0x681B, // ldr r3, [r3] ; load access rights (haxxme!) 21 | 0x4698, // mov r8, r3 ; store it for the DVD video bitcheck later 22 | 0x07DB // lsls r3, r3, #31; check AHBPROT bit 23 | }; 24 | 25 | int PatchAHB (void) 26 | { 27 | if (HAVE_AHBPROT) 28 | { 29 | u16 *patchme; 30 | 31 | // Disable memory protection 32 | write16(MEM2_PROT, 2); 33 | 34 | for (patchme=ES_MODULE_START; patchme < ES_MODULE_START+0x4000; patchme++) 35 | { 36 | if (!memcmp(patchme, ticket_check, sizeof(ticket_check))) 37 | { 38 | // write16/uncached poke doesn't work for this. Go figure. 39 | patchme[4] = 0x23FF; // li r3, 0xFF 40 | DCFlushRange(patchme+4, 2); 41 | break; 42 | } 43 | } 44 | 45 | return 1; 46 | } 47 | else 48 | return 0; 49 | } 50 | 51 | int ios_ReloadIOS(int ios, int *ahbprot) 52 | { 53 | int ret; 54 | 55 | #ifdef DOLPHINE 56 | return 0; 57 | #endif 58 | 59 | if (ahbprot != NULL) *ahbprot = 0; 60 | 61 | if (ios > 200) //mmm, just reload it 62 | { 63 | IOS_ReloadIOS(ios); 64 | return ios; 65 | } 66 | 67 | if (ios < 0 || ios > 254) // -1 can be passed to auto choose the preferred 68 | { 69 | ios = IOS_GetPreferredVersion(); 70 | 71 | if (ios <= 9) // mmm... maybe something gones wrong 72 | ios = 58; 73 | } 74 | 75 | /* Enable AHBPROT on title launch */ 76 | ret = PatchAHB(); 77 | if (ret) 78 | { 79 | /* Reload current IOS, typically IOS58 */ 80 | IOS_ReloadIOS(ios); 81 | 82 | if (HAVE_AHBPROT) 83 | { 84 | if (ahbprot != NULL) *ahbprot = 1; 85 | 86 | // Disable memory protection 87 | write16(MEM2_PROT, 2); 88 | mask32(HW_DIFLAGS, 0x200000, 0); 89 | } 90 | 91 | return ios; // Wow, it's works 92 | } 93 | 94 | // mmm... anyway re-load, but ahpbrot will be lost 95 | IOS_ReloadIOS(ios); 96 | 97 | return ios; 98 | } -------------------------------------------------------------------------------- /addon/priibooter_gui/source/ios.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define HAVE_AHBPROT ((*(vu32*)0xcd800064 == 0xFFFFFFFF) ? 1 : 0) 12 | #define MEM2_PROT 0x0D8B420A 13 | #define ES_MODULE_START (u16*)0x939F0000 14 | #define HW_DIFLAGS 0x0D800180 15 | 16 | static const u16 ticket_check[] = { 17 | 0x685B, // ldr r3,[r3,#4] ; get TMD pointer 18 | 0x22EC, 0x0052, // movls r2, 0x1D8 19 | 0x189B, // adds r3, r3, r2; add offset of access rights field in TMD 20 | 0x681B, // ldr r3, [r3] ; load access rights (haxxme!) 21 | 0x4698, // mov r8, r3 ; store it for the DVD video bitcheck later 22 | 0x07DB // lsls r3, r3, #31; check AHBPROT bit 23 | }; 24 | 25 | int PatchAHB (void) 26 | { 27 | if (HAVE_AHBPROT) 28 | { 29 | u16 *patchme; 30 | 31 | // Disable memory protection 32 | write16(MEM2_PROT, 2); 33 | 34 | for (patchme=ES_MODULE_START; patchme < ES_MODULE_START+0x4000; patchme++) 35 | { 36 | if (!memcmp(patchme, ticket_check, sizeof(ticket_check))) 37 | { 38 | // write16/uncached poke doesn't work for this. Go figure. 39 | patchme[4] = 0x23FF; // li r3, 0xFF 40 | DCFlushRange(patchme+4, 2); 41 | break; 42 | } 43 | } 44 | 45 | return 1; 46 | } 47 | else 48 | return 0; 49 | } 50 | 51 | int ios_ReloadIOS(int ios, int *ahbprot) 52 | { 53 | int ret; 54 | 55 | #ifdef DOLPHINE 56 | return 0; 57 | #endif 58 | 59 | if (ahbprot != NULL) *ahbprot = 0; 60 | 61 | if (ios > 200) //mmm, just reload it 62 | { 63 | IOS_ReloadIOS(ios); 64 | return ios; 65 | } 66 | 67 | if (ios < 0 || ios > 254) // -1 can be passed to auto choose the preferred 68 | { 69 | ios = IOS_GetPreferredVersion(); 70 | 71 | if (ios <= 9) // mmm... maybe something gones wrong 72 | ios = 58; 73 | } 74 | 75 | /* Enable AHBPROT on title launch */ 76 | ret = PatchAHB(); 77 | if (ret) 78 | { 79 | /* Reload current IOS, typically IOS58 */ 80 | IOS_ReloadIOS(ios); 81 | 82 | if (HAVE_AHBPROT) 83 | { 84 | if (ahbprot != NULL) *ahbprot = 1; 85 | 86 | // Disable memory protection 87 | write16(MEM2_PROT, 2); 88 | mask32(HW_DIFLAGS, 0x200000, 0); 89 | } 90 | 91 | return ios; // Wow, it's works 92 | } 93 | 94 | // mmm... anyway re-load, but ahpbrot will be lost 95 | IOS_ReloadIOS(ios); 96 | 97 | return ios; 98 | } -------------------------------------------------------------------------------- /source/zip/ioapi.h: -------------------------------------------------------------------------------- 1 | /* ioapi.h -- IO base function header for compress/uncompress .zip 2 | files using zlib + zip or unzip API 3 | 4 | Version 1.01e, February 12th, 2005 5 | 6 | Copyright (C) 1998-2005 Gilles Vollant 7 | */ 8 | 9 | #ifndef _ZLIBIOAPI_H 10 | #define _ZLIBIOAPI_H 11 | 12 | 13 | #define ZLIB_FILEFUNC_SEEK_CUR (1) 14 | #define ZLIB_FILEFUNC_SEEK_END (2) 15 | #define ZLIB_FILEFUNC_SEEK_SET (0) 16 | 17 | #define ZLIB_FILEFUNC_MODE_READ (1) 18 | #define ZLIB_FILEFUNC_MODE_WRITE (2) 19 | #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) 20 | 21 | #define ZLIB_FILEFUNC_MODE_EXISTING (4) 22 | #define ZLIB_FILEFUNC_MODE_CREATE (8) 23 | 24 | 25 | #ifndef ZCALLBACK 26 | 27 | #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) 28 | #define ZCALLBACK CALLBACK 29 | #else 30 | #define ZCALLBACK 31 | #endif 32 | #endif 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); 39 | typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); 40 | typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); 41 | typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); 42 | typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); 43 | typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); 44 | typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); 45 | 46 | typedef struct zlib_filefunc_def_s 47 | { 48 | open_file_func zopen_file; 49 | read_file_func zread_file; 50 | write_file_func zwrite_file; 51 | tell_file_func ztell_file; 52 | seek_file_func zseek_file; 53 | close_file_func zclose_file; 54 | testerror_file_func zerror_file; 55 | voidpf opaque; 56 | } zlib_filefunc_def; 57 | 58 | 59 | 60 | void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 61 | 62 | #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) 63 | #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) 64 | #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) 65 | #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) 66 | #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) 67 | #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) 68 | 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /source/mem2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "mem2.h" 9 | #include "debug.h" 10 | 11 | static heap_cntrl mem2_heap; 12 | 13 | typedef struct 14 | { 15 | char asciiId[6];// id in ascii format 16 | u64 titleId; // title id 17 | u32 priority; // Vote ! 18 | bool hidden; // if 1, this app will be not listed 19 | 20 | u8 ios; // ios to reload 21 | u8 vmode; // 0 Default Video Mode 1 NTSC480i 2 NTSC480p 3 PAL480i 4 PAL480p 5 PAL576i 6 MPAL480i 7 MPAL480p 22 | s8 language; // -1 Default Language 0 Japanese 1 English 2 German 3 French 4 Spanish 5 Italian 6 Dutch 7 S. Chinese 8 T. Chinese 9 Korean 23 | u8 vpatch; // 0 No Video patches 1 Smart Video patching 2 More Video patching 3 Full Video patching 24 | u8 hook; // 0 No Ocarina&debugger 1 Hooktype: VBI 2 Hooktype: KPAD 3 Hooktype: Joypad 4 Hooktype: GXDraw 5 Hooktype: GXFlush 6 Hooktype: OSSleepThread 7 Hooktype: AXNextFrame 25 | u8 ocarina; // 0 No Ocarina 1 Ocarina from NAND 2 Ocarina from SD 3 Ocarina from USB" 26 | u8 bootMode; // 0 Normal boot method 1 Load apploader 27 | u16 playcount; // how many time this title has bin executed 28 | } 29 | s_channelConfig; 30 | 31 | 32 | u32 InitMem2Manager () 33 | { 34 | int size = (36*1024*1024); 35 | u32 level; 36 | _CPU_ISR_Disable(level); 37 | size &= ~0x1f; // round down, because otherwise we may exceed the area 38 | 39 | gprintf ("InitMem2Manager = 0x%0X %u 0x%0X\r\n", SYS_GetArena2Hi(), size, SYS_GetArena2Hi()-size); 40 | void *mem2_heap_ptr = (void *)((u32)SYS_GetArena2Hi()-size); 41 | SYS_SetArena2Hi(mem2_heap_ptr); 42 | _CPU_ISR_Restore(level); 43 | size = __lwp_heap_init(&mem2_heap, mem2_heap_ptr, size, 32); 44 | return size; 45 | } 46 | 47 | void* mem2_malloc(u32 size) 48 | { 49 | void *ptr; 50 | ptr = __lwp_heap_allocate(&mem2_heap, size); 51 | Debug ("mem2 allocated %u bytes", mem2_getblocksize (ptr)); 52 | return ptr; 53 | } 54 | 55 | bool mem2_free(void *ptr) 56 | { 57 | return __lwp_heap_free(&mem2_heap, ptr); 58 | } 59 | 60 | static __inline__ heap_block* __lwp_heap_blockat(heap_block *block,u32 offset) 61 | { 62 | return (heap_block*)((char*)block + offset); 63 | } 64 | 65 | u32 mem2_getblocksize (void *ptr) 66 | { 67 | heap_block *block; 68 | u32 dsize,level; 69 | 70 | _CPU_ISR_Disable(level); 71 | u32 offset = *(((u32*)ptr)-1); 72 | block = __lwp_heap_blockat(ptr,-offset+-HEAP_BLOCK_USED_OVERHEAD); 73 | dsize = block->front_flag&~HEAP_BLOCK_USED; 74 | _CPU_ISR_Restore(level); 75 | 76 | return dsize; 77 | } 78 | 79 | void *MEM2_lo_alloc(unsigned int s) 80 | { 81 | return malloc(s); 82 | } 83 | 84 | void MEM2_lo_free(void *p) 85 | { 86 | free(p); 87 | } 88 | 89 | void *MEM2_lo_realloc(void *p, unsigned int s) 90 | { 91 | return realloc(p, s); 92 | 93 | } -------------------------------------------------------------------------------- /addon/nandbooter/source/codes/multidol.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file was autogenerated by raw2c. 3 | Visit http://www.devkitpro.org 4 | */ 5 | 6 | const unsigned char multidol[] = { 7 | 0x7f, 0xe8, 0x03, 0xa6, 0x7c, 0x08, 0x02, 0xa6, 0x90, 0x01, 0x00, 0xac, 0x7c, 0x00, 0x00, 0x26, 8 | 0x90, 0x01, 0x00, 0x0c, 0x7c, 0x09, 0x02, 0xa6, 0x90, 0x01, 0x00, 0x10, 0x7c, 0x01, 0x02, 0xa6, 9 | 0x90, 0x01, 0x00, 0x14, 0xbc, 0x61, 0x00, 0x18, 0x3c, 0x60, 0x80, 0x00, 0x60, 0x63, 0x18, 0xa8, 10 | 0x3c, 0xe0, 0x80, 0x00, 0x60, 0xe7, 0x11, 0x98, 0x3e, 0x60, 0x80, 0x00, 0x62, 0x73, 0x11, 0x88, 11 | 0x3e, 0x40, 0x4e, 0x80, 0x62, 0x52, 0x00, 0x20, 0x81, 0xc7, 0x00, 0x04, 0x81, 0xe7, 0x00, 0x08, 12 | 0x82, 0x07, 0x00, 0x0c, 0x82, 0x27, 0x00, 0x00, 0x3c, 0x80, 0x80, 0x00, 0x3c, 0xa0, 0x81, 0x33, 13 | 0x38, 0x84, 0xff, 0xfc, 0x84, 0xc4, 0x00, 0x04, 0x7c, 0x04, 0x28, 0x00, 0x40, 0x80, 0x00, 0x4c, 14 | 0x7c, 0x06, 0x70, 0x00, 0x40, 0x82, 0xff, 0xf0, 0x84, 0xc4, 0x00, 0x04, 0x7c, 0x06, 0x78, 0x00, 15 | 0x40, 0x82, 0xff, 0xe0, 0x84, 0xc4, 0x00, 0x04, 0x7c, 0x06, 0x80, 0x00, 0x40, 0x82, 0xff, 0xd4, 16 | 0x84, 0xc4, 0x00, 0x04, 0x7c, 0x06, 0x88, 0x00, 0x40, 0x82, 0xff, 0xc8, 0x84, 0xc4, 0x00, 0x04, 17 | 0x7c, 0x04, 0x28, 0x00, 0x40, 0x80, 0x00, 0x14, 0x7c, 0x06, 0x90, 0x00, 0x40, 0x82, 0xff, 0xf0, 18 | 0x48, 0x00, 0x00, 0xad, 0x4b, 0xff, 0xff, 0xb0, 0x3c, 0x60, 0x80, 0x00, 0x60, 0x63, 0x10, 0x00, 19 | 0x3e, 0x60, 0x80, 0x00, 0x62, 0x73, 0x11, 0x90, 0x3c, 0xe0, 0x80, 0x00, 0x60, 0xe7, 0x11, 0xa8, 20 | 0x81, 0xc7, 0x00, 0x04, 0x81, 0xe7, 0x00, 0x08, 0x82, 0x07, 0x00, 0x0c, 0x82, 0x27, 0x00, 0x00, 21 | 0x3c, 0x80, 0x80, 0x00, 0x3c, 0xa0, 0x81, 0x40, 0x38, 0x84, 0xff, 0xfc, 0x84, 0xc4, 0x00, 0x04, 22 | 0x7c, 0x04, 0x28, 0x00, 0x40, 0x80, 0x00, 0x38, 0x7c, 0x06, 0x70, 0x00, 0x40, 0x82, 0xff, 0xf0, 23 | 0x84, 0xc4, 0x00, 0x04, 0x7c, 0x06, 0x78, 0x00, 0x40, 0x82, 0xff, 0xe0, 0x84, 0xc4, 0x00, 0x04, 24 | 0x7c, 0x06, 0x80, 0x00, 0x40, 0x82, 0xff, 0xd4, 0x84, 0xc4, 0x00, 0x04, 0x7c, 0x06, 0x88, 0x00, 25 | 0x40, 0x82, 0xff, 0xc8, 0x48, 0x00, 0x00, 0x39, 0x4b, 0xff, 0xff, 0xc4, 0x80, 0x01, 0x00, 0xac, 26 | 0x7c, 0x08, 0x03, 0xa6, 0x80, 0x01, 0x00, 0x0c, 0x7c, 0x0f, 0xf1, 0x20, 0x80, 0x01, 0x00, 0x10, 27 | 0x7c, 0x09, 0x03, 0xa6, 0x80, 0x01, 0x00, 0x14, 0x7c, 0x01, 0x03, 0xa6, 0xb8, 0x61, 0x00, 0x18, 28 | 0x80, 0x01, 0x00, 0x08, 0x38, 0x21, 0x00, 0xa8, 0x48, 0x00, 0x07, 0x50, 0x7e, 0x44, 0x18, 0x50, 29 | 0x3c, 0xc0, 0x48, 0x00, 0x52, 0x46, 0x01, 0xba, 0x90, 0xc4, 0x00, 0x00, 0x90, 0xd3, 0x00, 0x00, 30 | 0x90, 0x93, 0x00, 0x04, 0x7c, 0x00, 0x20, 0xac, 0x7c, 0x00, 0x04, 0xac, 0x7c, 0x00, 0x27, 0xac, 31 | 0x4c, 0x00, 0x01, 0x2c, 0x4e, 0x80, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0xc7, 0x00, 0x4c, 0x7c, 0xe3, 0x3b, 0x78, 33 | 0x38, 0x87, 0x00, 0x34, 0x38, 0xa7, 0x00, 0x38, 0x4e, 0x80, 0x04, 0x20, 0x7c, 0x00, 0x04, 0xac, 34 | 0x4c, 0x00, 0x01, 0x2c, 0x7f, 0xe9, 0x03, 0xa6 35 | }; 36 | const int multidol_size = sizeof(multidol); 37 | -------------------------------------------------------------------------------- /source/plneek.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "globals.h" 6 | 7 | s_plneek *pln; 8 | 9 | bool plneek_GetNandName (void) 10 | { 11 | FILE *f; 12 | 13 | *vars.neekName = '\0'; 14 | 15 | f = fopen (PLNEEK_SDDIR, "rb"); 16 | if (!f) 17 | return FALSE; 18 | 19 | fread (vars.neekName, PLN_NAME_LEN, 1, f); 20 | fclose (f); 21 | 22 | return TRUE; 23 | } 24 | 25 | static bool GetNandDir (void) 26 | { 27 | FILE *f; 28 | 29 | f = fopen (PLNEEK_SDDIR, "rb"); 30 | if (!f) f = fopen (PLNEEK_USBDIR, "rb"); 31 | 32 | if (!f) return FALSE; 33 | 34 | fread (pln, sizeof(s_plneek), 1, f); 35 | fclose (f); 36 | 37 | return TRUE; 38 | } 39 | 40 | static bool WriteDatFile (char *buff) 41 | { 42 | FILE *f; 43 | 44 | f = fopen (PLNEEK_SDDAT, "wb"); 45 | if (!f) f = fopen (PLNEEK_USBDAT, "wb"); 46 | 47 | if (!f) return FALSE; 48 | 49 | fwrite (buff, strlen(buff)+1, 1, f); // Add 0 term 50 | fclose (f); 51 | 52 | return TRUE; 53 | } 54 | 55 | bool plneek_ShowMenu (void) 56 | { 57 | char *menu; 58 | char path[64]; 59 | 60 | pln = calloc (sizeof(s_plneek), 1); 61 | 62 | menu = calloc (2048, 1); 63 | 64 | int gnd = GetNandDir (); 65 | if (!gnd || pln->nandsCnt == 0) 66 | { 67 | *menu = '\0'; 68 | grlib_menuAddItem (menu, 0, "Continue"); 69 | 70 | char title[300]; 71 | sprintf (title, 72 | "Cannot open "PLNEEK_SDDIR"\n\nUNEEK nands folder must be\nin usb://nands\n\nOr plneek.dol isn't in sd root\nor priibooter.dol isn't updated (%d,%d)", 73 | gnd, pln->nandsCnt); 74 | 75 | grlib_menu (0, title, menu); 76 | 77 | free (menu); 78 | free (pln); 79 | return FALSE; 80 | } 81 | 82 | // Ok... we can compose the menu' with nand voices 83 | int i, id, ret; 84 | 85 | id = 100; 86 | *menu = '\0'; 87 | 88 | for (i = 0; i < pln->nandsCnt; i++) 89 | { 90 | if (pln->nands[i].count) 91 | { 92 | grlib_menuAddItem (menu, id, pln->nands[i].path); 93 | } 94 | id++; 95 | } 96 | 97 | grlib_menuAddSeparator (menu); 98 | 99 | grlib_menuAddItem (menu, 0, "Cancel"); 100 | 101 | ret = grlib_menu (0, "Please select your folder", menu); 102 | 103 | *path = '\0'; 104 | if (ret >= 100) 105 | { 106 | sprintf (path, pln->nands[ret-100].path); 107 | if (WriteDatFile (path)) 108 | { 109 | char buff[300]; 110 | 111 | sprintf (buff, "Your new NAND is selected\n\nWII Will now reboot\nNAND: %s", path); 112 | grlib_menu (0, buff, "OK"); 113 | 114 | Shutdown (); 115 | SYS_ResetSystem(SYS_RESTART,0,0); 116 | } 117 | else 118 | { 119 | grlib_menu (0, "There was an error updating "PLNEEK_SDDAT, "OK"); 120 | } 121 | } 122 | 123 | free (menu); 124 | free (pln); 125 | 126 | // Let's save back 127 | 128 | 129 | return TRUE; 130 | } -------------------------------------------------------------------------------- /addon/priibooter_gui/source/grlib/grlib_theme.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "grlib.h" 3 | 4 | static void CheckForTile (GRRLIB_texImg * tex) 5 | { 6 | if (!tex->tiledtex) 7 | { 8 | int w = tex->w / 3; 9 | int h = tex->h / 3; 10 | 11 | GRRLIB_InitTileSet (tex, w, h, 0); 12 | } 13 | } 14 | 15 | /* TILES LAYOUT 16 | 17 | |---|---|---| 18 | | 0 | 1 | 2 | 19 | |---|---|---| 20 | | 3 | 4 | 5 | 21 | |---|---|---| 22 | | 6 | 7 | 8 | 23 | |---|---|---| 24 | 25 | */ 26 | 27 | // magpx/y allow to expand image... 28 | // flag is for future use 29 | // tex is the tiled texture 30 | // texbk is the background texture... can be NULL, otherwise it will be used to fill the square... 31 | 32 | void grlib_DrawSquareThemed ( s_grlibobj *b, GRRLIB_texImg * tex, GRRLIB_texImg * texbk, int magx, int magy, u32 flag) 33 | { 34 | if (tex == NULL) return; 35 | 36 | f32 tw, th; 37 | s_grlibobj gb; 38 | 39 | CheckForTile (tex); 40 | 41 | grlib_MagObject (&gb, b, magx, magy); 42 | 43 | tw = tex->tilew; 44 | th = tex->tileh; 45 | 46 | // Upper left 47 | grlib_DrawTile (gb.x1, gb.y1, tw, th, tex, 0, RGBA (255,255,255,255), 0); 48 | // Upper right 49 | grlib_DrawTile (gb.x2-tw, gb.y1, tw, th, tex, 0, RGBA (255,255,255,255), 2); 50 | // Upper center 51 | grlib_DrawTile (gb.x1+tw, gb.y1, gb.x2-gb.x1 - (tw*2.0), th, tex, 0, RGBA (255,255,255,255), 1); 52 | 53 | // Lower left 54 | grlib_DrawTile (gb.x1, gb.y2-th, tw, th, tex, 0, RGBA (255,255,255,255), 6); 55 | // Lower right 56 | grlib_DrawTile (gb.x2-tw, gb.y2-th, tw, th, tex, 0, RGBA (255,255,255,255), 8); 57 | // Lower center 58 | grlib_DrawTile (gb.x1+tw, gb.y2-th, gb.x2-gb.x1 - (tw*2.0), th, tex, 0, RGBA (255,255,255,255), 7); 59 | 60 | // center left 61 | grlib_DrawTile (gb.x1, gb.y1+th, tw, gb.y2-gb.y1 - (th*2.0), tex, 0, RGBA (255,255,255,255), 3); 62 | // center right 63 | grlib_DrawTile (gb.x2-tw, gb.y1+th, tw, gb.y2-gb.y1 - (th*2.0), tex, 0, RGBA (255,255,255,255), 5); 64 | 65 | // center/center 66 | if (texbk == NULL) 67 | grlib_DrawTile (gb.x1+tw, gb.y1+th, gb.x2-gb.x1 - (tw*2.0), gb.y2-gb.y1 - (th*2.0), tex, 0, RGBA (255,255,255,255), 4); 68 | else 69 | { 70 | // Applichiamo la texture come sfondo 71 | 72 | int tbw, tbh; 73 | int bx, by, bw, bh; 74 | 75 | if (flag == DSTF_BKFILLBORDER) 76 | { 77 | bx = gb.x1+1; 78 | by = gb.y1+th; 79 | bw = gb.x2 - gb.x1 - 2; 80 | bh = gb.y2-gb.y1 - (th*2.0)+1; 81 | } 82 | else 83 | { 84 | bx = gb.x1+tw; 85 | by = gb.y1+th; 86 | bw = gb.x2-gb.x1 - (tw*2.0)+1; 87 | bh = gb.y2-gb.y1 - (th*2.0)+1; 88 | } 89 | 90 | if (texbk->w > bw) 91 | tbw = bw; 92 | else 93 | tbw = texbk->w; 94 | 95 | if (texbk->h > bh) 96 | tbh = bh; 97 | else 98 | tbh = texbk->h; 99 | 100 | grlib_DrawPart (bx, by, bw, bh, 0, 0, tbw, tbh, texbk, 0, RGBA (255,255,255,255)); 101 | } 102 | 103 | 104 | } 105 | 106 | -------------------------------------------------------------------------------- /source/sicksaxis-wrapper/sicksaxis-wrapper.c: -------------------------------------------------------------------------------- 1 | // A simple wrapper for libsicksaxis, to make it resemble WPAD/PAD more closely. 2 | // Written by daxtsu/thedax. I'm releasing this code into the public domain, so do whatever you want with it. 3 | 4 | #include 5 | #include "sicksaxis-wrapper.h" 6 | 7 | static DS3 first = { { 0 } }; 8 | static bool psPressed = false; 9 | 10 | bool DS3_Init() 11 | { 12 | USB_Initialize(); 13 | 14 | if (ss_init() < 0) 15 | { 16 | return false; 17 | } 18 | 19 | ss_initialize(&first); 20 | 21 | return true; 22 | } 23 | 24 | void DS3_Rumble() 25 | { 26 | if (first.connected && psPressed) 27 | { 28 | ss_set_rumble(&first, 2, 255, 2, 255); 29 | } 30 | } 31 | 32 | void DS3_Cleanup() 33 | { 34 | psPressed = false; 35 | ss_close(&first); 36 | USB_Deinitialize(); 37 | } 38 | 39 | unsigned int DS3_ButtonsDown() 40 | { 41 | if (!ss_is_connected(&first) || !psPressed) 42 | return 0; 43 | 44 | DS3 *controller; 45 | controller = &first; 46 | 47 | unsigned int pressed = 0; 48 | 49 | pressed |= controller->pad.buttons.PS ? DS3_BUTTON_PS : 0; 50 | pressed |= controller->pad.buttons.start ? DS3_BUTTON_START : 0; 51 | pressed |= controller->pad.buttons.select ? DS3_BUTTON_SELECT : 0; 52 | pressed |= controller->pad.buttons.triangle ? DS3_BUTTON_TRIANGLE : 0; 53 | pressed |= controller->pad.buttons.circle ? DS3_BUTTON_CIRCLE : 0; 54 | pressed |= controller->pad.buttons.cross ? DS3_BUTTON_CROSS : 0; 55 | pressed |= controller->pad.buttons.square ? DS3_BUTTON_SQUARE : 0; 56 | pressed |= controller->pad.buttons.up ? DS3_BUTTON_UP : 0; 57 | pressed |= controller->pad.buttons.right ? DS3_BUTTON_RIGHT : 0; 58 | pressed |= controller->pad.buttons.down ? DS3_BUTTON_DOWN : 0; 59 | pressed |= controller->pad.buttons.left ? DS3_BUTTON_LEFT : 0; 60 | pressed |= controller->pad.buttons.L1 ? DS3_BUTTON_L1 : 0; 61 | pressed |= controller->pad.buttons.L2 ? DS3_BUTTON_L2 : 0; 62 | pressed |= controller->pad.buttons.L3 ? DS3_BUTTON_L3 : 0; 63 | pressed |= controller->pad.buttons.R1 ? DS3_BUTTON_R1 : 0; 64 | pressed |= controller->pad.buttons.R2 ? DS3_BUTTON_R2 : 0; 65 | pressed |= controller->pad.buttons.R3 ? DS3_BUTTON_R3 : 0; 66 | 67 | return pressed; 68 | } 69 | 70 | bool DS3_Connected() 71 | { 72 | return first.connected > 0 && psPressed; 73 | } 74 | 75 | void DS3_ScanPads() 76 | { 77 | if (!ss_is_connected(&first)) 78 | { 79 | psPressed = false; 80 | ss_initialize(&first); 81 | if (ss_open(&first) > 0) 82 | { 83 | ss_start_reading(&first); 84 | ss_set_led(&first, 0); 85 | } 86 | } 87 | else if (first.pad.buttons.PS && !psPressed) 88 | { 89 | psPressed = true; 90 | ss_set_led(&first, 1); 91 | } 92 | } 93 | 94 | int DS3_StickX() 95 | { 96 | return psPressed? first.pad.left_analog.x - 128 : 0; 97 | } 98 | 99 | int DS3_SubStickX() 100 | { 101 | return psPressed? first.pad.right_analog.x - 128 : 0; 102 | } 103 | 104 | int DS3_StickY() 105 | { 106 | return psPressed? first.pad.left_analog.y - 128 : 0; 107 | } 108 | 109 | int DS3_SubStickY() 110 | { 111 | return psPressed? first.pad.right_analog.y - 128 : 0; 112 | } 113 | -------------------------------------------------------------------------------- /source/grlib/grlib_theme.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "grlib.h" 3 | 4 | static void CheckForTile (GRRLIB_texImg * tex) 5 | { 6 | if (!tex->tiledtex) 7 | { 8 | int w = tex->w / 3; 9 | int h = tex->h / 3; 10 | 11 | GRRLIB_InitTileSet (tex, w, h, 0); 12 | } 13 | } 14 | 15 | /* TILES LAYOUT 16 | 17 | |---|---|---| 18 | | 0 | 1 | 2 | 19 | |---|---|---| 20 | | 3 | 4 | 5 | 21 | |---|---|---| 22 | | 6 | 7 | 8 | 23 | |---|---|---| 24 | 25 | */ 26 | 27 | // magpx/y allow to expand image... 28 | // flag is for future use 29 | // tex is the tiled texture 30 | // texbk is the background texture... can be NULL, otherwise it will be used to fill the square... 31 | 32 | void grlib_DrawSquareThemed ( s_grlibobj *b, GRRLIB_texImg * tex, GRRLIB_texImg * texbk, f32 magx, f32 magy, u32 flag, u8 transparency) 33 | { 34 | if (tex == NULL) return; 35 | 36 | f32 tw, th; 37 | s_grlibobj gb; 38 | 39 | CheckForTile (tex); 40 | 41 | grlib_MagObject (&gb, b, magx, magy); 42 | 43 | tw = tex->tilew; 44 | th = tex->tileh; 45 | 46 | // Upper left 47 | grlib_DrawTile (gb.x1, gb.y1, tw, th, tex, 0, RGBA (255,255,255,transparency), 0); 48 | // Upper right 49 | grlib_DrawTile (gb.x2-tw, gb.y1, tw, th, tex, 0, RGBA (255,255,255,transparency), 2); 50 | // Upper center 51 | grlib_DrawTile (gb.x1+tw, gb.y1, gb.x2-gb.x1 - (tw*2.0), th, tex, 0, RGBA (255,255,255,transparency), 1); 52 | 53 | // Lower left 54 | grlib_DrawTile (gb.x1, gb.y2-th, tw, th, tex, 0, RGBA (255,255,255,transparency), 6); 55 | // Lower right 56 | grlib_DrawTile (gb.x2-tw, gb.y2-th, tw, th, tex, 0, RGBA (255,255,255,transparency), 8); 57 | // Lower center 58 | grlib_DrawTile (gb.x1+tw, gb.y2-th, gb.x2-gb.x1 - (tw*2.0), th, tex, 0, RGBA (255,255,255,transparency), 7); 59 | 60 | // center left 61 | grlib_DrawTile (gb.x1, gb.y1+th, tw, gb.y2-gb.y1 - (th*2.0), tex, 0, RGBA (255,255,255,transparency), 3); 62 | // center right 63 | grlib_DrawTile (gb.x2-tw, gb.y1+th, tw, gb.y2-gb.y1 - (th*2.0), tex, 0, RGBA (255,255,255,transparency), 5); 64 | 65 | // center/center 66 | if (texbk == NULL) 67 | grlib_DrawTile (gb.x1+tw, gb.y1+th, gb.x2-gb.x1 - (tw*2.0), gb.y2-gb.y1 - (th*2.0), tex, 0, RGBA (255,255,255,transparency), 4); 68 | else 69 | { 70 | // Applichiamo la texture come sfondo 71 | 72 | f32 tbw, tbh; 73 | f32 bx, by, bw, bh; 74 | 75 | if (flag == DSTF_BKFILLBORDER) 76 | { 77 | //gprintf ("#1"); 78 | bx = gb.x1+1; 79 | by = gb.y1+th; 80 | bw = gb.x2 - gb.x1 - 2; 81 | bh = gb.y2-gb.y1 - (th*2.0)+1; 82 | } 83 | else 84 | { 85 | //Ugprintf ("#2"); 86 | bx = gb.x1+tw; 87 | by = gb.y1+th; 88 | bw = gb.x2-gb.x1 - (tw*2.0); 89 | bh = gb.y2-gb.y1 - (th*2.0); 90 | } 91 | 92 | if (texbk->w > bw) 93 | tbw = bw; 94 | else 95 | tbw = texbk->w; 96 | 97 | if (texbk->h > bh) 98 | tbh = bh; 99 | else 100 | tbh = texbk->h; 101 | 102 | grlib_DrawPart (bx, by, bw, bh, 0, 0, tbw, tbh, texbk, 0, RGBA (255,255,255,transparency)); 103 | } 104 | 105 | 106 | } 107 | 108 | -------------------------------------------------------------------------------- /source/runloader.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "globals.h" 7 | #include "bin2o.h" 8 | #include "neek.h" 9 | 10 | extern void __exception_closeall(); 11 | bool SetupNeek2o (void); 12 | 13 | static void PrepareNeek2o(void) 14 | { 15 | char target[256]; 16 | 17 | SetupNeek2o (); 18 | 19 | // Create configuration file for n2oswitch ... 20 | u32 data[8]; 21 | data[0] = 0; 22 | data[1] = PLNANDSTATUS_NONE; 23 | data[2] = 0; 24 | data[3] = 0; 25 | data[4] = 1; // Force return to real 26 | sprintf (target, "%s/nandcfg.pl", NEEK2O_SNEEK); 27 | fsop_WriteFile (target, (u8*) data, sizeof(data)); 28 | 29 | // Boot neek2o 30 | Neek2oLoadKernel (); 31 | Shutdown (); 32 | Neek2oBoot (); 33 | } 34 | 35 | void RunLoader(void) 36 | { 37 | char argb[300]; 38 | char part[32]; 39 | 40 | if (config.run.game.loader == 3) // NEEK2O 41 | { 42 | //neek_CreateCDIConfig (config.run.asciiId); 43 | if (neek_ReadAndSelectCDIGame (config.run.asciiId)) 44 | PrepareNeek2o (); 45 | else 46 | { 47 | grlib_menu (0, "The game was not found in diconfig.bin.\nRun neek2o once to update gamelist and try again\npostLoader will now try to reload or reset your WII", "OK"); 48 | 49 | ReloadPostloader (); 50 | 51 | Shutdown (); 52 | SYS_ResetSystem(SYS_RESTART,0,0); 53 | } 54 | } 55 | 56 | if (config.run.neekSlot < 10) 57 | sprintf (part, "FAT%d", config.run.neekSlot + 1); 58 | else 59 | sprintf (part, "NTFS%d", config.run.neekSlot - 10 + 1); 60 | 61 | int ios; 62 | if (config.run.game.ios == 0) ios = 249; 63 | if (config.run.game.ios == 1) ios = 250; 64 | if (config.run.game.ios == 2) ios = 222; 65 | if (config.run.game.ios == 3) ios = 223; 66 | if (config.run.game.ios == 4) ios = 248; 67 | if (config.run.game.ios == 5) ios = 251; 68 | if (config.run.game.ios == 6) ios = 252; 69 | 70 | if (config.run.game.loader == 0) // CFG 71 | { 72 | sprintf (argb, "%s;partition=%s;intro=0;theme=pl;ios=%d", config.run.asciiId, part, ios); 73 | 74 | DirectDolBoot ("sd://apps/USBLoader/boot.dol", argb, 0); 75 | DirectDolBoot ("sd://apps/USBLoader_cfg/boot.dol", argb, 0); 76 | DirectDolBoot ("usb://apps/USBLoader/boot.dol", argb, 0); 77 | DirectDolBoot ("usb://apps/USBLoader_cfg/boot.dol", argb, 0); 78 | } 79 | if (config.run.game.loader == 1) // GX 80 | { 81 | sprintf (argb, "%s;ios=%d", config.run.asciiId, ios); 82 | 83 | DirectDolBoot ("sd://apps/usbloader_gx/boot.dol", argb, 0); 84 | DirectDolBoot ("usb://apps/usbloader_gx/boot.dol", argb, 0); 85 | } 86 | if (config.run.game.loader == 2) // WF 87 | { 88 | sprintf (argb, "%s;ios=%d", config.run.asciiId, ios); 89 | 90 | DirectDolBoot ("sd://apps/wiiflow/boot.dol", argb, 0); 91 | DirectDolBoot ("usb://apps/wiiflow/boot.dol", argb, 0); 92 | } 93 | 94 | grlib_menu (0, "The selected loader wasn't found.\npostLoader will now try to reload or reset your WII", "OK"); 95 | 96 | ReloadPostloader (); 97 | 98 | Shutdown (); 99 | SYS_ResetSystem(SYS_RESTART,0,0); 100 | } -------------------------------------------------------------------------------- /source/io.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include //for mkdir 5 | #include 6 | #include 7 | #include "usbstorage.h" 8 | #include "globals.h" 9 | #include "devices.h" 10 | 11 | bool CheckForPostLoaderFolders (void) 12 | { 13 | char path[PATHMAX]; 14 | 15 | sprintf (path, "%s://ploader",vars.defMount); 16 | if (!fsop_DirExist (path)) 17 | { 18 | if (!fsop_MakeFolder (path)) return FALSE; 19 | } 20 | 21 | sprintf (path, "%s://ploader/covers",vars.defMount); 22 | if (!fsop_DirExist (path)) 23 | { 24 | if (!fsop_MakeFolder (path)) return FALSE; 25 | } 26 | 27 | sprintf (path, "%s://ploader/covers.emu",vars.defMount); 28 | if (!fsop_DirExist (path)) 29 | { 30 | if (!fsop_MakeFolder (path)) return FALSE; 31 | } 32 | 33 | sprintf (path, "%s://ploader/config",vars.defMount); 34 | if (!fsop_DirExist (path)) 35 | { 36 | if (!fsop_MakeFolder (path)) return FALSE; 37 | } 38 | 39 | // If temp folder exist, clean it on sturtup 40 | sprintf (path, "%s://ploader/temp",vars.defMount); 41 | if (fsop_DirExist (path)) 42 | { 43 | fsop_KillFolderTree (path, NULL); 44 | } 45 | fsop_MakeFolder(path); 46 | 47 | return TRUE; 48 | } 49 | 50 | bool SetDefMount (int dev) 51 | { 52 | if (devices_Get (dev)) 53 | { 54 | strcpy (vars.defMount, devices_Get (dev)); 55 | return true; 56 | } 57 | 58 | return false; 59 | } 60 | 61 | static int cbsilent = 0; 62 | static int cb_Mount (void) 63 | { 64 | int ret = 0; 65 | char buff[128]; 66 | 67 | gprintf ("cb_Mount\n"); 68 | 69 | if (vars.interactive) 70 | sprintf (buff, "Waiting for USB device - (B) interrupt..."); 71 | else 72 | sprintf (buff, "Waiting for USB device - (A) interactive (B) interrupt..."); 73 | 74 | if (!cbsilent) ret = MasterInterface (0, 0, 1, buff); 75 | 76 | if (ret == 1) vars.interactive = 1; 77 | if (ret == 2) return 0; // this cause mount routine to stop. 78 | 79 | return 1; 80 | } 81 | 82 | bool MountDevices (bool silent) 83 | { 84 | cbsilent = silent; 85 | 86 | if (vars.ios > 200 || vars.neek == NEEK_USB) 87 | devices_Mount (DEVMODE_CIOSX, 0 /*vars.neek*/, vars.usbtime, cb_Mount); 88 | else 89 | devices_Mount (DEVMODE_IOS, 0 /*vars.neek*/, vars.usbtime, cb_Mount); 90 | 91 | bool cfgSD = false, cfgUSB = false; 92 | 93 | // First try to mount SD 94 | if (devices_Get (DEV_SD)) 95 | { 96 | // Try to load configuration file... maybe a user have choosen to use the SD as primary device for postLoader 97 | SetDefMount (DEV_SD); 98 | cfgSD = ConfigRead (); 99 | } 100 | 101 | // Contine with next device 102 | if (!extConfig.disableUSB) 103 | { 104 | if (devices_Get (DEV_USB) && !cfgSD) 105 | { 106 | SetDefMount (DEV_USB); 107 | cfgUSB = ConfigRead (); 108 | } 109 | } 110 | 111 | if (cfgSD || cfgUSB) // we have a valid device 112 | return TRUE; 113 | 114 | return false; 115 | } 116 | 117 | bool UnmountDevices (void) 118 | { 119 | Debug ("UnmountDevices()"); 120 | devices_Unmount (); 121 | return true; 122 | } -------------------------------------------------------------------------------- /meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | postLoader 4 | 4.7.96 5 | 20150422000000 6 | stfour 7 | Homebrew browser, channel launcher, neek2o disc loader 8 | ------------------- 9 | What postLoader is: 10 | ------------------- 11 | * HomeBrew Browser with subfolder and xml support 12 | * Channel\Title\Emus\Games Browser with filters and cover 13 | * neek2o and Uneek+DI game browser with cover support 14 | * game loaders forwarder (for CFG, GX and WiiFlow) with cover and filters support 15 | * DML gamecube browser with USB to SD copy feature 16 | * Themable user interface 17 | * Wiiload server 18 | * Emulators forwarder 19 | 20 | ------------------- 21 | Features: 22 | ------------------- 23 | 24 | General: 25 | * If started from priiloader it gains AHPBROT and spawn full hardware rights to homebrew applications 26 | * Autoboot your default application\channel: If you don't press (A) in time to enter in interactive mode, postLoader will launch the predefined app (if enabled) 27 | * Direct access to BOOTMII 28 | * Support costom splash screen (only from SD device) 29 | * Full support for UNEEK environment. May work under SNEEK 30 | * Support for Wiimote and GC controllers 31 | * Intergrated UNEEK nand switcher 32 | * wiiload update: If you send postLoader.dol via wiiload, postloader installation will be updated (after confirmation). 33 | 34 | oneek2o advanced support 35 | * USB Access for HOMEBREW (see historii.txt for important notices) 36 | * Multiple nand support for different region games 37 | * Built in game cache rebuilder (partially implemented, see historii.txt) 38 | 39 | Uneek+DI game browser (see historii.txt) 40 | * Support covers 41 | * Support title vote 42 | 43 | USB Loaders forwarder 44 | * Support cfg, gx and wiiflow (actually wiiflow crash) 45 | * Support covers 46 | * Support title vote 47 | * Support ios selection 48 | 49 | DML / Nintendont / Devolution Gamecube games 50 | * Support covers 51 | * Support title vote 52 | * Support ios selection 53 | * Can copy games from USB to SD before execute them 54 | 55 | Homebrew: 56 | * HB Channel replacement: It can be used to browse homebrew application, with it own interface. 57 | * Dangerous homebrews can be hidden 58 | * Full support for meta.xml arguments and all other tags. 59 | * It support subfolders (see notes) 60 | * Can browse SD and USB device (FAT32 on first\active partition) 61 | * WiiLoad support (straight, compressed dol, zip archieve) 62 | 63 | Channels: 64 | * Nand emulation (ciosx\waninkoko on slot 249) 65 | * AHBPROT is need for real nand browsing (otherwise ios249 is used) 66 | * Wii System Channel replacemente: Can browse and run Channels, WiiWare and VC. 67 | * Can run Titles from real and emulated NAND on SD or USB with folder support 68 | * Titles can be sorted voted and\or hiddened 69 | * Support interactive application sorting 70 | * Sort titles by vote\name 71 | * Titles filters (System channels\wiiware\neogeo\c64... etc) 72 | * Fast titles search 73 | * Download title icons from wiitdb 74 | * Alternate nand folder support (other that classic root) 75 | 76 | -------------------------------------------------------------------------------- /source/dns.c: -------------------------------------------------------------------------------- 1 | #include "dns.h" 2 | 3 | /** 4 | * Resolves a domainname to an ip address 5 | * It makes use of net_gethostbyname from libogc, which in turn makes use of a Wii BIOS function 6 | * Just like the net_gethostbyname function this function is NOT threadsafe! 7 | * 8 | * @param char* The domain name to resolve 9 | * @return u32 The ipaddress represented by four bytes inside an u32 (in network order) 10 | */ 11 | u32 getipbyname(char *domain) 12 | { 13 | //Care should be taken when using net_gethostbyname, 14 | //it returns a static buffer which makes it not threadsafe 15 | //TODO: implement some locking mechanism to make below code atomic 16 | struct hostent *host = net_gethostbyname(domain); 17 | 18 | if(host == NULL) { 19 | return 0; 20 | } 21 | 22 | u32 *ip = (u32*)host->h_addr_list[0]; 23 | return *ip; 24 | } 25 | 26 | 27 | 28 | //Defines how many DNS entries should be cached by getipbynamecached() 29 | #define MAX_DNS_CACHE_ENTRIES 20 30 | 31 | //The cache is defined as a linked list, 32 | //The last resolved domain name will always be at the front 33 | //This will allow heavily used domainnames to always stay cached 34 | struct dnsentry { 35 | char *domain; 36 | u32 ip; 37 | struct dnsentry *nextnode; 38 | } ; 39 | 40 | static struct dnsentry *firstdnsentry = NULL; 41 | static int dnsentrycount = 0; 42 | 43 | /** 44 | * Performs the same function as getipbyname(), 45 | * except that it will prevent extremely expensive net_gethostbyname() calls by caching the result 46 | */ 47 | u32 getipbynamecached(char *domain) 48 | { 49 | //Search if this domainname is already cached 50 | struct dnsentry *node = firstdnsentry; 51 | struct dnsentry *previousnode = NULL; 52 | 53 | while(node != NULL) 54 | { 55 | if(strcmp(node->domain, domain) == 0) 56 | { 57 | //DNS node found in the cache, move it to the front of the list 58 | if(previousnode != NULL) 59 | previousnode->nextnode = node->nextnode; 60 | 61 | if(node != firstdnsentry) 62 | node->nextnode = firstdnsentry; 63 | firstdnsentry = node; 64 | 65 | return node->ip; 66 | } 67 | //Go to the next element in the list 68 | previousnode = node; 69 | node = node->nextnode; 70 | } 71 | u32 ip = getipbyname(domain); 72 | 73 | //No cache of this domain could be found, create a cache node and add it to the front of the cache 74 | struct dnsentry *newnode = malloc(sizeof(struct dnsentry)); 75 | if(newnode == NULL) { 76 | return ip; 77 | } 78 | 79 | newnode->ip = ip; 80 | newnode->domain = malloc(strlen(domain)+1); 81 | if(newnode->domain == NULL) 82 | { 83 | free(newnode); 84 | return ip; 85 | } 86 | strcpy(newnode->domain, domain); 87 | 88 | newnode->nextnode = firstdnsentry; 89 | firstdnsentry = newnode; 90 | dnsentrycount++; 91 | 92 | //If the cache grows too big delete the last (and probably least important) node of the list 93 | if(dnsentrycount > MAX_DNS_CACHE_ENTRIES) 94 | { 95 | struct dnsentry *node = firstdnsentry; 96 | struct dnsentry *previousnode = NULL; 97 | 98 | //Fetch the last two elements of the list 99 | while(node->nextnode != NULL) 100 | { 101 | previousnode = node; 102 | node = node->nextnode; 103 | } 104 | 105 | if(node == NULL) 106 | { 107 | printf("Configuration error, MAX_DNS_ENTRIES reached while the list is empty\n"); 108 | exit(1); 109 | } else if(previousnode == NULL) 110 | { 111 | firstdnsentry = NULL; 112 | } else { 113 | previousnode->nextnode = NULL; 114 | } 115 | 116 | free(node->domain); 117 | free(node); 118 | dnsentrycount--; 119 | } 120 | 121 | return newnode->ip; 122 | } 123 | -------------------------------------------------------------------------------- /addon/di/source/debug.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /* 9 | 10 | Debug, will write debug information to sd and/or gecko.... as debug file is open/closed it will be VERY SLOW 11 | 12 | */ 13 | 14 | #define DEBUG_MAXCACHE 32 15 | static char dbgfile[64]; 16 | static char *cache[DEBUG_MAXCACHE]; 17 | 18 | static int started = 0; 19 | static int filelog = 0; 20 | static int geckolog = 0; 21 | 22 | s32 DebugStart (bool gecko, char *fn) 23 | { 24 | filelog = 0; 25 | started = 0; 26 | 27 | sprintf (dbgfile, fn); 28 | 29 | geckolog = usb_isgeckoalive (EXI_CHANNEL_1); 30 | 31 | // check if the file exist 32 | FILE * f = NULL; 33 | f = fopen(dbgfile, "rb"); 34 | if (f) 35 | { 36 | filelog = 1; 37 | fclose (f); 38 | } 39 | 40 | memset (cache, 0, sizeof(cache)); 41 | 42 | if (filelog || geckolog) 43 | started = 1; 44 | 45 | return started; 46 | } 47 | 48 | void DebugStop (void) 49 | { 50 | filelog = 0; 51 | started = 2; 52 | } 53 | 54 | void Debug (const char *text, ...) 55 | { 56 | if (!started || text == NULL) return; 57 | 58 | int i; 59 | char mex[1024]; 60 | FILE * f = NULL; 61 | 62 | va_list argp; 63 | va_start (argp, text); 64 | vsprintf (mex, text, argp); 65 | va_end (argp); 66 | 67 | strcat (mex, "\r\n"); 68 | 69 | if (geckolog) 70 | { 71 | usb_sendbuffer( EXI_CHANNEL_1, mex, strlen(mex) ); 72 | usb_flush(EXI_CHANNEL_1); 73 | } 74 | if (started == 2) return; 75 | if (filelog == 0) return; 76 | 77 | // If a message start with '@', do not open... it will be cached cache it... 78 | if (mex[0] != '@') 79 | f = fopen(dbgfile, "ab"); 80 | 81 | //if file cannot be opened, cannot open the file, maybe filesystem unmounted or nand emu active... use cache 82 | if (f) 83 | { 84 | for (i = 0; i < DEBUG_MAXCACHE; i++) 85 | { 86 | if (cache[i] != NULL) 87 | { 88 | fwrite (cache[i], 1, strlen(mex), f ); 89 | free (cache[i]); 90 | cache[i] = NULL; 91 | } 92 | } 93 | fwrite (mex, 1, strlen(mex), f ); 94 | fclose(f); 95 | } 96 | else 97 | { 98 | for (i = 0; i < DEBUG_MAXCACHE; i++) 99 | { 100 | if (cache[i] == NULL) 101 | { 102 | cache[i] = calloc (strlen(mex) + 1, 1); 103 | strcpy (cache[i], mex); 104 | break; 105 | } 106 | } 107 | } 108 | } 109 | 110 | static char ascii(char s) 111 | { 112 | if (s < 0x20) return '.'; 113 | if (s > 0x7E) return '.'; 114 | return s; 115 | } 116 | 117 | void gprintf (const char *format, ...) 118 | { 119 | char * tmp = NULL; 120 | va_list va; 121 | va_start(va, format); 122 | 123 | if((vasprintf(&tmp, format, va) >= 0) && tmp) 124 | { 125 | usb_sendbuffer(EXI_CHANNEL_1, tmp, strlen(tmp)); 126 | } 127 | va_end(va); 128 | 129 | if(tmp) 130 | free(tmp); 131 | } 132 | 133 | void Debug_hexdump (void *d, int len) 134 | { 135 | u8 *data; 136 | int i, off; 137 | data = (u8*) d; 138 | 139 | gprintf("\n 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF"); 140 | gprintf("\n==== =============================================== ================\n"); 141 | 142 | for (off = 0; off < len; off += 16) 143 | { 144 | gprintf("%04x ", off); 145 | for (i = 0; i < 16; i++) 146 | if ((i + off) >= len) 147 | gprintf(" "); 148 | else gprintf("%02x ", data[off + i]); 149 | 150 | gprintf(" "); 151 | for (i = 0; i < 16; i++) 152 | if ((i + off) >= len) 153 | gprintf(" "); 154 | else gprintf("%c", ascii(data[off + i])); 155 | gprintf("\n"); 156 | } 157 | } -------------------------------------------------------------------------------- /addon/forwarder/source/debug.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /* 9 | 10 | Debug, will write debug information to sd and/or gecko.... as debug file is open/closed it will be VERY SLOW 11 | 12 | */ 13 | 14 | #define DEBUG_MAXCACHE 32 15 | static char dbgfile[64]; 16 | static char *cache[DEBUG_MAXCACHE]; 17 | 18 | static int started = 0; 19 | static int filelog = 0; 20 | static int geckolog = 0; 21 | 22 | s32 DebugStart (bool gecko, char *fn) 23 | { 24 | filelog = 0; 25 | started = 0; 26 | 27 | sprintf (dbgfile, fn); 28 | 29 | geckolog = usb_isgeckoalive (EXI_CHANNEL_1); 30 | 31 | // check if the file exist 32 | FILE * f = NULL; 33 | f = fopen(dbgfile, "rb"); 34 | if (f) 35 | { 36 | filelog = 1; 37 | fclose (f); 38 | } 39 | 40 | memset (cache, 0, sizeof(cache)); 41 | 42 | if (filelog || geckolog) 43 | started = 1; 44 | 45 | return started; 46 | } 47 | 48 | void DebugStop (void) 49 | { 50 | filelog = 0; 51 | started = 2; 52 | } 53 | 54 | void Debug (const char *text, ...) 55 | { 56 | if (!started || text == NULL) return; 57 | 58 | int i; 59 | char mex[1024]; 60 | FILE * f = NULL; 61 | 62 | va_list argp; 63 | va_start (argp, text); 64 | vsprintf (mex, text, argp); 65 | va_end (argp); 66 | 67 | strcat (mex, "\r\n"); 68 | 69 | if (geckolog) 70 | { 71 | usb_sendbuffer( EXI_CHANNEL_1, mex, strlen(mex) ); 72 | usb_flush(EXI_CHANNEL_1); 73 | } 74 | if (started == 2) return; 75 | if (filelog == 0) return; 76 | 77 | // If a message start with '@', do not open... it will be cached cache it... 78 | if (mex[0] != '@') 79 | f = fopen(dbgfile, "ab"); 80 | 81 | //if file cannot be opened, cannot open the file, maybe filesystem unmounted or nand emu active... use cache 82 | if (f) 83 | { 84 | for (i = 0; i < DEBUG_MAXCACHE; i++) 85 | { 86 | if (cache[i] != NULL) 87 | { 88 | fwrite (cache[i], 1, strlen(mex), f ); 89 | free (cache[i]); 90 | cache[i] = NULL; 91 | } 92 | } 93 | fwrite (mex, 1, strlen(mex), f ); 94 | fclose(f); 95 | } 96 | else 97 | { 98 | for (i = 0; i < DEBUG_MAXCACHE; i++) 99 | { 100 | if (cache[i] == NULL) 101 | { 102 | cache[i] = calloc (strlen(mex) + 1, 1); 103 | strcpy (cache[i], mex); 104 | break; 105 | } 106 | } 107 | } 108 | } 109 | 110 | static char ascii(char s) 111 | { 112 | if (s < 0x20) return '.'; 113 | if (s > 0x7E) return '.'; 114 | return s; 115 | } 116 | 117 | void gprintf (const char *format, ...) 118 | { 119 | char * tmp = NULL; 120 | va_list va; 121 | va_start(va, format); 122 | 123 | if((vasprintf(&tmp, format, va) >= 0) && tmp) 124 | { 125 | usb_sendbuffer(EXI_CHANNEL_1, tmp, strlen(tmp)); 126 | } 127 | va_end(va); 128 | 129 | if(tmp) 130 | free(tmp); 131 | } 132 | 133 | void Debug_hexdump (void *d, int len) 134 | { 135 | u8 *data; 136 | int i, off; 137 | data = (u8*) d; 138 | 139 | gprintf("\n 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF"); 140 | gprintf("\n==== =============================================== ================\n"); 141 | 142 | for (off = 0; off < len; off += 16) 143 | { 144 | gprintf("%04x ", off); 145 | for (i = 0; i < 16; i++) 146 | if ((i + off) >= len) 147 | gprintf(" "); 148 | else gprintf("%02x ", data[off + i]); 149 | 150 | gprintf(" "); 151 | for (i = 0; i < 16; i++) 152 | if ((i + off) >= len) 153 | gprintf(" "); 154 | else gprintf("%c", ascii(data[off + i])); 155 | gprintf("\n"); 156 | } 157 | } -------------------------------------------------------------------------------- /addon/priibooter_gui/source/grlib/grlib_ui.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "grlib.h" 3 | #include 4 | 5 | extern s_grlibSettings grlibSettings; 6 | 7 | //DrawOnScreenMessage 8 | int grlib_dosm (const char *text, ...) // ab > 0 show and wait ab second, otherwhise, wait a or b press 9 | { 10 | int ret; 11 | static char mex[1024]; 12 | char *p1,*p2; 13 | 14 | int reverse = grlibSettings.fontBMF_reverse; 15 | 16 | grlibSettings.fontBMF_reverse = 0; 17 | 18 | if (text != NULL) 19 | { 20 | va_list argp; 21 | va_start(argp, text); 22 | vsprintf(mex, text, argp); 23 | va_end(argp); 24 | } 25 | 26 | // wait for no-button pressed 27 | do {WPAD_ScanPads();} while (WPAD_ButtonsDown(0)); 28 | 29 | s_grlibobj b; 30 | 31 | b.x1 = 70; 32 | b.y1 = 120; 33 | b.x2 = grlib_GetScreenW()-b.x1; 34 | b.y2 = grlib_GetScreenH()-b.y1; 35 | b.color = RGBA (255, 2552, 255, 255); 36 | b.bcolor = RGBA (0, 0, 0, 192); 37 | 38 | grlib_PopScreen (); 39 | grlib_DrawSquare (&b); 40 | grlib_DrawBoldEmptySquare (&b); 41 | 42 | b.x1 += 10; 43 | b.y1 += 10; 44 | 45 | p1 = mex; 46 | do 47 | { 48 | p2 = strstr (p1, "\n"); 49 | if (p2 != NULL) 50 | { 51 | *p2 = 0; 52 | p2++; 53 | } 54 | grlib_printf ( b.x1, b.y1, GRLIB_ALIGNLEFT, 0, p1); 55 | b.y1 +=15; 56 | p1 = p2; 57 | } 58 | while (p2 != NULL); 59 | 60 | grlib_Render (); 61 | 62 | ret = 0; 63 | do 64 | { 65 | WPAD_ScanPads(); 66 | if (WPAD_ButtonsDown(0) & WPAD_BUTTON_A) ret = 1; 67 | if (WPAD_ButtonsDown(0) & WPAD_BUTTON_B) ret = 2; 68 | } 69 | while (ret == 0); 70 | do {WPAD_ScanPads();} while (WPAD_ButtonsDown(0)); 71 | 72 | grlibSettings.fontBMF_reverse = reverse; 73 | return ret; 74 | } 75 | 76 | // if text start with "^+" the string is aligned to left, and [*] is drawn 77 | // if text start with "^-" the string is aligned to left, and [ ] is drawn 78 | void grlib_DrawButton ( s_grlibobj *b, int state) 79 | { 80 | int w, h; 81 | char text[64]; 82 | int toggle = -1; 83 | 84 | if (b->text[0] == '^') 85 | { 86 | if (b->text[1] == '+') toggle = 1; 87 | if (b->text[1] == '-') toggle = 0; 88 | 89 | if (toggle == 0) sprintf (text, "[\255*] %s", &b->text[2]); 90 | if (toggle == 1) sprintf (text, "[X] %s", &b->text[2]); 91 | } 92 | 93 | if (toggle == -1) strcpy(text, b->text); 94 | 95 | if (grlibSettings.theme.enabled) 96 | { 97 | if (state == BTNSTATE_SEL && grlibSettings.theme.texButtonSel) 98 | grlib_DrawSquareThemed ( b, grlibSettings.theme.texButtonSel, NULL, grlibSettings.theme.buttonMagX, grlibSettings.theme.buttonMagY, DSTF_NONE); 99 | else 100 | grlib_DrawSquareThemed ( b, grlibSettings.theme.texButton, NULL, grlibSettings.theme.buttonMagX, grlibSettings.theme.buttonMagY, DSTF_NONE); 101 | } 102 | else 103 | grlib_DrawSquare ( b ); 104 | 105 | grlib_GetFontMetrics (text, &w, &h); 106 | if (toggle == -1) 107 | grlib_printf ( 108 | b->x1 + (b->x2 - b->x1) / 2, 109 | b->y1 + (b->y2 - b->y1) / 2 - (h / 2) + grlibSettings.theme.buttonsTextOffsetY, 110 | GRLIB_ALIGNCENTER, 0, text 111 | ); 112 | else 113 | { 114 | grlib_printf ( 115 | b->x1 + 5, 116 | b->y1 + (b->y2 - b->y1) / 2 - (h / 2) + grlibSettings.theme.buttonsTextOffsetY, 117 | GRLIB_ALIGNLEFT, 0, text 118 | ); 119 | } 120 | } 121 | 122 | void grlib_Message (const char *text, ...) // ab > 0 show and wait ab second, otherwhise, wait a or b press 123 | { 124 | char * mex; 125 | 126 | mex = calloc (1, strlen(text) + 1024); 127 | if (!mex) return; 128 | 129 | mex[0] = '\0'; 130 | 131 | if (text != NULL) 132 | { 133 | va_list argp; 134 | va_start(argp, text); 135 | vsprintf(mex, text, argp); 136 | va_end(argp); 137 | } 138 | 139 | grlib_menu (mex, "OK"); 140 | 141 | free (mex); 142 | } 143 | -------------------------------------------------------------------------------- /addon/priibooter_gui/source/grlib/grlib_icon.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "grlib.h" 3 | 4 | void grlib_IconSettingInit (s_grlib_iconSetting *grlib_iconSetting) 5 | { 6 | memset (grlib_iconSetting, 0, sizeof(s_grlib_iconSetting)); 7 | } 8 | 9 | void grlib_IconInit (s_grlib_icon *icon, s_grlib_icon *parentIcon) 10 | { 11 | if (parentIcon) 12 | memcpy (icon, parentIcon, sizeof(s_grlib_icon)); 13 | else 14 | { 15 | memset (icon, 0, sizeof(s_grlib_icon)); 16 | icon->transparency = 255; 17 | } 18 | } 19 | 20 | void grlib_IconDraw (s_grlib_iconSetting *is, s_grlib_icon *icon) 21 | { 22 | GRRLIB_texImg *tex; 23 | f32 w, h; 24 | s_grlibobj gro, grob; 25 | 26 | if (icon->sel) 27 | { 28 | w = (f32)icon->w * is->magXSel; 29 | h = (f32)icon->h * is->magYSel; 30 | } 31 | else 32 | { 33 | w = (f32)icon->w * is->magX; 34 | h = (f32)icon->h * is->magY; 35 | } 36 | 37 | // Calculate icon bounds 38 | 39 | gro.x1 = (icon->x - w / 2.0) - icon->xoff; 40 | gro.x2 = (icon->x + w / 2.0) - icon->xoff; 41 | gro.y1 = (icon->y - h / 2.0) - icon->yoff; 42 | gro.y2 = (icon->y + h / 2.0) - icon->yoff; 43 | 44 | grlib_MagObject (&grob, &gro, is->border, is->border); 45 | 46 | // Draw background 47 | 48 | if (is->themed) { 49 | // Draw mask (if exist) 50 | if (!icon->noIcon) grlib_DrawSquareThemed (&grob, is->bkgTex, NULL, 0, 0, DSTF_NONE); 51 | } 52 | else 53 | { 54 | grob.bcolor = is->bkgColor; 55 | grob.color = is->borderColor; 56 | 57 | grlib_DrawSquare (&grob); 58 | } 59 | 60 | // Draw Icon 61 | if (!icon->noIcon) 62 | { 63 | if (icon->icon) 64 | tex = icon->icon; 65 | else if (icon->alticon) 66 | tex = icon->alticon; 67 | else 68 | tex = is->iconFake; 69 | 70 | grlib_DrawImg (gro.x1, gro.y1, w, h, tex, 0, RGBA(255, 255, 255, icon->transparency)); 71 | } 72 | 73 | // Draw text 74 | if (icon->title && strlen(icon->title)) 75 | { 76 | char desc[64]; 77 | 78 | strncpy (desc, icon->title, 63); 79 | 80 | bool cutted = FALSE; 81 | while (grlib_GetFontMetrics(desc, NULL, NULL) > w - 10 && strlen(desc) > 0) 82 | { 83 | desc[strlen(desc)-1] = 0; 84 | cutted = TRUE; 85 | } 86 | if (cutted) strcat (desc, "..."); 87 | 88 | int ofr = grlibSettings.fontBMF_reverse; 89 | grlibSettings.fontBMF_reverse = is->fontReverse; 90 | grlib_printf (gro.x1 + w / 2, gro.y1 + h / 2 - 5, GRLIB_ALIGNCENTER, 0, desc); 91 | grlibSettings.fontBMF_reverse = ofr; 92 | } 93 | 94 | // Draw overlay icons 95 | if (icon->iconOverlay[0]) 96 | { 97 | grlib_DrawImg (gro.x1, gro.y1, icon->iconOverlay[0]->w, icon->iconOverlay[0]->h, icon->iconOverlay[0], 0, RGBA(255, 255, 255, 255)); 98 | } 99 | 100 | if (icon->iconOverlay[1]) 101 | { 102 | grlib_DrawImg (gro.x2 - icon->iconOverlay[1]->w, gro.y1, icon->iconOverlay[1]->w, icon->iconOverlay[1]->h, icon->iconOverlay[1], 0, RGBA(255, 255, 255, 255)); 103 | } 104 | 105 | if (icon->iconOverlay[2]) 106 | { 107 | grlib_DrawImg (gro.x2 - icon->iconOverlay[2]->w, gro.y2 - icon->iconOverlay[2]->h, icon->iconOverlay[2]->w, icon->iconOverlay[2]->h, icon->iconOverlay[2], 0, RGBA(255, 255, 255, 255)); 108 | } 109 | 110 | // Draw outer frame 111 | if (icon->sel) 112 | { 113 | if (is->themed) 114 | { 115 | grlib_DrawSquareThemed (&grob, is->fgrTex, NULL, 0, 0, DSTF_NONE); 116 | grlib_DrawSquareThemed (&grob, is->fgrSelTex, NULL, 0, 0, DSTF_NONE); 117 | } 118 | else 119 | { 120 | grob.bcolor = is->bkgColor; 121 | grob.color = is->borderSelColor; 122 | 123 | grlib_DrawBoldEmptySquare (&grob); 124 | } 125 | } 126 | else 127 | { 128 | if (is->themed) 129 | { 130 | grlib_DrawSquareThemed (&grob, is->fgrTex, NULL, 0, 0, DSTF_NONE); 131 | } 132 | else 133 | { 134 | grob.bcolor = is->bkgColor; 135 | grob.color = is->borderColor; 136 | 137 | grlib_DrawEmptySquare (&grob); 138 | } 139 | } 140 | 141 | icon->rx1 = grob.x1; 142 | icon->rx2 = grob.x2; 143 | 144 | icon->ry1 = grob.y1; 145 | icon->ry2 = grob.y2; 146 | 147 | } -------------------------------------------------------------------------------- /source/sound.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | sound.c 4 | 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "cfg.h" 12 | #include "mystring.h" 13 | #include "globals.h" 14 | #include "mem2.h" 15 | #include "devices.h" 16 | #include "fsop/fsop.h" 17 | #include "mp3player.h" 18 | 19 | #define VOLUME 80 20 | #define MAXSONGS 256 21 | #define DATABUFFER_SIZE (32768) // defined in mp3player.c 22 | 23 | static char *playlist[MAXSONGS]; 24 | static int stopped = 0; 25 | static int songs = 0; 26 | static int currentSong = 0; 27 | static int currentVolume = 0; 28 | 29 | static void shuffle (void) 30 | { 31 | char *p; 32 | int i,j; 33 | 34 | for (i = 0; i < songs; i++) 35 | { 36 | j = rand () % songs; 37 | 38 | p = playlist[i]; 39 | playlist[i] = playlist[j]; 40 | playlist[j] = p; 41 | } 42 | } 43 | 44 | void snd_Mp3Go (void) 45 | { 46 | if (!songs || stopped || MP3Player_IsPlaying()) return; 47 | 48 | Debug ("snd_Mp3Go: index is %d", currentSong); 49 | Debug ("snd_Mp3Go: now playing '%s'", playlist[currentSong]); 50 | 51 | MP3Player_PlayFileDirect (playlist[currentSong]); 52 | 53 | currentSong++; 54 | if (currentSong >= songs) 55 | currentSong = 0; 56 | } 57 | 58 | /* 59 | 60 | */ 61 | 62 | static void ScanForMp3 (char *path) 63 | { 64 | DIR *pdir; 65 | struct dirent *pent; 66 | 67 | pdir=opendir(path); 68 | 69 | while ((pent=readdir(pdir)) != NULL) 70 | { 71 | if (songs >= MAXSONGS) break; 72 | 73 | if (ms_strstr (pent->d_name, ".mp3")) 74 | { 75 | playlist[songs] = calloc (1, strlen(path)+strlen(pent->d_name)+2); 76 | sprintf (playlist[songs], "%s/%s", path, pent->d_name); 77 | songs ++; 78 | } 79 | } 80 | 81 | closedir (pdir); 82 | } 83 | 84 | void snd_Volume (void) 85 | { 86 | if (config.volume < 1 || config.volume > 5) config.volume = 3; 87 | 88 | if (config.volume == 1) currentVolume = 25; 89 | if (config.volume == 2) currentVolume = 50; 90 | if (config.volume == 3) currentVolume = 75; 91 | if (config.volume == 4) currentVolume = 100; 92 | if (config.volume == 5) currentVolume = 125; 93 | 94 | MP3Player_Volume (currentVolume); 95 | } 96 | 97 | /* 98 | this function must be inited after io subsystem 99 | */ 100 | void snd_Init (void) 101 | { 102 | Debug ("snd_Init"); 103 | ASND_Init(NULL); 104 | MP3Player_Init(); 105 | 106 | stopped = 1; 107 | 108 | memset (playlist, 0, sizeof(playlist)); 109 | 110 | char path[128]; 111 | songs = 0; 112 | if (devices_Get(DEV_SD)) 113 | { 114 | sprintf (path, "%s://ploader/mp3", devices_Get(DEV_SD)); 115 | ScanForMp3 (path); 116 | 117 | sprintf (path, "%s://mp3", devices_Get(DEV_SD)); 118 | ScanForMp3 (path); 119 | } 120 | 121 | if (devices_Get(DEV_USB)) 122 | { 123 | sprintf (path, "%s://ploader/mp3", devices_Get(DEV_USB)); 124 | ScanForMp3 (path); 125 | 126 | sprintf (path, "%s://mp3", devices_Get(DEV_USB)); 127 | ScanForMp3 (path); 128 | } 129 | 130 | shuffle(); 131 | 132 | stopped = 0; 133 | currentSong = 0; 134 | snd_Volume (); 135 | snd_Mp3Go (); 136 | 137 | } 138 | 139 | void snd_Stop (void) 140 | { 141 | Debug ("snd_Stop"); 142 | 143 | u32 i; 144 | for (i = currentVolume; i > 0; i-=5) 145 | { 146 | MP3Player_Volume(i); 147 | usleep (20*1000); 148 | } 149 | 150 | MP3Player_Stop(); 151 | 152 | while (MP3Player_IsPlaying()) 153 | { 154 | usleep (1000*1000); 155 | Debug ("stopping..."); 156 | } 157 | ASND_End(); 158 | 159 | // Clear playlist 160 | for (i = 0; i < songs; i++) 161 | if (playlist[i]) 162 | { 163 | free (playlist[i]); 164 | playlist[i] = NULL; 165 | } 166 | 167 | stopped = 1; 168 | songs = 0; 169 | } 170 | 171 | void snd_Pause (void) 172 | { 173 | Debug ("snd_Pause"); 174 | 175 | u32 i; 176 | for (i = currentVolume; i > 0; i-=5) 177 | { 178 | MP3Player_Volume(i); 179 | usleep (20*1000); 180 | } 181 | MP3Player_Stop(); 182 | 183 | while (MP3Player_IsPlaying()) 184 | { 185 | usleep (1000*1000); 186 | Debug ("stopping..."); 187 | } 188 | 189 | stopped = 1; 190 | } 191 | 192 | void snd_Resume (void) 193 | { 194 | Debug ("snd_Resume"); 195 | stopped = 0; 196 | } 197 | -------------------------------------------------------------------------------- /addon/priibooter_gui/source/debug.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /* 9 | 10 | Debug, will write debug information to sd and/or gecko.... as debug file is open/closed it will be VERY SLOW 11 | 12 | */ 13 | 14 | #define DEBUG_MAXCACHE 32 15 | static char dbgfile[64]; 16 | static char *cache[DEBUG_MAXCACHE]; 17 | 18 | static int started = 0; 19 | static int filelog = 0; 20 | static int geckolog = 0; 21 | 22 | #define MAXDBGBUFF 4096 23 | char gprintfbuff[MAXDBGBUFF]; 24 | 25 | s32 DebugStart (bool gecko, char *fn) 26 | { 27 | filelog = 0; 28 | started = 0; 29 | 30 | sprintf (dbgfile, fn); 31 | 32 | geckolog = usb_isgeckoalive (EXI_CHANNEL_1); 33 | 34 | // check if the file exist 35 | FILE * f = NULL; 36 | f = fopen(dbgfile, "rb"); 37 | if (f) 38 | { 39 | filelog = 1; 40 | fclose (f); 41 | } 42 | 43 | memset (cache, 0, sizeof(cache)); 44 | 45 | if (filelog || geckolog) 46 | started = 1; 47 | 48 | return started; 49 | } 50 | 51 | void DebugStop (void) 52 | { 53 | filelog = 0; 54 | started = 2; 55 | } 56 | 57 | void Debug (const char *text, ...) 58 | { 59 | if (!started || text == NULL) return; 60 | 61 | int i; 62 | char mex[1024]; 63 | FILE * f = NULL; 64 | 65 | va_list argp; 66 | va_start (argp, text); 67 | vsprintf (mex, text, argp); 68 | va_end (argp); 69 | 70 | strcat (mex, "\r\n"); 71 | 72 | if (geckolog) 73 | { 74 | usb_sendbuffer( EXI_CHANNEL_1, mex, strlen(mex) ); 75 | usb_flush(EXI_CHANNEL_1); 76 | } 77 | if (started == 2) return; 78 | if (filelog == 0) return; 79 | 80 | // If a message start with '@', do not open... it will be cached cache it... 81 | if (mex[0] != '@') 82 | f = fopen(dbgfile, "ab"); 83 | 84 | //if file cannot be opened, cannot open the file, maybe filesystem unmounted or nand emu active... use cache 85 | if (f) 86 | { 87 | for (i = 0; i < DEBUG_MAXCACHE; i++) 88 | { 89 | if (cache[i] != NULL) 90 | { 91 | fwrite (cache[i], 1, strlen(mex), f ); 92 | free (cache[i]); 93 | cache[i] = NULL; 94 | } 95 | } 96 | fwrite (mex, 1, strlen(mex), f ); 97 | fclose(f); 98 | } 99 | else 100 | { 101 | for (i = 0; i < DEBUG_MAXCACHE; i++) 102 | { 103 | if (cache[i] == NULL) 104 | { 105 | cache[i] = calloc (strlen(mex) + 1, 1); 106 | strcpy (cache[i], mex); 107 | break; 108 | } 109 | } 110 | } 111 | } 112 | 113 | static char ascii(char s) 114 | { 115 | if (s < 0x20) return '.'; 116 | if (s > 0x7E) return '.'; 117 | return s; 118 | } 119 | 120 | void gprintf (const char *format, ...) 121 | { 122 | static int init = 0; 123 | 124 | if (!init) 125 | { 126 | init = 1; 127 | *gprintfbuff = '\0'; 128 | } 129 | 130 | char * tmp = NULL; 131 | va_list va; 132 | va_start(va, format); 133 | 134 | if ((vasprintf(&tmp, format, va) >= 0) && tmp) 135 | { 136 | if ((strlen (gprintfbuff) + strlen(tmp)) < MAXDBGBUFF) 137 | strcat (gprintfbuff, tmp); 138 | 139 | usb_sendbuffer(EXI_CHANNEL_1, tmp, strlen(tmp)); 140 | } 141 | va_end(va); 142 | 143 | if(tmp) 144 | free(tmp); 145 | } 146 | 147 | void gprintf_StoreBuff(char *fn) 148 | { 149 | FILE *f; 150 | 151 | f = fopen (fn, "ab"); 152 | if (f) 153 | { 154 | fwrite (gprintfbuff, strlen(gprintfbuff), 1, f); 155 | fclose (f); 156 | 157 | *gprintfbuff = '\0'; 158 | } 159 | } 160 | 161 | void Debug_hexdump (void *d, int len) 162 | { 163 | u8 *data; 164 | int i, off; 165 | data = (u8*) d; 166 | 167 | gprintf("\n 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF"); 168 | gprintf("\n==== =============================================== ================\n"); 169 | 170 | for (off = 0; off < len; off += 16) 171 | { 172 | gprintf("%04x ", off); 173 | for (i = 0; i < 16; i++) 174 | if ((i + off) >= len) 175 | gprintf(" "); 176 | else gprintf("%02x ", data[off + i]); 177 | 178 | gprintf(" "); 179 | for (i = 0; i < 16; i++) 180 | if ((i + off) >= len) 181 | gprintf(" "); 182 | else gprintf("%c", ascii(data[off + i])); 183 | gprintf("\n"); 184 | } 185 | } -------------------------------------------------------------------------------- /source/zip/ioapi.c: -------------------------------------------------------------------------------- 1 | /* ioapi.c -- IO base function header for compress/uncompress .zip 2 | files using zlib + zip or unzip API 3 | 4 | Version 1.01e, February 12th, 2005 5 | 6 | Copyright (C) 1998-2005 Gilles Vollant 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "zlib.h" 14 | #include "ioapi.h" 15 | 16 | 17 | 18 | /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ 19 | 20 | #ifndef SEEK_CUR 21 | #define SEEK_CUR 1 22 | #endif 23 | 24 | #ifndef SEEK_END 25 | #define SEEK_END 2 26 | #endif 27 | 28 | #ifndef SEEK_SET 29 | #define SEEK_SET 0 30 | #endif 31 | 32 | voidpf ZCALLBACK fopen_file_func OF(( 33 | voidpf opaque, 34 | const char* filename, 35 | int mode)); 36 | 37 | uLong ZCALLBACK fread_file_func OF(( 38 | voidpf opaque, 39 | voidpf stream, 40 | void* buf, 41 | uLong size)); 42 | 43 | uLong ZCALLBACK fwrite_file_func OF(( 44 | voidpf opaque, 45 | voidpf stream, 46 | const void* buf, 47 | uLong size)); 48 | 49 | long ZCALLBACK ftell_file_func OF(( 50 | voidpf opaque, 51 | voidpf stream)); 52 | 53 | long ZCALLBACK fseek_file_func OF(( 54 | voidpf opaque, 55 | voidpf stream, 56 | uLong offset, 57 | int origin)); 58 | 59 | int ZCALLBACK fclose_file_func OF(( 60 | voidpf opaque, 61 | voidpf stream)); 62 | 63 | int ZCALLBACK ferror_file_func OF(( 64 | voidpf opaque, 65 | voidpf stream)); 66 | 67 | 68 | voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) 69 | voidpf opaque; 70 | const char* filename; 71 | int mode; 72 | { 73 | FILE* file = NULL; 74 | const char* mode_fopen = NULL; 75 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) 76 | mode_fopen = "rb"; 77 | else 78 | if (mode & ZLIB_FILEFUNC_MODE_EXISTING) 79 | mode_fopen = "r+b"; 80 | else 81 | if (mode & ZLIB_FILEFUNC_MODE_CREATE) 82 | mode_fopen = "wb"; 83 | 84 | if ((filename!=NULL) && (mode_fopen != NULL)) 85 | file = fopen(filename, mode_fopen); 86 | return file; 87 | } 88 | 89 | 90 | uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) 91 | voidpf opaque; 92 | voidpf stream; 93 | void* buf; 94 | uLong size; 95 | { 96 | uLong ret; 97 | ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); 98 | return ret; 99 | } 100 | 101 | 102 | uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) 103 | voidpf opaque; 104 | voidpf stream; 105 | const void* buf; 106 | uLong size; 107 | { 108 | uLong ret; 109 | ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); 110 | return ret; 111 | } 112 | 113 | long ZCALLBACK ftell_file_func (opaque, stream) 114 | voidpf opaque; 115 | voidpf stream; 116 | { 117 | long ret; 118 | ret = ftell((FILE *)stream); 119 | return ret; 120 | } 121 | 122 | long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) 123 | voidpf opaque; 124 | voidpf stream; 125 | uLong offset; 126 | int origin; 127 | { 128 | int fseek_origin=0; 129 | long ret; 130 | switch (origin) 131 | { 132 | case ZLIB_FILEFUNC_SEEK_CUR : 133 | fseek_origin = SEEK_CUR; 134 | break; 135 | case ZLIB_FILEFUNC_SEEK_END : 136 | fseek_origin = SEEK_END; 137 | break; 138 | case ZLIB_FILEFUNC_SEEK_SET : 139 | fseek_origin = SEEK_SET; 140 | break; 141 | default: return -1; 142 | } 143 | ret = 0; 144 | fseek((FILE *)stream, offset, fseek_origin); 145 | return ret; 146 | } 147 | 148 | int ZCALLBACK fclose_file_func (opaque, stream) 149 | voidpf opaque; 150 | voidpf stream; 151 | { 152 | int ret; 153 | ret = fclose((FILE *)stream); 154 | return ret; 155 | } 156 | 157 | int ZCALLBACK ferror_file_func (opaque, stream) 158 | voidpf opaque; 159 | voidpf stream; 160 | { 161 | int ret; 162 | ret = ferror((FILE *)stream); 163 | return ret; 164 | } 165 | 166 | void fill_fopen_filefunc (pzlib_filefunc_def) 167 | zlib_filefunc_def* pzlib_filefunc_def; 168 | { 169 | pzlib_filefunc_def->zopen_file = fopen_file_func; 170 | pzlib_filefunc_def->zread_file = fread_file_func; 171 | pzlib_filefunc_def->zwrite_file = fwrite_file_func; 172 | pzlib_filefunc_def->ztell_file = ftell_file_func; 173 | pzlib_filefunc_def->zseek_file = fseek_file_func; 174 | pzlib_filefunc_def->zclose_file = fclose_file_func; 175 | pzlib_filefunc_def->zerror_file = ferror_file_func; 176 | pzlib_filefunc_def->opaque = NULL; 177 | } 178 | -------------------------------------------------------------------------------- /source/grlib/grlib_icon.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "grlib.h" 3 | 4 | void grlib_IconSettingInit (s_grlib_iconSetting *grlib_iconSetting) 5 | { 6 | memset (grlib_iconSetting, 0, sizeof(s_grlib_iconSetting)); 7 | grlib_iconSetting->transparency = 255; 8 | } 9 | 10 | void grlib_IconInit (s_grlib_icon *icon, s_grlib_icon *parentIcon) 11 | { 12 | if (parentIcon) 13 | memcpy (icon, parentIcon, sizeof(s_grlib_icon)); 14 | else 15 | { 16 | memset (icon, 0, sizeof(s_grlib_icon)); 17 | icon->transparency = 255; 18 | } 19 | } 20 | 21 | void grlib_IconDraw (s_grlib_iconSetting *is, s_grlib_icon *icon) 22 | { 23 | GRRLIB_texImg *tex; 24 | f32 w, h; 25 | s_grlibobj gro, grob; 26 | 27 | if (icon->sel) 28 | { 29 | w = (f32)icon->w * is->magXSel; 30 | h = (f32)icon->h * is->magYSel; 31 | } 32 | else 33 | { 34 | w = (f32)icon->w * is->magX; 35 | h = (f32)icon->h * is->magY; 36 | } 37 | 38 | // Calculate icon bounds 39 | 40 | gro.x1 = (icon->x - w / 2.0) - icon->xoff; 41 | gro.x2 = (icon->x + w / 2.0) - icon->xoff; 42 | gro.y1 = (icon->y - h / 2.0) - icon->yoff; 43 | gro.y2 = (icon->y + h / 2.0) - icon->yoff; 44 | 45 | grlib_MagObject (&grob, &gro, is->border, is->border); 46 | 47 | // Check if icon is visible ! 48 | if (!grlib_IsObjectVisible(&gro)) 49 | { 50 | return; 51 | } 52 | 53 | // Draw background 54 | 55 | if (is->themed) { 56 | // Draw mask (if exist) 57 | if (!icon->noIcon) grlib_DrawSquareThemed (&grob, is->bkgTex, NULL, 0, 0, DSTF_NONE, is->transparency); 58 | } 59 | else 60 | { 61 | grob.bcolor = is->bkgColor; 62 | grob.color = is->borderColor; 63 | 64 | grlib_DrawSquare (&grob); 65 | } 66 | 67 | // Draw Icon 68 | if (!icon->noIcon) 69 | { 70 | if (icon->icon) 71 | tex = icon->icon; 72 | else if (icon->alticon) 73 | tex = icon->alticon; 74 | else 75 | tex = is->iconFake; 76 | 77 | grlib_DrawImg (gro.x1, gro.y1, w, h, tex, 0, RGBA(255, 255, 255, icon->transparency)); 78 | } 79 | 80 | // Draw text 81 | if (icon->title && strlen(icon->title)) 82 | { 83 | char desc[128]; 84 | 85 | strncpy (desc, icon->title, 63); 86 | 87 | bool cutted = FALSE; 88 | int pt3 = grlib_GetFontMetrics("...", NULL, NULL); 89 | 90 | while (strlen(desc) > 0 && grlib_GetFontMetrics(desc, NULL, NULL) > (w - pt3)) 91 | { 92 | desc[strlen(desc)-1] = 0; 93 | cutted = TRUE; 94 | } 95 | if (cutted) strcat (desc, "..."); 96 | 97 | int ofr = grlibSettings.fontDef.reverse; 98 | grlibSettings.fontDef.reverse = is->fontReverse; 99 | if (icon->titleAlign == GRLIB_ALIGNICOTEXT_MIDDLE) 100 | grlib_printf (gro.x1 + w / 2, gro.y1 + h / 2 - 5, GRLIB_ALIGNCENTER, 0, desc); 101 | 102 | if (icon->titleAlign == GRLIB_ALIGNICOTEXT_BOTTOM) 103 | { 104 | int fh; 105 | grlib_GetFontMetrics (desc, NULL, &fh); 106 | grlib_printf (gro.x1 + w / 2, gro.y2 - fh - 7, GRLIB_ALIGNCENTER, 0, desc); 107 | } 108 | 109 | grlibSettings.fontDef.reverse = ofr; 110 | } 111 | 112 | // Draw overlay icons 113 | if (icon->iconOverlay[0]) 114 | { 115 | grlib_DrawImg (gro.x1, gro.y1, icon->iconOverlay[0]->w, icon->iconOverlay[0]->h, icon->iconOverlay[0], 0, RGBA(255, 255, 255, 255)); 116 | } 117 | 118 | if (icon->iconOverlay[1]) 119 | { 120 | grlib_DrawImg (gro.x2 - icon->iconOverlay[1]->w, gro.y1, icon->iconOverlay[1]->w, icon->iconOverlay[1]->h, icon->iconOverlay[1], 0, RGBA(255, 255, 255, 255)); 121 | } 122 | 123 | if (icon->iconOverlay[2]) 124 | { 125 | grlib_DrawImg (gro.x2 - icon->iconOverlay[2]->w, gro.y2 - icon->iconOverlay[2]->h, icon->iconOverlay[2]->w, icon->iconOverlay[2]->h, icon->iconOverlay[2], 0, RGBA(255, 255, 255, 255)); 126 | } 127 | 128 | // Draw outer frame 129 | if (icon->sel) 130 | { 131 | if (is->themed) 132 | { 133 | grlib_DrawSquareThemed (&grob, is->fgrTex, NULL, 0, 0, DSTF_NONE, is->transparency); 134 | grlib_DrawSquareThemed (&grob, is->fgrSelTex, NULL, 0, 0, DSTF_NONE, is->transparency); 135 | } 136 | else 137 | { 138 | grob.bcolor = is->bkgColor; 139 | grob.color = is->borderSelColor; 140 | 141 | grlib_DrawBoldEmptySquare (&grob); 142 | } 143 | } 144 | else 145 | { 146 | if (is->themed) 147 | { 148 | grlib_DrawSquareThemed (&grob, is->fgrTex, NULL, 0, 0, DSTF_NONE, is->transparency); 149 | } 150 | else 151 | { 152 | grob.bcolor = is->bkgColor; 153 | grob.color = is->borderColor; 154 | 155 | grlib_DrawEmptySquare (&grob); 156 | } 157 | } 158 | 159 | icon->rx1 = grob.x1; 160 | icon->rx2 = grob.x2; 161 | 162 | icon->ry1 = grob.y1; 163 | icon->ry2 = grob.y2; 164 | 165 | } -------------------------------------------------------------------------------- /addon/priibooter/source/ios.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define HAVE_AHBPROT ((*(vu32*)0xcd800064 == 0xFFFFFFFF) ? 1 : 0) 12 | #define MEM_REG_BASE 0xd8b4000 13 | #define MEM_PROT (MEM_REG_BASE + 0x20a) 14 | 15 | #define CHECK_AHB 0x0D800064 16 | #define MEM2_PROT 0x0D8B420A 17 | #define ES_MODULE_START (u16*)0x939F0000 18 | 19 | int ios_ReloadIOS(int ios, int *ahbprot); 20 | 21 | static const u16 ticket_check[] = { 22 | 0x685B, // ldr r3,[r3,#4] ; get TMD pointer 23 | 0x22EC, 0x0052, // movls r2, 0x1D8 24 | 0x189B, // adds r3, r3, r2; add offset of access rights field in TMD 25 | 0x681B, // ldr r3, [r3] ; load access rights (haxxme!) 26 | 0x4698, // mov r8, r3 ; store it for the DVD video bitcheck later 27 | 0x07DB // lsls r3, r3, #31; check AHBPROT bit 28 | }; 29 | 30 | static void disable_memory_protection() 31 | { 32 | write32(MEM_PROT, read32(MEM_PROT) & 0x0000FFFF); 33 | } 34 | 35 | 36 | int PatchAHB (void) 37 | { 38 | if (HAVE_AHBPROT) 39 | { 40 | u16 *patchme; 41 | 42 | // Disable memory protection 43 | write16(MEM2_PROT, 2); 44 | //disable_memory_protection (); 45 | 46 | for (patchme=ES_MODULE_START; patchme < ES_MODULE_START+0x4000; patchme++) 47 | { 48 | if (!memcmp(patchme, ticket_check, sizeof(ticket_check))) 49 | { 50 | // write16/uncached poke doesn't work for this. Go figure. 51 | patchme[4] = 0x23FF; // li r3, 0xFF 52 | DCFlushRange(patchme+4, 2); 53 | break; 54 | } 55 | } 56 | 57 | return 1; 58 | } 59 | else 60 | return 0; 61 | } 62 | 63 | static u32 apply_patch(char *name, const u8 *pattern, u32 pattern_size, const u8 *patch, u32 patch_size, u32 patch_offset) 64 | { 65 | u8 *ptr_start = (u8*)*((u32*)0x80003134), *ptr_end = (u8*)0x94000000; 66 | u32 found = 0; 67 | u8 *location = NULL; 68 | while (ptr_start < (ptr_end - patch_size)) 69 | { 70 | if (!memcmp(ptr_start, pattern, pattern_size)) 71 | { 72 | found++; 73 | location = ptr_start + patch_offset; 74 | u8 *start = location; 75 | u32 i; 76 | for (i = 0; i < patch_size; i++) 77 | { 78 | *location++ = patch[i]; 79 | } 80 | DCFlushRange((u8 *)(((u32)start) >> 5 << 5), (patch_size >> 5 << 5) + 64); 81 | ICInvalidateRange((u8 *)(((u32)start) >> 5 << 5), (patch_size >> 5 << 5) + 64); 82 | } 83 | ptr_start++; 84 | } 85 | return found; 86 | } 87 | 88 | const u8 es_set_ahbprot_pattern[] = { 0x68, 0x5B, 0x22, 0xEC, 0x00, 0x52, 0x18, 0x9B, 0x68, 0x1B, 0x46, 0x98, 0x07, 0xDB }; 89 | const u8 es_set_ahbprot_patch[] = { 0x01 }; 90 | 91 | u32 IOSPATCH_AHBPROT() 92 | { 93 | if (HAVE_AHBPROT) 94 | { 95 | disable_memory_protection(); 96 | return apply_patch("es_set_ahbprot", es_set_ahbprot_pattern, sizeof(es_set_ahbprot_pattern), es_set_ahbprot_patch, sizeof(es_set_ahbprot_patch), 25); 97 | } 98 | return 0; 99 | } 100 | 101 | int ios_ReloadIOS(int ios, int *ahbprot) 102 | { 103 | int ret; 104 | 105 | if (ahbprot != NULL) *ahbprot = 0; 106 | 107 | if (ios > 200) //mmm, just reload it 108 | { 109 | IOS_ReloadIOS(ios); 110 | return ios;//IOS_GetVersion(); 111 | } 112 | 113 | if (ios < 0 || ios > 254) // -1 can be passed to auto choose the preferred 114 | { 115 | ios = IOS_GetPreferredVersion(); 116 | 117 | // mmm... maybe something gones wrong 118 | if (ios <= 9) 119 | ios = 58; 120 | } 121 | 122 | /* Enable AHBPROT on title launch */ 123 | //ret = IOSPATCH_AHBPROT(); 124 | ret = PatchAHB(); 125 | if (ret) 126 | { 127 | /* Reload current IOS, typically IOS58 */ 128 | IOS_ReloadIOS(ios); 129 | 130 | if (HAVE_AHBPROT && ahbprot != NULL) *ahbprot = 1; 131 | 132 | return ios; // Wow, it's works 133 | } 134 | 135 | // mmm... anyway re-load, but ahpbrot is lost for sure 136 | IOS_ReloadIOS(ios); 137 | 138 | return ios; 139 | } 140 | 141 | void ReloadIOS (int os) 142 | { 143 | #ifndef DOLPHINE 144 | if (os == -1) 145 | { 146 | s32 version = IOS_GetVersion(); 147 | s32 preferred = IOS_GetPreferredVersion(); 148 | 149 | if (preferred > 0) 150 | IOS_ReloadIOS(preferred); 151 | else 152 | IOS_ReloadIOS(version); 153 | } 154 | else 155 | IOS_ReloadIOS(os); 156 | #endif 157 | } 158 | 159 | -------------------------------------------------------------------------------- /addon/priibooter/source/utils.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "common.h" 10 | 11 | static void *xfb = NULL; 12 | static GXRModeObj *rmode = NULL; 13 | 14 | void green_fix(void) //GREENSCREEN FIX 15 | { 16 | VIDEO_Configure(rmode); 17 | VIDEO_SetNextFramebuffer(xfb); 18 | VIDEO_SetBlack(TRUE); 19 | VIDEO_Flush(); 20 | VIDEO_WaitVSync(); 21 | } 22 | 23 | void InitVideo (void) 24 | { 25 | // Initialise the video system 26 | VIDEO_Init(); 27 | 28 | // Obtain the preferred video mode from the system 29 | // This will correspond to the settings in the Wii menu 30 | rmode = VIDEO_GetPreferredMode(NULL); 31 | 32 | // Allocate memory for the display in the uncached region 33 | xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); 34 | 35 | VIDEO_Configure(rmode); 36 | VIDEO_SetNextFramebuffer(xfb); 37 | VIDEO_SetBlack(FALSE); 38 | VIDEO_Flush(); 39 | VIDEO_WaitVSync(); 40 | if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); 41 | 42 | int x, y, w, h; 43 | x = 20; 44 | y = 32; 45 | w = rmode->fbWidth - (32); 46 | h = rmode->xfbHeight - (48); 47 | 48 | CON_InitEx(rmode, x, y, w, h); 49 | 50 | VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK); 51 | 52 | CON_InitEx(rmode, x, y, w, h); 53 | 54 | // Set console text color 55 | printf("\x1b[%u;%um", 37, false); 56 | printf("\x1b[%u;%um", 40, false); 57 | } 58 | 59 | void printd(const char *text, ...) 60 | { 61 | char Buffer[1024]; 62 | va_list args; 63 | 64 | va_start(args, text); 65 | vsprintf(Buffer, text, args); 66 | 67 | va_end(args); 68 | 69 | printf(Buffer); 70 | 71 | if (strstr (Buffer, "ERR:")) 72 | sleep (3); 73 | else 74 | sleep (0); 75 | } 76 | 77 | 78 | 79 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 80 | u8 *ReadFile2Buffer (char *path, size_t *filesize, int *err) 81 | { 82 | u8 *buff = NULL; 83 | int size; 84 | int bytes; 85 | int block = 65536; 86 | FILE* f = NULL; 87 | 88 | if (filesize) *filesize = 0; 89 | if (err) *err = 0; 90 | 91 | f = fopen(path, "rb"); 92 | if (!f) 93 | { 94 | if (err != NULL) *err = -1; 95 | return NULL; 96 | } 97 | 98 | //Get file size 99 | fseek( f, 0, SEEK_END); 100 | size = ftell(f); 101 | if (filesize) *filesize = size; 102 | 103 | if (size <= 0) 104 | { 105 | if (err != NULL) *err = -2; 106 | fclose (f); 107 | return NULL; 108 | } 109 | 110 | // Return to beginning.... 111 | fseek( f, 0, SEEK_SET); 112 | 113 | buff = malloc (size); 114 | if (buff == NULL) 115 | { 116 | if (err != NULL) *err = -3; 117 | fclose (f); 118 | return NULL; 119 | } 120 | 121 | bytes = 0; 122 | do 123 | { 124 | bytes += fread(&buff[bytes], 1, block, f ); 125 | } 126 | while (bytes < size); 127 | 128 | fclose (f); 129 | 130 | return buff; 131 | } 132 | 133 | bool FileExist (char *fn) 134 | { 135 | FILE * f; 136 | f = fopen(fn, "rb"); 137 | if (!f) return FALSE; 138 | fclose(f); 139 | return TRUE; 140 | } 141 | 142 | bool DirExist (char *path) 143 | { 144 | DIR *dir; 145 | 146 | dir=opendir(path); 147 | if (dir) 148 | { 149 | closedir(dir); 150 | return TRUE; 151 | } 152 | 153 | return FALSE; 154 | } 155 | 156 | /* 157 | this function will check if a folder "may" contain a valid nand 158 | */ 159 | bool IsNandFolder (char *path) 160 | { 161 | char npath[300]; 162 | 163 | sprintf (npath, "%s/TITLE", path); 164 | if (!DirExist(npath)) return FALSE; 165 | 166 | sprintf (npath, "%s/TICKET", path); 167 | if (!DirExist(npath)) return FALSE; 168 | 169 | sprintf (npath, "%s/SHARED1", path); 170 | if (!DirExist(npath)) return FALSE; 171 | 172 | sprintf (npath, "%s/SYS", path); 173 | if (!DirExist(npath)) return FALSE; 174 | 175 | return TRUE; 176 | } 177 | 178 | /* 179 | CountObjectsInFolder will count object in a foder. "." and ".." are skipped. 180 | It return -1 if the passed folder doesn't exist or is a file 181 | */ 182 | int CountObjectsInFolder(char *path) 183 | { 184 | int isFolder = 0; 185 | DIR *pdir; 186 | struct dirent *pent; 187 | int count = 0; 188 | 189 | pdir=opendir(path); 190 | 191 | while ((pent=readdir(pdir)) != NULL) 192 | { 193 | // Let's check if we have really a folder 194 | if (strcmp (pent->d_name, ".") == 0 || strcmp (pent->d_name, "..") == 0) 195 | isFolder = 1; 196 | else 197 | { 198 | count ++; 199 | } 200 | 201 | //printd (" > %s, %d\n", pent->d_name, count); 202 | } 203 | closedir(pdir); 204 | if (!isFolder) return -1; 205 | 206 | return count; 207 | } 208 | -------------------------------------------------------------------------------- /addon/nandbooter/source/codes/patchcode.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "patchcode.h" 8 | #include "codes.h" 9 | 10 | extern void patchhook(u32 address, u32 len); 11 | extern void patchhook2(u32 address, u32 len); 12 | extern void patchhook3(u32 address, u32 len); 13 | 14 | extern u32 ocarinaoption; 15 | extern u32 debuggeroption; 16 | extern u32 hooktypeoption; 17 | 18 | extern void multidolhook(u32 address); 19 | 20 | static const u32 multidolpatch1[2] = { 21 | 0x3C03FFB4,0x28004F43 22 | }; 23 | 24 | static const u32 multidolpatch2[2] = { 25 | 0x3F608000, 0x807B0018 26 | }; 27 | 28 | const u32 viwiihooks[4] = { 29 | 0x7CE33B78,0x38870034,0x38A70038,0x38C7004C 30 | }; 31 | 32 | const u32 kpadhooks[4] = { 33 | 0x9A3F005E,0x38AE0080,0x389FFFFC,0x7E0903A6 34 | }; 35 | 36 | const u32 kpadoldhooks[6] = { 37 | 0x801D0060, 0x901E0060, 0x801D0064, 0x901E0064, 0x801D0068, 0x901E0068 38 | }; 39 | 40 | const u32 joypadhooks[4] = { 41 | 0x3AB50001, 0x3A73000C, 0x2C150004, 0x3B18000C 42 | }; 43 | 44 | const u32 gxdrawhooks[4] = { 45 | 0x3CA0CC01, 0x38000061, 0x3C804500, 0x98058000 46 | }; 47 | 48 | const u32 gxflushhooks[4] = { 49 | 0x90010014, 0x800305FC, 0x2C000000, 0x41820008 50 | }; 51 | 52 | const u32 ossleepthreadhooks[4] = { 53 | 0x90A402E0, 0x806502E4, 0x908502E4, 0x2C030000 54 | }; 55 | 56 | const u32 axnextframehooks[4] = { 57 | 0x3800000E, 0x7FE3FB78, 0xB0050000, 0x38800080 58 | }; 59 | 60 | const u32 wpadbuttonsdownhooks[4] = { 61 | 0x7D6B4A14, 0x816B0010, 0x7D635B78, 0x4E800020 62 | }; 63 | 64 | const u32 wpadbuttonsdown2hooks[4] = { 65 | 0x7D6B4A14, 0x800B0010, 0x7C030378, 0x4E800020 66 | }; 67 | 68 | const u32 multidolchanhooks[4] = { 69 | 0x4200FFF4, 0x48000004, 0x38800000, 0x4E800020 70 | }; 71 | 72 | //--------------------------------------------------------------------------------- 73 | bool dochannelhooks(void *addr, u32 len, bool bootcontentloaded) 74 | //--------------------------------------------------------------------------------- 75 | { 76 | void *addr_start = addr; 77 | void *addr_end = addr+len; 78 | bool patched = false; 79 | bool multidolpatched = false; 80 | 81 | while(addr_start < addr_end) 82 | { 83 | switch(hooktypeoption) 84 | { 85 | 86 | case 0x00: 87 | 88 | break; 89 | 90 | case 0x01: 91 | if(memcmp(addr_start, viwiihooks, sizeof(viwiihooks))==0) 92 | { 93 | patchhook((u32)addr_start, len); 94 | patched = true; 95 | } 96 | break; 97 | 98 | case 0x02: 99 | 100 | if(memcmp(addr_start, kpadhooks, sizeof(kpadhooks))==0) 101 | { 102 | patchhook((u32)addr_start, len); 103 | patched = true; 104 | } 105 | 106 | if(memcmp(addr_start, kpadoldhooks, sizeof(kpadoldhooks))==0) 107 | { 108 | patchhook((u32)addr_start, len); 109 | patched = true; 110 | } 111 | break; 112 | 113 | case 0x03: 114 | 115 | if(memcmp(addr_start, joypadhooks, sizeof(joypadhooks))==0) 116 | { 117 | patchhook((u32)addr_start, len); 118 | patched = true; 119 | } 120 | break; 121 | 122 | case 0x04: 123 | 124 | if(memcmp(addr_start, gxdrawhooks, sizeof(gxdrawhooks))==0) 125 | { 126 | patchhook((u32)addr_start, len); 127 | patched = true; 128 | } 129 | break; 130 | 131 | case 0x05: 132 | 133 | if(memcmp(addr_start, gxflushhooks, sizeof(gxflushhooks))==0) 134 | { 135 | patchhook((u32)addr_start, len); 136 | patched = true; 137 | } 138 | break; 139 | 140 | case 0x06: 141 | 142 | if(memcmp(addr_start, ossleepthreadhooks, sizeof(ossleepthreadhooks))==0) 143 | { 144 | patchhook((u32)addr_start, len); 145 | patched = true; 146 | } 147 | break; 148 | 149 | case 0x07: 150 | 151 | if(memcmp(addr_start, axnextframehooks, sizeof(axnextframehooks))==0) 152 | { 153 | patchhook((u32)addr_start, len); 154 | patched = true; 155 | } 156 | break; 157 | 158 | case 0x08: 159 | 160 | //if(memcmp(addr_start, customhook, customhooksize)==0){ 161 | // patchhook((u32)addr_start, len); 162 | //patched = true; 163 | //} 164 | break; 165 | } 166 | if (hooktypeoption != 0) 167 | { 168 | if(memcmp(addr_start, multidolchanhooks, sizeof(multidolchanhooks))==0) 169 | { 170 | *(((u32*)addr_start)+1) = 0x7FE802A6; 171 | DCFlushRange(((u32*)addr_start)+1, 4); 172 | ICInvalidateRange(((u32*)addr_start)+1, 4); 173 | 174 | multidolhook((u32)addr_start+sizeof(multidolchanhooks)-4); 175 | multidolpatched = true; 176 | } 177 | } 178 | 179 | addr_start += 4; 180 | } 181 | 182 | if (bootcontentloaded) 183 | { 184 | return multidolpatched; 185 | } else 186 | { 187 | return patched; 188 | } 189 | } -------------------------------------------------------------------------------- /source/ioConfig.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "globals.h" 3 | #include "mystring.h" 4 | #include "devices.h" 5 | #include "fsop/fsop.h" 6 | 7 | /* 8 | ioConfig manage the configuration file 9 | 10 | TODO: use text configuration files... maybe 11 | */ 12 | 13 | // This function will init the structures used to keep configuration files 14 | bool ConfigWrite (void) 15 | { 16 | char path[PATHMAX]; 17 | char ver[32]; 18 | FILE *f; 19 | 20 | Debug ("ConfigWrite()"); 21 | 22 | if (vars.defMount[0] == '\0') return false; 23 | 24 | if (vars.neek == NEEK_NONE) 25 | sprintf (path, "%s://ploader/ploader.cfg", vars.defMount); 26 | else 27 | sprintf (path, "%s://ploader/pldneek.cfg", vars.defMount); 28 | 29 | f = fopen (path, "wb"); 30 | 31 | Debug ("ConfigWrite: %s (0x%X)", path, f); 32 | if (!f) return false; 33 | 34 | // Let's write version 35 | sprintf (ver, "%s", CFGVER); 36 | fwrite (ver, sizeof(ver), 1, f); 37 | 38 | // Write configuration data 39 | fwrite (&config, sizeof(config), 1, f); 40 | fclose (f); 41 | 42 | return true; 43 | } 44 | 45 | static void InitConfigCats (void) 46 | { 47 | strcpy (config.appCats[0], "Games"); 48 | strcpy (config.appCats[1], "Utility"); 49 | strcpy (config.appCats[2], "Emulators"); 50 | strcpy (config.appCats[3], "Backup loaders"); 51 | strcpy (config.appCats[4], "Hacking tools"); 52 | strcpy (config.appCats[5], "n/a"); 53 | strcpy (config.appCats[6], "n/a"); 54 | strcpy (config.appCats[7], "n/a"); 55 | } 56 | 57 | bool ConfigRead (void) 58 | { 59 | char path[PATHMAX]; 60 | char ver[32]; 61 | FILE *f; 62 | 63 | memset (&config, 0, sizeof(config)); 64 | 65 | if (vars.defMount[0] == '\0') return false; 66 | 67 | if (vars.neek == NEEK_NONE) 68 | sprintf (path, "%s://ploader/ploader.cfg", vars.defMount); 69 | else 70 | sprintf (path, "%s://ploader/pldneek.cfg", vars.defMount); 71 | 72 | f = fopen (path, "rb"); 73 | Debug ("ConfigRead: %s (0x%X)", path, f); 74 | if (!f) 75 | { 76 | Debug ("unable to open configuration file", path); 77 | InitConfigCats (); 78 | return false; 79 | } 80 | 81 | // read configuration data 82 | fread (ver, sizeof(ver), 1, f); 83 | ver[31] = 0; // make sure to terminate string 84 | 85 | if (strcmp (ver, CFGVER) == 0) 86 | { 87 | Debug ("Valid configuration found"); 88 | fread (&config, sizeof(config), 1, f); 89 | } 90 | else 91 | { 92 | Debug ("Invalid configuration found"); 93 | InitConfigCats (); 94 | } 95 | 96 | fclose (f); 97 | 98 | return true; 99 | } 100 | 101 | ////////////////////////////////////////////////// 102 | 103 | bool ExtConfigWrite (void) 104 | { 105 | char path[PATHMAX]; 106 | char idStart[16]; 107 | char idStop[16]; 108 | size_t size; 109 | u8 *bootdol; 110 | u8 *cfg; 111 | 112 | if (!vars.saveExtendedConf) return true; 113 | vars.saveExtendedConf = 0; 114 | 115 | memcpy (idStart, EXTCONFIG, EXTCONFIGOFFS); 116 | idStart[EXTCONFIGOFFS] = '\0'; 117 | 118 | memcpy (idStop, &EXTCONFIG[EXTCONFIGSIZE+EXTCONFIGOFFS], EXTCONFIGOFFS); 119 | idStop[EXTCONFIGOFFS] = '\0'; 120 | 121 | //mt_Lock(); 122 | 123 | int dev; 124 | for (dev = 0; dev <= 1; dev++) 125 | if (devices_Get (dev)) 126 | { 127 | sprintf (path, "%s:/%s/boot.dol", devices_Get (dev), HBAPPFOLDER); 128 | 129 | bootdol = fsop_ReadFile (path, 0, &size); 130 | if (bootdol) 131 | { 132 | gprintf ("ExtConfigWrite: searching signature\n"); 133 | cfg = ms_FindStringInBuffer (bootdol, size, idStart); 134 | if (cfg) 135 | { 136 | gprintf ("ExtConfigWrite: signature found\n"); 137 | 138 | cfg += EXTCONFIGOFFS; 139 | memcpy (cfg, &extConfig, sizeof (s_extConfig)); 140 | 141 | gprintf ("extConfig.use249 = %d\n", extConfig.use249); 142 | gprintf ("extConfig.disableUSB = %d\n", extConfig.disableUSB); 143 | gprintf ("extConfig.disableUSBneek = %d\n", extConfig.disableUSBneek); 144 | 145 | gprintf ("ExtConfigWrite: fsop_WriteFile %s %d\n", path, size); 146 | fsop_WriteFile (path, bootdol, size); 147 | free (bootdol); 148 | } 149 | } 150 | } 151 | 152 | //mt_Unlock(); 153 | 154 | return true; 155 | } 156 | 157 | bool ExtConfigRead (void) 158 | { 159 | char buff[17]; 160 | strcpy (buff, "0123456789ABCDEF"); 161 | 162 | int ret = memcmp (&EXTCONFIG[EXTCONFIGOFFS], buff, 16); 163 | gprintf ("ExtConfigRead: memcmp ret = %d\n", ret); 164 | 165 | // Check if it is intialized.... 166 | if (ret == 0) 167 | { 168 | gprintf ("ExtConfigRead: valid data not found\n"); 169 | memset (&extConfig, 0, sizeof (s_extConfig)); 170 | } 171 | else 172 | { 173 | gprintf ("ExtConfigRead: found valid data\n"); 174 | memcpy (&extConfig, &EXTCONFIG[EXTCONFIGOFFS], sizeof (s_extConfig)); 175 | } 176 | 177 | gprintf ("extConfig.use249 = %d\n", extConfig.use249); 178 | gprintf ("extConfig.disableUSB = %d\n", extConfig.disableUSB); 179 | gprintf ("extConfig.disableUSBneek = %d\n", extConfig.disableUSBneek); 180 | 181 | return true; 182 | } 183 | -------------------------------------------------------------------------------- /addon/forwarder/source/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | forwarder dol used in postloader channel 4 | 5 | load postloader from sd/isfs/fat32. 6 | 7 | */ 8 | 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include "../build/bin2o.h" 20 | #include "ios.h" 21 | #include "debug.h" 22 | 23 | #define VER "1.5" 24 | 25 | #define EXECUTE_ADDR ((u8 *) 0x92000000) 26 | #define BOOTER_ADDR ((u8 *) 0x93000000) 27 | #define ARGS_ADDR ((u8 *) 0x93200000) 28 | #define CMDL_ADDR ((u8 *) 0x93200000+sizeof(struct __argv)) 29 | #define HBMAGIC_ADDR ((u8 *) 0x93200000-8) 30 | 31 | #define TITLE_ID(x,y) (((u64)(x) << 32) | (y)) 32 | 33 | #define NEEK 1 34 | 35 | extern void __exception_closeall(); 36 | typedef void (*entrypoint) (void); 37 | 38 | u32 cookie; 39 | void *exeBuffer = (void *) EXECUTE_ADDR; 40 | 41 | #define CFG_HOME_WII_MENU 0x50756E65 42 | #define MAXFILESIZE 16777216 // 16mb 43 | 44 | static void *xfb = NULL; 45 | static GXRModeObj *rmode = NULL; 46 | 47 | static int disableOutput = 0; 48 | 49 | void InitVideo (void) 50 | { 51 | VIDEO_Init(); 52 | rmode = VIDEO_GetPreferredMode(NULL); 53 | xfb = SYS_AllocateFramebuffer(rmode); 54 | VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK); 55 | xfb = MEM_K0_TO_K1(xfb); 56 | console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); 57 | VIDEO_Configure(rmode); 58 | VIDEO_SetNextFramebuffer(xfb); 59 | VIDEO_SetBlack(FALSE); 60 | VIDEO_Flush(); 61 | VIDEO_WaitVSync(); 62 | VIDEO_WaitVSync(); 63 | } 64 | 65 | bool LoadFile (char *path) 66 | { 67 | FILE *f; 68 | size_t size; 69 | 70 | f = fopen(path, "rb"); 71 | if (!f) return false; 72 | 73 | size = fread(exeBuffer, 1, MAXFILESIZE, f ); 74 | fclose (f); 75 | 76 | if (size <= 0) return false; 77 | 78 | return true; 79 | } 80 | 81 | bool LoadPostloaderFromISFS (void) 82 | { 83 | char path[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); 84 | 85 | ISFS_Initialize(); 86 | 87 | strcpy (path, "/apps/postLoader/boot.dol"); 88 | 89 | s32 fd = ISFS_Open (path, ISFS_OPEN_READ); 90 | if (fd < 0) 91 | goto fail; 92 | s32 filesize = ISFS_Seek(fd, 0, 2); 93 | if (filesize == 0) 94 | goto fail; 95 | ISFS_Seek (fd, 0, 0); 96 | 97 | // exeBuffer is already 32bit aligned... should work fine 98 | s32 readed = ISFS_Read (fd, exeBuffer, filesize); 99 | ISFS_Close (fd); 100 | 101 | if (readed != filesize) 102 | goto fail; 103 | 104 | return TRUE; 105 | 106 | fail: 107 | ISFS_Deinitialize (); 108 | return FALSE; 109 | } 110 | 111 | bool GetFileToBoot (void) 112 | { 113 | bool ret = false; 114 | 115 | if (ret == false && fatMountSimple("fat", &__io_wiisd)) 116 | { 117 | ret = LoadFile("fat://apps/postloader/boot.dol"); 118 | 119 | fatUnmount("fat:/"); 120 | __io_wiisd.shutdown(); 121 | } 122 | 123 | if (ret == false) 124 | ret = LoadPostloaderFromISFS (); 125 | 126 | if (ret == false && fatMountSimple("fat", &__io_usbstorage)) 127 | { 128 | ret = LoadFile("fat://apps/postloader/boot.dol"); 129 | 130 | fatUnmount("fat:/"); 131 | __io_wiisd.shutdown(); 132 | } 133 | 134 | return ret; 135 | } 136 | 137 | int main(int argc, char *argv[]) 138 | { 139 | gprintf ("postLoader forwarder "VER"\n"); 140 | 141 | InitVideo (); 142 | 143 | if ( 144 | HBMAGIC_ADDR[0] == 'P' && 145 | HBMAGIC_ADDR[1] == 'O' && 146 | HBMAGIC_ADDR[2] == 'S' && 147 | HBMAGIC_ADDR[3] == 'T' 148 | ) 149 | { 150 | disableOutput = 1; 151 | gprintf ("Magic world found !\n"); 152 | goto directstart; 153 | } 154 | 155 | if (!disableOutput) 156 | { 157 | printf ("\n\n"); 158 | printf ("Loading postLoader..."); 159 | } 160 | 161 | gprintf ("Searching for postLoader\n"); 162 | if (!GetFileToBoot ()) 163 | { 164 | gprintf ("postLoader not found\n"); 165 | printf ("\n\n\n"); 166 | printf ("postloader not found... \n\n"); 167 | printf ("booting to system menu..."); 168 | 169 | sleep (3); 170 | 171 | // Let's try to start system menu... use magic word, as we may have priiloader behind 172 | *(vu32*)0x8132FFFB = CFG_HOME_WII_MENU; 173 | DCFlushRange((void*)0x8132FFFB,4); 174 | 175 | SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); 176 | return 0; 177 | } 178 | 179 | struct __argv arg; 180 | memset (&arg, 0, sizeof(struct __argv)); 181 | 182 | memcpy(ARGS_ADDR, &arg, sizeof(arg)); 183 | DCFlushRange(ARGS_ADDR, sizeof(arg) + arg.length); 184 | 185 | directstart: 186 | 187 | HBMAGIC_ADDR[0] = 'X'; 188 | HBMAGIC_ADDR[1] = 'X'; 189 | HBMAGIC_ADDR[2] = 'X'; 190 | HBMAGIC_ADDR[3] = 'X'; 191 | 192 | memcpy(BOOTER_ADDR, booter_dol, booter_dol_size); 193 | DCFlushRange(BOOTER_ADDR, booter_dol_size); 194 | 195 | entrypoint exeEntryPoint; 196 | exeEntryPoint = (entrypoint) BOOTER_ADDR; 197 | 198 | gprintf ("booting...\n"); 199 | 200 | if (!disableOutput) 201 | printf ("booting!"); 202 | 203 | /* cleaning up and load dol */ 204 | SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); 205 | _CPU_ISR_Disable (cookie); 206 | __exception_closeall (); 207 | exeEntryPoint (); 208 | _CPU_ISR_Restore (cookie); 209 | 210 | exit (0); 211 | } -------------------------------------------------------------------------------- /addon/nandbooter/source/isfs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "tools.h" 6 | #include "isfs.h" 7 | 8 | 9 | 10 | 11 | s32 __FileCmp(const void *a, const void *b) 12 | { 13 | dirent_t *hdr1 = (dirent_t *)a; 14 | dirent_t *hdr2 = (dirent_t *)b; 15 | 16 | if (hdr1->type == hdr2->type) 17 | { 18 | return strcmp(hdr1->name, hdr2->name); 19 | } else 20 | { 21 | return 0; 22 | } 23 | } 24 | 25 | s32 getdircount(char *path, u32 *cnt) 26 | { 27 | if (cnt == NULL) return -2; 28 | u32 temp = 0; 29 | s32 res = ISFS_ReadDir(path, NULL, &temp); 30 | if (res != ISFS_OK) 31 | { 32 | debug("ERR: (getdircount) Could not get dir entry count(ret: %d) for:\n'%s'\n", res, path); 33 | return -1; 34 | } 35 | *cnt = temp; 36 | 37 | return 1; 38 | } 39 | 40 | s32 getdir(char *path, dirent_t **ent, u32 *cnt) 41 | { 42 | if (ent == NULL) return -2; 43 | 44 | s32 res; 45 | u32 num = 0; 46 | 47 | int i, j, k; 48 | 49 | res = getdircount(path, &num); 50 | if (res < 0) 51 | { 52 | //debug("Error: could not get dir entry count! (result: %d)\n", res); 53 | return -1; 54 | } 55 | *cnt = num; 56 | 57 | if (num == 0) return 0; 58 | 59 | char ebuf[ISFS_MAXPATH + 1]; 60 | 61 | char *nbuf = (char *)allocate_memory(13 * num); 62 | if (nbuf == NULL) 63 | { 64 | debug("ERR: (getdir) could not allocate buffer for name list!\n"); 65 | return -2; 66 | } 67 | 68 | res = ISFS_ReadDir(path, nbuf, &num); 69 | if (res != ISFS_OK) 70 | { 71 | debug("ERR: (getdir) could not get name list! (result: %d)\n", res); 72 | free(nbuf); 73 | return -3; 74 | } 75 | 76 | *ent = malloc(sizeof(dirent_t) * num); 77 | if (*ent == NULL) 78 | { 79 | debug("ERR: (getdir) could not allocate buffer\n"); 80 | free(nbuf); 81 | return -4; 82 | } 83 | 84 | for (i = 0, k = 0; i < num; i++) 85 | { 86 | for (j = 0; nbuf[k] != 0; j++, k++) 87 | ebuf[j] = nbuf[k]; 88 | ebuf[j] = 0; 89 | k++; 90 | 91 | strcpy((*ent)[i].name, ebuf); 92 | } 93 | 94 | qsort(*ent, *cnt, sizeof(dirent_t), __FileCmp); 95 | 96 | free(nbuf); 97 | return 0; 98 | } 99 | 100 | s32 read_full_file_from_nand(char *filepath, u8 **buffer, u32 *filesize) 101 | { 102 | s32 Fd; 103 | int ret; 104 | 105 | if (buffer == NULL) 106 | { 107 | debug("\n(read_full_file_from_nand) NULL Pointer\n"); 108 | return -1; 109 | } 110 | 111 | Fd = ISFS_Open(filepath, ISFS_OPEN_READ); 112 | if (Fd < 0) 113 | { 114 | debug("\n(read_full_file_from_nand) ISFS_Open %s failed %d\n", filepath, Fd); 115 | return Fd; 116 | } 117 | 118 | fstats *status = allocate_memory(sizeof(fstats)); 119 | if (status == NULL) 120 | { 121 | debug("\n(read_full_file_from_nand) Out of memory for status\n"); 122 | ISFS_Close(Fd); 123 | return -1; 124 | } 125 | 126 | ret = ISFS_GetFileStats(Fd, status); 127 | if (ret < 0) 128 | { 129 | debug("\n(read_full_file_from_nand) ISFS_GetFileStats failed %d\n", ret); 130 | ISFS_Close(Fd); 131 | free(status); 132 | return -1; 133 | } 134 | 135 | *buffer = allocate_memory(status->file_length); 136 | if (*buffer == NULL) 137 | { 138 | debug("\n(read_full_file_from_nand) Out of memory for buffer\n"); 139 | ISFS_Close(Fd); 140 | free(status); 141 | return -1; 142 | } 143 | 144 | ret = ISFS_Read(Fd, *buffer, status->file_length); 145 | if (ret < 0) 146 | { 147 | debug("\n(read_full_file_from_nand) ISFS_Read failed %d\n", ret); 148 | ISFS_Close(Fd); 149 | free(status); 150 | free(*buffer); 151 | return ret; 152 | } 153 | ISFS_Close(Fd); 154 | 155 | *filesize = status->file_length; 156 | free(status); 157 | 158 | return 0; 159 | } 160 | 161 | s32 read_file_from_nand(char *filepath, u8 *buffer, u32 filesize) 162 | { 163 | s32 Fd; 164 | int ret; 165 | 166 | if (buffer == NULL) 167 | { 168 | debug("ERR: (read_file_from_nand) NULL Pointer\n"); 169 | return -1; 170 | } 171 | 172 | Fd = ISFS_Open(filepath, ISFS_OPEN_READ); 173 | if (Fd < 0) 174 | { 175 | debug("ERR: (read_file_from_nand) ISFS_Open %s failed %d\n", filepath, Fd); 176 | return Fd; 177 | } 178 | 179 | fstats *status = allocate_memory(sizeof(fstats)); 180 | if (status == NULL) 181 | { 182 | debug("ERR: (read_file_from_nand) Out of memory for status\n"); 183 | ISFS_Close(Fd); 184 | return -1; 185 | } 186 | 187 | ret = ISFS_GetFileStats(Fd, status); 188 | if (ret < 0) 189 | { 190 | debug("ERR: (read_file_from_nand) ISFS_GetFileStats failed %d\n", ret); 191 | ISFS_Close(Fd); 192 | free(status); 193 | return -1; 194 | } 195 | 196 | if (filesize > status->file_length) 197 | { 198 | debug("ERR: (read_file_from_nand) Reading %u bytes failed, filesize: %u\n", filesize, status->file_length); 199 | ISFS_Close(Fd); 200 | free(status); 201 | return -1; 202 | } 203 | 204 | ret = ISFS_Read(Fd, buffer, filesize); 205 | if (ret < 0) 206 | { 207 | debug("ERR: (read_file_from_nand) ISFS_Read failed %d\n", ret); 208 | ISFS_Close(Fd); 209 | free(status); 210 | return ret; 211 | } 212 | ISFS_Close(Fd); 213 | 214 | free(status); 215 | 216 | return 0; 217 | } 218 | -------------------------------------------------------------------------------- /source/zip/crypt.h: -------------------------------------------------------------------------------- 1 | /* crypt.h -- base code for crypt/uncrypt ZIPfile 2 | 3 | 4 | Version 1.01e, February 12th, 2005 5 | 6 | Copyright (C) 1998-2005 Gilles Vollant 7 | 8 | This code is a modified version of crypting code in Infozip distribution 9 | 10 | The encryption/decryption parts of this source code (as opposed to the 11 | non-echoing password parts) were originally written in Europe. The 12 | whole source package can be freely distributed, including from the USA. 13 | (Prior to January 2000, re-export from the US was a violation of US law.) 14 | 15 | This encryption code is a direct transcription of the algorithm from 16 | Roger Schlafly, described by Phil Katz in the file appnote.txt. This 17 | file (appnote.txt) is distributed with the PKZIP program (even in the 18 | version without encryption capabilities). 19 | 20 | If you don't need crypting in your application, just define symbols 21 | NOCRYPT and NOUNCRYPT. 22 | 23 | This code support the "Traditional PKWARE Encryption". 24 | 25 | The new AES encryption added on Zip format by Winzip (see the page 26 | http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong 27 | Encryption is not supported. 28 | */ 29 | 30 | #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) 31 | 32 | /*********************************************************************** 33 | * Return the next byte in the pseudo-random sequence 34 | */ 35 | static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) 36 | { 37 | unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an 38 | * unpredictable manner on 16-bit systems; not a problem 39 | * with any known compiler so far, though */ 40 | 41 | temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; 42 | return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); 43 | } 44 | 45 | /*********************************************************************** 46 | * Update the encryption keys with the next byte of plain text 47 | */ 48 | static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) 49 | { 50 | (*(pkeys+0)) = CRC32((*(pkeys+0)), c); 51 | (*(pkeys+1)) += (*(pkeys+0)) & 0xff; 52 | (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; 53 | { 54 | register int keyshift = (int)((*(pkeys+1)) >> 24); 55 | (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); 56 | } 57 | return c; 58 | } 59 | 60 | 61 | /*********************************************************************** 62 | * Initialize the encryption keys and the random header according to 63 | * the given password. 64 | */ 65 | static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) 66 | { 67 | *(pkeys+0) = 305419896L; 68 | *(pkeys+1) = 591751049L; 69 | *(pkeys+2) = 878082192L; 70 | while (*passwd != '\0') { 71 | update_keys(pkeys,pcrc_32_tab,(int)*passwd); 72 | passwd++; 73 | } 74 | } 75 | 76 | #define zdecode(pkeys,pcrc_32_tab,c) \ 77 | (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) 78 | 79 | #define zencode(pkeys,pcrc_32_tab,c,t) \ 80 | (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) 81 | 82 | #ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED 83 | 84 | #define RAND_HEAD_LEN 12 85 | /* "last resort" source for second part of crypt seed pattern */ 86 | # ifndef ZCR_SEED2 87 | # define ZCR_SEED2 3141592654UL /* use PI as default pattern */ 88 | # endif 89 | 90 | static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) 91 | const char *passwd; /* password string */ 92 | unsigned char *buf; /* where to write header */ 93 | int bufSize; 94 | unsigned long* pkeys; 95 | const unsigned long* pcrc_32_tab; 96 | unsigned long crcForCrypting; 97 | { 98 | int n; /* index in random header */ 99 | int t; /* temporary */ 100 | int c; /* random byte */ 101 | unsigned char header[RAND_HEAD_LEN-2]; /* random header */ 102 | static unsigned calls = 0; /* ensure different random header each time */ 103 | 104 | if (bufSize> 7) & 0xff; 119 | header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); 120 | } 121 | /* Encrypt random header (last two bytes is high word of crc) */ 122 | init_keys(passwd, pkeys, pcrc_32_tab); 123 | for (n = 0; n < RAND_HEAD_LEN-2; n++) 124 | { 125 | buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); 126 | } 127 | buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); 128 | buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); 129 | return n; 130 | } 131 | 132 | #endif 133 | -------------------------------------------------------------------------------- /addon/nandbooter/source/nand.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "nand.h" 7 | #include "tools.h" 8 | 9 | /* Buffer */ 10 | static const char fs[] ATTRIBUTE_ALIGN(32) = "/dev/fs"; 11 | static const char fat[] ATTRIBUTE_ALIGN(32) = "fat"; 12 | static u32 inbuf[8] ATTRIBUTE_ALIGN(32); 13 | static int partition = 0; 14 | 15 | static nandDevice ndevList[] = { 16 | { "Disable", 0, 0x00, 0x00 }, 17 | { "SD/SDHC Card", 1, 0xF0, 0xF1 }, 18 | { "USB 2.0 Mass Storage Device", 2, 0xF2, 0xF3 }, 19 | }; 20 | 21 | s32 Nand_Mount(nandDevice *dev) 22 | { 23 | s32 fd, ret; 24 | u32 inlen = 0; 25 | ioctlv *vector = NULL; 26 | u32 *buffer = NULL; 27 | int rev = IOS_GetRevision(); 28 | 29 | debug ("Nand_Mount: ios_rev = %d\n", rev); 30 | 31 | /* Open FAT module */ 32 | fd = IOS_Open(fat, 0); 33 | if (fd < 0) 34 | { 35 | debug ("Nand_Mount: IOS_Open failed = %d\n", fd); 36 | return fd; 37 | } 38 | 39 | /* Prepare vector */ 40 | if(rev >= 21 && rev < 30000) 41 | { 42 | // NOTE: 43 | // The official cIOSX rev21 by Waninkoko ignores the partition argument 44 | // and the nand is always expected to be on the 1st partition. 45 | // However this way earlier d2x betas having revision 21 take in 46 | // consideration the partition argument. 47 | inlen = 1; 48 | 49 | /* Allocate memory */ 50 | buffer = (u32 *)memalign(32, sizeof(u32)*3); 51 | 52 | /* Set vector pointer */ 53 | vector = (ioctlv *)buffer; 54 | 55 | buffer[0] = (u32)(buffer + 2); 56 | buffer[1] = sizeof(u32); 57 | buffer[2] = (u32)partition; 58 | } 59 | 60 | /* Mount device */ 61 | ret = IOS_Ioctlv(fd, dev->mountCmd, inlen, 0, vector); 62 | 63 | debug ("Nand_Mount: IOS_Ioctlv = %d\n", ret); 64 | 65 | /* Close FAT module */ 66 | IOS_Close(fd); 67 | 68 | /* Free memory */ 69 | if(buffer != NULL) 70 | free(buffer); 71 | 72 | return ret; 73 | } 74 | 75 | s32 Nand_Unmount(nandDevice *dev) 76 | { 77 | s32 fd, ret; 78 | 79 | /* Open FAT module */ 80 | fd = IOS_Open("fat", 0); 81 | if (fd < 0) 82 | return fd; 83 | 84 | /* Unmount device */ 85 | ret = IOS_Ioctlv(fd, dev->umountCmd, 0, 0, NULL); 86 | 87 | /* Close FAT module */ 88 | IOS_Close(fd); 89 | 90 | return ret; 91 | } 92 | 93 | s32 Nand_Enable(nandDevice *dev, char *path) 94 | { 95 | s32 fd, ret; 96 | 97 | /* Open /dev/fs */ 98 | fd = IOS_Open("/dev/fs", 0); 99 | if (fd < 0) 100 | return fd; 101 | 102 | memset(inbuf, 0, sizeof(inbuf)); 103 | 104 | /* Set input buffer */ 105 | if (IOS_GetRevision() >= 20) 106 | { 107 | // New method, fully enable full emulation 108 | inbuf[0] = dev->mode | 0x100; 109 | } else 110 | { 111 | // Old method 112 | inbuf[0] = dev->mode; 113 | } 114 | 115 | /* Enable NAND emulator */ 116 | if (path && strlen(path) > 0) 117 | { 118 | // We have a path... try to pass it to 119 | u32 *buffer = NULL; 120 | 121 | int pathlen = strlen(path)+1; 122 | 123 | /* Allocate memory */ 124 | buffer = (u32 *)memalign(32, (sizeof(u32)*5)+pathlen); 125 | 126 | buffer[0] = (u32)(buffer + 4); 127 | buffer[1] = sizeof(u32); // actually not used by cios 128 | buffer[2] = (u32)(buffer + 5); 129 | buffer[3] = pathlen; // actually not used by cios 130 | buffer[4] = inbuf[0]; 131 | strcpy((char*)(buffer+5), path); 132 | 133 | ret = IOS_Ioctlv(fd, 100, 2, 0, (ioctlv *)buffer); 134 | 135 | free (buffer); 136 | 137 | debug ("Nand_Enable IOS_Ioctlv = %d\n", ret); 138 | } 139 | else 140 | { 141 | ret = IOS_Ioctl(fd, 100, inbuf, sizeof(inbuf), NULL, 0); 142 | 143 | debug ("Nand_Enable IOS_Ioctl = %d\n", ret); 144 | } 145 | 146 | /* Close /dev/fs */ 147 | IOS_Close(fd); 148 | 149 | return ret; 150 | } 151 | 152 | s32 Nand_Disable(void) 153 | { 154 | s32 fd, ret; 155 | 156 | /* Open /dev/fs */ 157 | fd = IOS_Open("/dev/fs", 0); 158 | if (fd < 0) 159 | return fd; 160 | 161 | /* Set input buffer */ 162 | inbuf[0] = 0; 163 | 164 | /* Disable NAND emulator */ 165 | ret = IOS_Ioctl(fd, 100, inbuf, sizeof(inbuf), NULL, 0); 166 | 167 | /* Close /dev/fs */ 168 | IOS_Close(fd); 169 | 170 | return ret; 171 | } 172 | 173 | static int mounted = 0; 174 | static int slot = 0; 175 | 176 | s32 get_nand_device() 177 | { 178 | return mounted; 179 | } 180 | 181 | s32 Enable_Emu(int selection, char *path) 182 | { 183 | if (mounted != 0) return -1; 184 | 185 | s32 ret; 186 | nandDevice *ndev = NULL; 187 | ndev = &ndevList[selection]; 188 | 189 | partition = 0; 190 | do 191 | { 192 | ret = Nand_Mount(ndev); 193 | 194 | if (ret < 0) 195 | partition ++; 196 | } 197 | while (partition < 4 && ret < 0); 198 | 199 | if (ret < 0) 200 | return ret; 201 | 202 | debug ("Enabling Nand\n"); 203 | 204 | ret = Nand_Enable(ndev, path); 205 | if (ret < 0) 206 | { 207 | Nand_Unmount(ndev); 208 | return ret; 209 | } 210 | 211 | debug ("Nand Mounted= %d\n", ret); 212 | 213 | mounted = 1; 214 | slot = selection; 215 | 216 | return 0; 217 | } 218 | 219 | s32 Disable_Emu() 220 | { 221 | if (mounted == 0) return 0; 222 | 223 | nandDevice *ndev = NULL; 224 | ndev = &ndevList[slot]; 225 | 226 | Nand_Disable(); 227 | Nand_Unmount(ndev); 228 | 229 | mounted = 0; 230 | 231 | return 0; 232 | } 233 | -------------------------------------------------------------------------------- /source/screensaver.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "globals.h" 9 | #include "bin2o.h" 10 | #include "devices.h" 11 | 12 | static bool Play (char * fn) // return true interrupt the screensaver 13 | { 14 | static int xs = 0; 15 | GRRLIB_texImg *img; 16 | 17 | //Debug ("Play: %s", fn); 18 | 19 | if (fn == NULL) 20 | img = GRRLIB_LoadTexturePNG (icon_png); 21 | else 22 | { 23 | //mt_Lock(); 24 | img = GRRLIB_LoadTextureFromFile (fn); 25 | //mt_Unlock(); 26 | } 27 | 28 | if (!img) return false; 29 | 30 | int x = (rand () % 500) + 70; 31 | int y = (rand () % 300) + 90; 32 | 33 | GRRLIB_Rectangle (0, 0, 640, 480, RGBA (0,0,0,255), 1 ); 34 | grlib_PushScreen (); 35 | 36 | int i; 37 | float z = 0; 38 | 39 | float ratio = ((float)img->w / (float)img->h)/1.3; 40 | 41 | Video_SetFont(TTFNORM); 42 | 43 | for (i = 360; i >= 0; i-=4) 44 | { 45 | grlib_PopScreen (); 46 | grlib_DrawImgCenter (x, y, z, z/ratio, img, (float)i, RGBA(255,255,255,255)); 47 | 48 | grlib_printf (xs++, 450, GRLIB_ALIGNCENTER, 0, "postLoader " VER " (press any key)"); 49 | if (xs > 1000) xs = -360; 50 | 51 | grlib_Render (); 52 | usleep (1000); 53 | 54 | if (grlib_GetUserInput() || grlibSettings.wiiswitch_reset || grlibSettings.wiiswitch_poweroff) return true; 55 | 56 | if (fn == NULL) 57 | z += 5; 58 | else 59 | z += 3; 60 | } 61 | 62 | for (i = 0; i < 100; i++) 63 | { 64 | grlib_PopScreen (); 65 | grlib_DrawImgCenter (x, y, z, z/ratio, img, 0, RGBA(255,255,255,255)); 66 | 67 | grlib_printf (xs++, 450, GRLIB_ALIGNCENTER, 0, "postLoader " VER " (press any key)"); 68 | if (xs > 1000) xs = -360; 69 | 70 | grlib_Render (); 71 | usleep (1000); 72 | 73 | if (grlib_GetUserInput() || grlibSettings.wiiswitch_reset || grlibSettings.wiiswitch_poweroff) return true; 74 | } 75 | 76 | for (i = 255; i >= 0; i -= 5) 77 | { 78 | grlib_PopScreen (); 79 | grlib_DrawImgCenter (x, y, z, z/ratio, img, 0, RGBA(255,255,255,i)); 80 | 81 | grlib_printf (xs++, 450, GRLIB_ALIGNCENTER, 0, "postLoader " VER " (press any key)"); 82 | if (xs > 1000) xs = -360; 83 | 84 | grlib_Render (); 85 | usleep (1000); 86 | 87 | if (grlib_GetUserInput() || grlibSettings.wiiswitch_reset || grlibSettings.wiiswitch_poweroff) return true; 88 | } 89 | 90 | GRRLIB_FreeTexture (img); 91 | 92 | devices_TickUSB (); 93 | 94 | snd_Mp3Go (); 95 | 96 | return false; 97 | } 98 | 99 | #define PATHS 2 100 | static bool ScreenSaver (void) 101 | { 102 | bool ret = false; 103 | DIR *pdir[2]; 104 | struct dirent *pent; 105 | int fr; 106 | int cp = 0; 107 | int count = 0; 108 | 109 | char path[2][128]; 110 | char fn[128]; 111 | 112 | Debug ("ScreenSaver: start"); 113 | 114 | fr = grlibSettings.fontDef.reverse; 115 | grlibSettings.fontDef.reverse = 0; 116 | 117 | sprintf (path[0], "%s://ploader/covers", vars.defMount); 118 | sprintf (path[1], "%s://ploader/covers.emu", vars.defMount); 119 | 120 | pdir[0] = NULL; 121 | pdir[1] = NULL; 122 | 123 | do 124 | { 125 | if (!pdir[cp]) 126 | pdir[cp] = opendir(path[cp]); 127 | 128 | if (pdir[cp]) 129 | pent = readdir(pdir[cp]); 130 | else 131 | pent = NULL; 132 | 133 | if (pent) 134 | { 135 | if (strstr (pent->d_name, ".png") != NULL || strstr (pent->d_name, ".PNG") != NULL) 136 | { 137 | sprintf (fn, "%s/%s", path[cp], pent->d_name); 138 | 139 | Debug ("ScreenSaver: %s", fn); 140 | 141 | ret = Play (fn); 142 | if (ret) break; 143 | } 144 | } 145 | 146 | if (count++ > 4) 147 | { 148 | ret = Play (NULL); 149 | if (ret) break; 150 | } 151 | 152 | if (!pent) 153 | { 154 | if (pdir[cp]) closedir(pdir[cp]); 155 | pdir[cp] = NULL; 156 | cp ++; 157 | if (cp >= PATHS) cp = 0; 158 | } 159 | } 160 | while (!ret); 161 | 162 | if (pdir[0]) closedir(pdir[0]); 163 | if (pdir[1]) closedir(pdir[1]); 164 | 165 | grlibSettings.fontDef.reverse = fr; 166 | 167 | if (ret) return true; 168 | return false; 169 | } 170 | 171 | // Do burnin checking and hdd live and mp3 playing 172 | bool LiveCheck (int reset) 173 | { 174 | static int ss = 0; 175 | static time_t t = 0; 176 | static time_t tss = 0; 177 | static time_t tp = 0; 178 | static time_t ct = 0; // current time 179 | static int xLast = 0, yLast = 0, bAct = 0; 180 | 181 | ct = time(NULL); 182 | 183 | if (reset) 184 | { 185 | tp = tss = t = ct; 186 | } 187 | 188 | // No user input ? 189 | if (grlib_irPos.x == xLast && grlib_irPos.y == yLast && grlibSettings.buttonActivity == bAct) 190 | { 191 | if ((ct - tss) > 1) 192 | { 193 | tss = ct; 194 | ss ++; 195 | } 196 | 197 | if (ss > 60) 198 | return ScreenSaver (); 199 | } 200 | else 201 | { 202 | xLast = grlib_irPos.x; 203 | yLast = grlib_irPos.y; 204 | bAct = grlibSettings.buttonActivity; 205 | ss = 0; 206 | } 207 | 208 | if ((ct - t) > 30) 209 | { 210 | t = ct; 211 | 212 | devices_TickUSB (); 213 | } 214 | 215 | if ((ct - tp) > 2) 216 | { 217 | tp = ct; 218 | snd_Mp3Go (); 219 | } 220 | 221 | return false; 222 | } -------------------------------------------------------------------------------- /source/autoupdate.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "globals.h" 7 | #include "ios.h" 8 | #include "http.h" 9 | #include "devices.h" 10 | 11 | static int ShowInfo (char *buff, char *ver) 12 | { 13 | char *title; 14 | 15 | Video_SetFont(TTFNORM); 16 | 17 | int j = 0, i = strlen("postLoader "); 18 | while (buff[i] != '\r' && buff[i] != '\n') 19 | ver[j++] = buff[i++]; 20 | ver[j++] = '\0'; 21 | 22 | title = calloc (1, strlen (buff)); 23 | 24 | if (strcmp (VER, ver) == 0) 25 | { 26 | //grlib_menu ("You already have the last version", " OK "); 27 | //free (buff); 28 | //return -1; 29 | 30 | strcpy (title, "You already have the last version!!!\n\n"); 31 | } 32 | 33 | 34 | int k, nl, lines; 35 | 36 | //strcpy (title, ""); 37 | j = strlen (title); 38 | nl = 0; 39 | k = 0; 40 | lines = 0; 41 | for (i = 0; i < strlen (buff); i++) 42 | { 43 | if (k > 80) nl = 1; 44 | 45 | if (buff[i] == '\n') 46 | { 47 | k = 0; 48 | nl = 0; 49 | lines ++; 50 | } 51 | if (nl && buff[i] == ' ') 52 | { 53 | strcat (title, "\n"); 54 | k = 0; 55 | nl = 0; 56 | lines ++; 57 | } 58 | else 59 | { 60 | title[j] = buff[i]; 61 | title[j+1] = 0; 62 | } 63 | 64 | if (lines > 17) 65 | { 66 | strcat (title, "... CUT ..."); 67 | j = strlen(title); 68 | break; 69 | } 70 | j++; 71 | k++; 72 | } 73 | title[j] = 0; 74 | 75 | Video_SetFontMenu(TTFSMALL); 76 | int item = grlib_menu (0, title, "Update to %s~Skip", ver); 77 | Video_SetFontMenu(TTFNORM); 78 | 79 | free (title); 80 | free (buff); 81 | 82 | return item; 83 | } 84 | 85 | static int cb_mode = 0; 86 | static void cb_au (void) 87 | { 88 | static u32 mstout = 0; 89 | u32 ms = ticks_to_millisecs(gettime()); 90 | 91 | if (mstout < ms) 92 | { 93 | if (cb_mode == 0) 94 | Video_WaitPanel (TEX_HGL, 0, "Please wait %d %%|downloading %u of %u Kb", (http.bytes * 100)/http.size, http.bytes / 1024, http.size / 1024); 95 | 96 | if (cb_mode == 1) 97 | Video_WaitPanel (TEX_HGL, 0, "Please wait...|updating postLoader"); 98 | 99 | mstout = ms + 200; 100 | } 101 | } 102 | 103 | int AutoUpdate (void) 104 | { 105 | char buff[300]; 106 | char *outbuf; 107 | u32 outlen=0; 108 | 109 | cb_mode = 0; 110 | 111 | grlib_Redraw (); 112 | grlib_PushScreen (); 113 | 114 | Video_WaitPanel (TEX_HGL, 0, "Checking online update"); 115 | sprintf (buff, "http://postloader.googlecode.com/svn/trunk/historii.txt"); 116 | outbuf = (char*)downloadfile (buff, &outlen, NULL); // outbuf is 0 terminated 117 | if (!outbuf) 118 | { 119 | Video_WaitPanel (TEX_HGL, 0, "Error getting update informations (%d)", outlen); 120 | sleep (3); 121 | return 0; 122 | } 123 | 124 | char ver[64]; 125 | if (ShowInfo (outbuf,ver) == 0) 126 | { 127 | //sprintf (buff, "http://postloader.googlecode.com/files/plupdate.%s.zip", ver); 128 | sprintf (buff, "http://postloader.mooo.com/index.php?down=downloads/plupdate.%s.zip", ver); 129 | 130 | outbuf = (char*)downloadfile (buff, &outlen, cb_au); // outbuf is 0 terminated 131 | 132 | Debug ("AutoUpdate %s -> %d", buff, outlen); 133 | int fail = false; 134 | 135 | if (!outbuf) fail = true; 136 | if (outlen > 2 && !(outbuf[0] == 'P' && outbuf[1] == 'K')) fail = true; 137 | if (outlen < 2) fail = true; 138 | if (outlen != http.size) fail = true; // wow ! 139 | 140 | if (fail) 141 | { 142 | if (outbuf) free (outbuf); 143 | grlib_menu (0, "The update file doesn't exist. Please retry later", " OK "); 144 | return 0; 145 | } 146 | 147 | sprintf (buff, "%s://ploader/temp/update.zip", vars.defMount); 148 | FILE *f = fopen (buff, "wb"); 149 | outlen = fwrite (outbuf, 1, outlen, f); 150 | fclose (f); 151 | if (outlen != http.size) 152 | { 153 | grlib_menu (0, "An error is occured while writing to device", " OK "); 154 | unlink (buff); 155 | return 0; 156 | } 157 | 158 | char target[128]; 159 | sprintf (target, "%s://ploader/temp/update/", vars.defMount); 160 | 161 | fsop_CreateFolderTree (target); 162 | 163 | int errcnt; 164 | ZipUnpack (buff, target, NULL, &errcnt); 165 | 166 | if (errcnt) 167 | { 168 | sprintf (buff, "An error is occured during unpacking of updatefile (%d)", errcnt); 169 | grlib_menu (0, buff, " OK "); 170 | free (outbuf); 171 | return 0; 172 | } 173 | unlink (buff); 174 | 175 | free (outbuf); 176 | 177 | // We can update, no errors 178 | sprintf (buff, "%s://ploader/temp/update/", vars.defMount); 179 | 180 | cb_mode = 1; 181 | 182 | if (devices_Get(DEV_SD)) 183 | { 184 | sprintf (target, "%s://apps/postloader/boot.dol", devices_Get(DEV_SD)); 185 | if (fsop_FileExist (target)) 186 | { 187 | sprintf (target, "%s://", devices_Get(DEV_SD)); 188 | fsop_CopyFolder (buff, target, cb_au); 189 | } 190 | } 191 | if (devices_Get (DEV_USB)) 192 | { 193 | sprintf (target, "%s://apps/postloader/boot.dol", devices_Get(DEV_USB)); 194 | if (fsop_FileExist (target)) 195 | { 196 | sprintf (target, "%s://", devices_Get(DEV_USB)); 197 | fsop_CopyFolder (buff, target, cb_au); 198 | } 199 | } 200 | 201 | if (grlib_menu (0, "postLoader should be restarted now, proceed ?", " Yes ##1~No, after##-1") == 1) 202 | ReloadPostloader(); 203 | 204 | } 205 | 206 | return 1; 207 | } 208 | --------------------------------------------------------------------------------