rpcsx/rpcs3/Emu/Cell/lv2/sys_dbg.cpp

60 lines
1.4 KiB
C++
Raw Normal View History

2015-07-09 17:30:37 +02:00
#include "stdafx.h"
#include "sys_dbg.h"
2015-07-09 17:30:37 +02:00
2016-04-14 00:23:53 +02:00
#include "Emu/Cell/ErrorCodes.h"
#include "Emu/Cell/Modules/sys_lv2dbg.h"
2015-07-09 17:30:37 +02:00
LOG_CHANNEL(sys_dbg);
2018-02-09 15:49:37 +01:00
error_code sys_dbg_read_process_memory(s32 pid, u32 address, u32 size, vm::ptr<void> data)
{
sys_dbg.warning("sys_dbg_read_process_memory(pid=0x%x, address=0x%llx, size=0x%x, data=*0x%x)", pid, address, size, data);
2016-08-19 23:14:10 +02:00
// Todo(TGEnigma): Process lookup (only 1 process exists right now)
if (pid != 1)
{
return CELL_LV2DBG_ERROR_DEINVALIDARGUMENTS;
}
if (!size || !data)
{
return CELL_LV2DBG_ERROR_DEINVALIDARGUMENTS;
}
// Check if data destination is writable
if (!vm::check_addr(data.addr(), vm::page_writable, size))
{
return CELL_EFAULT;
}
std::memcpy(data.get_ptr(), vm::get_super_ptr(address), size);
return CELL_OK;
}
error_code sys_dbg_write_process_memory(s32 pid, u32 address, u32 size, vm::cptr<void> data)
{
sys_dbg.warning("sys_dbg_write_process_memory(pid=0x%x, address=0x%llx, size=0x%x, data=*0x%x)", pid, address, size, data);
// Todo(TGEnigma): Process lookup (only 1 process exists right now)
if (pid != 1)
{
return CELL_LV2DBG_ERROR_DEINVALIDARGUMENTS;
}
if (!size || !data)
{
return CELL_LV2DBG_ERROR_DEINVALIDARGUMENTS;
}
// Check if data source is readable
if (!vm::check_addr(data.addr(), vm::page_readable, size))
{
return CELL_EFAULT;
}
std::memcpy(vm::get_super_ptr(address), data.get_ptr(), size);
return CELL_OK;
}