diff options
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 8b079bc40..a1ecc4540 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -35,6 +35,7 @@ | |||
| 35 | #include "core/hle/lock.h" | 35 | #include "core/hle/lock.h" |
| 36 | #include "core/hle/result.h" | 36 | #include "core/hle/result.h" |
| 37 | #include "core/hle/service/service.h" | 37 | #include "core/hle/service/service.h" |
| 38 | #include "core/memory.h" | ||
| 38 | 39 | ||
| 39 | namespace Kernel { | 40 | namespace Kernel { |
| 40 | namespace { | 41 | namespace { |
| @@ -1066,9 +1067,8 @@ static ResultCode UnmapSharedMemory(Handle shared_memory_handle, VAddr addr, u64 | |||
| 1066 | return shared_memory->Unmap(*current_process, addr); | 1067 | return shared_memory->Unmap(*current_process, addr); |
| 1067 | } | 1068 | } |
| 1068 | 1069 | ||
| 1069 | /// Query process memory | 1070 | static ResultCode QueryProcessMemory(VAddr memory_info_address, VAddr page_info_address, |
| 1070 | static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_info*/, | 1071 | Handle process_handle, VAddr address) { |
| 1071 | Handle process_handle, u64 address) { | ||
| 1072 | LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); | 1072 | LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); |
| 1073 | const auto& handle_table = Core::CurrentProcess()->GetHandleTable(); | 1073 | const auto& handle_table = Core::CurrentProcess()->GetHandleTable(); |
| 1074 | SharedPtr<Process> process = handle_table.Get<Process>(process_handle); | 1074 | SharedPtr<Process> process = handle_table.Get<Process>(process_handle); |
| @@ -1079,16 +1079,29 @@ static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_i | |||
| 1079 | } | 1079 | } |
| 1080 | 1080 | ||
| 1081 | const auto& vm_manager = process->VMManager(); | 1081 | const auto& vm_manager = process->VMManager(); |
| 1082 | const auto result = vm_manager.QueryMemory(address); | 1082 | const MemoryInfo memory_info = vm_manager.QueryMemory(address); |
| 1083 | |||
| 1084 | Memory::Write64(memory_info_address, memory_info.base_address); | ||
| 1085 | Memory::Write64(memory_info_address + 8, memory_info.size); | ||
| 1086 | Memory::Write32(memory_info_address + 16, memory_info.state); | ||
| 1087 | Memory::Write32(memory_info_address + 20, memory_info.attributes); | ||
| 1088 | Memory::Write32(memory_info_address + 24, memory_info.permission); | ||
| 1089 | |||
| 1090 | // Page info appears to be currently unused by the kernel and is always set to zero. | ||
| 1091 | Memory::Write32(page_info_address, 0); | ||
| 1083 | 1092 | ||
| 1084 | *memory_info = result; | ||
| 1085 | return RESULT_SUCCESS; | 1093 | return RESULT_SUCCESS; |
| 1086 | } | 1094 | } |
| 1087 | 1095 | ||
| 1088 | /// Query memory | 1096 | static ResultCode QueryMemory(VAddr memory_info_address, VAddr page_info_address, |
| 1089 | static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, VAddr addr) { | 1097 | VAddr query_address) { |
| 1090 | LOG_TRACE(Kernel_SVC, "called, addr={:X}", addr); | 1098 | LOG_TRACE(Kernel_SVC, |
| 1091 | return QueryProcessMemory(memory_info, page_info, CurrentProcess, addr); | 1099 | "called, memory_info_address=0x{:016X}, page_info_address=0x{:016X}, " |
| 1100 | "query_address=0x{:016X}", | ||
| 1101 | memory_info_address, page_info_address, query_address); | ||
| 1102 | |||
| 1103 | return QueryProcessMemory(memory_info_address, page_info_address, CurrentProcess, | ||
| 1104 | query_address); | ||
| 1092 | } | 1105 | } |
| 1093 | 1106 | ||
| 1094 | /// Exits the current process | 1107 | /// Exits the current process |