From 6913d3942f9532568671d03e0d8c1598b655ced6 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sat, 13 Jun 2020 06:50:12 +0800 Subject: [PATCH 1/3] Add sysclib_strstr jpcsp ref: https://github.com/jpcsp/jpcsp/commit/b4158f2ec7fc6db3efb0c0efcaa70df99b3f6b1a --- Core/HLE/sceKernelInterrupt.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Core/HLE/sceKernelInterrupt.cpp b/Core/HLE/sceKernelInterrupt.cpp index 72d0c98da6..b558797fb0 100644 --- a/Core/HLE/sceKernelInterrupt.cpp +++ b/Core/HLE/sceKernelInterrupt.cpp @@ -752,6 +752,17 @@ static u32 sysclib_memset(u32 destAddr, int data, int size) { return 0; } +static int sysclib_strstr(u32 s1, u32 s2 ) { + ERROR_LOG(SCEKERNEL, "Untested sysclib_strstr(%08x, %08x)", s1, s2); + std::string str1 = Memory::GetCharPointer(s1); + std::string str2 = Memory::GetCharPointer(s2); + int index = str1.find(str2); + if (index < 0) { + return 0; + } + return s1 + index; +} + const HLEFunction SysclibForKernel[] = { {0xAB7592FF, &WrapU_UUU, "memcpy", 'x', "xxx", HLE_KERNEL_SYSCALL }, @@ -762,6 +773,7 @@ const HLEFunction SysclibForKernel[] = {0x81D0D1F7, &WrapI_UUU, "memcmp", 'i', "xxx", HLE_KERNEL_SYSCALL }, {0x7661E728, &WrapI_UU, "sprintf", 'i', "xx", HLE_KERNEL_SYSCALL }, {0x10F3BB61, &WrapU_UII, "memset", 'x', "xii", HLE_KERNEL_SYSCALL }, + {0x0D188658, &WrapI_CC, "strstr", 'i', "xx", HLE_KERNEL_SYSCALL }, }; void Register_Kernel_Library() From d0d2834fc93adf85fd631a81daee00ac8dc239f4 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sat, 13 Jun 2020 06:58:02 +0800 Subject: [PATCH 2/3] oop --- Core/HLE/sceKernelInterrupt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceKernelInterrupt.cpp b/Core/HLE/sceKernelInterrupt.cpp index b558797fb0..08158e9afb 100644 --- a/Core/HLE/sceKernelInterrupt.cpp +++ b/Core/HLE/sceKernelInterrupt.cpp @@ -752,7 +752,7 @@ static u32 sysclib_memset(u32 destAddr, int data, int size) { return 0; } -static int sysclib_strstr(u32 s1, u32 s2 ) { +static int sysclib_strstr(u32 s1, u32 s2) { ERROR_LOG(SCEKERNEL, "Untested sysclib_strstr(%08x, %08x)", s1, s2); std::string str1 = Memory::GetCharPointer(s1); std::string str2 = Memory::GetCharPointer(s2); @@ -773,7 +773,7 @@ const HLEFunction SysclibForKernel[] = {0x81D0D1F7, &WrapI_UUU, "memcmp", 'i', "xxx", HLE_KERNEL_SYSCALL }, {0x7661E728, &WrapI_UU, "sprintf", 'i', "xx", HLE_KERNEL_SYSCALL }, {0x10F3BB61, &WrapU_UII, "memset", 'x', "xii", HLE_KERNEL_SYSCALL }, - {0x0D188658, &WrapI_CC, "strstr", 'i', "xx", HLE_KERNEL_SYSCALL }, + {0x0D188658, &WrapI_UU, "strstr", 'i', "xx", HLE_KERNEL_SYSCALL }, }; void Register_Kernel_Library() From 10112fa6a2d4589e1ccd44625ed6bf80b2a997ac Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sat, 13 Jun 2020 20:46:35 +0800 Subject: [PATCH 3/3] Change to @unknownbrackets logic Avoid warnings --- Core/HLE/sceKernelInterrupt.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceKernelInterrupt.cpp b/Core/HLE/sceKernelInterrupt.cpp index 08158e9afb..18c8cfb35c 100644 --- a/Core/HLE/sceKernelInterrupt.cpp +++ b/Core/HLE/sceKernelInterrupt.cpp @@ -756,11 +756,11 @@ static int sysclib_strstr(u32 s1, u32 s2) { ERROR_LOG(SCEKERNEL, "Untested sysclib_strstr(%08x, %08x)", s1, s2); std::string str1 = Memory::GetCharPointer(s1); std::string str2 = Memory::GetCharPointer(s2); - int index = str1.find(str2); - if (index < 0) { + size_t index = str1.find(str2); + if (index == str1.npos) { return 0; } - return s1 + index; + return s1 + (uint32_t)index; } const HLEFunction SysclibForKernel[] =