void mk_mload_version() { mload_ver_str[0] = 0; mload_ver = 0; if (CFG.ios_mload || (is_ios_type(IOS_TYPE_WANIN) && IOS_GetRevision() >= 18) ) { if (IOS_GetRevision() >= 4) { if (is_ios_type(IOS_TYPE_WANIN)) { char *info = get_ios_info_from_tmd(); if (info) { sprintf(mload_ver_str, "Base: IOS%s ", info); } else { sprintf(mload_ver_str, "Base: IOS?? DI:%d ", wanin_mload_get_IOS_base()); } } else { sprintf(mload_ver_str, "Base: IOS%d ", mload_get_IOS_base()); } } if (IOS_GetRevision() > 4) { int v, s = 0; v = mload_ver = mload_get_version(); if (v>0) { s = v & 0x0F; v = v >> 4; } sprintf(mload_ver_str + strlen(mload_ver_str), "mload v%d.%d ", v, s); } else {
void IOS_GetCurrentIOSInfo() { memset(&CurrentIOS, 0, sizeof(IOS_Info)); CurrentIOS.Version = IOS_GetVersion(); CurrentIOS.Base = CurrentIOS.Version; CurrentIOS.Revision = IOS_GetRevision(); CurrentIOS.SubRevision = 0; CurrentIOS.Type = IOS_GetType(CurrentIOS.Version); if(CurrentIOS.Type == IOS_TYPE_D2X) { iosinfo_t *iosInfo = IOS_GetInfo(CurrentIOS.Version); CurrentIOS.Revision = iosInfo->version; CurrentIOS.Base = iosInfo->baseios; gprintf("D2X IOS%i[%i] v%i\n", CurrentIOS.Version, CurrentIOS.Base, CurrentIOS.Revision); MEM2_free(iosInfo); } else if(CurrentIOS.Type == IOS_TYPE_WANIN) { if(CurrentIOS.Revision >= 18) CurrentIOS.Base = wanin_mload_get_IOS_base(); gprintf("Waninkoko IOS%i[%i] v%i\n", CurrentIOS.Version, CurrentIOS.Base, CurrentIOS.Revision); } else if(CurrentIOS.Type == IOS_TYPE_HERMES) { CurrentIOS.Base = mload_get_IOS_base(); if(CurrentIOS.Revision > 4) { CurrentIOS.Revision = mload_get_version() >> 4; CurrentIOS.SubRevision = mload_get_version() & 0xF; }
int load_modules(const u8 * ehcmodule, int ehcmodule_size, const u8 * dip, int dip_size) { if(mload_init() < 0) return -1; dip_plugin = (u8 *) dip; dip_plugin_size = dip_size; mload_elf((u8 *) ehcmodule, &my_data_elf); my_thread_id= mload_run_thread(my_data_elf.start, my_data_elf.stack, my_data_elf.size_stack, my_data_elf.prio); if(my_thread_id < 0) return -2; usleep(350*1000); // Test for IOS int is_ios = mload_get_IOS_base(); u32 dip_address = 0x1377C000; switch(is_ios) { case 36: memcpy(ios_36, dip_plugin, 4); // copy the entry_point memcpy(dip_plugin, ios_36, 4*10); // copy the adresses from the array mload_seek(dip_address, SEEK_SET); // copy dip_plugin in the starlet mload_write(dip_plugin, dip_plugin_size); // enables DIP plugin mload_seek(0x20209040, SEEK_SET); mload_write(ios_36, 4); break; case 37: memcpy(ios_37, dip_plugin, 4); // copy the entry_point memcpy(dip_plugin, ios_37, 4*10); // copy the adresses from the array mload_seek(dip_address, SEEK_SET); // copy dip_plugin in the starlet mload_write(dip_plugin,dip_plugin_size); // enables DIP plugin mload_seek(0x20209030, SEEK_SET); mload_write(ios_37, 4); break; case 38: memcpy(ios_38, dip_plugin, 4); // copy the entry_point memcpy(dip_plugin, ios_38, 4*10); // copy the adresses from the array mload_seek(dip_address, SEEK_SET); // copy dip_plugin in the starlet mload_write(dip_plugin,dip_plugin_size); // enables DIP plugin mload_seek(0x20208030, SEEK_SET); mload_write(ios_38, 4); break; case 57: memcpy(ios_57, dip_plugin, 4); // copy the entry_point memcpy(dip_plugin, ios_57, 4*10); // copy the adresses from the array mload_seek(dip_address, SEEK_SET); // copy dip_plugin in the starlet mload_write(dip_plugin,dip_plugin_size); // enables DIP plugin mload_seek(0x20208030, SEEK_SET); mload_write(ios_57, 4); break; case 60: memcpy(ios_60, dip_plugin, 4); // copy the entry_point memcpy(dip_plugin, ios_60, 4*10); // copy the adresses from the array mload_seek(dip_address, SEEK_SET); // copy dip_plugin in the starlet mload_write(dip_plugin,dip_plugin_size); // enables DIP plugin mload_seek(0x20208030, SEEK_SET); mload_write(ios_60, 4); break; } mload_close(); return 0; }
int load_ehc_module() { int is_ios=0; #if 0 FILE *fp; // WARNING!!!: load external module suspended if(sd_ok && !external_ehcmodule) { fp=fopen("sd:/apps/usbloader_gx/ehcmodule.elf","rb"); if(fp==NULL) fp=fopen("sd:/apps/usbloadergx/ehcmodule.elf","rb"); if(fp!=0) { fseek(fp, 0, SEEK_END); size_external_ehcmodule = ftell(fp); external_ehcmodule= memalign(32, size_external_ehcmodule); if(!external_ehcmodule) {fclose(fp);} else { fseek(fp, 0, SEEK_SET); if(fread(external_ehcmodule,1, size_external_ehcmodule ,fp)!=size_external_ehcmodule) {free(external_ehcmodule); external_ehcmodule=NULL;} fclose(fp); } } } #endif /* if(mload_init()<0) return -1; mload_elf((void *) logmodule, &my_data_elf); my_thread_id= mload_run_thread(my_data_elf.start, my_data_elf.stack, my_data_elf.size_stack, my_data_elf.prio); if(my_thread_id<0) return -1; */ if(!external_ehcmodule) { #ifdef DEBUG_MLOAD gprintf("before mload_init\n"); #endif if(mload_init()<0) return -1; #ifdef DEBUG_MLOAD gprintf("after mload_init\n"); #endif if (IOS_GetRevision() == 4) { #ifdef DEBUG_MLOAD gprintf("Loading ehcmodule v4\n"); #endif mload_elf((void *) ehcmodule_frag_v4_bin, &my_data_elf); } else if (IOS_GetRevision() == 65535) { #ifdef DEBUG_MLOAD gprintf("Loading ehcmodule v5\n"); #endif mload_elf((void *) ehcmodule_frag_v5_bin, &my_data_elf); } else { return -2; } // mload_elf((void *) ehcmodule, &my_data_elf); #ifdef DEBUG_MLOAD gprintf("before mload_run_thread\n"); #endif my_thread_id= mload_run_thread(my_data_elf.start, my_data_elf.stack, my_data_elf.size_stack, my_data_elf.prio); if(my_thread_id<0) return -1; //if(mload_module(ehcmodule, size_ehcmodule)<0) return -1; } else { //if(mload_module(external_ehcmodule, size_external_ehcmodule)<0) return -1; if(mload_init()<0) return -1; mload_elf((void *) external_ehcmodule, &my_data_elf); my_thread_id= mload_run_thread(my_data_elf.start, my_data_elf.stack, my_data_elf.size_stack, my_data_elf.prio); if(my_thread_id<0) return -1; } usleep(350*1000); // Test for IOS #if 0 mload_seek(0x20207c84, SEEK_SET); mload_read(patch_datas, 32); if(patch_datas[0]==0x6e657665 ) { is_ios=38; } else { is_ios=36; } #endif is_ios=mload_get_IOS_base(); switch(is_ios) { case 36: memcpy(ios_36, dip_plugin, 4); // copy the entry_point memcpy(dip_plugin, ios_36, 4*10); // copy the adresses from the array mload_seek(0x1377E000, SEEK_SET); // copy dip_plugin in the starlet mload_write(dip_plugin,size_dip_plugin); // enables DIP plugin mload_seek(0x20209040, SEEK_SET); mload_write(ios_36, 4); break; case 37: memcpy(ios_37, dip_plugin, 4); // copy the entry_point memcpy(dip_plugin, ios_37, 4*10); // copy the adresses from the array mload_seek(0x1377E000, SEEK_SET); // copy dip_plugin in the starlet mload_write(dip_plugin,size_dip_plugin); // enables DIP plugin mload_seek(0x20209030, SEEK_SET); mload_write(ios_37, 4); break; case 38: memcpy(ios_38, dip_plugin, 4); // copy the entry_point memcpy(dip_plugin, ios_38, 4*10); // copy the adresses from the array mload_seek(0x1377E000, SEEK_SET); // copy dip_plugin in the starlet mload_write(dip_plugin,size_dip_plugin); // enables DIP plugin mload_seek(0x20208030, SEEK_SET); mload_write(ios_38, 4); break; case 57: memcpy(ios_57, dip_plugin, 4); // copy the entry_point memcpy(dip_plugin, ios_57, 4*10); // copy the adresses from the array mload_seek(0x1377E000, SEEK_SET); // copy dip_plugin in the starlet mload_write(dip_plugin,size_dip_plugin); // enables DIP plugin mload_seek(0x20208030, SEEK_SET); mload_write(ios_57, 4); break; case 60: memcpy(ios_60, dip_plugin, 4); // copy the entry_point memcpy(dip_plugin, ios_60, 4*10); // copy the adresses from the array mload_seek(0x1377E000, SEEK_SET); // copy dip_plugin in the starlet mload_write(dip_plugin,size_dip_plugin); // enables DIP plugin mload_seek(0x20208030, SEEK_SET); mload_write(ios_60, 4); break; } mload_close(); return 0; }