mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-09-08 07:39:08 +01:00
Kernel/SVC: Implemented svcQueryProcessMemory
This commit is contained in:
parent
41513cfb0c
commit
83fa3f977d
2 changed files with 28 additions and 6 deletions
|
@ -99,6 +99,18 @@ template<ResultCode func(MemoryInfo*, PageInfo*, u32)> void Wrap() {
|
||||||
FuncReturn(retval);
|
FuncReturn(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<ResultCode func(MemoryInfo*, PageInfo*, Handle, u32)> void Wrap() {
|
||||||
|
MemoryInfo memory_info = {};
|
||||||
|
PageInfo page_info = {};
|
||||||
|
u32 retval = func(&memory_info, &page_info, PARAM(2), PARAM(3)).raw;
|
||||||
|
Core::g_app_core->SetReg(1, memory_info.base_address);
|
||||||
|
Core::g_app_core->SetReg(2, memory_info.size);
|
||||||
|
Core::g_app_core->SetReg(3, memory_info.permission);
|
||||||
|
Core::g_app_core->SetReg(4, memory_info.state);
|
||||||
|
Core::g_app_core->SetReg(5, page_info.flags);
|
||||||
|
FuncReturn(retval);
|
||||||
|
}
|
||||||
|
|
||||||
template<ResultCode func(s32*, u32)> void Wrap(){
|
template<ResultCode func(s32*, u32)> void Wrap(){
|
||||||
s32 param_1 = 0;
|
s32 param_1 = 0;
|
||||||
u32 retval = func(¶m_1, PARAM(1)).raw;
|
u32 retval = func(¶m_1, PARAM(1)).raw;
|
||||||
|
|
|
@ -530,11 +530,16 @@ static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count)
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Query memory
|
/// Query process memory
|
||||||
static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32 addr) {
|
static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_info, Handle process_handle, u32 addr) {
|
||||||
auto vma = Kernel::g_current_process->address_space->FindVMA(addr);
|
using Kernel::Process;
|
||||||
|
Kernel::SharedPtr<Process> process = Kernel::g_handle_table.Get<Process>(process_handle);
|
||||||
|
if (process == nullptr)
|
||||||
|
return ERR_INVALID_HANDLE;
|
||||||
|
|
||||||
if (vma == Kernel::g_current_process->address_space->vma_map.end())
|
auto vma = process->address_space->FindVMA(addr);
|
||||||
|
|
||||||
|
if (vma == process->address_space->vma_map.end())
|
||||||
return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
||||||
|
|
||||||
memory_info->base_address = vma->second.base;
|
memory_info->base_address = vma->second.base;
|
||||||
|
@ -543,10 +548,15 @@ static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32
|
||||||
memory_info->state = static_cast<u32>(vma->second.meminfo_state);
|
memory_info->state = static_cast<u32>(vma->second.meminfo_state);
|
||||||
|
|
||||||
page_info->flags = 0;
|
page_info->flags = 0;
|
||||||
LOG_TRACE(Kernel_SVC, "called addr=0x%08X", addr);
|
LOG_TRACE(Kernel_SVC, "called process=0x%08X addr=0x%08X", process_handle, addr);
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Query memory
|
||||||
|
static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32 addr) {
|
||||||
|
return QueryProcessMemory(memory_info, page_info, Kernel::CurrentProcess, addr);
|
||||||
|
}
|
||||||
|
|
||||||
/// Create an event
|
/// Create an event
|
||||||
static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) {
|
static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) {
|
||||||
using Kernel::Event;
|
using Kernel::Event;
|
||||||
|
@ -818,7 +828,7 @@ static const FunctionDef SVC_Table[] = {
|
||||||
{0x7A, nullptr, "AddCodeSegment"},
|
{0x7A, nullptr, "AddCodeSegment"},
|
||||||
{0x7B, nullptr, "Backdoor"},
|
{0x7B, nullptr, "Backdoor"},
|
||||||
{0x7C, nullptr, "KernelSetState"},
|
{0x7C, nullptr, "KernelSetState"},
|
||||||
{0x7D, nullptr, "QueryProcessMemory"},
|
{0x7D, HLE::Wrap<QueryProcessMemory>, "QueryProcessMemory"},
|
||||||
};
|
};
|
||||||
|
|
||||||
Common::Profiling::TimingCategory profiler_svc("SVC Calls");
|
Common::Profiling::TimingCategory profiler_svc("SVC Calls");
|
||||||
|
|
Loading…
Reference in a new issue