From bf73cb57caec9d910231684bd225afe6bccd2929 Mon Sep 17 00:00:00 2001 From: Steveice10 <1269164+Steveice10@users.noreply.github.com> Date: Fri, 17 Feb 2023 06:20:56 -0800 Subject: [PATCH] am: Return installed titles in GetNumTickets and GetTicketList stubs. (#6292) --- src/core/hle/service/am/am.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 4578ffc23..af4532b75 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -1087,7 +1087,11 @@ void Module::Interface::DeleteTicket(Kernel::HLERequestContext& ctx) { void Module::Interface::GetNumTickets(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x0008, 0, 0); // 0x00080000 + u32 ticket_count = 0; + for (const auto& title_list : am->am_title_list) { + ticket_count += static_cast(title_list.size()); + } IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); rb.Push(RESULT_SUCCESS); @@ -1101,9 +1105,18 @@ void Module::Interface::GetTicketList(Kernel::HLERequestContext& ctx) { u32 ticket_index = rp.Pop(); auto& ticket_tids_out = rp.PopMappedBuffer(); + u32 tickets_written = 0; + for (const auto& title_list : am->am_title_list) { + const auto tickets_to_write = + std::min(static_cast(title_list.size()), ticket_list_count - tickets_written); + ticket_tids_out.Write(title_list.data(), tickets_written * sizeof(u64), + tickets_to_write * sizeof(u64)); + tickets_written += tickets_to_write; + } + IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); rb.Push(RESULT_SUCCESS); - rb.Push(ticket_list_count); + rb.Push(tickets_written); rb.PushMappedBuffer(ticket_tids_out); LOG_WARNING(Service_AM, "(STUBBED) ticket_list_count=0x{:08x}, ticket_index=0x{:08x}", ticket_list_count, ticket_index);