Merge pull request #279 from Pouare514/fix/dreaming-sarah-boot
fix(libkernel): boot Dreaming Sarah past unwind and debug raise
This commit is contained in:
commit
4181fbd521
|
|
@ -1,9 +1,18 @@
|
|||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
#include "prx/libkernel/DirectMemory/DirectMemory.hpp"
|
||||
#include "prx/libkernel/KernelErrors.hpp"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <psapi.h>
|
||||
#else
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
void* APS5_VABI dlopen_nid_postfix(const char* path, int flags);
|
||||
|
|
@ -26,11 +35,52 @@ int APS5_VABI sceKernelDlsym(KernelModule handle, const char* symbol, void** add
|
|||
}
|
||||
|
||||
int APS5_VABI sceKernelGetModuleInfoForUnwind(uint64_t addr, int flags, ModuleInfoForUnwind* info) {
|
||||
(void)addr;
|
||||
(void)flags;
|
||||
(void)info;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
(void)flags;
|
||||
if (!info) return SCE_KERNEL_ERROR_EFAULT;
|
||||
#ifdef _WIN32
|
||||
MEMORY_BASIC_INFORMATION mbi{};
|
||||
if (!VirtualQuery(reinterpret_cast<LPCVOID>(addr), &mbi, sizeof(mbi))) return SCE_KERNEL_ERROR_ESRCH;
|
||||
info->st_size = sizeof(ModuleInfoForUnwind);
|
||||
info->eh_frame_hdr_addr = 0;
|
||||
info->eh_frame_addr = 0;
|
||||
info->eh_frame_size = 0;
|
||||
info->seg0_addr = reinterpret_cast<std::uint64_t>(mbi.BaseAddress);
|
||||
info->seg0_size = mbi.RegionSize;
|
||||
char path[4096] = {};
|
||||
DWORD len = GetMappedFileNameA(GetCurrentProcess(), mbi.BaseAddress, path, sizeof(path) - 1);
|
||||
path[len] = '\0';
|
||||
std::strncpy(info->name, path, sizeof(info->name) - 1);
|
||||
info->name[sizeof(info->name) - 1] = '\0';
|
||||
return 0;
|
||||
#else
|
||||
std::ifstream maps("/proc/self/maps");
|
||||
if (!maps) throw std::runtime_error("sceKernelGetModuleInfoForUnwind: failed to open /proc/self/maps");
|
||||
std::string line;
|
||||
while (std::getline(maps, line)) {
|
||||
std::uint64_t start = 0;
|
||||
std::uint64_t end = 0;
|
||||
char perms[8] = {};
|
||||
std::uint64_t offset = 0;
|
||||
unsigned int devMajor = 0;
|
||||
unsigned int devMinor = 0;
|
||||
std::uint64_t inode = 0;
|
||||
char path[4096] = {};
|
||||
int parsed = std::sscanf(line.c_str(), "%llx-%llx %7s %llx %x:%x %llu %4095s",
|
||||
(unsigned long long*)&start, (unsigned long long*)&end, perms,
|
||||
(unsigned long long*)&offset, &devMajor, &devMinor, (unsigned long long*)&inode, path);
|
||||
if (parsed < 7 || addr < start || addr >= end) continue;
|
||||
info->st_size = sizeof(ModuleInfoForUnwind);
|
||||
std::strncpy(info->name, parsed >= 8 ? path : "", sizeof(info->name) - 1);
|
||||
info->name[sizeof(info->name) - 1] = '\0';
|
||||
info->eh_frame_hdr_addr = 0;
|
||||
info->eh_frame_addr = 0;
|
||||
info->eh_frame_size = 0;
|
||||
info->seg0_addr = start;
|
||||
info->seg0_size = end - start;
|
||||
return 0;
|
||||
}
|
||||
return SCE_KERNEL_ERROR_ESRCH;
|
||||
#endif
|
||||
}
|
||||
|
||||
int APS5_VABI sceKernelGetModuleInfoFromAddr(uint64_t addr, int n, ModuleInfo* r) {
|
||||
|
|
|
|||
|
|
@ -26,15 +26,11 @@ int APS5_VABI sceKernelRaiseException(Pthread thread, int signum) {
|
|||
}
|
||||
|
||||
void APS5_VABI sceKernelDebugRaiseException(int c1, int c2) {
|
||||
(void)c1;
|
||||
(void)c2;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
APS5_LOG_OUT("sceKernelDebugRaiseException c1=%d c2=%d", c1, c2);
|
||||
}
|
||||
|
||||
void APS5_VABI sceKernelDebugRaiseExceptionOnReleaseMode(int c1, int c2) {
|
||||
(void)c1;
|
||||
(void)c2;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
APS5_LOG_OUT("sceKernelDebugRaiseExceptionOnReleaseMode c1=%d c2=%d", c1, c2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue