diff --git a/Ryujinx.Core/OsHle/Svc/SvcThread.cs b/Ryujinx.Core/OsHle/Svc/SvcThread.cs index 77cef44c..f58c2dc0 100644 --- a/Ryujinx.Core/OsHle/Svc/SvcThread.cs +++ b/Ryujinx.Core/OsHle/Svc/SvcThread.cs @@ -1,6 +1,8 @@ using ChocolArm64.State; using Ryujinx.Core.OsHle.Handles; +using static Ryujinx.Core.OsHle.ErrorCode; + namespace Ryujinx.Core.OsHle.Svc { partial class SvcHandler @@ -61,11 +63,11 @@ namespace Ryujinx.Core.OsHle.Svc } private void SvcSleepThread(AThreadState ThreadState) - { + { ulong NanoSecs = ThreadState.X0; KThread CurrThread = Process.GetThread(ThreadState.Tpidr); - + if (NanoSecs == 0) { Process.Scheduler.Yield(CurrThread); @@ -117,7 +119,7 @@ namespace Ryujinx.Core.OsHle.Svc private void SvcGetThreadId(AThreadState ThreadState) { - int Handle = (int)ThreadState.X0; + int Handle = (int)ThreadState.X1; KThread Thread = Process.HandleTable.GetData(Handle); @@ -126,8 +128,12 @@ namespace Ryujinx.Core.OsHle.Svc ThreadState.X0 = 0; ThreadState.X1 = (ulong)Thread.ThreadId; } + else + { + Logging.Warn($"Tried to GetThreadId on invalid thread handle 0x{Handle:x8}!"); - //TODO: Error codes. + ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle); + } } } } \ No newline at end of file