diff --git a/Lang/ENG.LNG b/Lang/ENG.LNG index bbedbaa0..12369d93 100644 --- a/Lang/ENG.LNG +++ b/Lang/ENG.LNG @@ -330,3 +330,4 @@ lang(328, change_timestamp_of, "change timestamp of:") lang(329, title_cfg, "create title.cfg") lang(329, Build_Info, "BuildInfo") lang(330, Loading_Flash_Modules, "Loading Flash Modules...") +lang(331, This_file_isnt_an_IRX, "This file isn't an IRX") diff --git a/Lang/SPA.LNG b/Lang/SPA.LNG index f75f64cf..24eb4c01 100644 --- a/Lang/SPA.LNG +++ b/Lang/SPA.LNG @@ -331,3 +331,4 @@ lang(328, change_timestamp_of, "cambiar fecha de:") lang(329, title_cfg, "crear title.cfg") lang(329, Build_Info, "BuildInfo") lang(330, Loading_Flash_Modules, "Cargando modulos flash...") +lang(331, This_file_isnt_an_IRX, "Esto no es un driver IRX") diff --git a/include/launchelf.h b/include/launchelf.h index 916f3f35..777c2b9e 100644 --- a/include/launchelf.h +++ b/include/launchelf.h @@ -227,7 +227,7 @@ int IsSupportedFileType(char *path); void loadFlashModules(void); /* elf.c */ -int checkELFheader(char *filename); +int checkELFheader(char *filename, int is_irx); void RunLoaderElf(char *filename, char *); /* draw.c */ diff --git a/src/elf.c b/src/elf.c index 59ee669b..98cd2f99 100644 --- a/src/elf.c +++ b/src/elf.c @@ -51,8 +51,15 @@ typedef struct // Modified version of loader from Independence // (C) 2003 Marcus R. Brown //-------------------------------------------------------------- -int checkELFheader(char *path) +/** + * @brief checks if path corresponds to an ELF file + * @param path path to the ELF file + * @param is_irx if we are looking for an IRX driver or EE ELF + * @return larger than 0 if success +*/ +int checkELFheader(char *path, int is_irx) { + u16 elftype = (is_irx)? 0xFF80 : 0x2; elf_header_t elf_head; u8 *boot_elf = (u8 *)&elf_head; elf_header_t *eh = (elf_header_t *)boot_elf; @@ -109,7 +116,7 @@ int checkELFheader(char *path) genRead(fd, boot_elf, sizeof(elf_header_t)); genClose(fd); - if ((_lw((u32)&eh->ident) != ELF_MAGIC) || eh->type != 2) + if ((_lw((u32)&eh->ident) != ELF_MAGIC) || eh->type != elftype) goto error; return 1; //return 1 for successful check diff --git a/src/filer.c b/src/filer.c index 68bcbbcc..63968439 100644 --- a/src/filer.c +++ b/src/filer.c @@ -3611,6 +3611,8 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) files[nfiles++].stats.AttrFile = sceMcFileAttrFile; strcpy(files[nfiles].name, LNG(Load_CNF)); files[nfiles++].stats.AttrFile = sceMcFileAttrFile; + strcpy(files[nfiles].name, "Load_IRX"); + files[nfiles++].stats.AttrFile = sceMcFileAttrFile; //Next 2 lines add an optional font test routine strcpy(files[nfiles].name, LNG(ShowFont)); files[nfiles++].stats.AttrFile = sceMcFileAttrFile; @@ -3943,6 +3945,10 @@ int getFilePath(char *out, int cnfmode) browser_pushed = FALSE; sprintf(msg0, "%s.", LNG(This_file_isnt_an_ELF)); out[0] = 0; + } else if ( ((cnfmode == USBD_IRX_CNF) || (cnfmode == USBKBD_IRX_CNF) || (cnfmode == USBMASS_IRX_CNF))&&(checkELFheader(out, TRUE) < 0) ) { + browser_pushed = FALSE; + sprintf(msg0, "%s.", LNG(This_file_isnt_an_IRX)); + out[0] = 0; } else { strcpy(LastDir, path); rv = 1; //flag pathname selected @@ -3964,7 +3970,7 @@ int getFilePath(char *out, int cnfmode) //pushed R3 for a file (treat as uLE-related) sprintf(out, "%s%s", path, files[browser_sel].name); // Must to include a function for check IRX Header - if (((cnfmode == LK_ELF_CNF) || (cnfmode == NON_CNF)) && (checkELFheader(out) < 0)) { + if (((cnfmode == LK_ELF_CNF) || (cnfmode == NON_CNF)) && (checkELFheader(out, FALSE) < 0)) { browser_pushed = FALSE; sprintf(msg0, "%s.", LNG(This_file_isnt_an_ELF)); out[0] = 0; @@ -4469,7 +4475,7 @@ int getFilePath(char *out, int cnfmode) iconcolr = COLOR_GRAPH1; } else { iconbase = ICON_FILE; - if (genCmpFileExt(files[top + i].name, "ELF")) + if (genCmpFileExt(files[top + i].name, "ELF") || genCmpFileExt(files[top + i].name, "IRX")) iconcolr = COLOR_GRAPH2; else if ( genCmpFileExt(files[top + i].name, "TXT") || diff --git a/src/main.c b/src/main.c index 8a04f503..910e348d 100644 --- a/src/main.c +++ b/src/main.c @@ -1864,6 +1864,26 @@ static void Set_CNF_Path(void) sprintf(mainMsg, "%s ", LNG(Bogus)); sprintf(mainMsg + 6, "%s = \"%s\"", LNG(CNF_Path), setting->CNF_Path); } + +static void load_irx_manual(void) +{ + int id, ret; + char IRX_path[MAX_PATH] = ""; + char *tmp; + + if (getFilePath(IRX_path, USBKBD_IRX_CNF)>0) + return; + if (exists(IRX_path)) { + tmp = strrchr(IRX_path, '/'); + if (tmp == NULL) + tmp = "IRX LOAD"; + else + tmp++; + id = SifLoadStartModule(IRX_path, 0, NULL, &ret); + sprintf(mainMsg, "%s: id:%d, ret:%d (%s)", tmp, id, ret, (id>0 && ret != 1) ? LNG(OK) : LNG(Failed)); + DPRINTF(mainMsg); + } +} //------------------------------ //endfunc Set_CNF_Path //--------------------------------------------------------------------------- @@ -2031,13 +2051,13 @@ int IsSupportedFileType(char *path) if(strchr(path, ':') != NULL) { if ((genCmpFileExt(path, "TXT") || genCmpFileExt(path, "CHT") || genCmpFileExt(path, "CFG") || genCmpFileExt(path, "INI") || genCmpFileExt(path, "CNF") ) || (genCmpFileExt(path, "JPG") || genCmpFileExt(path, "JPEG"))) return 1; else if(genCmpFileExt(path, "IRX")) return 0; - else return(checkELFheader(path) >= 0); + else return(checkELFheader(path, FALSE) >= 0); } else //No ':', hence no device name in path, which means it is a special action (e.g. MISC/*). return 1; #else if (strchr(path, ':') != NULL) { if (genCmpFileExt(path, "ELF")) { - return (checkELFheader(path) >= 0); + return (checkELFheader(path, FALSE) >= 0); } else if ((genCmpFileExt(path, "TXT") || genCmpFileExt(path, "CHT") || genCmpFileExt(path, "CFG") || genCmpFileExt(path, "INI") || genCmpFileExt(path, "CNF") ) || (genCmpFileExt(path, "JPG") || genCmpFileExt(path, "JPEG"))) { return 1; } else @@ -2080,7 +2100,7 @@ static void Execute(char *pathin) goto CheckELF_path; strcpy(fullpath, "mc0:"); strcat(fullpath, path + 3); - if (checkELFheader(fullpath) > 0) + if (checkELFheader(fullpath, FALSE) > 0) goto ELFchecked; fullpath[2] = '1'; goto CheckELF_fullpath; @@ -2092,7 +2112,7 @@ static void Execute(char *pathin) goto CheckELF_path; } else if (!strncmp(path, "hdd0:/", 6)) { loadHddModules(); - if ((t = checkELFheader(path)) <= 0) + if ((t = checkELFheader(path, FALSE)) <= 0) goto ELFnotFound; //coming here means the ELF is fine sprintf(party, "hdd0:%s", path + 6); @@ -2103,7 +2123,7 @@ static void Execute(char *pathin) #ifdef DVRP } else if (!strncmp(path, "dvr_hdd0:/", 10)) { loadDVRPHddModules(); - if ((t = checkELFheader(path)) <= 0) + if ((t = checkELFheader(path, FALSE)) <= 0) goto ELFnotFound; //coming here means the ELF is fine sprintf(party, "dvr_hdd0:%s", path + 10); @@ -2115,13 +2135,13 @@ static void Execute(char *pathin) #ifdef XFROM } else if (!strncmp(path, "xfrom:/", 7)) { loadFlashModules(); - if ((t = checkELFheader(path)) <= 0) + if ((t = checkELFheader(path, FALSE)) <= 0) goto ELFnotFound; strcpy(fullpath, path); goto ELFchecked; #endif } else if (!strncmp(path, "mass", 4)) { - if ((t = checkELFheader(path)) <= 0) + if ((t = checkELFheader(path, FALSE)) <= 0) goto ELFnotFound; //coming here means the ELF is fine party[0] = 0; @@ -2395,6 +2415,9 @@ static void Execute(char *pathin) } Show_build_info(); return; + } else if (!stricmp(path, "Load_IRX")) { + load_irx_manual(); + return; #ifndef SUPPORT_SYSTEM_2X6 } else if (!strncmp(path, "cdfs", 4)) { CDVD_FlushCache(); @@ -2407,7 +2430,7 @@ static void Execute(char *pathin) CheckELF_path: strcpy(fullpath, path); CheckELF_fullpath: - if ((t = checkELFheader(fullpath)) <= 0) + if ((t = checkELFheader(fullpath, FALSE)) <= 0) goto ELFnotFound; ELFchecked: CleanUp();