Skip to content

Commit

Permalink
act: Add more command names and implement GetErrorCode (#237)
Browse files Browse the repository at this point in the history
* act: Add more command names and implement GetErrorCode

The command names have been extracted from 3dbrew and the JavaScript
bindings that the NNID settings uses internally.

The error names have been extracted from the Wii U implementation
(102-XXXX), which are compatible with the 3DS ones except for 022-5XXX,
which are error codes specific to the 3DS.

* act: Split error codes into separate file
  • Loading branch information
DaniElectra authored Aug 21, 2024
1 parent d8760de commit 5115f64
Show file tree
Hide file tree
Showing 7 changed files with 1,474 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ add_library(citra_core STATIC
hle/service/ac/ac_u.h
hle/service/act/act.cpp
hle/service/act/act.h
hle/service/act/act_errors.cpp
hle/service/act/act_errors.h
hle/service/act/act_a.cpp
hle/service/act/act_a.h
hle/service/act/act_u.cpp
Expand Down
22 changes: 18 additions & 4 deletions src/core/hle/service/act/act.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "core/hle/kernel/shared_memory.h"
#include "core/hle/service/act/act.h"
#include "core/hle/service/act/act_a.h"
#include "core/hle/service/act/act_errors.h"
#include "core/hle/service/act/act_u.h"

namespace Service::ACT {
Expand All @@ -31,15 +32,28 @@ void Module::Interface::Initialize(Kernel::HLERequestContext& ctx) {
rb.Push(ResultSuccess);
}

void Module::Interface::GetAccountDataBlock(Kernel::HLERequestContext& ctx) {
void Module::Interface::GetErrorCode(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
const auto unknown = rp.Pop<u8>();
const auto result = rp.Pop<Result>();

LOG_DEBUG(Service_ACT, "called result={:08X}", result.raw);

const u32 error_code = GetACTErrorCode(result);

IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(ResultSuccess);
rb.Push(error_code);
}

void Module::Interface::GetAccountInfo(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
const auto account_slot = rp.Pop<u8>();
const auto size = rp.Pop<u32>();
const auto block_id = rp.Pop<u32>();
[[maybe_unused]] auto output_buffer = rp.PopMappedBuffer();

LOG_DEBUG(Service_ACT, "(STUBBED) called unknown={:02X}, size={:08X}, block_id={:08X}", unknown,
size, block_id);
LOG_DEBUG(Service_ACT, "(STUBBED) called account_slot={:02X}, size={:08X}, block_id={:08X}",
account_slot, size, block_id);

IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultSuccess);
Expand Down
16 changes: 13 additions & 3 deletions src/core/hle/service/act/act.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,27 @@ class Module final {
void Initialize(Kernel::HLERequestContext& ctx);

/**
* ACT::GetAccountDataBlock service function.
* ACT::GetErrorCode service function.
* Inputs:
* 1 : u8 Unknown
* 1 : Result code
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Error code
*/
void GetErrorCode(Kernel::HLERequestContext& ctx);

/**
* ACT::GetAccountInfo service function.
* Inputs:
* 1 : Account slot
* 2 : Size
* 3 : Block ID
* 4 : Output Buffer Mapping Translation Header ((Size << 4) | 0xC)
* 5 : Output Buffer Pointer
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void GetAccountDataBlock(Kernel::HLERequestContext& ctx);
void GetAccountInfo(Kernel::HLERequestContext& ctx);
};

private:
Expand Down
50 changes: 48 additions & 2 deletions src/core/hle/service/act/act_a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,61 @@ ACT_A::ACT_A(std::shared_ptr<Module> act) : Module::Interface(std::move(act), "a
// act:u shared commands
// clang-format off
{0x0001, &ACT_A::Initialize, "Initialize"},
{0x0002, nullptr, "GetErrorCode"},
{0x0006, &ACT_A::GetAccountDataBlock, "GetAccountDataBlock"},
{0x0002, &ACT_A::GetErrorCode, "GetErrorCode"},
{0x0003, nullptr, "GetLastResponseCode"},
{0x0005, nullptr, "GetCommonInfo"},
{0x0006, &ACT_A::GetAccountInfo, "GetAccountInfo"},
{0x0007, nullptr, "GetResultAsync"},
{0x0008, nullptr, "GetMiiImageData"},
{0x0009, nullptr, "SetNfsPassword"},
{0x000B, nullptr, "AcquireEulaList"},
{0x000C, nullptr, "AcquireTimeZoneList"},
{0x000D, nullptr, "GenerateUuid"},
{0x000F, nullptr, "FindSlotNoByUuid"},
{0x0010, nullptr, "SaveData"},
{0x0011, nullptr, "GetTransferableId"},
{0x0012, nullptr, "AcquireNexServiceToken"},
{0x0013, nullptr, "GetNexServiceToken"},
{0x0014, nullptr, "AcquireIndependentServiceToken"},
{0x0015, nullptr, "GetIndependentServiceToken"},
{0x0016, nullptr, "AcquireAccountInfo"},
{0x0017, nullptr, "AcquireAccountIdByPrincipalId"},
{0x0018, nullptr, "AcquirePrincipalIdByAccountId"},
{0x0019, nullptr, "AcquireMii"},
{0x001A, nullptr, "AcquireAccountInfoEx"},
{0x001D, nullptr, "InquireMailAddress"},
{0x001E, nullptr, "AcquireEula"},
{0x001F, nullptr, "AcquireEulaLanguageList"},
// act:a
{0x0402, nullptr, "CreateConsoleAccount"},
{0x0403, nullptr, "CommitConsoleAccount"},
{0x0404, nullptr, "UnbindServerAccount"},
{0x0405, nullptr, "DeleteConsoleAccount"},
{0x0407, nullptr, "UnloadConsoleAccount"},
{0x0408, nullptr, "EnableAccountPasswordCache"},
{0x0409, nullptr, "SetDefaultAccount"},
{0x040A, nullptr, "ReplaceAccountId"},
{0x040B, nullptr, "GetSupportContext"},
{0x0412, nullptr, "UpdateMii"},
{0x0413, nullptr, "UpdateMiiImage"},
{0x0414, nullptr, "InquireAccountIdAvailability"},
{0x0415, nullptr, "BindToNewServerAccount"},
{0x0416, nullptr, "BindToExistentServerAccount"},
{0x0417, nullptr, "InquireBindingToExistentServerAccount"},
{0x041A, nullptr, "AcquireAccountTokenEx"},
{0x041B, nullptr, "AgreeEula"},
{0x041C, nullptr, "SyncAccountInfo"},
{0x041E, nullptr, "UpdateAccountPassword"},
{0x041F, nullptr, "ReissueAccountPassword"},
{0x0420, nullptr, "SetAccountPasswordInput"},
{0x0421, nullptr, "UploadMii"},
{0x0423, nullptr, "ValidateMailAddress"},
{0x0423, nullptr, "SendConfirmationMail"},
{0x0428, nullptr, "ApproveByCreditCard"},
{0x0428, nullptr, "SendCoppaCodeMail"},
{0x042F, nullptr, "UpdateAccountInfoEx"},
{0x0430, nullptr, "UpdateAccountMailAddress"},
{0x0435, nullptr, "DeleteServerAccount"},
// clang-format on
};
RegisterHandlers(functions);
Expand Down
Loading

0 comments on commit 5115f64

Please sign in to comment.