コード例 #1
0
        private KernelResult ConnectToPort(int clientPortHandle, out int clientSessionHandle)
        {
            clientSessionHandle = 0;

            KProcess currentProcess = _system.Scheduler.GetCurrentProcess();

            KClientPort clientPort = currentProcess.HandleTable.GetObject <KClientPort>(clientPortHandle);

            if (clientPort == null)
            {
                return(KernelResult.InvalidHandle);
            }

            KernelResult result = currentProcess.HandleTable.ReserveHandle(out int handle);

            if (result != KernelResult.Success)
            {
                return(result);
            }

            KAutoObject session;

            if (clientPort.IsLight)
            {
                result = clientPort.ConnectLight(out KLightClientSession clientSession);

                session = clientSession;
            }
            else
            {
                result = clientPort.Connect(out KClientSession clientSession);

                session = clientSession;
            }

            if (result != KernelResult.Success)
            {
                currentProcess.HandleTable.CancelHandleReservation(handle);

                return(result);
            }

            currentProcess.HandleTable.SetReservedHandleObj(handle, session);

            session.DecrementReferenceCount();

            clientSessionHandle = handle;

            return(result);
        }
コード例 #2
0
ファイル: SvcSystem.cs プロジェクト: mokmax/Ryujinx
        private KernelResult ManageNamedPort(ulong namePtr, int maxSessions, out int handle)
        {
            handle = 0;

            if (!KernelTransfer.UserToKernelString(_system, namePtr, 12, out string name))
            {
                return(KernelResult.UserCopyFailed);
            }

            if (maxSessions < 0 || name.Length > 11)
            {
                return(KernelResult.MaximumExceeded);
            }

            if (maxSessions == 0)
            {
                return(KClientPort.RemoveName(_system, name));
            }

            KPort port = new KPort(_system);

            KProcess currentProcess = _system.Scheduler.GetCurrentProcess();

            KernelResult result = currentProcess.HandleTable.GenerateHandle(port.ServerPort, out handle);

            if (result != KernelResult.Success)
            {
                return(result);
            }

            port.Initialize(maxSessions, false, 0);

            result = port.SetName(name);

            if (result != KernelResult.Success)
            {
                currentProcess.HandleTable.CloseHandle(handle);
            }

            return(result);
        }
コード例 #3
0
ファイル: KPort.cs プロジェクト: zhubaojian/Ryujinx
 public KPort(Horizon System) : base(System)
 {
     ServerPort = new KServerPort(System);
     ClientPort = new KClientPort(System);
 }