diff --git a/Common/StringUtil.cpp b/Common/StringUtil.cpp index 2f53d49851..a476524e34 100644 --- a/Common/StringUtil.cpp +++ b/Common/StringUtil.cpp @@ -138,10 +138,16 @@ bool TryParse(const std::string &str, u32 *const output) return false; if (ULONG_MAX > UINT_MAX) { +#ifdef _MSC_VER +#pragma warning disable(4309); +#endif // Note: The typecasts avoid GCC warnings when long is 32 bits wide. if (value >= static_cast(0x100000000ull) && value <= static_cast(0xFFFFFFFF00000000ull)) return false; +#ifdef _MSC_VER +#pragma warning enable(4309); +#endif } *output = static_cast(value); diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 641baba4fa..81bbf65cfc 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -157,28 +157,6 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *erro u32 __entrytableAddr; }; - SectionID textSection = reader.GetSectionByName(".text"); - - u32 textStart = reader.GetSectionAddr(textSection); - u32 textSize = reader.GetSectionSize(textSection); - - bool hasSymbols = false; - bool dontadd = false; - - if (!host->AttemptLoadSymbolMap()) - { - hasSymbols = reader.LoadSymbols(); - if (!hasSymbols) - { - symbolMap.ResetSymbolMap(); - MIPSAnalyst::ScanForFunctions(textStart, textStart+textSize); - } - } - else - { - dontadd = true; - } - struct PspModuleInfo { // 0, 0, 1, 1 ? @@ -200,6 +178,34 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *erro else modinfo = (PspModuleInfo *)reader.GetPtr(reader.GetSegmentPaddr(0) + reader.GetSegmentOffset(0)); + // Check for module "blacklist" - if a module has the same name as a HLE'd module, we don't load it. + if (GetModuleIndex(modinfo->name) >= 0) { + ERROR_LOG(LOADER, "The module %s is HLE'd - ignoring in __KernelLoadELFFromPtr()", modinfo->name); + return 0; + } + + bool hasSymbols = false; + bool dontadd = false; + + SectionID textSection = reader.GetSectionByName(".text"); + + u32 textStart = reader.GetSectionAddr(textSection); + u32 textSize = reader.GetSectionSize(textSection); + + if (!host->AttemptLoadSymbolMap()) + { + hasSymbols = reader.LoadSymbols(); + if (!hasSymbols) + { + symbolMap.ResetSymbolMap(); + MIPSAnalyst::ScanForFunctions(textStart, textStart+textSize); + } + } + else + { + dontadd = true; + } + module->gp_value = modinfo->gp; strncpy(module->name, modinfo->name, 28); @@ -259,6 +265,10 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *erro DEBUG_LOG(LOADER,"-------------------------------------------------------------"); } + + // Look at the exports, too. + +#pragma pack(push, 1) struct PspLibEntEntry { u32 name; /* ent's name (module name) address */ @@ -269,6 +279,7 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *erro u16 fcount; u32 resident; }; +#pragma pack(pop) int numEnts = (modinfo->libentend - modinfo->libent)/sizeof(PspLibEntEntry); PspLibEntEntry *ent = (PspLibEntEntry *)Memory::GetPointer(modinfo->libent); @@ -291,7 +302,11 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *erro } INFO_LOG(HLE,"Exporting ent %d named %s, %d funcs, %d vars, resident %08x", m, name, ent->fcount, ent->vcount, ent->resident); + + // This appears to return bogus pointers for modules like sceAtrac3Plus (running Puzzle Bobble Pocket, name = sceAtrac3plus) u32 *residentPtr = (u32*)Memory::GetPointer(ent[m].resident); + + // TODO: Re-enable when it works for (u32 j = 0; j < ent[m].fcount; j++) { u32 nid = residentPtr[j]; @@ -477,12 +492,14 @@ u32 sceKernelLoadModule(const char *name, u32 flags) PSPFileInfo info = pspFileSystem.GetFileInfo(name); std::string error_string; s64 size = (s64)info.size; + if (!size) { ERROR_LOG(LOADER, "Module file is size 0: %s", name); return false; } - u32 handle = pspFileSystem.OpenFile(name, FILEACCESS_READ); + + u32 handle = pspFileSystem.OpenFile(name, FILEACCESS_READ); u8 *temp = new u8[(int)size];