Service/AM: Implement GetProductCode (#3549)

* [skip ci]

* [skip ci]

* [skip ci]

* [skip ci]

* Service/AM: Implement GetProductCode

* fix?

* remove close

* Use PushRaw

* Use NCCHContainer

* 2 if found

* struct

* fix build?

* fix

* remove return

* fix?

* 6 words
This commit is contained in:
Valentin Vanelslande 2018-05-05 08:43:31 -05:00 committed by Weiyi Wang
parent 0da3b75c9e
commit 473fd552c8
5 changed files with 41 additions and 3 deletions

View File

@ -712,6 +712,32 @@ void Module::Interface::DeleteUserProgram(Kernel::HLERequestContext& ctx) {
LOG_ERROR(Service_AM, "FileUtil::DeleteDirRecursively unexpectedly failed");
}
void Module::Interface::GetProductCode(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx, 0x0005, 3, 0);
FS::MediaType media_type = rp.PopEnum<FS::MediaType>();
u64 title_id = rp.Pop<u64>();
std::string path = GetTitleContentPath(media_type, title_id);
if (!FileUtil::Exists(path)) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState,
ErrorLevel::Permanent));
} else {
struct ProductCode {
u8 code[0x10];
};
ProductCode product_code;
IPC::RequestBuilder rb = rp.MakeBuilder(6, 0);
FileSys::NCCHContainer ncch(path);
ncch.Load();
std::memcpy(&product_code.code, &ncch.ncch_header.product_code, 0x10);
rb.Push(RESULT_SUCCESS);
rb.PushRaw(product_code);
}
}
void Module::Interface::GetDLCTitleInfos(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx, 0x1005, 2, 4); // 0x10050084

View File

@ -242,6 +242,18 @@ public:
*/
void DeleteUserProgram(Kernel::HLERequestContext& ctx);
/**
* AM::GetProductCode service function
* Gets the product code of a title
* Inputs:
* 1 : Media Type
* 2-3 : Title ID
* Outputs:
* 1 : Result, 0 on success, otherwise error code
* 2-5 : Product Code
*/
void GetProductCode(Kernel::HLERequestContext& ctx);
/**
* AM::GetDLCTitleInfos service function
* Wrapper for AM::GetProgramInfos, explicitly checks that TID high value is 0004008C.

View File

@ -13,7 +13,7 @@ AM_NET::AM_NET(std::shared_ptr<Module> am) : Module::Interface(std::move(am), "a
{0x00020082, &AM_NET::GetProgramList, "GetProgramList"},
{0x00030084, &AM_NET::GetProgramInfos, "GetProgramInfos"},
{0x000400C0, &AM_NET::DeleteUserProgram, "DeleteUserProgram"},
{0x000500C0, nullptr, "GetProductCode"},
{0x000500C0, &AM_NET::GetProductCode, "GetProductCode"},
{0x000600C0, nullptr, "GetStorageId"},
{0x00070080, &AM_NET::DeleteTicket, "DeleteTicket"},
{0x00080000, &AM_NET::GetNumTickets, "GetNumTickets"},

View File

@ -13,7 +13,7 @@ AM_SYS::AM_SYS(std::shared_ptr<Module> am) : Module::Interface(std::move(am), "a
{0x00020082, &AM_SYS::GetProgramList, "GetProgramList"},
{0x00030084, &AM_SYS::GetProgramInfos, "GetProgramInfos"},
{0x000400C0, &AM_SYS::DeleteUserProgram, "DeleteUserProgram"},
{0x000500C0, nullptr, "GetProductCode"},
{0x000500C0, &AM_SYS::GetProductCode, "GetProductCode"},
{0x000600C0, nullptr, "GetStorageId"},
{0x00070080, &AM_SYS::DeleteTicket, "DeleteTicket"},
{0x00080000, &AM_SYS::GetNumTickets, "GetNumTickets"},

View File

@ -13,7 +13,7 @@ AM_U::AM_U(std::shared_ptr<Module> am) : Module::Interface(std::move(am), "am:u"
{0x00020082, &AM_U::GetProgramList, "GetProgramList"},
{0x00030084, &AM_U::GetProgramInfos, "GetProgramInfos"},
{0x000400C0, &AM_U::DeleteUserProgram, "DeleteUserProgram"},
{0x000500C0, nullptr, "GetProductCode"},
{0x000500C0, &AM_U::GetProductCode, "GetProductCode"},
{0x000600C0, nullptr, "GetStorageId"},
{0x00070080, &AM_U::DeleteTicket, "DeleteTicket"},
{0x00080000, &AM_U::GetNumTickets, "GetNumTickets"},