mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
More module loading cleanup, choose better filenames for dumped PRX files
This commit is contained in:
parent
7e2f724d35
commit
a79f986411
4 changed files with 20 additions and 3 deletions
|
@ -250,6 +250,15 @@ std::string_view StripPrefix(std::string_view prefix, std::string_view s) {
|
|||
}
|
||||
}
|
||||
|
||||
std::string_view KeepAfterLast(std::string_view s, char c) {
|
||||
size_t pos = s.rfind(c);
|
||||
if (pos != std::string_view::npos) {
|
||||
return s.substr(pos + 1);
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
void SkipSpace(const char **ptr) {
|
||||
while (**ptr && isspace(**ptr)) {
|
||||
(*ptr)++;
|
||||
|
|
|
@ -94,6 +94,8 @@ std::string StringFromInt(int value);
|
|||
std::string StripSpaces(const std::string &s);
|
||||
std::string StripQuotes(const std::string &s);
|
||||
|
||||
std::string_view KeepAfterLast(std::string_view s, char c);
|
||||
|
||||
std::string_view StripSpaces(std::string_view s);
|
||||
std::string_view StripQuotes(std::string_view s);
|
||||
|
||||
|
|
|
@ -985,6 +985,7 @@ static int gzipDecompress(u8 *OutBuffer, int OutBufferLength, u8 *InBuffer) {
|
|||
}
|
||||
err = inflate(&stream, Z_FINISH);
|
||||
if (err != Z_STREAM_END) {
|
||||
ERROR_LOG(Log::Loader, "gzipDecompress: Didn't reach the end of the input, output buffer too small?");
|
||||
inflateEnd(&stream);
|
||||
return -2;
|
||||
}
|
||||
|
@ -1118,6 +1119,7 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load
|
|||
elfSize = maxElfSize;
|
||||
ptr = newptr;
|
||||
int ret = pspDecryptPRX(in, (u8*)ptr, head->psp_size);
|
||||
_dbg_assert_(ret <= maxElfSize);
|
||||
if (ret <= 0 && Read32(ptr + 0x150) == ELF_MAGIC) {
|
||||
ret = head->psp_size - 0x150;
|
||||
memcpy(newptr, in + 0x150, ret);
|
||||
|
@ -1133,7 +1135,8 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load
|
|||
|
||||
if (reportedModule) {
|
||||
// Opportunity to dump the decrypted elf, even if we choose to fake it.
|
||||
std::string elfFilename(filename);
|
||||
// NOTE: filename is not necessarily a good choice!
|
||||
std::string elfFilename(KeepAfterLast(filename, '/'));
|
||||
if (elfFilename.empty()) {
|
||||
// Use the name from the header.
|
||||
elfFilename = head->modname;
|
||||
|
|
|
@ -882,7 +882,10 @@ void DumpFileIfEnabled(const u8 *dataPtr, const u32 length, const char *name, Du
|
|||
}
|
||||
|
||||
const char *extension = DumpFileTypeToFileExtension(type);
|
||||
const std::string filenameToDumpTo = StringFromFormat("%s_%s%s", g_paramSFO.GetDiscID().c_str(), name, extension);
|
||||
std::string filenameToDumpTo = StringFromFormat("%s_%s", g_paramSFO.GetDiscID().c_str(), name);
|
||||
if (!endsWithNoCase(filenameToDumpTo, extension)) {
|
||||
filenameToDumpTo += extension;
|
||||
}
|
||||
const Path dumpDirectory = GetSysDirectory(DIRECTORY_DUMP);
|
||||
const Path fullPath = dumpDirectory / filenameToDumpTo;
|
||||
|
||||
|
@ -939,7 +942,7 @@ void DumpFileIfEnabled(const u8 *dataPtr, const u32 length, const char *name, Du
|
|||
strcpy(path, fullPath.c_str());
|
||||
|
||||
// Re-suing the translation string here.
|
||||
g_OSD.Show(OSDType::MESSAGE_SUCCESS, titleStr, fullPath.ToVisualString(), 5.0f, "decr");
|
||||
g_OSD.Show(OSDType::MESSAGE_SUCCESS, titleStr, fullPath.ToVisualString(), 5.0f);
|
||||
if (System_GetPropertyBool(SYSPROP_CAN_SHOW_FILE)) {
|
||||
g_OSD.SetClickCallback("decr", [](bool clicked, void *userdata) {
|
||||
char *path = (char *)userdata;
|
||||
|
|
Loading…
Add table
Reference in a new issue