From c02b8c895b49b511a4316ee5e7bf1ab9a081869b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 12 Dec 2018 11:04:10 -0500 Subject: vm_manager: Migrate MemoryInfo and PageInfo to vm_manager.h Gets the two structures out of an unrelated header and places them with the rest of the memory management code. This also corrects the structures. PageInfo appears to only contain a 32-bit flags member, and the extra padding word in MemoryInfo isn't necessary. --- src/core/hle/kernel/svc_wrap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/hle/kernel/svc_wrap.h') diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h index 24aef46c9..3893b0f4a 100644 --- a/src/core/hle/kernel/svc_wrap.h +++ b/src/core/hle/kernel/svc_wrap.h @@ -7,7 +7,7 @@ #include "common/common_types.h" #include "core/arm/arm_interface.h" #include "core/core.h" -#include "core/hle/kernel/svc.h" +#include "core/hle/kernel/vm_manager.h" #include "core/hle/result.h" #include "core/memory.h" -- cgit v1.2.3 From a8cc03502b41b44150af71535d2b662a7ee3390c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 12 Dec 2018 11:34:01 -0500 Subject: vm_manager: Migrate memory querying to the VMManager interface Gets rid of the need to directly access the managed VMAs outside of the memory manager itself just for querying memory. --- src/core/hle/kernel/svc_wrap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/hle/kernel/svc_wrap.h') diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h index 3893b0f4a..27a11d82e 100644 --- a/src/core/hle/kernel/svc_wrap.h +++ b/src/core/hle/kernel/svc_wrap.h @@ -199,7 +199,7 @@ void SvcWrap() { Memory::Write64(Param(0), memory_info.base_address); Memory::Write64(Param(0) + 8, memory_info.size); - Memory::Write32(Param(0) + 16, memory_info.type); + Memory::Write32(Param(0) + 16, memory_info.state); Memory::Write32(Param(0) + 20, memory_info.attributes); Memory::Write32(Param(0) + 24, memory_info.permission); -- cgit v1.2.3 From d8deb39b83409f1d9b5eeec0a719d560e4409aae Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 12 Dec 2018 11:48:06 -0500 Subject: svc: Handle memory writing explicitly within QueryProcessMemory Moves the memory writes directly into QueryProcessMemory instead of letting the wrapper function do it. It would be inaccurate to allow the handler to do it because there's cases where memory shouldn't even be written to. For example, if the given process handle is invalid. HOWEVER, if the memory writing is within the wrapper, then we have no control over if these memory writes occur, meaning in an error case, 68 bytes of memory randomly get trashed with zeroes, 64 of those being written to wherever the memory info address points to, and the remaining 4 being written wherever the page info address points to. One solution in this case would be to just conditionally check within the handler itself, but this is kind of smelly, given the handler shouldn't be performing conditional behavior itself, it's a behavior of the managed function. In other words, if you remove the handler from the equation entirely, does the function still retain its proper behavior? In this case, no. Now, we don't potentially trash memory from this function if an invalid query is performed. --- src/core/hle/kernel/svc_wrap.h | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'src/core/hle/kernel/svc_wrap.h') diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h index 27a11d82e..f03b5438b 100644 --- a/src/core/hle/kernel/svc_wrap.h +++ b/src/core/hle/kernel/svc_wrap.h @@ -7,9 +7,7 @@ #include "common/common_types.h" #include "core/arm/arm_interface.h" #include "core/core.h" -#include "core/hle/kernel/vm_manager.h" #include "core/hle/result.h" -#include "core/memory.h" namespace Kernel { @@ -191,21 +189,6 @@ void SvcWrap() { FuncReturn(retval); } -template -void SvcWrap() { - MemoryInfo memory_info = {}; - PageInfo page_info = {}; - u32 retval = func(&memory_info, &page_info, Param(2)).raw; - - Memory::Write64(Param(0), memory_info.base_address); - Memory::Write64(Param(0) + 8, memory_info.size); - Memory::Write32(Param(0) + 16, memory_info.state); - Memory::Write32(Param(0) + 20, memory_info.attributes); - Memory::Write32(Param(0) + 24, memory_info.permission); - - FuncReturn(retval); -} - template void SvcWrap() { u32 param_1 = 0; -- cgit v1.2.3 From b79f08661337f22d46d519218c1cc6c013a14d2c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 12 Dec 2018 13:42:21 -0500 Subject: svc: Enable svcQueryProcessMemory svcQueryProcessMemory is trivial to implement, given all the behavior necessary for it is present, it just needs a handler for it. --- src/core/hle/kernel/svc_wrap.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/core/hle/kernel/svc_wrap.h') diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h index f03b5438b..b762fd93e 100644 --- a/src/core/hle/kernel/svc_wrap.h +++ b/src/core/hle/kernel/svc_wrap.h @@ -130,6 +130,11 @@ void SvcWrap() { func(Param(0), Param(1), static_cast(Param(3)), static_cast(Param(3))).raw); } +template +void SvcWrap() { + FuncReturn(func(Param(0), Param(1), static_cast(Param(2)), Param(3)).raw); +} + template void SvcWrap() { FuncReturn(func(static_cast(Param(0)), Param(1), static_cast(Param(2))).raw); -- cgit v1.2.3