bool NandTitle::Exists(u64 tid) { char app[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); tmd* titleTmd = GetTMD(tid); if (!titleTmd) return false; u16 i; bool ok = false; for (i = 0; i < titleTmd->num_contents; i++) { if (!titleTmd->contents[i].index) { ok = true; break; } } if (!ok) return false; snprintf(app, sizeof(app), "/title/%08x/%08x/content/%08x.app", TITLE_UPPER( tid ), TITLE_LOWER( tid ), titleTmd->contents[i].cid); s32 fd = ISFS_Open(app, ISFS_OPEN_READ); if (fd >= 0) ISFS_Close(fd); //gprintf(" fd: %d\n", fd ); return fd >= 0 || fd == -102; //102 means it exists, but we dont have permission to open it }
u16 NandTitle::VersionFromIndex(u32 i) { if (i >= titleIds.size()) return 0; tmd* Tmd = GetTMD(titleIds.at(i)); if (!Tmd) return 0; return Tmd->title_version; }
u8 IOS_GetType(u8 slot) { /* No more checks needed */ if(neek2o() || Sys_DolphinMode()) return IOS_TYPE_NEEK2O; /* Lets do this */ u32 TMD_Length; signed_blob *TMD_Buffer = GetTMD(slot, &TMD_Length); if(TMD_Buffer == NULL) return IOS_TYPE_STUB; tmd *iosTMD = (tmd*)SIGNATURE_PAYLOAD(TMD_Buffer); if(Title_GetSize_FromTMD(iosTMD) < 0x100000 || iosTMD->title_version == 65280) { MEM2_free(TMD_Buffer); return IOS_TYPE_STUB; } u32 title_rev = iosTMD->title_version; MEM2_free(TMD_Buffer); u8 base = 0; switch(slot) { case 222: case 223: case 224: case 225: if(title_rev == 1) return IOS_TYPE_KWIIRK; else return IOS_TYPE_HERMES; case 245: case 246: case 247: case 248: case 249: case 250: case 251: if(IOS_D2X(slot, &base)) return IOS_TYPE_D2X; else return IOS_TYPE_WANIN; default: if(IOS_D2X(slot, &base)) return IOS_TYPE_D2X; else return IOS_TYPE_NORMAL_IOS; } }
u16 NandTitle::VersionOf(u64 tid) { for (u32 i = 0; i < titleIds.size(); i++) { if (titleIds.at(i) == tid) { tmd* Tmd = GetTMD(tid); if (!Tmd) break; return Tmd->title_version; } } return 0; }
iosinfo_t *IOS_GetInfo(u8 ios) { u32 TMD_Length; signed_blob *TMD = GetTMD(ios, &TMD_Length); if(TMD == NULL) return NULL; char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); sprintf(filepath, "/title/00000001/%08x/content/%08x.app", ios, *(u8 *)((u32)TMD+0x1E7)); MEM2_free(TMD); u32 size = 0; u8 *buffer = ISFS_GetFile(filepath, &size, sizeof(iosinfo_t)); if(buffer == NULL || size == 0) return NULL; iosinfo_t *iosinfo = (iosinfo_t *)buffer; return iosinfo; }
s32 checkTitle(u64 title_id) { signed_blob *TMD = NULL; tmd *t = NULL; u32 TMD_size = 0; s32 ret = 0; ret = GetTMD(title_id, &TMD, &TMD_size); if (ret == 0) { t = (tmd*)SIGNATURE_PAYLOAD(TMD); return t->title_version; } else { ret = -2; } free(TMD); return ret; }
//--------------------------------------------------------------------------------- int main(int argc, char **argv) { //--------------------------------------------------------------------------------- // Initialise the video system VIDEO_Init(); Video_SetMode(); WPAD_Init(); PAD_Init(); if(AHBPROT_DISABLED) IosPatch_RUNTIME(true, false, false, true); else IOS_ReloadIOS(236); menu(); signed_blob *p_tmd = NULL; u32 len; s32 ret; ret = GetTMD(0x0001000154484246LL, &p_tmd, &len); if(ret < 0) { *(vu32*)0x8132FFFB = 0x50756E65; DCFlushRange((void*)0x8132FFFB, 4); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } else { WII_LaunchTitle(0x0001000154484246); } return 0; }