1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-30 22:52:03 +00:00
Ryujinx/Ryujinx.HLE/HOS/Kernel/KernelTransfer.cs

71 lines
2 KiB
C#
Raw Normal View History

using ChocolArm64.Memory;
namespace Ryujinx.HLE.HOS.Kernel
{
static class KernelTransfer
{
2018-12-01 20:01:59 +00:00
public static bool UserToKernelInt32(Horizon system, long address, out int value)
{
2018-12-01 20:01:59 +00:00
KProcess currentProcess = system.Scheduler.GetCurrentProcess();
2018-12-01 20:01:59 +00:00
if (currentProcess.CpuMemory.IsMapped(address) &&
currentProcess.CpuMemory.IsMapped(address + 3))
{
2018-12-01 20:01:59 +00:00
value = currentProcess.CpuMemory.ReadInt32(address);
return true;
}
2018-12-01 20:01:59 +00:00
value = 0;
return false;
}
2018-12-01 20:01:59 +00:00
public static bool UserToKernelString(Horizon system, long address, int size, out string value)
{
2018-12-01 20:01:59 +00:00
KProcess currentProcess = system.Scheduler.GetCurrentProcess();
2018-12-01 20:01:59 +00:00
if (currentProcess.CpuMemory.IsMapped(address) &&
currentProcess.CpuMemory.IsMapped(address + size - 1))
{
2018-12-01 20:01:59 +00:00
value = MemoryHelper.ReadAsciiString(currentProcess.CpuMemory, address, size);
return true;
}
2018-12-01 20:01:59 +00:00
value = null;
return false;
}
2018-12-01 20:01:59 +00:00
public static bool KernelToUserInt32(Horizon system, long address, int value)
{
2018-12-01 20:01:59 +00:00
KProcess currentProcess = system.Scheduler.GetCurrentProcess();
2018-12-01 20:01:59 +00:00
if (currentProcess.CpuMemory.IsMapped(address) &&
currentProcess.CpuMemory.IsMapped(address + 3))
{
2018-12-01 20:01:59 +00:00
currentProcess.CpuMemory.WriteInt32ToSharedAddr(address, value);
return true;
}
return false;
}
2018-12-01 20:01:59 +00:00
public static bool KernelToUserInt64(Horizon system, long address, long value)
{
2018-12-01 20:01:59 +00:00
KProcess currentProcess = system.Scheduler.GetCurrentProcess();
2018-12-01 20:01:59 +00:00
if (currentProcess.CpuMemory.IsMapped(address) &&
currentProcess.CpuMemory.IsMapped(address + 7))
{
2018-12-01 20:01:59 +00:00
currentProcess.CpuMemory.WriteInt64(address, value);
return true;
}
return false;
}
}
}