2018-02-04 18:08:20 -05:00
|
|
|
using ChocolArm64.Memory;
|
|
|
|
using ChocolArm64.State;
|
2018-10-17 13:15:50 -04:00
|
|
|
using Ryujinx.Common.Logging;
|
2018-08-16 19:47:36 -04:00
|
|
|
using Ryujinx.HLE.Exceptions;
|
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
|
|
|
using Ryujinx.HLE.HOS.Services;
|
2018-02-04 18:08:20 -05:00
|
|
|
using System;
|
2018-02-19 14:37:13 -05:00
|
|
|
using System.Threading;
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-08-16 19:47:36 -04:00
|
|
|
using static Ryujinx.HLE.HOS.ErrorCode;
|
2018-03-05 14:18:37 -05:00
|
|
|
|
2018-08-16 19:47:36 -04:00
|
|
|
namespace Ryujinx.HLE.HOS.Kernel
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
|
|
|
partial class SvcHandler
|
|
|
|
{
|
2018-02-27 18:45:07 -05:00
|
|
|
private const int AllowedCpuIdBitmask = 0b1111;
|
|
|
|
|
|
|
|
private const bool EnableProcessDebugging = false;
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private void SvcExitProcess(CpuThreadState ThreadState)
|
2018-02-27 18:45:07 -05:00
|
|
|
{
|
2018-08-16 19:47:36 -04:00
|
|
|
Device.System.ExitProcess(Process.ProcessId);
|
2018-02-27 18:45:07 -05:00
|
|
|
}
|
2018-02-15 07:16:16 -05:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private void SignalEvent64(CpuThreadState ThreadState)
|
2018-03-05 10:58:19 -05:00
|
|
|
{
|
2018-09-23 14:11:46 -04:00
|
|
|
ThreadState.X0 = (ulong)SignalEvent((int)ThreadState.X0);
|
|
|
|
}
|
2018-03-05 10:58:19 -05:00
|
|
|
|
2018-09-23 14:11:46 -04:00
|
|
|
private KernelResult SignalEvent(int Handle)
|
|
|
|
{
|
|
|
|
KWritableEvent WritableEvent = Process.HandleTable.GetObject<KWritableEvent>(Handle);
|
2018-03-05 10:58:19 -05:00
|
|
|
|
2018-09-23 14:11:46 -04:00
|
|
|
KernelResult Result;
|
|
|
|
|
|
|
|
if (WritableEvent != null)
|
|
|
|
{
|
|
|
|
WritableEvent.Signal();
|
|
|
|
|
|
|
|
Result = KernelResult.Success;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Result = KernelResult.InvalidHandle;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Result != KernelResult.Success)
|
|
|
|
{
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintWarning(LogClass.KernelSvc, "Operation failed with error: " + Result + "!");
|
2018-09-23 14:11:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private void ClearEvent64(CpuThreadState ThreadState)
|
2018-09-23 14:11:46 -04:00
|
|
|
{
|
|
|
|
ThreadState.X0 = (ulong)ClearEvent((int)ThreadState.X0);
|
|
|
|
}
|
|
|
|
|
|
|
|
private KernelResult ClearEvent(int Handle)
|
|
|
|
{
|
|
|
|
KernelResult Result;
|
|
|
|
|
|
|
|
KWritableEvent WritableEvent = Process.HandleTable.GetObject<KWritableEvent>(Handle);
|
|
|
|
|
|
|
|
if (WritableEvent == null)
|
|
|
|
{
|
|
|
|
KReadableEvent ReadableEvent = Process.HandleTable.GetObject<KReadableEvent>(Handle);
|
|
|
|
|
|
|
|
Result = ReadableEvent?.Clear() ?? KernelResult.InvalidHandle;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Result = WritableEvent.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Result != KernelResult.Success)
|
|
|
|
{
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintWarning(LogClass.KernelSvc, "Operation failed with error: " + Result + "!");
|
2018-09-23 14:11:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return Result;
|
2018-03-05 10:58:19 -05:00
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private void SvcCloseHandle(CpuThreadState ThreadState)
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-02-18 14:28:07 -05:00
|
|
|
int Handle = (int)ThreadState.X0;
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-09-23 14:11:46 -04:00
|
|
|
object Obj = Process.HandleTable.GetObject<object>(Handle);
|
|
|
|
|
|
|
|
Process.HandleTable.CloseHandle(Handle);
|
2018-03-19 14:58:46 -04:00
|
|
|
|
|
|
|
if (Obj == null)
|
|
|
|
{
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintWarning(LogClass.KernelSvc, $"Invalid handle 0x{Handle:x8}!");
|
2018-03-19 14:58:46 -04:00
|
|
|
|
|
|
|
ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Obj is KSession Session)
|
|
|
|
{
|
|
|
|
Session.Dispose();
|
|
|
|
}
|
2018-08-15 14:59:51 -04:00
|
|
|
else if (Obj is KTransferMemory TransferMemory)
|
2018-03-19 14:58:46 -04:00
|
|
|
{
|
2018-08-15 14:59:51 -04:00
|
|
|
Process.MemoryManager.ResetTransferMemory(
|
|
|
|
TransferMemory.Position,
|
|
|
|
TransferMemory.Size);
|
2018-03-19 14:58:46 -04:00
|
|
|
}
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-03-05 14:18:37 -05:00
|
|
|
ThreadState.X0 = 0;
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private void ResetSignal64(CpuThreadState ThreadState)
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-09-23 14:11:46 -04:00
|
|
|
ThreadState.X0 = (ulong)ResetSignal((int)ThreadState.X0);
|
|
|
|
}
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-09-23 14:11:46 -04:00
|
|
|
private KernelResult ResetSignal(int Handle)
|
|
|
|
{
|
|
|
|
KReadableEvent ReadableEvent = Process.HandleTable.GetObject<KReadableEvent>(Handle);
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-09-23 14:11:46 -04:00
|
|
|
KernelResult Result;
|
2018-03-19 14:58:46 -04:00
|
|
|
|
2018-09-23 14:11:46 -04:00
|
|
|
//TODO: KProcess support.
|
|
|
|
if (ReadableEvent != null)
|
|
|
|
{
|
|
|
|
Result = ReadableEvent.ClearIfSignaled();
|
2018-03-19 14:58:46 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-23 14:11:46 -04:00
|
|
|
Result = KernelResult.InvalidHandle;
|
|
|
|
}
|
2018-03-19 14:58:46 -04:00
|
|
|
|
2018-09-23 14:11:46 -04:00
|
|
|
if (Result == KernelResult.InvalidState)
|
|
|
|
{
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintDebug(LogClass.KernelSvc, "Operation failed with error: " + Result + "!");
|
2018-09-23 14:11:46 -04:00
|
|
|
}
|
|
|
|
else if (Result != KernelResult.Success)
|
|
|
|
{
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintWarning(LogClass.KernelSvc, "Operation failed with error: " + Result + "!");
|
2018-03-19 14:58:46 -04:00
|
|
|
}
|
2018-09-23 14:11:46 -04:00
|
|
|
|
|
|
|
return Result;
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private void SvcGetSystemTick(CpuThreadState ThreadState)
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-03-10 18:51:55 -05:00
|
|
|
ThreadState.X0 = ThreadState.CntpctEl0;
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private void SvcConnectToNamedPort(CpuThreadState ThreadState)
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-02-18 14:28:07 -05:00
|
|
|
long StackPtr = (long)ThreadState.X0;
|
|
|
|
long NamePtr = (long)ThreadState.X1;
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
string Name = MemoryHelper.ReadAsciiString(Memory, NamePtr, 8);
|
2018-02-04 18:08:20 -05:00
|
|
|
|
|
|
|
//TODO: Validate that app has perms to access the service, and that the service
|
|
|
|
//actually exists, return error codes otherwise.
|
2018-09-18 19:36:43 -04:00
|
|
|
KSession Session = new KSession(ServiceFactory.MakeService(System, Name), Name);
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-09-23 14:11:46 -04:00
|
|
|
if (Process.HandleTable.GenerateHandle(Session, out int Handle) != KernelResult.Success)
|
|
|
|
{
|
|
|
|
throw new InvalidOperationException("Out of handles!");
|
|
|
|
}
|
2018-04-04 20:01:36 -04:00
|
|
|
|
2018-03-05 14:18:37 -05:00
|
|
|
ThreadState.X0 = 0;
|
2018-09-23 14:11:46 -04:00
|
|
|
ThreadState.X1 = (uint)Handle;
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private void SvcSendSyncRequest(CpuThreadState ThreadState)
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-03-19 14:58:46 -04:00
|
|
|
SendSyncRequest(ThreadState, ThreadState.Tpidr, 0x100, (int)ThreadState.X0);
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private void SvcSendSyncRequestWithUserBuffer(CpuThreadState ThreadState)
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-03-19 14:58:46 -04:00
|
|
|
SendSyncRequest(
|
|
|
|
ThreadState,
|
|
|
|
(long)ThreadState.X0,
|
|
|
|
(long)ThreadState.X1,
|
|
|
|
(int)ThreadState.X2);
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private void SendSyncRequest(CpuThreadState ThreadState, long MessagePtr, long Size, int Handle)
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-03-19 14:58:46 -04:00
|
|
|
KThread CurrThread = Process.GetThread(ThreadState.Tpidr);
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
byte[] MessageData = Memory.ReadBytes(MessagePtr, Size);
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-09-23 14:11:46 -04:00
|
|
|
KSession Session = Process.HandleTable.GetObject<KSession>(Handle);
|
2018-02-19 14:37:13 -05:00
|
|
|
|
2018-03-19 14:58:46 -04:00
|
|
|
if (Session != null)
|
|
|
|
{
|
2018-09-18 19:36:43 -04:00
|
|
|
//Process.Scheduler.Suspend(CurrThread);
|
|
|
|
|
|
|
|
System.CriticalSectionLock.Lock();
|
2018-02-19 14:37:13 -05:00
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
KThread CurrentThread = System.Scheduler.GetCurrentThread();
|
2018-08-14 18:02:42 -04:00
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
CurrentThread.SignaledObj = null;
|
|
|
|
CurrentThread.ObjSyncResult = 0;
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
CurrentThread.Reschedule(ThreadSchedState.Paused);
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
IpcMessage Message = new IpcMessage(MessageData, MessagePtr);
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
ThreadPool.QueueUserWorkItem(ProcessIpcRequest, new HleIpcMessage(
|
|
|
|
CurrentThread,
|
|
|
|
Session,
|
|
|
|
Message,
|
|
|
|
MessagePtr));
|
|
|
|
|
|
|
|
System.CriticalSectionLock.Unlock();
|
|
|
|
|
|
|
|
ThreadState.X0 = (ulong)CurrentThread.ObjSyncResult;
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintWarning(LogClass.KernelSvc, $"Invalid session handle 0x{Handle:x8}!");
|
2018-02-19 14:37:13 -05:00
|
|
|
|
2018-03-19 14:58:46 -04:00
|
|
|
ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
|
|
|
|
}
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
|
|
|
|
2018-09-18 19:36:43 -04:00
|
|
|
private void ProcessIpcRequest(object State)
|
|
|
|
{
|
|
|
|
HleIpcMessage IpcMessage = (HleIpcMessage)State;
|
|
|
|
|
|
|
|
IpcMessage.Thread.ObjSyncResult = (int)IpcHandler.IpcCall(
|
|
|
|
Device,
|
|
|
|
Process,
|
|
|
|
Memory,
|
|
|
|
IpcMessage.Session,
|
|
|
|
IpcMessage.Message,
|
|
|
|
IpcMessage.MessagePtr);
|
|
|
|
|
|
|
|
IpcMessage.Thread.Reschedule(ThreadSchedState.Running);
|
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private void SvcBreak(CpuThreadState ThreadState)
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-02-18 14:28:07 -05:00
|
|
|
long Reason = (long)ThreadState.X0;
|
|
|
|
long Unknown = (long)ThreadState.X1;
|
|
|
|
long Info = (long)ThreadState.X2;
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-10-08 14:53:08 -04:00
|
|
|
if ((Reason & (1 << 31)) == 0)
|
|
|
|
{
|
|
|
|
Process.PrintStackTrace(ThreadState);
|
2018-04-22 01:48:17 -04:00
|
|
|
|
2018-10-08 14:53:08 -04:00
|
|
|
throw new GuestBrokeExecutionException();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintInfo(LogClass.KernelSvc, "Debugger triggered");
|
2018-10-08 14:53:08 -04:00
|
|
|
Process.PrintStackTrace(ThreadState);
|
|
|
|
}
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private void SvcOutputDebugString(CpuThreadState ThreadState)
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-02-18 14:28:07 -05:00
|
|
|
long Position = (long)ThreadState.X0;
|
|
|
|
long Size = (long)ThreadState.X1;
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
string Str = MemoryHelper.ReadAsciiString(Memory, Position, Size);
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-10-17 13:15:50 -04:00
|
|
|
Logger.PrintWarning(LogClass.KernelSvc, Str);
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-03-05 14:18:37 -05:00
|
|
|
ThreadState.X0 = 0;
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private void SvcGetInfo(CpuThreadState ThreadState)
|
2018-02-04 18:08:20 -05:00
|
|
|
{
|
2018-02-18 14:28:07 -05:00
|
|
|
long StackPtr = (long)ThreadState.X0;
|
|
|
|
int InfoType = (int)ThreadState.X1;
|
|
|
|
long Handle = (long)ThreadState.X2;
|
|
|
|
int InfoId = (int)ThreadState.X3;
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-02-06 18:28:32 -05:00
|
|
|
//Fail for info not available on older Kernel versions.
|
|
|
|
if (InfoType == 18 ||
|
2018-03-30 11:27:48 -04:00
|
|
|
InfoType == 19 ||
|
2018-09-18 00:30:35 -04:00
|
|
|
InfoType == 20 ||
|
2018-09-23 14:11:46 -04:00
|
|
|
InfoType == 21 ||
|
|
|
|
InfoType == 22)
|
2018-02-06 18:28:32 -05:00
|
|
|
{
|
2018-07-19 00:03:53 -04:00
|
|
|
ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidEnumValue);
|
2018-02-06 18:28:32 -05:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-04 18:08:20 -05:00
|
|
|
switch (InfoType)
|
|
|
|
{
|
2018-02-27 18:45:07 -05:00
|
|
|
case 0:
|
|
|
|
ThreadState.X1 = AllowedCpuIdBitmask;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2018-08-15 14:59:51 -04:00
|
|
|
ThreadState.X1 = (ulong)Process.MemoryManager.MapRegionStart;
|
2018-02-27 18:45:07 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2018-08-15 14:59:51 -04:00
|
|
|
ThreadState.X1 = (ulong)Process.MemoryManager.MapRegionEnd -
|
|
|
|
(ulong)Process.MemoryManager.MapRegionStart;
|
2018-02-27 18:45:07 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2018-08-15 14:59:51 -04:00
|
|
|
ThreadState.X1 = (ulong)Process.MemoryManager.HeapRegionStart;
|
2018-02-27 18:45:07 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
2018-08-15 14:59:51 -04:00
|
|
|
ThreadState.X1 = (ulong)Process.MemoryManager.HeapRegionEnd -
|
|
|
|
(ulong)Process.MemoryManager.HeapRegionStart;
|
2018-02-27 18:45:07 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
2018-08-16 19:47:36 -04:00
|
|
|
ThreadState.X1 = (ulong)Process.Device.Memory.Allocator.TotalAvailableSize;
|
2018-02-27 18:45:07 -05:00
|
|
|
break;
|
2018-04-04 20:01:36 -04:00
|
|
|
|
2018-02-27 18:45:07 -05:00
|
|
|
case 7:
|
2018-08-16 19:47:36 -04:00
|
|
|
ThreadState.X1 = (ulong)Process.Device.Memory.Allocator.TotalUsedSize;
|
2018-02-27 18:45:07 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
ThreadState.X1 = EnableProcessDebugging ? 1 : 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 11:
|
|
|
|
ThreadState.X1 = (ulong)Rng.Next() + ((ulong)Rng.Next() << 32);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 12:
|
2018-08-15 14:59:51 -04:00
|
|
|
ThreadState.X1 = (ulong)Process.MemoryManager.AddrSpaceStart;
|
2018-02-27 18:45:07 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 13:
|
2018-08-15 14:59:51 -04:00
|
|
|
ThreadState.X1 = (ulong)Process.MemoryManager.AddrSpaceEnd -
|
|
|
|
(ulong)Process.MemoryManager.AddrSpaceStart;
|
2018-02-27 18:45:07 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 14:
|
2018-08-15 14:59:51 -04:00
|
|
|
ThreadState.X1 = (ulong)Process.MemoryManager.NewMapRegionStart;
|
2018-02-27 18:45:07 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 15:
|
2018-08-15 14:59:51 -04:00
|
|
|
ThreadState.X1 = (ulong)Process.MemoryManager.NewMapRegionEnd -
|
|
|
|
(ulong)Process.MemoryManager.NewMapRegionStart;
|
2018-02-27 18:45:07 -05:00
|
|
|
break;
|
2018-06-10 20:46:42 -04:00
|
|
|
|
2018-05-22 16:40:46 -04:00
|
|
|
case 16:
|
2018-08-15 14:59:51 -04:00
|
|
|
ThreadState.X1 = (ulong)(Process.MetaData?.SystemResourceSize ?? 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 17:
|
|
|
|
ThreadState.X1 = (ulong)Process.MemoryManager.PersonalMmHeapUsage;
|
2018-05-22 16:40:46 -04:00
|
|
|
break;
|
2018-02-04 18:08:20 -05:00
|
|
|
|
2018-04-22 01:48:17 -04:00
|
|
|
default:
|
|
|
|
Process.PrintStackTrace(ThreadState);
|
|
|
|
|
2018-08-16 19:47:36 -04:00
|
|
|
throw new NotImplementedException($"SvcGetInfo: {InfoType} 0x{Handle:x8} {InfoId}");
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
|
|
|
|
2018-03-05 14:18:37 -05:00
|
|
|
ThreadState.X0 = 0;
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
2018-09-23 14:11:46 -04:00
|
|
|
|
2018-10-30 21:43:02 -04:00
|
|
|
private void CreateEvent64(CpuThreadState State)
|
2018-09-23 14:11:46 -04:00
|
|
|
{
|
|
|
|
KernelResult Result = CreateEvent(out int WEventHandle, out int REventHandle);
|
|
|
|
|
|
|
|
State.X0 = (ulong)Result;
|
|
|
|
State.X1 = (ulong)WEventHandle;
|
|
|
|
State.X2 = (ulong)REventHandle;
|
|
|
|
}
|
|
|
|
|
|
|
|
private KernelResult CreateEvent(out int WEventHandle, out int REventHandle)
|
|
|
|
{
|
|
|
|
KEvent Event = new KEvent(System);
|
|
|
|
|
|
|
|
KernelResult Result = Process.HandleTable.GenerateHandle(Event.WritableEvent, out WEventHandle);
|
|
|
|
|
|
|
|
if (Result == KernelResult.Success)
|
|
|
|
{
|
|
|
|
Result = Process.HandleTable.GenerateHandle(Event.ReadableEvent, out REventHandle);
|
|
|
|
|
|
|
|
if (Result != KernelResult.Success)
|
|
|
|
{
|
|
|
|
Process.HandleTable.CloseHandle(WEventHandle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
REventHandle = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Result;
|
|
|
|
}
|
2018-02-04 18:08:20 -05:00
|
|
|
}
|
2018-02-24 18:09:10 -05:00
|
|
|
}
|