From 05ae4ac6e932f7a13630c02f5f59154a4e68c73c Mon Sep 17 00:00:00 2001 From: Adrian <78108584+AdrianCassar@users.noreply.github.com> Date: Sun, 24 Nov 2024 14:50:09 +0000 Subject: [PATCH] [XAM] Implemented XamUserGetUserFlags & XamUserGetUserFlagsFromXUID --- src/xenia/kernel/xam/user_profile.h | 2 ++ src/xenia/kernel/xam/xam_user.cc | 23 +++++++++++++++++++++++ src/xenia/xbox.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/src/xenia/kernel/xam/user_profile.h b/src/xenia/kernel/xam/user_profile.h index 7b940e6f0..b78367d4d 100644 --- a/src/xenia/kernel/xam/user_profile.h +++ b/src/xenia/kernel/xam/user_profile.h @@ -160,6 +160,8 @@ class UserProfile { uint32_t signin_state() const { return 1; } uint32_t type() const { return 1 | 2; /* local | online profile? */ } + uint32_t GetCachedFlags() const { return account_info_.GetCachedFlags(); }; + void AddSetting(std::unique_ptr setting); UserSetting* GetSetting(uint32_t setting_id); diff --git a/src/xenia/kernel/xam/xam_user.cc b/src/xenia/kernel/xam/xam_user.cc index f92e8525a..0b8b65939 100644 --- a/src/xenia/kernel/xam/xam_user.cc +++ b/src/xenia/kernel/xam/xam_user.cc @@ -707,6 +707,29 @@ dword_result_t XamUserGetSubscriptionType_entry(dword_t user_index, } DECLARE_XAM_EXPORT1(XamUserGetSubscriptionType, kUserProfiles, kStub); +dword_result_t XamUserGetUserFlags_entry(dword_t user_index) { + if (!kernel_state()->xam_state()->IsUserSignedIn(user_index)) { + return 0; + } + + const auto& user_profile = + kernel_state()->xam_state()->GetUserProfile(user_index); + + return user_profile->GetCachedFlags(); +} +DECLARE_XAM_EXPORT1(XamUserGetUserFlags, kUserProfiles, kImplemented); + +dword_result_t XamUserGetUserFlagsFromXUID_entry(qword_t xuid) { + if (!kernel_state()->xam_state()->IsUserSignedIn(xuid)) { + return 0; + } + + const auto& user_profile = kernel_state()->xam_state()->GetUserProfile(xuid); + + return user_profile->GetCachedFlags(); +} +DECLARE_XAM_EXPORT1(XamUserGetUserFlagsFromXUID, kUserProfiles, kImplemented); + constexpr uint8_t kStatsMaxAmount = 64; struct X_STATS_DETAILS { diff --git a/src/xenia/xbox.h b/src/xenia/xbox.h index b7307b98e..4f10728c6 100644 --- a/src/xenia/xbox.h +++ b/src/xenia/xbox.h @@ -620,6 +620,8 @@ struct X_XAMACCOUNTINFO { AccountReservedFlags::kLiveEnabled); } + uint32_t GetCachedFlags() const { return cached_user_flags; }; + uint32_t GetCountry() const { return (cached_user_flags & kCountryMask) >> 8; }