private void SvcSetThreadActivity(AThreadState ThreadState) { int Handle = (int)ThreadState.X0; bool Pause = (int)ThreadState.X1 == 1; KThread Thread = Process.HandleTable.GetObject <KThread>(Handle); if (Thread == null) { Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!"); ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle); return; } if (Thread.Owner != Process) { Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread owner process!"); ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle); return; } long Result = Thread.SetActivity(Pause); if (Result != 0) { Device.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!"); } ThreadState.X0 = (ulong)Result; }
private void SvcSetThreadActivity(CpuThreadState threadState) { int handle = (int)threadState.X0; bool pause = (int)threadState.X1 == 1; KThread thread = _process.HandleTable.GetObject <KThread>(handle); if (thread == null) { Logger.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{handle:x8}!"); threadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle); return; } if (thread.Owner != _system.Scheduler.GetCurrentProcess()) { Logger.PrintWarning(LogClass.KernelSvc, $"Invalid thread, it belongs to another process."); threadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle); return; } if (thread == _system.Scheduler.GetCurrentThread()) { Logger.PrintWarning(LogClass.KernelSvc, "Invalid thread, current thread is not accepted."); threadState.X0 = (ulong)KernelResult.InvalidThread; return; } long result = thread.SetActivity(pause); if (result != 0) { Logger.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{result:x}!"); } threadState.X0 = (ulong)result; }