diff options
| -rw-r--r-- | src/core/hle/service/prepo/prepo.cpp | 105 | ||||
| -rw-r--r-- | src/core/hle/service/prepo/prepo.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/service.cpp | 2 | ||||
| -rw-r--r-- | src/core/reporter.cpp | 10 | ||||
| -rw-r--r-- | src/core/reporter.h | 10 |
5 files changed, 99 insertions, 30 deletions
diff --git a/src/core/hle/service/prepo/prepo.cpp b/src/core/hle/service/prepo/prepo.cpp index 7e134f5c1..0f79135ff 100644 --- a/src/core/hle/service/prepo/prepo.cpp +++ b/src/core/hle/service/prepo/prepo.cpp | |||
| @@ -2,34 +2,31 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <json.hpp> | ||
| 6 | #include "common/file_util.h" | ||
| 7 | #include "common/hex_util.h" | 5 | #include "common/hex_util.h" |
| 8 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 9 | #include "common/scm_rev.h" | ||
| 10 | #include "core/hle/ipc_helpers.h" | 7 | #include "core/hle/ipc_helpers.h" |
| 11 | #include "core/hle/kernel/process.h" | 8 | #include "core/hle/kernel/process.h" |
| 12 | #include "core/hle/service/acc/profile_manager.h" | 9 | #include "core/hle/service/acc/profile_manager.h" |
| 13 | #include "core/hle/service/prepo/prepo.h" | 10 | #include "core/hle/service/prepo/prepo.h" |
| 14 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
| 15 | #include "core/reporter.h" | 12 | #include "core/reporter.h" |
| 16 | #include "core/settings.h" | ||
| 17 | 13 | ||
| 18 | namespace Service::PlayReport { | 14 | namespace Service::PlayReport { |
| 19 | 15 | ||
| 20 | class PlayReport final : public ServiceFramework<PlayReport> { | 16 | class PlayReport final : public ServiceFramework<PlayReport> { |
| 21 | public: | 17 | public: |
| 22 | explicit PlayReport(const char* name) : ServiceFramework{name} { | 18 | explicit PlayReport(Core::System& system, const char* name) |
| 19 | : ServiceFramework{name}, system(system) { | ||
| 23 | // clang-format off | 20 | // clang-format off |
| 24 | static const FunctionInfo functions[] = { | 21 | static const FunctionInfo functions[] = { |
| 25 | {10100, nullptr, "SaveReportOld"}, | 22 | {10100, &PlayReport::SaveReport<Core::Reporter::PlayReportType::Old>, "SaveReportOld"}, |
| 26 | {10101, &PlayReport::SaveReportWithUserOld, "SaveReportWithUserOld"}, | 23 | {10101, &PlayReport::SaveReportWithUser<Core::Reporter::PlayReportType::Old>, "SaveReportWithUserOld"}, |
| 27 | {10102, nullptr, "SaveReport"}, | 24 | {10102, &PlayReport::SaveReport<Core::Reporter::PlayReportType::New>, "SaveReport"}, |
| 28 | {10103, nullptr, "SaveReportWithUser"}, | 25 | {10103, &PlayReport::SaveReportWithUser<Core::Reporter::PlayReportType::New>, "SaveReportWithUser"}, |
| 29 | {10200, nullptr, "RequestImmediateTransmission"}, | 26 | {10200, nullptr, "RequestImmediateTransmission"}, |
| 30 | {10300, nullptr, "GetTransmissionStatus"}, | 27 | {10300, nullptr, "GetTransmissionStatus"}, |
| 31 | {20100, nullptr, "SaveSystemReport"}, | 28 | {20100, &PlayReport::SaveSystemReport, "SaveSystemReport"}, |
| 32 | {20101, nullptr, "SaveSystemReportWithUser"}, | 29 | {20101, &PlayReport::SaveSystemReportWithUser, "SaveSystemReportWithUser"}, |
| 33 | {20200, nullptr, "SetOperationMode"}, | 30 | {20200, nullptr, "SetOperationMode"}, |
| 34 | {30100, nullptr, "ClearStorage"}, | 31 | {30100, nullptr, "ClearStorage"}, |
| 35 | {30200, nullptr, "ClearStatistics"}, | 32 | {30200, nullptr, "ClearStatistics"}, |
| @@ -47,7 +44,28 @@ public: | |||
| 47 | } | 44 | } |
| 48 | 45 | ||
| 49 | private: | 46 | private: |
| 50 | void SaveReportWithUserOld(Kernel::HLERequestContext& ctx) { | 47 | template <Core::Reporter::PlayReportType Type> |
| 48 | void SaveReport(Kernel::HLERequestContext& ctx) { | ||
| 49 | IPC::RequestParser rp{ctx}; | ||
| 50 | const auto process_id = rp.PopRaw<u64>(); | ||
| 51 | |||
| 52 | const auto data1 = ctx.ReadBuffer(0); | ||
| 53 | const auto data2 = ctx.ReadBuffer(1); | ||
| 54 | |||
| 55 | LOG_DEBUG(Service_PREPO, | ||
| 56 | "called, type={:02X}, process_id={:016X}, data1_size={:016X}, data2_size={:016X}", | ||
| 57 | static_cast<u8>(Type), process_id, data1.size(), data2.size()); | ||
| 58 | |||
| 59 | const auto& reporter{system.GetReporter()}; | ||
| 60 | reporter.SavePlayReport(Type, system.CurrentProcess()->GetTitleID(), {data1, data2}, | ||
| 61 | process_id); | ||
| 62 | |||
| 63 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 64 | rb.Push(RESULT_SUCCESS); | ||
| 65 | } | ||
| 66 | |||
| 67 | template <Core::Reporter::PlayReportType Type> | ||
| 68 | void SaveReportWithUser(Kernel::HLERequestContext& ctx) { | ||
| 51 | IPC::RequestParser rp{ctx}; | 69 | IPC::RequestParser rp{ctx}; |
| 52 | const auto user_id = rp.PopRaw<u128>(); | 70 | const auto user_id = rp.PopRaw<u128>(); |
| 53 | const auto process_id = rp.PopRaw<u64>(); | 71 | const auto process_id = rp.PopRaw<u64>(); |
| @@ -57,24 +75,65 @@ private: | |||
| 57 | 75 | ||
| 58 | LOG_DEBUG( | 76 | LOG_DEBUG( |
| 59 | Service_PREPO, | 77 | Service_PREPO, |
| 60 | "called, user_id={:016X}{:016X}, unk1={:016X}, data1_size={:016X}, data2_size={:016X}", | 78 | "called, type={:02X}, user_id={:016X}{:016X}, process_id={:016X}, data1_size={:016X}, " |
| 61 | user_id[1], user_id[0], process_id, data1.size(), data2.size()); | 79 | "data2_size={:016X}", |
| 80 | static_cast<u8>(Type), user_id[1], user_id[0], process_id, data1.size(), data2.size()); | ||
| 81 | |||
| 82 | const auto& reporter{system.GetReporter()}; | ||
| 83 | reporter.SavePlayReport(Type, system.CurrentProcess()->GetTitleID(), {data1, data2}, | ||
| 84 | process_id, user_id); | ||
| 85 | |||
| 86 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 87 | rb.Push(RESULT_SUCCESS); | ||
| 88 | } | ||
| 89 | |||
| 90 | void SaveSystemReport(Kernel::HLERequestContext& ctx) { | ||
| 91 | IPC::RequestParser rp{ctx}; | ||
| 92 | const auto title_id = rp.PopRaw<u64>(); | ||
| 93 | |||
| 94 | const auto data1 = ctx.ReadBuffer(0); | ||
| 95 | const auto data2 = ctx.ReadBuffer(1); | ||
| 96 | |||
| 97 | LOG_DEBUG(Service_PREPO, "called, title_id={:016X}, data1_size={:016X}, data2_size={:016X}", | ||
| 98 | title_id, data1.size(), data2.size()); | ||
| 99 | |||
| 100 | const auto& reporter{system.GetReporter()}; | ||
| 101 | reporter.SavePlayReport(Core::Reporter::PlayReportType::System, title_id, {data1, data2}); | ||
| 102 | |||
| 103 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 104 | rb.Push(RESULT_SUCCESS); | ||
| 105 | } | ||
| 62 | 106 | ||
| 63 | const auto& reporter{Core::System::GetInstance().GetReporter()}; | 107 | void SaveSystemReportWithUser(Kernel::HLERequestContext& ctx) { |
| 64 | reporter.SavePlayReport(Core::CurrentProcess()->GetTitleID(), process_id, {data1, data2}, | 108 | IPC::RequestParser rp{ctx}; |
| 65 | user_id); | 109 | const auto user_id = rp.PopRaw<u128>(); |
| 110 | const auto title_id = rp.PopRaw<u64>(); | ||
| 111 | |||
| 112 | const auto data1 = ctx.ReadBuffer(0); | ||
| 113 | const auto data2 = ctx.ReadBuffer(1); | ||
| 114 | |||
| 115 | LOG_DEBUG(Service_PREPO, | ||
| 116 | "called, user_id={:016X}{:016X}, title_id={:016X}, data1_size={:016X}, " | ||
| 117 | "data2_size={:016X}", | ||
| 118 | user_id[1], user_id[0], title_id, data1.size(), data2.size()); | ||
| 119 | |||
| 120 | const auto& reporter{system.GetReporter()}; | ||
| 121 | reporter.SavePlayReport(Core::Reporter::PlayReportType::System, title_id, {data1, data2}, | ||
| 122 | std::nullopt, user_id); | ||
| 66 | 123 | ||
| 67 | IPC::ResponseBuilder rb{ctx, 2}; | 124 | IPC::ResponseBuilder rb{ctx, 2}; |
| 68 | rb.Push(RESULT_SUCCESS); | 125 | rb.Push(RESULT_SUCCESS); |
| 69 | } | 126 | } |
| 127 | |||
| 128 | Core::System& system; | ||
| 70 | }; | 129 | }; |
| 71 | 130 | ||
| 72 | void InstallInterfaces(SM::ServiceManager& service_manager) { | 131 | void InstallInterfaces(Core::System& system) { |
| 73 | std::make_shared<PlayReport>("prepo:a")->InstallAsService(service_manager); | 132 | std::make_shared<PlayReport>(system, "prepo:a")->InstallAsService(system.ServiceManager()); |
| 74 | std::make_shared<PlayReport>("prepo:a2")->InstallAsService(service_manager); | 133 | std::make_shared<PlayReport>(system, "prepo:a2")->InstallAsService(system.ServiceManager()); |
| 75 | std::make_shared<PlayReport>("prepo:m")->InstallAsService(service_manager); | 134 | std::make_shared<PlayReport>(system, "prepo:m")->InstallAsService(system.ServiceManager()); |
| 76 | std::make_shared<PlayReport>("prepo:s")->InstallAsService(service_manager); | 135 | std::make_shared<PlayReport>(system, "prepo:s")->InstallAsService(system.ServiceManager()); |
| 77 | std::make_shared<PlayReport>("prepo:u")->InstallAsService(service_manager); | 136 | std::make_shared<PlayReport>(system, "prepo:u")->InstallAsService(system.ServiceManager()); |
| 78 | } | 137 | } |
| 79 | 138 | ||
| 80 | } // namespace Service::PlayReport | 139 | } // namespace Service::PlayReport |
diff --git a/src/core/hle/service/prepo/prepo.h b/src/core/hle/service/prepo/prepo.h index 0e7b01331..0ebc3a938 100644 --- a/src/core/hle/service/prepo/prepo.h +++ b/src/core/hle/service/prepo/prepo.h | |||
| @@ -10,6 +10,6 @@ class ServiceManager; | |||
| 10 | 10 | ||
| 11 | namespace Service::PlayReport { | 11 | namespace Service::PlayReport { |
| 12 | 12 | ||
| 13 | void InstallInterfaces(SM::ServiceManager& service_manager); | 13 | void InstallInterfaces(Core::System& system); |
| 14 | 14 | ||
| 15 | } // namespace Service::PlayReport | 15 | } // namespace Service::PlayReport |
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 454387467..906fdc415 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -241,7 +241,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) { | |||
| 241 | PCIe::InstallInterfaces(*sm); | 241 | PCIe::InstallInterfaces(*sm); |
| 242 | PCTL::InstallInterfaces(*sm); | 242 | PCTL::InstallInterfaces(*sm); |
| 243 | PCV::InstallInterfaces(*sm); | 243 | PCV::InstallInterfaces(*sm); |
| 244 | PlayReport::InstallInterfaces(*sm); | 244 | PlayReport::InstallInterfaces(system); |
| 245 | PM::InstallInterfaces(system); | 245 | PM::InstallInterfaces(system); |
| 246 | PSC::InstallInterfaces(*sm); | 246 | PSC::InstallInterfaces(*sm); |
| 247 | PSM::InstallInterfaces(*sm); | 247 | PSM::InstallInterfaces(*sm); |
diff --git a/src/core/reporter.cpp b/src/core/reporter.cpp index cfe0771e2..9c657929e 100644 --- a/src/core/reporter.cpp +++ b/src/core/reporter.cpp | |||
| @@ -304,8 +304,8 @@ void Reporter::SaveUnimplementedAppletReport( | |||
| 304 | SaveToFile(std::move(out), GetPath("unimpl_applet_report", title_id, timestamp)); | 304 | SaveToFile(std::move(out), GetPath("unimpl_applet_report", title_id, timestamp)); |
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | void Reporter::SavePlayReport(u64 title_id, u64 process_id, std::vector<std::vector<u8>> data, | 307 | void Reporter::SavePlayReport(PlayReportType type, u64 title_id, std::vector<std::vector<u8>> data, |
| 308 | std::optional<u128> user_id) const { | 308 | std::optional<u64> process_id, std::optional<u128> user_id) const { |
| 309 | if (!IsReportingEnabled()) { | 309 | if (!IsReportingEnabled()) { |
| 310 | return; | 310 | return; |
| 311 | } | 311 | } |
| @@ -321,7 +321,11 @@ void Reporter::SavePlayReport(u64 title_id, u64 process_id, std::vector<std::vec | |||
| 321 | data_out.push_back(Common::HexToString(d)); | 321 | data_out.push_back(Common::HexToString(d)); |
| 322 | } | 322 | } |
| 323 | 323 | ||
| 324 | out["play_report_process_id"] = fmt::format("{:016X}", process_id); | 324 | if (process_id.has_value()) { |
| 325 | out["play_report_process_id"] = fmt::format("{:016X}", *process_id); | ||
| 326 | } | ||
| 327 | |||
| 328 | out["play_report_type"] = fmt::format("{:02}", static_cast<u8>(type)); | ||
| 325 | out["play_report_data"] = std::move(data_out); | 329 | out["play_report_data"] = std::move(data_out); |
| 326 | 330 | ||
| 327 | SaveToFile(std::move(out), GetPath("play_report", title_id, timestamp)); | 331 | SaveToFile(std::move(out), GetPath("play_report", title_id, timestamp)); |
diff --git a/src/core/reporter.h b/src/core/reporter.h index 44256de50..f08aa11fb 100644 --- a/src/core/reporter.h +++ b/src/core/reporter.h | |||
| @@ -46,8 +46,14 @@ public: | |||
| 46 | std::vector<std::vector<u8>> normal_channel, | 46 | std::vector<std::vector<u8>> normal_channel, |
| 47 | std::vector<std::vector<u8>> interactive_channel) const; | 47 | std::vector<std::vector<u8>> interactive_channel) const; |
| 48 | 48 | ||
| 49 | void SavePlayReport(u64 title_id, u64 process_id, std::vector<std::vector<u8>> data, | 49 | enum class PlayReportType { |
| 50 | std::optional<u128> user_id = {}) const; | 50 | Old, |
| 51 | New, | ||
| 52 | System, | ||
| 53 | }; | ||
| 54 | |||
| 55 | void SavePlayReport(PlayReportType type, u64 title_id, std::vector<std::vector<u8>> data, | ||
| 56 | std::optional<u64> process_id = {}, std::optional<u128> user_id = {}) const; | ||
| 51 | 57 | ||
| 52 | void SaveErrorReport(u64 title_id, ResultCode result, | 58 | void SaveErrorReport(u64 title_id, ResultCode result, |
| 53 | std::optional<std::string> custom_text_main = {}, | 59 | std::optional<std::string> custom_text_main = {}, |