Example #1
0
        public long GetSharedMemoryHandle(ServiceCtx Context)
        {
            int Handle = Context.Process.HandleTable.OpenHandle(HidSharedMem);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            return(0);
        }
Example #2
0
        public long QuerySystemEvent(ServiceCtx Context)
        {
            int Handle = Context.Process.HandleTable.OpenHandle(UpdateEvent);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            return(0);
        }
Example #3
0
        public long AcquireNpadStyleSetUpdateEventHandle(ServiceCtx Context)
        {
            int Handle = Context.Process.HandleTable.OpenHandle(NpadStyleSetUpdateEvent);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            return(0);
        }
Example #4
0
        public long QuerySystemEvent(ServiceCtx Context)
        {
            int Handle = Context.Ns.Os.Handles.GenerateId(new HEvent());

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            return(0);
        }
Example #5
0
        public long RegisterBufferEvent(ServiceCtx Context)
        {
            int Handle = Context.Process.HandleTable.OpenHandle(ReleaseEvent);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            return(0);
        }
Example #6
0
        // GetService(ServiceName name) -> handle<move, session>
        public ResultCode GetService(ServiceCtx context)
        {
            if (!_isInitialized)
            {
                return(ResultCode.NotInitialized);
            }

            string name = ReadName(context);

            if (name == string.Empty)
            {
                return(ResultCode.InvalidName);
            }

            KSession session = new KSession(context.Device.System.KernelContext);

            if (_registeredServices.TryGetValue(name, out KPort port))
            {
                KernelResult result = port.EnqueueIncomingSession(session.ServerSession);

                if (result != KernelResult.Success)
                {
                    throw new InvalidOperationException($"Session enqueue on port returned error \"{result}\".");
                }
            }
            else
            {
                if (_services.TryGetValue(name, out Type type))
                {
                    ServiceAttribute serviceAttribute = (ServiceAttribute)type.GetCustomAttributes(typeof(ServiceAttribute)).First(service => ((ServiceAttribute)service).Name == name);

                    session.ClientSession.Service = serviceAttribute.Parameter != null ? (IpcService)Activator.CreateInstance(type, context, serviceAttribute.Parameter)
                                                                                       : (IpcService)Activator.CreateInstance(type, context);
                }
                else
                {
                    if (ServiceConfiguration.IgnoreMissingServices)
                    {
                        Logger.PrintWarning(LogClass.Service, $"Missing service {name} ignored");

                        session.ClientSession.Service = new DummyService(name);
                    }
                    else
                    {
                        throw new NotImplementedException(name);
                    }
                }
            }

            if (context.Process.HandleTable.GenerateHandle(session.ClientSession, out int handle) != KernelResult.Success)
            {
                throw new InvalidOperationException("Out of handles!");
            }

            context.Response.HandleDesc = IpcHandleDesc.MakeMove(handle);

            return(ResultCode.Success);
        }
Example #7
0
        public long GetSystemEventReadableHandles(ServiceCtx Context)
        {
            int Handle0 = Context.Process.HandleTable.OpenHandle(Event0);
            int Handle1 = Context.Process.HandleTable.OpenHandle(Event1);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle0, Handle1);

            return(0);
        }
Example #8
0
        //GetSystemEventReadableHandles() -> (KObject, KObject)
        public long GetSystemEventReadableHandles(ServiceCtx Context)
        {
            //FIXME: Is this supposed to return 2 events?
            int Handle = Context.Process.HandleTable.OpenHandle(Event);

            Context.Response.HandleDesc = IpcHandleDesc.MakeMove(Handle);

            return(0);
        }
Example #9
0
        public long GetNativeHandle(ServiceCtx Context)
        {
            int  Id  = Context.RequestData.ReadInt32();
            uint Unk = Context.RequestData.ReadUInt32();

            Context.Response.HandleDesc = IpcHandleDesc.MakeMove(0xbadcafe);

            return(0);
        }
Example #10
0
        public long AttachAvailabilityChangeEvent(ServiceCtx Context)
        {
            Context.Device.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");

            int Handle = Context.Process.HandleTable.OpenHandle(AvailabilityChangeEvent);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            return(0);
        }
Example #11
0
        public long GetIrsensorSharedMemoryHandle(ServiceCtx Context)
        {
            int Handle = Context.Process.HandleTable.OpenHandle(IrSensorSharedMem);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            Context.Ns.Log.PrintStub(LogClass.ServiceHid, "Stubbed.");

            return(0);
        }
Example #12
0
        public long GetSharedMemoryNativeHandle(ServiceCtx Context)
        {
            Context.Device.System.Font.EnsureInitialized();

            int Handle = Context.Process.HandleTable.OpenHandle(Context.Device.System.FontSharedMem);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            return(0);
        }
Example #13
0
        public long GetEventHandle(ServiceCtx Context)
        {
            KEvent Event = Context.Process.AppletState.MessageEvent;

            int Handle = Context.Process.HandleTable.OpenHandle(Event);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            return(0);
        }
        public long GetPopFromGeneralChannelEvent(ServiceCtx Context)
        {
            int Handle = Context.Process.HandleTable.OpenHandle(ChannelEvent);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");

            return(0);
        }
        public long GetDisplayVSyncEvent(ServiceCtx Context)
        {
            string Name = GetDisplayName(Context);

            int Handle = Context.Process.HandleTable.OpenHandle(Context.Ns.Os.VsyncEvent);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            return(0);
        }
Example #16
0
        public long QueryAudioDeviceOutputEvent(ServiceCtx Context)
        {
            int Handle = Context.Process.HandleTable.OpenHandle(SystemEvent);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            Context.Device.Log.PrintStub(LogClass.ServiceAudio, "Stubbed.");

            return(0);
        }
Example #17
0
        public long AttachDeactivateEvent(ServiceCtx Context)
        {
            Context.Ns.Log.PrintStub(LogClass.ServiceNfp, "Stubbed.");

            int Handle = Context.Process.HandleTable.OpenHandle(DeactivateEvent);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            return(0);
        }
Example #18
0
        public long GetDisplayVSyncEvent(ServiceCtx Context)
        {
            string Name = GetDisplayName(Context);

            int Handle = Context.Ns.Os.Handles.GenerateId(new HEvent());

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            return(0);
        }
Example #19
0
        public long GetDefaultDisplayResolutionChangeEvent(ServiceCtx Context)
        {
            int Handle = Context.Process.HandleTable.OpenHandle(DisplayResolutionChangeEvent);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");

            return(0);
        }
Example #20
0
        // GetSharedMemoryHandle() -> handle<copy>
        public ResultCode GetSharedMemoryHandle(ServiceCtx context)
        {
            if (context.Process.HandleTable.GenerateHandle(_hidSharedMem, out int handle) != KernelResult.Success)
            {
                throw new InvalidOperationException("Out of handles!");
            }

            context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);

            return(ResultCode.Success);
        }
Example #21
0
        public long GetSharedMemoryHandle(ServiceCtx Context)
        {
            if (Context.Process.HandleTable.GenerateHandle(HidSharedMem, out int Handle) != KernelResult.Success)
            {
                throw new InvalidOperationException("Out of handles!");
            }

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            return(0);
        }
        // GetFinishNotificationEvent() -> handle<copy>
        public ResultCode GetFinishNotificationEvent(ServiceCtx context)
        {
            if (context.Process.HandleTable.GenerateHandle(_finishNotificationEvent.ReadableEvent, out int finishNotificationEventHandle) != KernelResult.Success)
            {
                throw new InvalidOperationException("Out of handles!");
            }

            context.Response.HandleDesc = IpcHandleDesc.MakeCopy(finishNotificationEventHandle);

            return(ResultCode.Success);
        }
Example #23
0
        private ResultCode GetAddOnContentListChangedEventImpl(ServiceCtx context)
        {
            if (context.Process.HandleTable.GenerateHandle(_addOnContentListChangedEvent.ReadableEvent, out int addOnContentListChangedEventHandle) != KernelResult.Success)
            {
                throw new InvalidOperationException("Out of handles!");
            }

            context.Response.HandleDesc = IpcHandleDesc.MakeCopy(addOnContentListChangedEventHandle);

            return(ResultCode.Success);
        }
Example #24
0
        // GetSystemEvent() -> handle<copy>
        public ResultCode GetSystemEvent(ServiceCtx context)
        {
            if (context.Process.HandleTable.GenerateHandle(_asyncExecution.SystemEvent.ReadableEvent, out int _systemEventHandle) != KernelResult.Success)
            {
                throw new InvalidOperationException("Out of handles!");
            }

            context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_systemEventHandle);

            return(ResultCode.Success);
        }
Example #25
0
        // RegisterBufferEvent() -> handle<copy>
        public ResultCode RegisterBufferEvent(ServiceCtx context)
        {
            if (context.Process.HandleTable.GenerateHandle(_releaseEvent.ReadableEvent, out int handle) != KernelResult.Success)
            {
                throw new InvalidOperationException("Out of handles!");
            }

            context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);

            return(ResultCode.Success);
        }
Example #26
0
        // GetPurchasedEventReadableHandle() -> handle<copy, event>
        public ResultCode GetPurchasedEventReadableHandle(ServiceCtx context)
        {
            if (context.Process.HandleTable.GenerateHandle(_purchasedEvent.ReadableEvent, out int handle) != KernelResult.Success)
            {
                throw new InvalidOperationException("Out of handles!");
            }

            context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);

            return ResultCode.Success;
        }
Example #27
0
        public long GetNativeHandle(ServiceCtx Context)
        {
            int  Id  = Context.RequestData.ReadInt32();
            uint Unk = Context.RequestData.ReadUInt32();

            int Handle = Context.Process.HandleTable.OpenHandle(ReleaseEvent);

            Context.Response.HandleDesc = IpcHandleDesc.MakeMove(Handle);

            return(0);
        }
Example #28
0
        public long QuerySystemEvent(ServiceCtx context)
        {
            if (context.Process.HandleTable.GenerateHandle(_updateEvent.ReadableEvent, out int handle) != KernelResult.Success)
            {
                throw new InvalidOperationException("Out of handles!");
            }

            context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);

            return(0);
        }
Example #29
0
        public long GetAppletStateChangedEvent(ServiceCtx Context)
        {
            StateChangedEvent.WaitEvent.Set();

            int Handle = Context.Process.HandleTable.OpenHandle(StateChangedEvent);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");

            return(0);
        }
Example #30
0
        public long GetLibraryAppletLaunchableEvent(ServiceCtx Context)
        {
            LaunchableEvent.WaitEvent.Set();

            int Handle = Context.Process.HandleTable.OpenHandle(LaunchableEvent);

            Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);

            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");

            return(0);
        }