diff --git a/app/src/main/cpp/skyline/kernel/ipc.cpp b/app/src/main/cpp/skyline/kernel/ipc.cpp index 7b196ff3..63d2d028 100644 --- a/app/src/main/cpp/skyline/kernel/ipc.cpp +++ b/app/src/main/cpp/skyline/kernel/ipc.cpp @@ -97,7 +97,7 @@ namespace skyline::kernel::ipc { std::array tls{}; u8 *currPtr = tls.data(); auto header = reinterpret_cast(currPtr); - header->raw_sz = static_cast((sizeof(PayloadHeader) + argVec.size() + constant::PaddingSum + (isDomain ? sizeof(DomainHeaderRequest) : 0)) / sizeof(u32)); // Size is in 32-bit units because Nintendo + header->raw_sz = static_cast((sizeof(PayloadHeader) + argVec.size() + (domainObjects.size() * sizeof(handle_t)) + constant::PaddingSum + (isDomain ? sizeof(DomainHeaderRequest) : 0)) / sizeof(u32)); // Size is in 32-bit units because Nintendo header->handle_desc = (!copyHandles.empty() || !moveHandles.empty()); currPtr += sizeof(CommandHeader); diff --git a/app/src/main/cpp/skyline/kernel/services/am/appletOE.cpp b/app/src/main/cpp/skyline/kernel/services/am/appletOE.cpp index 241021c4..29c93133 100644 --- a/app/src/main/cpp/skyline/kernel/services/am/appletOE.cpp +++ b/app/src/main/cpp/skyline/kernel/services/am/appletOE.cpp @@ -10,10 +10,37 @@ namespace skyline::kernel::service::am { } IApplicationProxy::IApplicationProxy(const DeviceState &state, ServiceManager& manager) : BaseService(state, manager, false, Service::am_IApplicationProxy, { - {0x0, SFunc(IApplicationProxy::GetCommonStateGetter)} + {0x0, SFunc(IApplicationProxy::GetCommonStateGetter)}, + {0x1, SFunc(IApplicationProxy::GetSelfController)}, + {0xB, SFunc(IApplicationProxy::GetLibraryAppletCreator)}, + {0x14, SFunc(IApplicationProxy::GetApplicationFunctions)} }) {} void IApplicationProxy::GetCommonStateGetter(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - // TODO: This + manager.NewService(Service::am_ICommonStateGetter, session, response); } + + void IApplicationProxy::GetSelfController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.NewService(Service::am_ISelfController, session, response); + } + + void IApplicationProxy::GetLibraryAppletCreator(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.NewService(Service::am_ILibraryAppletCreator, session, response); + } + + void IApplicationProxy::GetApplicationFunctions(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + manager.NewService(Service::am_IApplicationFunctions, session, response); + } + + ICommonStateGetter::ICommonStateGetter(const DeviceState &state, ServiceManager& manager) : BaseService(state, manager, false, Service::am_IApplicationProxy, { + }) {} + + ISelfController::ISelfController(const DeviceState &state, ServiceManager& manager) : BaseService(state, manager, false, Service::am_IApplicationProxy, { + }) {} + + ILibraryAppletCreator::ILibraryAppletCreator(const DeviceState &state, ServiceManager& manager) : BaseService(state, manager, false, Service::am_IApplicationProxy, { + }) {} + + IApplicationFunctions::IApplicationFunctions(const DeviceState &state, ServiceManager& manager) : BaseService(state, manager, false, Service::am_IApplicationProxy, { + }) {} } diff --git a/app/src/main/cpp/skyline/kernel/services/am/appletOE.h b/app/src/main/cpp/skyline/kernel/services/am/appletOE.h index b8eaaae5..9755f1f0 100644 --- a/app/src/main/cpp/skyline/kernel/services/am/appletOE.h +++ b/app/src/main/cpp/skyline/kernel/services/am/appletOE.h @@ -28,5 +28,40 @@ namespace skyline::kernel::service::am { * @brief This returns #ICommonStateGetter (https://switchbrew.org/wiki/Applet_Manager_services#ICommonStateGetter) */ void GetCommonStateGetter(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This returns #ISelfController (https://switchbrew.org/wiki/Applet_Manager_services#ISelfController) + */ + void GetSelfController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This returns #ILibraryAppletCreator (https://switchbrew.org/wiki/Applet_Manager_services#ILibraryAppletCreator) + */ + void GetLibraryAppletCreator(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This returns #IApplicationFunctions (https://switchbrew.org/wiki/Applet_Manager_services#IApplicationFunctions) + */ + void GetApplicationFunctions(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + }; + + class ICommonStateGetter : public BaseService { + public: + ICommonStateGetter(const DeviceState &state, ServiceManager &manager); + }; + + class ISelfController : public BaseService { + public: + ISelfController(const DeviceState &state, ServiceManager &manager); + }; + + class ILibraryAppletCreator : public BaseService { + public: + ILibraryAppletCreator(const DeviceState &state, ServiceManager &manager); + }; + + class IApplicationFunctions : public BaseService { + public: + IApplicationFunctions(const DeviceState &state, ServiceManager &manager); }; } diff --git a/app/src/main/cpp/skyline/kernel/services/base_service.h b/app/src/main/cpp/skyline/kernel/services/base_service.h index d25ae152..b543aaa7 100644 --- a/app/src/main/cpp/skyline/kernel/services/base_service.h +++ b/app/src/main/cpp/skyline/kernel/services/base_service.h @@ -14,7 +14,7 @@ namespace skyline::kernel::service { * @brief This contains an enum for every service that's present */ enum class Service { - sm, set_sys, apm, apm_ISession, am_appletOE, am_IApplicationProxy + sm, set_sys, apm, apm_ISession, am_appletOE, am_IApplicationProxy, am_ICommonStateGetter, am_IApplicationFunctions, am_ISelfController, am_ILibraryAppletCreator }; /** @@ -41,7 +41,7 @@ namespace skyline::kernel::service { public: Service serviceType; //!< Which service this is uint numSessions{}; //Write(Logger::Info, "Service has cmdid [0x{:X}]", i.first); + vTable.at(request.payload->value)(session, request, response); } catch (std::out_of_range&) { - state.logger->Write(Logger::Warn, "Cannot find function in service with type {}: 0x{:X}", serviceType, u32(request.payload->value)); + state.logger->Write(Logger::Warn, "Cannot find function in service with type {0}: 0x{1:X} ({1})", serviceType, u32(request.payload->value)); } }; diff --git a/app/src/main/cpp/skyline/kernel/services/serviceman.cpp b/app/src/main/cpp/skyline/kernel/services/serviceman.cpp index 935ee400..ae3f8dce 100644 --- a/app/src/main/cpp/skyline/kernel/services/serviceman.cpp +++ b/app/src/main/cpp/skyline/kernel/services/serviceman.cpp @@ -30,6 +30,18 @@ namespace skyline::kernel::service { case Service::am_IApplicationProxy: serviceMap[serviceType] = std::make_shared(state, *this); break; + case Service::am_ICommonStateGetter: + serviceMap[serviceType] = std::make_shared(state, *this); + break; + case Service::am_ISelfController: + serviceMap[serviceType] = std::make_shared(state, *this); + break; + case Service::am_ILibraryAppletCreator: + serviceMap[serviceType] = std::make_shared(state, *this); + break; + case Service::am_IApplicationFunctions: + serviceMap[serviceType] = std::make_shared(state, *this); + break; } serviceObj = serviceMap[serviceType]; } else