public ServiceNotImplementedException(IIpcService service, ServiceCtx context, string message, Exception inner)
     : base(message, inner)
 {
     Service = service;
     Context = context;
     Request = context.Request;
 }
Example #2
0
        protected T GetObject <T>(ServiceCtx context, int index) where T : IpcService
        {
            int objId = context.Request.ObjectIds[index];

            IIpcService obj = _parent.GetObject(objId);

            return(obj is T t ? t : null);
        }
Example #3
0
        protected static T GetObject <T>(ServiceCtx context, int index) where T : IpcService
        {
            IpcService service = context.Session.Service;

            if (!service._isDomain)
            {
                int handle = context.Request.HandleDesc.ToMove[index];

                KSession session = context.Process.HandleTable.GetObject <KSession>(handle);

                return(session?.Service is T ? (T)session.Service : null);
            }

            int objId = context.Request.ObjectIds[index];

            IIpcService obj = service.GetObject(objId);

            return(obj is T ? (T)obj : null);
        }
Example #4
0
        protected static T GetObject <T>(ServiceCtx Context, int Index) where T : IpcService
        {
            IpcService Service = Context.Session.Service;

            if (!Service.IsDomain)
            {
                int Handle = Context.Request.HandleDesc.ToMove[Index];

                KSession Session = Context.Process.HandleTable.GetObject <KSession>(Handle);

                return(Session?.Service is T ? (T)Session.Service : null);
            }

            int ObjId = Context.Request.ObjectIds[Index];

            IIpcService Obj = Service.GetObject(ObjId);

            return(Obj is T ? (T)Obj : null);
        }
Example #5
0
        public void CallMethod(ServiceCtx context)
        {
            IIpcService service = this;

            if (_isDomain)
            {
                int domainWord0 = context.RequestData.ReadInt32();
                int domainObjId = context.RequestData.ReadInt32();

                int domainCmd       = (domainWord0 >> 0) & 0xff;
                int inputObjCount   = (domainWord0 >> 8) & 0xff;
                int dataPayloadSize = (domainWord0 >> 16) & 0xffff;

                context.RequestData.BaseStream.Seek(0x10 + dataPayloadSize, SeekOrigin.Begin);

                for (int index = 0; index < inputObjCount; index++)
                {
                    context.Request.ObjectIds.Add(context.RequestData.ReadInt32());
                }

                context.RequestData.BaseStream.Seek(0x10, SeekOrigin.Begin);

                if (domainCmd == 1)
                {
                    service = GetObject(domainObjId);

                    context.ResponseData.Write(0L);
                    context.ResponseData.Write(0L);
                }
                else if (domainCmd == 2)
                {
                    Delete(domainObjId);

                    context.ResponseData.Write(0L);

                    return;
                }
                else
                {
                    throw new NotImplementedException($"Domain command: {domainCmd}");
                }
            }

            long sfciMagic = context.RequestData.ReadInt64();
            int  commandId = (int)context.RequestData.ReadInt64();

            if (service.Commands.TryGetValue(commandId, out ServiceProcessRequest processRequest))
            {
                context.ResponseData.BaseStream.Seek(_isDomain ? 0x20 : 0x10, SeekOrigin.Begin);

                Logger.PrintDebug(LogClass.KernelIpc, $"{service.GetType().Name}: {processRequest.Method.Name}");

                long result = processRequest(context);

                if (_isDomain)
                {
                    foreach (int id in context.Response.ObjectIds)
                    {
                        context.ResponseData.Write(id);
                    }

                    context.ResponseData.BaseStream.Seek(0, SeekOrigin.Begin);

                    context.ResponseData.Write(context.Response.ObjectIds.Count);
                }

                context.ResponseData.BaseStream.Seek(_isDomain ? 0x10 : 0, SeekOrigin.Begin);

                context.ResponseData.Write(IpcMagic.Sfco);
                context.ResponseData.Write(result);
            }
            else
            {
                string dbgMessage = $"{context.Session.ServiceName} {service.GetType().Name}: {commandId}";

                throw new NotImplementedException(dbgMessage);
            }
        }
Example #6
0
 private int Add(IIpcService obj)
 {
     return(_domainObjects.Add(obj));
 }
Example #7
0
        public void CallMethod(ServiceCtx Context)
        {
            IIpcService Service = this;

            if (IsDomain)
            {
                int DomainWord0 = Context.RequestData.ReadInt32();
                int DomainObjId = Context.RequestData.ReadInt32();

                long Padding = Context.RequestData.ReadInt64();

                int DomainCmd = DomainWord0 & 0xff;

                if (DomainCmd == 1)
                {
                    Service = GetObject(DomainObjId);

                    Context.ResponseData.Write(0L);
                    Context.ResponseData.Write(0L);
                }
                else if (DomainCmd == 2)
                {
                    Delete(DomainObjId);

                    Context.ResponseData.Write(0L);

                    return;
                }
                else
                {
                    throw new NotImplementedException($"Domain command: {DomainCmd}");
                }
            }

            long SfciMagic = Context.RequestData.ReadInt64();
            int  CommandId = (int)Context.RequestData.ReadInt64();

            if (Service.Commands.TryGetValue(CommandId, out ServiceProcessRequest ProcessRequest))
            {
                Context.ResponseData.BaseStream.Seek(IsDomain ? 0x20 : 0x10, SeekOrigin.Begin);

                Context.Ns.Log.PrintDebug(LogClass.KernelIpc, $"{Service.GetType().Name}: {ProcessRequest.Method.Name}");

                long Result = ProcessRequest(Context);

                if (IsDomain)
                {
                    foreach (int Id in Context.Response.ResponseObjIds)
                    {
                        Context.ResponseData.Write(Id);
                    }

                    Context.ResponseData.BaseStream.Seek(0, SeekOrigin.Begin);

                    Context.ResponseData.Write(Context.Response.ResponseObjIds.Count);
                }

                Context.ResponseData.BaseStream.Seek(IsDomain ? 0x10 : 0, SeekOrigin.Begin);

                Context.ResponseData.Write(IpcMagic.Sfco);
                Context.ResponseData.Write(Result);
            }
            else
            {
                string DbgMessage = $"{Context.Session.ServiceName} {Service.GetType().Name}: {CommandId}";

                throw new NotImplementedException(DbgMessage);
            }
        }
Example #8
0
 private int Add(IIpcService Obj)
 {
     return(DomainObjects.Add(Obj));
 }
Example #9
0
        public void CallMethod(ServiceCtx context)
        {
            IIpcService service = this;

            if (_isDomain)
            {
                int domainWord0 = context.RequestData.ReadInt32();
                int domainObjId = context.RequestData.ReadInt32();

                int domainCmd       = (domainWord0 >> 0) & 0xff;
                int inputObjCount   = (domainWord0 >> 8) & 0xff;
                int dataPayloadSize = (domainWord0 >> 16) & 0xffff;

                context.RequestData.BaseStream.Seek(0x10 + dataPayloadSize, SeekOrigin.Begin);

                for (int index = 0; index < inputObjCount; index++)
                {
                    context.Request.ObjectIds.Add(context.RequestData.ReadInt32());
                }

                context.RequestData.BaseStream.Seek(0x10, SeekOrigin.Begin);

                if (domainCmd == 1)
                {
                    service = GetObject(domainObjId);

                    context.ResponseData.Write(0L);
                    context.ResponseData.Write(0L);
                }
                else if (domainCmd == 2)
                {
                    Delete(domainObjId);

                    context.ResponseData.Write(0L);

                    return;
                }
                else
                {
                    throw new NotImplementedException($"Domain command: {domainCmd}");
                }
            }

            long sfciMagic = context.RequestData.ReadInt64();
            int  commandId = (int)context.RequestData.ReadInt64();

            bool serviceExists = service.Commands.TryGetValue(commandId, out MethodInfo processRequest);

            if (ServiceConfiguration.IgnoreMissingServices || serviceExists)
            {
                ResultCode result = ResultCode.Success;

                context.ResponseData.BaseStream.Seek(_isDomain ? 0x20 : 0x10, SeekOrigin.Begin);

                if (serviceExists)
                {
                    Logger.Debug?.Print(LogClass.KernelIpc, $"{service.GetType().Name}: {processRequest.Name}");

                    result = (ResultCode)processRequest.Invoke(service, new object[] { context });
                }
                else
                {
                    string serviceName;

                    DummyService dummyService = service as DummyService;

                    serviceName = (dummyService == null) ? service.GetType().FullName : dummyService.ServiceName;

                    Logger.Warning?.Print(LogClass.KernelIpc, $"Missing service {serviceName}: {commandId} ignored");
                }

                if (_isDomain)
                {
                    foreach (int id in context.Response.ObjectIds)
                    {
                        context.ResponseData.Write(id);
                    }

                    context.ResponseData.BaseStream.Seek(0, SeekOrigin.Begin);

                    context.ResponseData.Write(context.Response.ObjectIds.Count);
                }

                context.ResponseData.BaseStream.Seek(_isDomain ? 0x10 : 0, SeekOrigin.Begin);

                context.ResponseData.Write(IpcMagic.Sfco);
                context.ResponseData.Write((long)result);
            }
            else
            {
                string dbgMessage = $"{service.GetType().FullName}: {commandId}";

                throw new ServiceNotImplementedException(context, dbgMessage);
            }
        }
Example #10
0
 public HSession(IIpcService Service)
 {
     this.Service = Service;
 }
 public ServiceNotImplementedException(IIpcService service, ServiceCtx context)
     : this(service, context, "The service call is not implemented.")
 {
 }