diff options
| author | 2017-10-04 12:05:13 -0500 | |
|---|---|---|
| committer | 2017-10-04 14:03:59 -0500 | |
| commit | 7b09b30ef11d1d4001a50bbb91abdfb86b954ce2 (patch) | |
| tree | 885601c5021a58356e2a5c78b06b5a76444dc8b9 | |
| parent | SVC: Replace GetPointer usage with ReadBlock in OutputDebugString. (diff) | |
| download | yuzu-7b09b30ef11d1d4001a50bbb91abdfb86b954ce2.tar.gz yuzu-7b09b30ef11d1d4001a50bbb91abdfb86b954ce2.tar.xz yuzu-7b09b30ef11d1d4001a50bbb91abdfb86b954ce2.zip | |
SVC: Replace GetPointer usage with ReadCString in ConnectToPort.
| -rw-r--r-- | src/core/hle/function_wrappers.h | 15 | ||||
| -rw-r--r-- | src/core/hle/svc.cpp | 14 |
2 files changed, 9 insertions, 20 deletions
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h index cb0b430ee..a982b2b54 100644 --- a/src/core/hle/function_wrappers.h +++ b/src/core/hle/function_wrappers.h | |||
| @@ -151,21 +151,6 @@ void Wrap() { | |||
| 151 | FuncReturn(func(PARAM(0)).raw); | 151 | FuncReturn(func(PARAM(0)).raw); |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | template <ResultCode func(s64*, u32, u32*, u32)> | ||
| 155 | void Wrap() { | ||
| 156 | FuncReturn(func((s64*)Memory::GetPointer(PARAM(0)), PARAM(1), | ||
| 157 | (u32*)Memory::GetPointer(PARAM(2)), (s32)PARAM(3)) | ||
| 158 | .raw); | ||
| 159 | } | ||
| 160 | |||
| 161 | template <ResultCode func(u32*, const char*)> | ||
| 162 | void Wrap() { | ||
| 163 | u32 param_1 = 0; | ||
| 164 | u32 retval = func(¶m_1, (char*)Memory::GetPointer(PARAM(1))).raw; | ||
| 165 | Core::CPU().SetReg(1, param_1); | ||
| 166 | FuncReturn(retval); | ||
| 167 | } | ||
| 168 | |||
| 169 | template <ResultCode func(u32*, s32, s32)> | 154 | template <ResultCode func(u32*, s32, s32)> |
| 170 | void Wrap() { | 155 | void Wrap() { |
| 171 | u32 param_1 = 0; | 156 | u32 param_1 = 0; |
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 37eeeb860..2ae177ab5 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -201,17 +201,21 @@ static ResultCode UnmapMemoryBlock(Kernel::Handle handle, u32 addr) { | |||
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | /// Connect to an OS service given the port name, returns the handle to the port to out | 203 | /// Connect to an OS service given the port name, returns the handle to the port to out |
| 204 | static ResultCode ConnectToPort(Kernel::Handle* out_handle, const char* port_name) { | 204 | static ResultCode ConnectToPort(Kernel::Handle* out_handle, VAddr port_name_address) { |
| 205 | if (port_name == nullptr) | 205 | if (!Memory::IsValidVirtualAddress(port_name_address)) |
| 206 | return Kernel::ERR_NOT_FOUND; | 206 | return Kernel::ERR_NOT_FOUND; |
| 207 | if (std::strlen(port_name) > 11) | 207 | |
| 208 | static constexpr std::size_t PortNameMaxLength = 11; | ||
| 209 | // Read 1 char beyond the max allowed port name to detect names that are too long. | ||
| 210 | std::string port_name = Memory::ReadCString(port_name_address, PortNameMaxLength + 1); | ||
| 211 | if (port_name.size() > PortNameMaxLength) | ||
| 208 | return Kernel::ERR_PORT_NAME_TOO_LONG; | 212 | return Kernel::ERR_PORT_NAME_TOO_LONG; |
| 209 | 213 | ||
| 210 | LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name); | 214 | LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name.c_str()); |
| 211 | 215 | ||
| 212 | auto it = Service::g_kernel_named_ports.find(port_name); | 216 | auto it = Service::g_kernel_named_ports.find(port_name); |
| 213 | if (it == Service::g_kernel_named_ports.end()) { | 217 | if (it == Service::g_kernel_named_ports.end()) { |
| 214 | LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name); | 218 | LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name.c_str()); |
| 215 | return Kernel::ERR_NOT_FOUND; | 219 | return Kernel::ERR_NOT_FOUND; |
| 216 | } | 220 | } |
| 217 | 221 | ||