| 391 | } |
| 392 | |
| 393 | static bool cdvdUncheckedLoadDiscElf(ElfObject* elfo, IsoReader& isor, const std::string_view elfpath, bool isPSXElf, Error* error) |
| 394 | { |
| 395 | // Strip out cdrom: prefix, and any leading slashes. |
| 396 | size_t start_pos = (elfpath[5] == '0') ? 7 : 6; |
| 397 | while (start_pos < elfpath.size() && (elfpath[start_pos] == '\\' || elfpath[start_pos] == '/')) |
| 398 | start_pos++; |
| 399 | |
| 400 | // Strip out any version information. Some games use ;2 (MLB2k6), others put multiple versions in |
| 401 | // (Syphon Filter Omega Strain). The PS2 BIOS appears to ignore the suffix entirely, so we'll do |
| 402 | // the same, and hope that no games actually have multiple ELFs with different versions. |
| 403 | // Previous notes: |
| 404 | // Mimic PS2 behavior! |
| 405 | // Much trial-and-error with changing the ISOFS and BOOT2 contents of an image have shown that |
| 406 | // the PS2 BIOS performs the peculiar task of *ignoring* the version info from the parsed BOOT2 |
| 407 | // filename *and* the ISOFS, when loading the game's ELF image. What this means is: |
| 408 | // |
| 409 | // 1. a valid PS2 ELF can have any version (ISOFS), and the version need not match the one in SYSTEM.CNF. |
| 410 | // 2. the version info on the file in the BOOT2 parameter of SYSTEM.CNF can be missing, 10 chars long, |
| 411 | // or anything else. Its all ignored. |
| 412 | // 3. Games loading their own files do *not* exhibit this behavior; likely due to using newer IOP modules |
| 413 | // or lower level filesystem APIs (fortunately that doesn't affect us). |
| 414 | // |
| 415 | size_t length = elfpath.length() - start_pos; |
| 416 | const size_t semi_pos = elfpath.find(';', start_pos); |
| 417 | if (semi_pos != std::string::npos) |
| 418 | length = semi_pos - start_pos; |
| 419 | |
| 420 | std::string iso_filename(elfpath.substr(start_pos, length)); |
| 421 | DevCon.WriteLn(fmt::format("cdvdLoadElf(): '{}' -> '{}' in ISO.", elfpath, iso_filename)); |
| 422 | if (iso_filename.empty()) |
| 423 | { |
| 424 | Error::SetString(error, "ISO filename is empty."); |
| 425 | return false; |
| 426 | } |
| 427 | |
| 428 | return elfo->OpenIsoFile(std::move(iso_filename), isor, isPSXElf, error); |
| 429 | } |
| 430 | |
| 431 | bool cdvdLoadElf(ElfObject* elfo, const std::string_view elfpath, bool isPSXElf, Error* error) |
| 432 | { |
no test coverage detected