From 04d723baf96e35222c922fb212f92e60f8b7370c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 12 Sep 2018 04:49:08 -0400 Subject: [PATCH 1/2] svc: Correct parameter type for OutputDebugString() This should be a u64 to represent size. --- src/core/hle/kernel/svc.cpp | 2 +- src/core/hle/kernel/svc_wrap.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 1c9373ed87..07a6c40144 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -273,7 +273,7 @@ static void Break(u64 reason, u64 info1, u64 info2) { } /// Used to output a message on a debug hardware unit - does nothing on a retail unit -static void OutputDebugString(VAddr address, s32 len) { +static void OutputDebugString(VAddr address, u64 len) { std::string str(len, '\0'); Memory::ReadBlock(address, str.data(), str.size()); LOG_DEBUG(Debug_Emulated, "{}", str); diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h index 79c3fe31b6..1eda5f879c 100644 --- a/src/core/hle/kernel/svc_wrap.h +++ b/src/core/hle/kernel/svc_wrap.h @@ -222,9 +222,9 @@ void SvcWrap() { func((s64)PARAM(0)); } -template +template void SvcWrap() { - func(PARAM(0), (s32)(PARAM(1) & 0xFFFFFFFF)); + func(PARAM(0), PARAM(1)); } template From 9b3bc0b282393a9bf19b4bcb1c2830a879278fbf Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 12 Sep 2018 04:51:41 -0400 Subject: [PATCH 2/2] svc: Do nothing if svcOutputDebugString() is given a length of zero While unlikely, it does avoid constructing a std::string and unnecessarily calling into the memory code if a game or executable decides to be really silly about their logging. --- src/core/hle/kernel/svc.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 07a6c40144..0b2a7e3cb7 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -274,6 +274,10 @@ static void Break(u64 reason, u64 info1, u64 info2) { /// Used to output a message on a debug hardware unit - does nothing on a retail unit static void OutputDebugString(VAddr address, u64 len) { + if (len == 0) { + return; + } + std::string str(len, '\0'); Memory::ReadBlock(address, str.data(), str.size()); LOG_DEBUG(Debug_Emulated, "{}", str);