summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Mat M2018-10-24 10:10:29 -0400
committerGravatar GitHub2018-10-24 10:10:29 -0400
commit77e705a8fa0a70dac2eb81b95fedc5e98d7c274e (patch)
tree29bf11e757a34d608652b901f9c58ce4ad25aeaf /src/core
parentMerge pull request #1551 from ogniK5377/improved-svcbreak (diff)
parentconfigure_system: Clear current username before overwriting (diff)
downloadyuzu-77e705a8fa0a70dac2eb81b95fedc5e98d7c274e.tar.gz
yuzu-77e705a8fa0a70dac2eb81b95fedc5e98d7c274e.tar.xz
yuzu-77e705a8fa0a70dac2eb81b95fedc5e98d7c274e.zip
Merge pull request #1468 from DarkLordZach/profile-manager-ui
qt: Add UI to manage emulated user profiles
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/acc/acc.cpp54
-rw-r--r--src/core/hle/service/acc/profile_manager.cpp147
-rw-r--r--src/core/hle/service/acc/profile_manager.h21
-rw-r--r--src/core/hle/service/am/am.cpp33
-rw-r--r--src/core/settings.h2
5 files changed, 227 insertions, 30 deletions
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index e61748ca3..cf065c2e0 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -2,9 +2,13 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm>
5#include <array> 6#include <array>
7#include "common/common_paths.h"
6#include "common/common_types.h" 8#include "common/common_types.h"
9#include "common/file_util.h"
7#include "common/logging/log.h" 10#include "common/logging/log.h"
11#include "common/string_util.h"
8#include "common/swap.h" 12#include "common/swap.h"
9#include "core/core_timing.h" 13#include "core/core_timing.h"
10#include "core/hle/ipc_helpers.h" 14#include "core/hle/ipc_helpers.h"
@@ -16,6 +20,9 @@
16#include "core/hle/service/acc/profile_manager.h" 20#include "core/hle/service/acc/profile_manager.h"
17 21
18namespace Service::Account { 22namespace Service::Account {
23
24constexpr u32 MAX_JPEG_IMAGE_SIZE = 0x20000;
25
19// TODO: RE this structure 26// TODO: RE this structure
20struct UserData { 27struct UserData {
21 INSERT_PADDING_WORDS(1); 28 INSERT_PADDING_WORDS(1);
@@ -27,6 +34,11 @@ struct UserData {
27}; 34};
28static_assert(sizeof(UserData) == 0x80, "UserData structure has incorrect size"); 35static_assert(sizeof(UserData) == 0x80, "UserData structure has incorrect size");
29 36
37static std::string GetImagePath(UUID uuid) {
38 return FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) +
39 "/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg";
40}
41
30class IProfile final : public ServiceFramework<IProfile> { 42class IProfile final : public ServiceFramework<IProfile> {
31public: 43public:
32 explicit IProfile(UUID user_id, ProfileManager& profile_manager) 44 explicit IProfile(UUID user_id, ProfileManager& profile_manager)
@@ -73,11 +85,11 @@ private:
73 } 85 }
74 86
75 void LoadImage(Kernel::HLERequestContext& ctx) { 87 void LoadImage(Kernel::HLERequestContext& ctx) {
76 LOG_WARNING(Service_ACC, "(STUBBED) called"); 88 LOG_DEBUG(Service_ACC, "called");
77 // smallest jpeg https://github.com/mathiasbynens/small/blob/master/jpeg.jpg 89 // smallest jpeg https://github.com/mathiasbynens/small/blob/master/jpeg.jpg
78 // TODO(mailwl): load actual profile image from disk, width 256px, max size 0x20000 90 // used as a backup should the one on disk not exist
79 constexpr u32 jpeg_size = 107; 91 constexpr u32 backup_jpeg_size = 107;
80 static constexpr std::array<u8, jpeg_size> jpeg{ 92 static constexpr std::array<u8, backup_jpeg_size> backup_jpeg{
81 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 93 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
82 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 94 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04,
83 0x08, 0x06, 0x06, 0x05, 0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 95 0x08, 0x06, 0x06, 0x05, 0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a,
@@ -87,18 +99,42 @@ private:
87 0xff, 0xcc, 0x00, 0x06, 0x00, 0x10, 0x10, 0x05, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 99 0xff, 0xcc, 0x00, 0x06, 0x00, 0x10, 0x10, 0x05, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01,
88 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, 100 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9,
89 }; 101 };
90 ctx.WriteBuffer(jpeg); 102
91 IPC::ResponseBuilder rb{ctx, 3}; 103 IPC::ResponseBuilder rb{ctx, 3};
92 rb.Push(RESULT_SUCCESS); 104 rb.Push(RESULT_SUCCESS);
93 rb.Push<u32>(jpeg_size); 105
106 const FileUtil::IOFile image(GetImagePath(user_id), "rb");
107
108 if (!image.IsOpen()) {
109 LOG_WARNING(Service_ACC,
110 "Failed to load user provided image! Falling back to built-in backup...");
111 ctx.WriteBuffer(backup_jpeg);
112 rb.Push<u32>(backup_jpeg_size);
113 } else {
114 const auto size = std::min<u32>(image.GetSize(), MAX_JPEG_IMAGE_SIZE);
115 std::vector<u8> buffer(size);
116 image.ReadBytes(buffer.data(), buffer.size());
117
118 ctx.WriteBuffer(buffer.data(), buffer.size());
119 rb.Push<u32>(buffer.size());
120 }
94 } 121 }
95 122
96 void GetImageSize(Kernel::HLERequestContext& ctx) { 123 void GetImageSize(Kernel::HLERequestContext& ctx) {
97 LOG_WARNING(Service_ACC, "(STUBBED) called"); 124 LOG_DEBUG(Service_ACC, "called");
98 constexpr u32 jpeg_size = 107; 125 constexpr u32 backup_jpeg_size = 107;
99 IPC::ResponseBuilder rb{ctx, 3}; 126 IPC::ResponseBuilder rb{ctx, 3};
100 rb.Push(RESULT_SUCCESS); 127 rb.Push(RESULT_SUCCESS);
101 rb.Push<u32>(jpeg_size); 128
129 const FileUtil::IOFile image(GetImagePath(user_id), "rb");
130
131 if (!image.IsOpen()) {
132 LOG_WARNING(Service_ACC,
133 "Failed to load user provided image! Falling back to built-in backup...");
134 rb.Push<u32>(backup_jpeg_size);
135 } else {
136 rb.Push<u32>(std::min<u32>(image.GetSize(), MAX_JPEG_IMAGE_SIZE));
137 }
102 } 138 }
103 139
104 const ProfileManager& profile_manager; 140 const ProfileManager& profile_manager;
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp
index bcb3475db..06f7d1b15 100644
--- a/src/core/hle/service/acc/profile_manager.cpp
+++ b/src/core/hle/service/acc/profile_manager.cpp
@@ -4,32 +4,57 @@
4 4
5#include <random> 5#include <random>
6#include <boost/optional.hpp> 6#include <boost/optional.hpp>
7#include "common/file_util.h"
7#include "core/hle/service/acc/profile_manager.h" 8#include "core/hle/service/acc/profile_manager.h"
8#include "core/settings.h" 9#include "core/settings.h"
9 10
10namespace Service::Account { 11namespace Service::Account {
12
13struct UserRaw {
14 UUID uuid;
15 UUID uuid2;
16 u64 timestamp;
17 ProfileUsername username;
18 INSERT_PADDING_BYTES(0x80);
19};
20static_assert(sizeof(UserRaw) == 0xC8, "UserRaw has incorrect size.");
21
22struct ProfileDataRaw {
23 INSERT_PADDING_BYTES(0x10);
24 std::array<UserRaw, MAX_USERS> users;
25};
26static_assert(sizeof(ProfileDataRaw) == 0x650, "ProfileDataRaw has incorrect size.");
27
11// TODO(ogniK): Get actual error codes 28// TODO(ogniK): Get actual error codes
12constexpr ResultCode ERROR_TOO_MANY_USERS(ErrorModule::Account, -1); 29constexpr ResultCode ERROR_TOO_MANY_USERS(ErrorModule::Account, -1);
13constexpr ResultCode ERROR_USER_ALREADY_EXISTS(ErrorModule::Account, -2); 30constexpr ResultCode ERROR_USER_ALREADY_EXISTS(ErrorModule::Account, -2);
14constexpr ResultCode ERROR_ARGUMENT_IS_NULL(ErrorModule::Account, 20); 31constexpr ResultCode ERROR_ARGUMENT_IS_NULL(ErrorModule::Account, 20);
15 32
16const UUID& UUID::Generate() { 33constexpr char ACC_SAVE_AVATORS_BASE_PATH[] = "/system/save/8000000000000010/su/avators/";
34
35UUID UUID::Generate() {
17 std::random_device device; 36 std::random_device device;
18 std::mt19937 gen(device()); 37 std::mt19937 gen(device());
19 std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max()); 38 std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max());
20 uuid[0] = distribution(gen); 39 return UUID{distribution(gen), distribution(gen)};
21 uuid[1] = distribution(gen);
22 return *this;
23} 40}
24 41
25ProfileManager::ProfileManager() { 42ProfileManager::ProfileManager() {
26 // TODO(ogniK): Create the default user we have for now until loading/saving users is added 43 ParseUserSaveFile();
27 auto user_uuid = UUID{1, 0}; 44
28 ASSERT(CreateNewUser(user_uuid, Settings::values.username).IsSuccess()); 45 if (user_count == 0)
29 OpenUser(user_uuid); 46 CreateNewUser(UUID::Generate(), "yuzu");
47
48 auto current = std::clamp<int>(Settings::values.current_user, 0, MAX_USERS - 1);
49 if (UserExistsIndex(current))
50 current = 0;
51
52 OpenUser(*GetUser(current));
30} 53}
31 54
32ProfileManager::~ProfileManager() = default; 55ProfileManager::~ProfileManager() {
56 WriteUserSaveFile();
57}
33 58
34/// After a users creation it needs to be "registered" to the system. AddToProfiles handles the 59/// After a users creation it needs to be "registered" to the system. AddToProfiles handles the
35/// internal management of the users profiles 60/// internal management of the users profiles
@@ -101,6 +126,12 @@ ResultCode ProfileManager::CreateNewUser(UUID uuid, const std::string& username)
101 return CreateNewUser(uuid, username_output); 126 return CreateNewUser(uuid, username_output);
102} 127}
103 128
129boost::optional<UUID> ProfileManager::GetUser(std::size_t index) const {
130 if (index >= MAX_USERS)
131 return boost::none;
132 return profiles[index].user_uuid;
133}
134
104/// Returns a users profile index based on their user id. 135/// Returns a users profile index based on their user id.
105boost::optional<std::size_t> ProfileManager::GetUserIndex(const UUID& uuid) const { 136boost::optional<std::size_t> ProfileManager::GetUserIndex(const UUID& uuid) const {
106 if (!uuid) { 137 if (!uuid) {
@@ -164,6 +195,12 @@ bool ProfileManager::UserExists(UUID uuid) const {
164 return (GetUserIndex(uuid) != boost::none); 195 return (GetUserIndex(uuid) != boost::none);
165} 196}
166 197
198bool ProfileManager::UserExistsIndex(std::size_t index) const {
199 if (index >= MAX_USERS)
200 return false;
201 return profiles[index].user_uuid.uuid != INVALID_UUID;
202}
203
167/// Opens a specific user 204/// Opens a specific user
168void ProfileManager::OpenUser(UUID uuid) { 205void ProfileManager::OpenUser(UUID uuid) {
169 auto idx = GetUserIndex(uuid); 206 auto idx = GetUserIndex(uuid);
@@ -239,4 +276,96 @@ bool ProfileManager::CanSystemRegisterUser() const {
239 // emulate qlaunch. Update this to dynamically change. 276 // emulate qlaunch. Update this to dynamically change.
240} 277}
241 278
279bool ProfileManager::RemoveUser(UUID uuid) {
280 auto index = GetUserIndex(uuid);
281 if (index == boost::none) {
282 return false;
283 }
284
285 profiles[*index] = ProfileInfo{};
286 std::stable_partition(profiles.begin(), profiles.end(),
287 [](const ProfileInfo& profile) { return profile.user_uuid; });
288 return true;
289}
290
291bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) {
292 auto index = GetUserIndex(uuid);
293 if (profile_new.user_uuid == UUID(INVALID_UUID) || index == boost::none) {
294 return false;
295 }
296
297 auto& profile = profiles[*index];
298 profile.user_uuid = profile_new.user_uuid;
299 profile.username = profile_new.username;
300 profile.creation_time = profile_new.timestamp;
301
302 return true;
303}
304
305void ProfileManager::ParseUserSaveFile() {
306 FileUtil::IOFile save(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) +
307 ACC_SAVE_AVATORS_BASE_PATH + "profiles.dat",
308 "rb");
309
310 if (!save.IsOpen()) {
311 LOG_WARNING(Service_ACC, "Failed to load profile data from save data... Generating new "
312 "user 'yuzu' with random UUID.");
313 return;
314 }
315
316 ProfileDataRaw data;
317 if (save.ReadBytes(&data, sizeof(ProfileDataRaw)) != sizeof(ProfileDataRaw)) {
318 LOG_WARNING(Service_ACC, "profiles.dat is smaller than expected... Generating new user "
319 "'yuzu' with random UUID.");
320 return;
321 }
322
323 for (std::size_t i = 0; i < MAX_USERS; ++i) {
324 const auto& user = data.users[i];
325
326 if (user.uuid != UUID(INVALID_UUID))
327 AddUser({user.uuid, user.username, user.timestamp, {}, false});
328 }
329
330 std::stable_partition(profiles.begin(), profiles.end(),
331 [](const ProfileInfo& profile) { return profile.user_uuid; });
332}
333
334void ProfileManager::WriteUserSaveFile() {
335 ProfileDataRaw raw{};
336
337 for (std::size_t i = 0; i < MAX_USERS; ++i) {
338 raw.users[i].username = profiles[i].username;
339 raw.users[i].uuid2 = profiles[i].user_uuid;
340 raw.users[i].uuid = profiles[i].user_uuid;
341 raw.users[i].timestamp = profiles[i].creation_time;
342 }
343
344 const auto raw_path =
345 FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + "/system/save/8000000000000010";
346 if (FileUtil::Exists(raw_path) && !FileUtil::IsDirectory(raw_path))
347 FileUtil::Delete(raw_path);
348
349 const auto path = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) +
350 ACC_SAVE_AVATORS_BASE_PATH + "profiles.dat";
351
352 if (!FileUtil::CreateFullPath(path)) {
353 LOG_WARNING(Service_ACC, "Failed to create full path of profiles.dat. Create the directory "
354 "nand/system/save/8000000000000010/su/avators to mitigate this "
355 "issue.");
356 return;
357 }
358
359 FileUtil::IOFile save(path, "wb");
360
361 if (!save.IsOpen()) {
362 LOG_WARNING(Service_ACC, "Failed to write save data to file... No changes to user data "
363 "made in current session will be saved.");
364 return;
365 }
366
367 save.Resize(sizeof(ProfileDataRaw));
368 save.WriteBytes(&raw, sizeof(ProfileDataRaw));
369}
370
242}; // namespace Service::Account 371}; // namespace Service::Account
diff --git a/src/core/hle/service/acc/profile_manager.h b/src/core/hle/service/acc/profile_manager.h
index bffd4cf4d..235208d56 100644
--- a/src/core/hle/service/acc/profile_manager.h
+++ b/src/core/hle/service/acc/profile_manager.h
@@ -36,7 +36,7 @@ struct UUID {
36 } 36 }
37 37
38 // TODO(ogniK): Properly generate uuids based on RFC-4122 38 // TODO(ogniK): Properly generate uuids based on RFC-4122
39 const UUID& Generate(); 39 static UUID Generate();
40 40
41 // Set the UUID to {0,0} to be considered an invalid user 41 // Set the UUID to {0,0} to be considered an invalid user
42 void Invalidate() { 42 void Invalidate() {
@@ -45,6 +45,15 @@ struct UUID {
45 std::string Format() const { 45 std::string Format() const {
46 return fmt::format("0x{:016X}{:016X}", uuid[1], uuid[0]); 46 return fmt::format("0x{:016X}{:016X}", uuid[1], uuid[0]);
47 } 47 }
48
49 std::string FormatSwitch() const {
50 std::array<u8, 16> s{};
51 std::memcpy(s.data(), uuid.data(), sizeof(u128));
52 return fmt::format("{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{"
53 ":02x}{:02x}{:02x}{:02x}{:02x}",
54 s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9], s[10], s[11],
55 s[12], s[13], s[14], s[15]);
56 }
48}; 57};
49static_assert(sizeof(UUID) == 16, "UUID is an invalid size!"); 58static_assert(sizeof(UUID) == 16, "UUID is an invalid size!");
50 59
@@ -81,12 +90,13 @@ static_assert(sizeof(ProfileBase) == 0x38, "ProfileBase is an invalid size");
81/// objects 90/// objects
82class ProfileManager { 91class ProfileManager {
83public: 92public:
84 ProfileManager(); // TODO(ogniK): Load from system save 93 ProfileManager();
85 ~ProfileManager(); 94 ~ProfileManager();
86 95
87 ResultCode AddUser(const ProfileInfo& user); 96 ResultCode AddUser(const ProfileInfo& user);
88 ResultCode CreateNewUser(UUID uuid, const ProfileUsername& username); 97 ResultCode CreateNewUser(UUID uuid, const ProfileUsername& username);
89 ResultCode CreateNewUser(UUID uuid, const std::string& username); 98 ResultCode CreateNewUser(UUID uuid, const std::string& username);
99 boost::optional<UUID> GetUser(std::size_t index) const;
90 boost::optional<std::size_t> GetUserIndex(const UUID& uuid) const; 100 boost::optional<std::size_t> GetUserIndex(const UUID& uuid) const;
91 boost::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const; 101 boost::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const;
92 bool GetProfileBase(boost::optional<std::size_t> index, ProfileBase& profile) const; 102 bool GetProfileBase(boost::optional<std::size_t> index, ProfileBase& profile) const;
@@ -100,6 +110,7 @@ public:
100 std::size_t GetUserCount() const; 110 std::size_t GetUserCount() const;
101 std::size_t GetOpenUserCount() const; 111 std::size_t GetOpenUserCount() const;
102 bool UserExists(UUID uuid) const; 112 bool UserExists(UUID uuid) const;
113 bool UserExistsIndex(std::size_t index) const;
103 void OpenUser(UUID uuid); 114 void OpenUser(UUID uuid);
104 void CloseUser(UUID uuid); 115 void CloseUser(UUID uuid);
105 UserIDArray GetOpenUsers() const; 116 UserIDArray GetOpenUsers() const;
@@ -108,7 +119,13 @@ public:
108 119
109 bool CanSystemRegisterUser() const; 120 bool CanSystemRegisterUser() const;
110 121
122 bool RemoveUser(UUID uuid);
123 bool SetProfileBase(UUID uuid, const ProfileBase& profile);
124
111private: 125private:
126 void ParseUserSaveFile();
127 void WriteUserSaveFile();
128
112 std::array<ProfileInfo, MAX_USERS> profiles{}; 129 std::array<ProfileInfo, MAX_USERS> profiles{};
113 std::size_t user_count = 0; 130 std::size_t user_count = 0;
114 boost::optional<std::size_t> AddToProfiles(const ProfileInfo& profile); 131 boost::optional<std::size_t> AddToProfiles(const ProfileInfo& profile);
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index ecf72ae24..4ed66d817 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -4,11 +4,13 @@
4 4
5#include <array> 5#include <array>
6#include <cinttypes> 6#include <cinttypes>
7#include <cstring>
7#include <stack> 8#include <stack>
8#include "core/core.h" 9#include "core/core.h"
9#include "core/hle/ipc_helpers.h" 10#include "core/hle/ipc_helpers.h"
10#include "core/hle/kernel/event.h" 11#include "core/hle/kernel/event.h"
11#include "core/hle/kernel/process.h" 12#include "core/hle/kernel/process.h"
13#include "core/hle/service/acc/profile_manager.h"
12#include "core/hle/service/am/am.h" 14#include "core/hle/service/am/am.h"
13#include "core/hle/service/am/applet_ae.h" 15#include "core/hle/service/am/applet_ae.h"
14#include "core/hle/service/am/applet_oe.h" 16#include "core/hle/service/am/applet_oe.h"
@@ -26,6 +28,16 @@
26 28
27namespace Service::AM { 29namespace Service::AM {
28 30
31constexpr u32 POP_LAUNCH_PARAMETER_MAGIC = 0xC79497CA;
32
33struct LaunchParameters {
34 u32_le magic;
35 u32_le is_account_selected;
36 u128 current_user;
37 INSERT_PADDING_BYTES(0x70);
38};
39static_assert(sizeof(LaunchParameters) == 0x88);
40
29IWindowController::IWindowController() : ServiceFramework("IWindowController") { 41IWindowController::IWindowController() : ServiceFramework("IWindowController") {
30 // clang-format off 42 // clang-format off
31 static const FunctionInfo functions[] = { 43 static const FunctionInfo functions[] = {
@@ -724,20 +736,23 @@ void IApplicationFunctions::EndBlockingHomeButton(Kernel::HLERequestContext& ctx
724} 736}
725 737
726void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) { 738void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
727 constexpr std::array<u8, 0x88> data{{ 739 LaunchParameters params{};
728 0xca, 0x97, 0x94, 0xc7, // Magic
729 1, 0, 0, 0, // IsAccountSelected (bool)
730 1, 0, 0, 0, // User Id (word 0)
731 0, 0, 0, 0, // User Id (word 1)
732 0, 0, 0, 0, // User Id (word 2)
733 0, 0, 0, 0 // User Id (word 3)
734 }};
735 740
736 std::vector<u8> buffer(data.begin(), data.end()); 741 params.magic = POP_LAUNCH_PARAMETER_MAGIC;
742 params.is_account_selected = 1;
743
744 Account::ProfileManager profile_manager{};
745 const auto uuid = profile_manager.GetUser(Settings::values.current_user);
746 ASSERT(uuid != boost::none);
747 params.current_user = uuid->uuid;
737 748
738 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 749 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
739 750
740 rb.Push(RESULT_SUCCESS); 751 rb.Push(RESULT_SUCCESS);
752
753 std::vector<u8> buffer(sizeof(LaunchParameters));
754 std::memcpy(buffer.data(), &params, buffer.size());
755
741 rb.PushIpcInterface<AM::IStorage>(buffer); 756 rb.PushIpcInterface<AM::IStorage>(buffer);
742 757
743 LOG_DEBUG(Service_AM, "called"); 758 LOG_DEBUG(Service_AM, "called");
diff --git a/src/core/settings.h b/src/core/settings.h
index ca80718e2..b5aeff29b 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -114,7 +114,7 @@ struct Values {
114 // System 114 // System
115 bool use_docked_mode; 115 bool use_docked_mode;
116 bool enable_nfc; 116 bool enable_nfc;
117 std::string username; 117 int current_user;
118 int language_index; 118 int language_index;
119 119
120 // Controls 120 // Controls