private void SendSyncRequest(CpuThreadState threadState, long messagePtr, long size, int handle) { byte[] messageData = _memory.ReadBytes(messagePtr, size); KSession session = _process.HandleTable.GetObject <KSession>(handle); if (session != null) { _system.CriticalSection.Enter(); KThread currentThread = _system.Scheduler.GetCurrentThread(); currentThread.SignaledObj = null; currentThread.ObjSyncResult = 0; currentThread.Reschedule(ThreadSchedState.Paused); IpcMessage message = new IpcMessage(messageData, messagePtr); ThreadPool.QueueUserWorkItem(ProcessIpcRequest, new HleIpcMessage( currentThread, session, message, messagePtr)); _system.ThreadCounter.AddCount(); _system.CriticalSection.Leave(); threadState.X0 = (ulong)currentThread.ObjSyncResult; } else { Logger.PrintWarning(LogClass.KernelSvc, $"Invalid session handle 0x{handle:x8}!"); threadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle); } }
private void SendSyncRequest(CpuThreadState ThreadState, long MessagePtr, long Size, int Handle) { byte[] MessageData = Memory.ReadBytes(MessagePtr, Size); KSession Session = Process.HandleTable.GetObject <KSession>(Handle); if (Session != null) { System.CriticalSection.Enter(); KThread CurrentThread = System.Scheduler.GetCurrentThread(); CurrentThread.SignaledObj = null; CurrentThread.ObjSyncResult = 0; CurrentThread.Reschedule(ThreadSchedState.Paused); IpcMessage Message = new IpcMessage(MessageData, MessagePtr); ThreadPool.QueueUserWorkItem(ProcessIpcRequest, new HleIpcMessage( CurrentThread, Session, Message, MessagePtr)); System.ThreadCounter.AddCount(); System.CriticalSection.Leave(); ThreadState.X0 = (ulong)CurrentThread.ObjSyncResult; } else { Logger.PrintWarning(LogClass.KernelSvc, $"Invalid session handle 0x{Handle:x8}!"); ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle); } }