diff options
| author | 2015-07-20 00:34:41 -0400 | |
|---|---|---|
| committer | 2015-07-20 00:34:41 -0400 | |
| commit | cd2bb2dc698d5ce142394a22c5abff0cb89d431a (patch) | |
| tree | 41175f58f896e2a911d9e2ab1143411c881f7698 /src/core | |
| parent | Merge pull request #951 from Subv/bit5 (diff) | |
| parent | Kernel/SVC: Implemented svcQueryProcessMemory (diff) | |
| download | yuzu-cd2bb2dc698d5ce142394a22c5abff0cb89d431a.tar.gz yuzu-cd2bb2dc698d5ce142394a22c5abff0cb89d431a.tar.xz yuzu-cd2bb2dc698d5ce142394a22c5abff0cb89d431a.zip | |
Merge pull request #939 from Subv/queryprocmem
Kernel/SVC: Implemented svcQueryProcessMemory
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/function_wrappers.h | 12 | ||||
| -rw-r--r-- | src/core/hle/svc.cpp | 22 |
2 files changed, 28 insertions, 6 deletions
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h index 1ac6032a6..9294789ec 100644 --- a/src/core/hle/function_wrappers.h +++ b/src/core/hle/function_wrappers.h | |||
| @@ -99,6 +99,18 @@ template<ResultCode func(MemoryInfo*, PageInfo*, u32)> void Wrap() { | |||
| 99 | FuncReturn(retval); | 99 | FuncReturn(retval); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | template<ResultCode func(MemoryInfo*, PageInfo*, Handle, u32)> void Wrap() { | ||
| 103 | MemoryInfo memory_info = {}; | ||
| 104 | PageInfo page_info = {}; | ||
| 105 | u32 retval = func(&memory_info, &page_info, PARAM(2), PARAM(3)).raw; | ||
| 106 | Core::g_app_core->SetReg(1, memory_info.base_address); | ||
| 107 | Core::g_app_core->SetReg(2, memory_info.size); | ||
| 108 | Core::g_app_core->SetReg(3, memory_info.permission); | ||
| 109 | Core::g_app_core->SetReg(4, memory_info.state); | ||
| 110 | Core::g_app_core->SetReg(5, page_info.flags); | ||
| 111 | FuncReturn(retval); | ||
| 112 | } | ||
| 113 | |||
| 102 | template<ResultCode func(s32*, u32)> void Wrap(){ | 114 | template<ResultCode func(s32*, u32)> void Wrap(){ |
| 103 | s32 param_1 = 0; | 115 | s32 param_1 = 0; |
| 104 | u32 retval = func(¶m_1, PARAM(1)).raw; | 116 | u32 retval = func(¶m_1, PARAM(1)).raw; |
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 9d441ccfc..802ecc52a 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -530,11 +530,16 @@ static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count) | |||
| 530 | return RESULT_SUCCESS; | 530 | return RESULT_SUCCESS; |
| 531 | } | 531 | } |
| 532 | 532 | ||
| 533 | /// Query memory | 533 | /// Query process memory |
| 534 | static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32 addr) { | 534 | static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_info, Handle process_handle, u32 addr) { |
| 535 | auto vma = Kernel::g_current_process->address_space->FindVMA(addr); | 535 | using Kernel::Process; |
| 536 | Kernel::SharedPtr<Process> process = Kernel::g_handle_table.Get<Process>(process_handle); | ||
| 537 | if (process == nullptr) | ||
| 538 | return ERR_INVALID_HANDLE; | ||
| 539 | |||
| 540 | auto vma = process->address_space->FindVMA(addr); | ||
| 536 | 541 | ||
| 537 | if (vma == Kernel::g_current_process->address_space->vma_map.end()) | 542 | if (vma == process->address_space->vma_map.end()) |
| 538 | return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage); | 543 | return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage); |
| 539 | 544 | ||
| 540 | memory_info->base_address = vma->second.base; | 545 | memory_info->base_address = vma->second.base; |
| @@ -543,10 +548,15 @@ static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32 | |||
| 543 | memory_info->state = static_cast<u32>(vma->second.meminfo_state); | 548 | memory_info->state = static_cast<u32>(vma->second.meminfo_state); |
| 544 | 549 | ||
| 545 | page_info->flags = 0; | 550 | page_info->flags = 0; |
| 546 | LOG_TRACE(Kernel_SVC, "called addr=0x%08X", addr); | 551 | LOG_TRACE(Kernel_SVC, "called process=0x%08X addr=0x%08X", process_handle, addr); |
| 547 | return RESULT_SUCCESS; | 552 | return RESULT_SUCCESS; |
| 548 | } | 553 | } |
| 549 | 554 | ||
| 555 | /// Query memory | ||
| 556 | static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32 addr) { | ||
| 557 | return QueryProcessMemory(memory_info, page_info, Kernel::CurrentProcess, addr); | ||
| 558 | } | ||
| 559 | |||
| 550 | /// Create an event | 560 | /// Create an event |
| 551 | static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) { | 561 | static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) { |
| 552 | using Kernel::Event; | 562 | using Kernel::Event; |
| @@ -818,7 +828,7 @@ static const FunctionDef SVC_Table[] = { | |||
| 818 | {0x7A, nullptr, "AddCodeSegment"}, | 828 | {0x7A, nullptr, "AddCodeSegment"}, |
| 819 | {0x7B, nullptr, "Backdoor"}, | 829 | {0x7B, nullptr, "Backdoor"}, |
| 820 | {0x7C, nullptr, "KernelSetState"}, | 830 | {0x7C, nullptr, "KernelSetState"}, |
| 821 | {0x7D, nullptr, "QueryProcessMemory"}, | 831 | {0x7D, HLE::Wrap<QueryProcessMemory>, "QueryProcessMemory"}, |
| 822 | }; | 832 | }; |
| 823 | 833 | ||
| 824 | Common::Profiling::TimingCategory profiler_svc("SVC Calls"); | 834 | Common::Profiling::TimingCategory profiler_svc("SVC Calls"); |