From c6e43ae79d0708e63c0f07b199867daa4efa0be8 Mon Sep 17 00:00:00 2001 From: shinyquagsire23 Date: Mon, 6 Nov 2017 11:50:53 -0700 Subject: [PATCH] Services/AM: Rename and adjust FindContentInfos for accuracy --- src/core/hle/service/am/am.cpp | 24 ++++++++++++++++++++---- src/core/hle/service/am/am.h | 5 +++-- src/core/hle/service/am/am_app.cpp | 2 +- src/core/hle/service/am/am_sys.cpp | 2 +- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 7d29475d7..f94c47768 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -401,14 +401,28 @@ void GetNumPrograms(Service::Interface* self) { rb.Push(am_title_list[media_type].size()); } -void FindContentInfos(Service::Interface* self) { +void FindDLCContentInfos(Service::Interface* self) { IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1002, 4, 4); // 0x10020104 auto media_type = static_cast(rp.Pop()); u64 title_id = rp.Pop(); u32 content_count = rp.Pop(); - VAddr content_requested_in = rp.PopMappedBuffer(); - VAddr content_info_out = rp.PopMappedBuffer(); + + size_t input_buffer_size, output_buffer_size; + IPC::MappedBufferPermissions input_buffer_perms, output_buffer_perms; + VAddr content_requested_in = rp.PopMappedBuffer(&input_buffer_size, &input_buffer_perms); + VAddr content_info_out = rp.PopMappedBuffer(&output_buffer_size, &output_buffer_perms); + + // Validate that only DLC TIDs are passed in + u32 tid_high = static_cast(title_id >> 32); + if (tid_high != TID_HIGH_DLC) { + IPC::RequestBuilder rb = rp.MakeBuilder(1, 4); + rb.Push(ResultCode(ErrCodes::InvalidTIDInList, ErrorModule::AM, + ErrorSummary::InvalidArgument, ErrorLevel::Usage)); + rb.PushMappedBuffer(content_requested_in, input_buffer_size, input_buffer_perms); + rb.PushMappedBuffer(content_info_out, output_buffer_size, output_buffer_perms); + return; + } std::vector content_requested(content_count); Memory::ReadBlock(content_requested_in, content_requested.data(), content_count * sizeof(u16)); @@ -440,8 +454,10 @@ void FindContentInfos(Service::Interface* self) { } } - IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + IPC::RequestBuilder rb = rp.MakeBuilder(1, 4); rb.Push(RESULT_SUCCESS); + rb.PushMappedBuffer(content_requested_in, input_buffer_size, input_buffer_perms); + rb.PushMappedBuffer(content_info_out, output_buffer_size, output_buffer_perms); } void ListContentInfos(Service::Interface* self) { diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index b3b3a5b07..b8f1053b6 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -96,7 +96,8 @@ void ScanForAllTitles(); void GetNumPrograms(Service::Interface* self); /** - * AM::FindContentInfos service function + * AM::FindDLCContentInfos service function + * Explicitly checks that TID high value is 0004008C or an error is returned. * Inputs: * 1 : MediaType * 2-3 : u64, Title ID @@ -106,7 +107,7 @@ void GetNumPrograms(Service::Interface* self); * Outputs: * 1 : Result, 0 on success, otherwise error code */ -void FindContentInfos(Service::Interface* self); +void FindDLCContentInfos(Service::Interface* self); /** * AM::ListContentInfos service function diff --git a/src/core/hle/service/am/am_app.cpp b/src/core/hle/service/am/am_app.cpp index db85067d0..6dd93497a 100644 --- a/src/core/hle/service/am/am_app.cpp +++ b/src/core/hle/service/am/am_app.cpp @@ -10,7 +10,7 @@ namespace AM { const Interface::FunctionInfo FunctionTable[] = { {0x100100C0, GetNumContentInfos, "GetNumContentInfos"}, - {0x10020104, FindContentInfos, "FindContentInfos"}, + {0x10020104, FindDLCContentInfos, "FindDLCContentInfos"}, {0x10030142, ListContentInfos, "ListContentInfos"}, {0x10040102, DeleteContents, "DeleteContents"}, {0x10050084, GetDLCTitleInfos, "GetDLCTitleInfos"}, diff --git a/src/core/hle/service/am/am_sys.cpp b/src/core/hle/service/am/am_sys.cpp index 7787fdfed..cb860653f 100644 --- a/src/core/hle/service/am/am_sys.cpp +++ b/src/core/hle/service/am/am_sys.cpp @@ -55,7 +55,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x002C0084, nullptr, "GetProgramInfosIgnorePlatform"}, {0x002D00C0, CheckContentRightsIgnorePlatform, "CheckContentRightsIgnorePlatform"}, {0x100100C0, GetNumContentInfos, "GetNumContentInfos"}, - {0x10020104, FindContentInfos, "FindContentInfos"}, + {0x10020104, FindDLCContentInfos, "FindDLCContentInfos"}, {0x10030142, ListContentInfos, "ListContentInfos"}, {0x10040102, DeleteContents, "DeleteContents"}, {0x10050084, GetDLCTitleInfos, "GetDLCTitleInfos"},