From e42a970ee385d98fdda88d0435ddbed97d473f47 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sat, 24 Sep 2022 22:40:19 +0800 Subject: [PATCH] Add some sysclib's nids Find in prxshot.prx --- Core/HLE/sceKernelInterrupt.cpp | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/Core/HLE/sceKernelInterrupt.cpp b/Core/HLE/sceKernelInterrupt.cpp index 4c91ffe529..74e11e413b 100644 --- a/Core/HLE/sceKernelInterrupt.cpp +++ b/Core/HLE/sceKernelInterrupt.cpp @@ -826,6 +826,63 @@ static u32 sysclib_strncpy(u32 dest, u32 src, u32 size) { return hleLogSuccessX(SCEKERNEL, dest); } +static u32 sysclib_strtol(u32 t, u32 endStringtemp, int base) { + ERROR_LOG(SCEKERNEL, "Unimp sysclib_strtol(%08x, %08x, %i)", t ,endStringtemp, base); + // base == 0 seems to be handled as base == 10. + if (base == 0){ + base = 10; + } + std::string str = Memory::GetCharPointer(t); + std::string endString = Memory::GetCharPointer(endStringtemp); + + // Skip any leading "0x" in case of base 16 + if (base == 16 && (str.rfind("0x", 0) == 0 || str.rfind("0X", 0) == 0)) { + str = str.substr(2); + } + return 0; +} + +static u32 sysclib_strchr(u32 src, int c) { + const std::string str = Memory::GetCharPointer(src); + ERROR_LOG(SCEKERNEL, "Untest sysclib_strchr(%c, %i)", str,c); + int index = str.find(str,c); + if (index < 0) { + return 0; + } + return 0; +} + +static u32 sysclib_strrchr(u32 src, int c) { + const std::string str = Memory::GetCharPointer(src); + ERROR_LOG(SCEKERNEL, "Untest sysclib_strchr(%c, %i)", str, c); + int index = str.rfind(str, c); + if (index < 0) { + return 0; + } + return 0; +} + +const u8 look_ctype_table[128] = { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x08, 0x08, 0x08, 0x08, 0x08, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x18, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x10, 0x10, 0x10, 0x10, 0x20 +}; + +static u32 sysclib_toupper(u32 c) { + ERROR_LOG(SCEKERNEL, "Untest sysclib_toupper(%i)",c); + int ctype = look_ctype_table[c & 0xFF]; + if ((ctype & 0x02) != 0) { + c -= 0x20; + } + + return c; +} + + const HLEFunction SysclibForKernel[] = { {0xAB7592FF, &WrapU_UUU, "memcpy", 'x', "xxx", HLE_KERNEL_SYSCALL }, @@ -840,6 +897,10 @@ const HLEFunction SysclibForKernel[] = {0x7AB35214, &WrapI_UUU, "strncmp", 'i', "xxx", HLE_KERNEL_SYSCALL }, {0xA48D2592, &WrapU_UUU, "memmove", 'x', "xxx", HLE_KERNEL_SYSCALL }, {0xB49A7697, &WrapU_UUU, "strncpy", 'x', "xxi", HLE_KERNEL_SYSCALL }, + {0x47DD934D, &WrapU_UUI, "strtol", 'x', "xxi", HLE_KERNEL_SYSCALL }, + {0xB1DC2AE8, &WrapU_UI, "strchr", 'x', "xx", HLE_KERNEL_SYSCALL }, + {0x4C0E0274, &WrapU_UI, "strrchr", 'x', "xx", HLE_KERNEL_SYSCALL }, + {0xCE2F7487, &WrapU_U, "toupper", 'x', "x", HLE_KERNEL_SYSCALL }, }; void Register_Kernel_Library()