From 71c7dddac4826bcc0e7cd617887d943e50f5661c Mon Sep 17 00:00:00 2001 From: Cuyler36 Date: Tue, 6 Feb 2018 19:31:22 -0500 Subject: [PATCH] Service/FS_User: Stub Secure Value Functions Stubbing these functions results in save loading fixes in games which require a secure value. An example is shown here with Animal Crossing: New Leaf: [Before](https://puu.sh/zidZC/f1523e81cb.png) [After](https://puu.sh/zifeT/57026eae44.png) --- src/core/hle/service/fs/fs_user.cpp | 58 ++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index c6b0445d6..27585496a 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -990,6 +990,60 @@ static void GetNumSeeds(Service::Interface* self) { rb.Push(0); } +/** + * FS_User::SetSaveDataSecureValue service function. + * Inputs: + * 0 : 0x08650140 + * 1-2 : Secure Value + * 3 : Secure Value Slot + * 4 : Title Id + * 5 : Title Variation + * Outputs: + * 0 : 0x08650140 + * 1 : Result of function, 0 on success, otherwise error code + */ +static void SetSaveDataSecureValue(Service::Interface* self) { + IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x865, 5, 0); + + // TODO: Generate and Save the Secure Value + + LOG_WARNING(Service_FS, "(STUBBED) called"); + + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + + rb.Push(RESULT_SUCCESS); +} + +/** + * FS_User::GetSaveDataSecureValue service function. + * Inputs: + * 0 : 0x086600C0 + * 1 : Secure Value Slot + * 2 : Title Id + * 3 : Title Variation + * Outputs: + * 0 : 0x086600C0 + * 1 : Result of function, 0 on success, otherwise error code + * 2 : If Secure Value doesn't exist, 0, if it exists, 1 + * 3-4 : Secure Value + */ +static void GetSaveDataSecureValue(Service::Interface* self) { + IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x866, 3, 0); + + u32 secure_value_slot = rp.Pop(); + + LOG_WARNING(Service_FS, "(STUBBED) called Secure Value Slot=%08X", secure_value_slot); + + IPC::RequestBuilder rb = rp.MakeBuilder(4, 0); + + rb.Push(RESULT_SUCCESS); + + // TODO: Implement Secure Value Lookup & Generation + + rb.Push(0); + rb.Push(0); +} + const Interface::FunctionInfo FunctionTable[] = { {0x000100C6, nullptr, "Dummy1"}, {0x040100C4, nullptr, "Control"}, @@ -1093,8 +1147,8 @@ const Interface::FunctionInfo FunctionTable[] = { {0x08620040, SetPriority, "SetPriority"}, {0x08630000, GetPriority, "GetPriority"}, {0x08640000, nullptr, "GetNandInfo"}, - {0x08650140, nullptr, "SetSaveDataSecureValue"}, - {0x086600C0, nullptr, "GetSaveDataSecureValue"}, + {0x08650140, SetSaveDataSecureValue, "SetSaveDataSecureValue"}, + {0x086600C0, GetSaveDataSecureValue, "GetSaveDataSecureValue"}, {0x086700C4, nullptr, "ControlSecureSave"}, {0x08680000, nullptr, "GetMediaType"}, {0x08690000, nullptr, "GetNandEraseCount"},