ngct.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "common/string_util.h"
  4. #include "core/core.h"
  5. #include "core/hle/service/ipc_helpers.h"
  6. #include "core/hle/service/ngct/ngct.h"
  7. #include "core/hle/service/server_manager.h"
  8. #include "core/hle/service/service.h"
  9. namespace Service::NGCT {
  10. class IService final : public ServiceFramework<IService> {
  11. public:
  12. explicit IService(Core::System& system_) : ServiceFramework{system_, "ngct:u"} {
  13. // clang-format off
  14. static const FunctionInfo functions[] = {
  15. {0, &IService::Match, "Match"},
  16. {1, &IService::Filter, "Filter"},
  17. };
  18. // clang-format on
  19. RegisterHandlers(functions);
  20. }
  21. private:
  22. void Match(HLERequestContext& ctx) {
  23. const auto buffer = ctx.ReadBuffer();
  24. const auto text = Common::StringFromFixedZeroTerminatedBuffer(
  25. reinterpret_cast<const char*>(buffer.data()), buffer.size());
  26. LOG_WARNING(Service_NGCT, "(STUBBED) called, text={}", text);
  27. IPC::ResponseBuilder rb{ctx, 3};
  28. rb.Push(ResultSuccess);
  29. // Return false since we don't censor anything
  30. rb.Push(false);
  31. }
  32. void Filter(HLERequestContext& ctx) {
  33. const auto buffer = ctx.ReadBuffer();
  34. const auto text = Common::StringFromFixedZeroTerminatedBuffer(
  35. reinterpret_cast<const char*>(buffer.data()), buffer.size());
  36. LOG_WARNING(Service_NGCT, "(STUBBED) called, text={}", text);
  37. // Return the same string since we don't censor anything
  38. ctx.WriteBuffer(buffer);
  39. IPC::ResponseBuilder rb{ctx, 2};
  40. rb.Push(ResultSuccess);
  41. }
  42. };
  43. void LoopProcess(Core::System& system) {
  44. auto server_manager = std::make_unique<ServerManager>(system);
  45. server_manager->RegisterNamedService("ngct:u", std::make_shared<IService>(system));
  46. ServerManager::RunServer(std::move(server_manager));
  47. }
  48. } // namespace Service::NGCT