diff --git a/src/core/system.cpp b/src/core/system.cpp index 43b69f4e3..c8a88998e 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -1616,11 +1616,14 @@ void ResetPerformanceCounters() ResetThrottler(); } -bool LoadEXE(const char* filename) +static bool LoadEXEToRAM(const char* filename, bool patch_bios) { std::FILE* fp = FileSystem::OpenCFile(filename, "rb"); if (!fp) + { + Log_ErrorPrintf("Failed to open exe file '%s'", filename); return false; + } std::fseek(fp, 0, SEEK_END); const u32 file_size = static_cast(std::ftell(fp)); @@ -1629,6 +1632,7 @@ bool LoadEXE(const char* filename) BIOS::PSEXEHeader header; if (std::fread(&header, sizeof(header), 1, fp) != 1 || !BIOS::IsValidPSExeHeader(header, file_size)) { + Log_ErrorPrintf("'%s' is not a valid PS-EXE", filename); std::fclose(fp); return false; } @@ -1672,6 +1676,18 @@ bool LoadEXE(const char* filename) return BIOS::PatchBIOSForEXE(Bus::g_bios, Bus::BIOS_SIZE, r_pc, r_gp, r_sp, r_fp); } +bool LoadEXE(const char* filename) +{ + const std::string libps_path(FileSystem::BuildRelativePath(filename, "libps.exe")); + if (!libps_path.empty() && FileSystem::FileExists(libps_path.c_str()) && !LoadEXEToRAM(libps_path.c_str(), false)) + { + Log_ErrorPrintf("Failed to load libps.exe from '%s'", libps_path.c_str()); + return false; + } + + return LoadEXEToRAM(filename, true); +} + bool InjectEXEFromBuffer(const void* buffer, u32 buffer_size, bool patch_bios) { const u8* buffer_ptr = static_cast(buffer);