[Kernel] Removed XAM specific entities from KernelState
This commit is contained in:
committed by
Radosław Gliński
parent
6f65ec382c
commit
e409a384ec
91
src/xenia/kernel/xam/achievement_manager.cc
Normal file
91
src/xenia/kernel/xam/achievement_manager.cc
Normal file
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2023 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "achievement_manager.h"
|
||||
#include "xenia/emulator.h"
|
||||
#include "xenia/gpu/graphics_system.h"
|
||||
#include "xenia/kernel/kernel_state.h"
|
||||
#include "xenia/kernel/util/shim_utils.h"
|
||||
#include "xenia/ui/imgui_guest_notification.h"
|
||||
|
||||
DEFINE_bool(show_achievement_notification, false,
|
||||
"Show achievement notification on screen.", "UI");
|
||||
|
||||
DECLARE_int32(user_language);
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xam {
|
||||
|
||||
AchievementManager::AchievementManager() { unlocked_achievements.clear(); };
|
||||
|
||||
void AchievementManager::EarnAchievement(uint64_t xuid, uint32_t title_id,
|
||||
uint32_t achievement_id) {
|
||||
if (IsAchievementUnlocked(achievement_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Emulator* emulator = kernel_state()->emulator();
|
||||
ui::WindowedAppContext& app_context =
|
||||
kernel_state()->emulator()->display_window()->app_context();
|
||||
ui::ImGuiDrawer* imgui_drawer = emulator->imgui_drawer();
|
||||
|
||||
const util::XdbfGameData title_xdbf = kernel_state()->title_xdbf();
|
||||
const util::XdbfAchievementTableEntry achievement =
|
||||
title_xdbf.GetAchievement(achievement_id);
|
||||
|
||||
if (!achievement.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
const XLanguage title_language = title_xdbf.GetExistingLanguage(
|
||||
static_cast<XLanguage>(cvars::user_language));
|
||||
|
||||
const std::string label =
|
||||
title_xdbf.GetStringTableEntry(title_language, achievement.label_id);
|
||||
const std::string desc = title_xdbf.GetStringTableEntry(
|
||||
title_language, achievement.description_id);
|
||||
|
||||
XELOGI("Achievement unlocked: {}", label);
|
||||
|
||||
unlocked_achievements[achievement_id] = Clock::QueryHostSystemTime();
|
||||
// Even if we disable popup we still should store info that this
|
||||
// achievement was earned.
|
||||
if (!cvars::show_achievement_notification) {
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string description =
|
||||
fmt::format("{}G - {}", achievement.gamerscore, label);
|
||||
|
||||
app_context.CallInUIThread([imgui_drawer, description]() {
|
||||
new xe::ui::AchievementNotificationWindow(
|
||||
imgui_drawer, "Achievement unlocked", description, 0,
|
||||
kernel_state()->notification_position_);
|
||||
});
|
||||
}
|
||||
|
||||
bool AchievementManager::IsAchievementUnlocked(uint32_t achievement_id) {
|
||||
auto itr = unlocked_achievements.find(achievement_id);
|
||||
|
||||
return itr != unlocked_achievements.cend();
|
||||
}
|
||||
|
||||
uint64_t AchievementManager::GetAchievementUnlockTime(uint32_t achievement_id) {
|
||||
auto itr = unlocked_achievements.find(achievement_id);
|
||||
if (itr == unlocked_achievements.cend()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
} // namespace xam
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
63
src/xenia/kernel/xam/achievement_manager.h
Normal file
63
src/xenia/kernel/xam/achievement_manager.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2023 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_XAM_ACHIEVEMENT_MANAGER_H_
|
||||
#define XENIA_KERNEL_XAM_ACHIEVEMENT_MANAGER_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/xbox.h"
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xam {
|
||||
|
||||
// TODO(gibbed): probably a FILETIME/LARGE_INTEGER, unknown currently
|
||||
struct X_ACHIEVEMENT_UNLOCK_TIME {
|
||||
xe::be<uint32_t> unk_0;
|
||||
xe::be<uint32_t> unk_4;
|
||||
};
|
||||
|
||||
struct X_ACHIEVEMENT_DETAILS {
|
||||
xe::be<uint32_t> id;
|
||||
xe::be<uint32_t> label_ptr;
|
||||
xe::be<uint32_t> description_ptr;
|
||||
xe::be<uint32_t> unachieved_ptr;
|
||||
xe::be<uint32_t> image_id;
|
||||
xe::be<uint32_t> gamerscore;
|
||||
X_ACHIEVEMENT_UNLOCK_TIME unlock_time;
|
||||
xe::be<uint32_t> flags;
|
||||
|
||||
static const size_t kStringBufferSize = 464;
|
||||
};
|
||||
static_assert_size(X_ACHIEVEMENT_DETAILS, 36);
|
||||
|
||||
class AchievementManager {
|
||||
public:
|
||||
AchievementManager();
|
||||
|
||||
void EarnAchievement(uint64_t xuid, uint32_t title_id,
|
||||
uint32_t achievement_id);
|
||||
|
||||
bool IsAchievementUnlocked(uint32_t achievement_id);
|
||||
uint64_t GetAchievementUnlockTime(uint32_t achievement_id);
|
||||
|
||||
private:
|
||||
std::map<uint32_t, uint64_t> unlocked_achievements;
|
||||
// void Load();
|
||||
// void Save();
|
||||
};
|
||||
|
||||
} // namespace xam
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_KERNEL_XAM_ACHIEVEMENT_MANAGER_H_
|
||||
@@ -54,7 +54,8 @@ X_HRESULT XgiApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
|
||||
XELOGD("XGIUserSetContextEx: {} - Set to value: {}", desc,
|
||||
context_value);
|
||||
|
||||
UserProfile* user_profile = kernel_state_->user_profile(user_index);
|
||||
UserProfile* user_profile =
|
||||
kernel_state_->xam_state()->GetUserProfile(user_index);
|
||||
if (user_profile) {
|
||||
user_profile->contexts_[context_id] = context_value;
|
||||
}
|
||||
@@ -81,7 +82,7 @@ X_HRESULT XgiApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
|
||||
Property(property_id, value_size,
|
||||
memory_->TranslateVirtual<uint8_t*>(value_ptr));
|
||||
|
||||
auto user = kernel_state_->user_profile(user_index);
|
||||
auto user = kernel_state_->xam_state()->GetUserProfile(user_index);
|
||||
if (user) {
|
||||
user->AddProperty(&property);
|
||||
}
|
||||
@@ -197,7 +198,8 @@ X_HRESULT XgiApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
|
||||
context_ptr, context_id);
|
||||
uint32_t value = 0;
|
||||
if (context) {
|
||||
UserProfile* user_profile = kernel_state_->user_profile(user_index);
|
||||
UserProfile* user_profile =
|
||||
kernel_state_->xam_state()->GetUserProfile(user_index);
|
||||
if (user_profile) {
|
||||
if (user_profile->contexts_.find(context_id) !=
|
||||
user_profile->contexts_.cend()) {
|
||||
|
||||
@@ -275,7 +275,9 @@ X_RESULT ContentManager::ReadContentHeaderFile(const std::string_view file_name,
|
||||
// usually requires title_id to be provided
|
||||
// Kinda simple workaround for that, but still assumption
|
||||
data.title_id = title_id;
|
||||
data.unk134 = kernel_state_->user_profile(uint32_t(0))->xuid();
|
||||
data.xuid = kernel_state_->xam_state()
|
||||
->GetUserProfile(static_cast<uint32_t>(0))
|
||||
->xuid();
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
return X_STATUS_NO_SUCH_FILE;
|
||||
@@ -400,8 +402,9 @@ X_RESULT ContentManager::DeleteContent(const XCONTENT_AGGREGATE_DATA& data) {
|
||||
|
||||
std::filesystem::path ContentManager::ResolveGameUserContentPath() {
|
||||
auto title_id = fmt::format("{:08X}", kernel_state_->title_id());
|
||||
auto user_name =
|
||||
xe::to_path(kernel_state_->user_profile(uint32_t(0))->name());
|
||||
auto user_name = xe::to_path(kernel_state_->xam_state()
|
||||
->GetUserProfile(static_cast<uint32_t>(0))
|
||||
->name());
|
||||
|
||||
// Per-game per-profile data location:
|
||||
// content_root/title_id/profile/user_name
|
||||
|
||||
@@ -94,7 +94,7 @@ struct XCONTENT_DATA {
|
||||
static_assert_size(XCONTENT_DATA, 0x134);
|
||||
|
||||
struct XCONTENT_AGGREGATE_DATA : XCONTENT_DATA {
|
||||
be<uint64_t> unk134; // some titles store XUID here?
|
||||
be<uint64_t> xuid; // some titles store XUID here?
|
||||
be<uint32_t> title_id;
|
||||
|
||||
XCONTENT_AGGREGATE_DATA() = default;
|
||||
@@ -104,7 +104,7 @@ struct XCONTENT_AGGREGATE_DATA : XCONTENT_DATA {
|
||||
set_display_name(other.display_name());
|
||||
set_file_name(other.file_name());
|
||||
padding[0] = padding[1] = 0;
|
||||
unk134 = 0;
|
||||
xuid = 0;
|
||||
title_id = kCurrentlyRunningTitleId;
|
||||
}
|
||||
|
||||
|
||||
@@ -334,8 +334,9 @@ dword_result_t XamContentGetCreator_entry(dword_t user_index,
|
||||
// User always creates saves.
|
||||
*is_creator_ptr = 1;
|
||||
if (creator_xuid_ptr) {
|
||||
if (kernel_state()->IsUserSignedIn(user_index)) {
|
||||
const auto& user_profile = kernel_state()->user_profile(user_index);
|
||||
if (kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
const auto& user_profile =
|
||||
kernel_state()->xam_state()->GetUserProfile(user_index);
|
||||
*creator_xuid_ptr = user_profile->xuid();
|
||||
} else {
|
||||
result = X_ERROR_NO_SUCH_USER;
|
||||
|
||||
@@ -234,7 +234,7 @@ X_HRESULT_result_t XamUserGetDeviceContext_entry(dword_t user_index,
|
||||
// If this function fails they assume zero, so let's fail AND
|
||||
// set zero just to be safe.
|
||||
*out_ptr = 0;
|
||||
if (kernel_state()->IsUserSignedIn(user_index) ||
|
||||
if (kernel_state()->xam_state()->IsUserSignedIn(user_index) ||
|
||||
(user_index & 0xFF) == 0xFF) {
|
||||
*out_ptr = (uint32_t)user_index;
|
||||
return X_E_SUCCESS;
|
||||
|
||||
95
src/xenia/kernel/xam/xam_state.cc
Normal file
95
src/xenia/kernel/xam/xam_state.cc
Normal file
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2024 Xenia Canary. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "xenia/kernel/xam/xam_state.h"
|
||||
#include "xenia/emulator.h"
|
||||
|
||||
DEFINE_uint32(max_signed_profiles, 4,
|
||||
"Limits how many profiles can be assigned. Possible values: 1-4",
|
||||
"Kernel");
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xam {
|
||||
|
||||
XamState::XamState(Emulator* emulator, KernelState* kernel_state)
|
||||
: kernel_state_(kernel_state) {
|
||||
app_manager_ = std::make_unique<AppManager>();
|
||||
|
||||
auto content_root = emulator->content_root();
|
||||
if (!content_root.empty()) {
|
||||
content_root = std::filesystem::absolute(content_root);
|
||||
}
|
||||
content_manager_ =
|
||||
std::make_unique<ContentManager>(kernel_state, content_root);
|
||||
|
||||
user_profiles_.emplace(0, std::make_unique<xam::UserProfile>(0));
|
||||
|
||||
achievement_manager_ = std::make_unique<AchievementManager>();
|
||||
|
||||
AppManager::RegisterApps(kernel_state, app_manager_.get());
|
||||
}
|
||||
|
||||
XamState::~XamState() {
|
||||
app_manager_.reset();
|
||||
achievement_manager_.reset();
|
||||
content_manager_.reset();
|
||||
}
|
||||
|
||||
UserProfile* XamState::GetUserProfile(uint32_t user_index) const {
|
||||
if (!IsUserSignedIn(user_index)) {
|
||||
return nullptr;
|
||||
}
|
||||
return user_profiles_.at(user_index).get();
|
||||
}
|
||||
|
||||
UserProfile* XamState::GetUserProfile(uint64_t xuid) const {
|
||||
for (const auto& [key, value] : user_profiles_) {
|
||||
if (value->xuid() == xuid) {
|
||||
return user_profiles_.at(key).get();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void XamState::UpdateUsedUserProfiles() {
|
||||
const std::bitset<4> used_slots = kernel_state_->GetConnectedUsers();
|
||||
|
||||
const uint32_t signed_profile_count =
|
||||
std::max(static_cast<uint32_t>(1),
|
||||
std::min(static_cast<uint32_t>(4), cvars::max_signed_profiles));
|
||||
|
||||
for (uint32_t i = 1; i < signed_profile_count; i++) {
|
||||
bool is_used = used_slots.test(i);
|
||||
|
||||
if (IsUserSignedIn(i) && !is_used) {
|
||||
user_profiles_.erase(i);
|
||||
kernel_state_->BroadcastNotification(
|
||||
kXNotificationIDSystemInputDevicesChanged, 0);
|
||||
}
|
||||
|
||||
if (!IsUserSignedIn(i) && is_used) {
|
||||
user_profiles_.emplace(i, std::make_unique<xam::UserProfile>(i));
|
||||
kernel_state_->BroadcastNotification(
|
||||
kXNotificationIDSystemInputDevicesChanged, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool XamState::IsUserSignedIn(uint32_t user_index) const {
|
||||
return user_profiles_.find(user_index) != user_profiles_.cend();
|
||||
}
|
||||
|
||||
bool XamState::IsUserSignedIn(uint64_t xuid) const {
|
||||
return GetUserProfile(xuid) != nullptr;
|
||||
}
|
||||
|
||||
} // namespace xam
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
66
src/xenia/kernel/xam/xam_state.h
Normal file
66
src/xenia/kernel/xam/xam_state.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2024 Xenia Canary. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_XAM_XAM_STATE_H_
|
||||
#define XENIA_KERNEL_XAM_XAM_STATE_H_
|
||||
|
||||
#include <memory>
|
||||
#include "xenia/kernel/xam/achievement_manager.h"
|
||||
#include "xenia/kernel/xam/app_manager.h"
|
||||
#include "xenia/kernel/xam/content_manager.h"
|
||||
#include "xenia/kernel/xam/user_profile.h"
|
||||
|
||||
namespace xe {
|
||||
class Emulator;
|
||||
};
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
class KernelState;
|
||||
}
|
||||
} // namespace xe
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xam {
|
||||
|
||||
class XamState {
|
||||
public:
|
||||
XamState(Emulator* emulator, KernelState* kernel_state);
|
||||
~XamState();
|
||||
|
||||
AppManager* app_manager() const { return app_manager_.get(); }
|
||||
ContentManager* content_manager() const { return content_manager_.get(); }
|
||||
AchievementManager* achievement_manager() const {
|
||||
return achievement_manager_.get();
|
||||
}
|
||||
|
||||
UserProfile* GetUserProfile(uint32_t user_index) const;
|
||||
UserProfile* GetUserProfile(uint64_t xuid) const;
|
||||
|
||||
void UpdateUsedUserProfiles();
|
||||
|
||||
bool IsUserSignedIn(uint32_t user_index) const;
|
||||
bool IsUserSignedIn(uint64_t xuid) const;
|
||||
|
||||
private:
|
||||
KernelState* kernel_state_;
|
||||
|
||||
std::unique_ptr<AppManager> app_manager_;
|
||||
std::unique_ptr<ContentManager> content_manager_;
|
||||
std::unique_ptr<AchievementManager> achievement_manager_;
|
||||
|
||||
std::map<uint8_t, std::unique_ptr<UserProfile>> user_profiles_;
|
||||
};
|
||||
|
||||
} // namespace xam
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
#endif
|
||||
@@ -574,7 +574,8 @@ dword_result_t XamShowDeviceSelectorUI_entry(
|
||||
return X_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (user_index != 0xFF && !kernel_state()->IsUserSignedIn(user_index)) {
|
||||
if (user_index != 0xFF &&
|
||||
!kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
kernel_state()->CompleteOverlappedImmediate(overlapped,
|
||||
X_ERROR_NO_SUCH_USER);
|
||||
return X_ERROR_IO_PENDING;
|
||||
@@ -682,7 +683,7 @@ dword_result_t XamShowMarketplaceUI_entry(dword_t user_index, dword_t ui_type,
|
||||
return X_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (!kernel_state()->IsUserSignedIn(user_index)) {
|
||||
if (!kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
return X_ERROR_NO_SUCH_USER;
|
||||
}
|
||||
|
||||
@@ -758,7 +759,7 @@ dword_result_t XamShowMarketplaceDownloadItemsUI_entry(
|
||||
return X_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (!kernel_state()->IsUserSignedIn(user_index)) {
|
||||
if (!kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
if (overlapped) {
|
||||
kernel_state()->CompleteOverlappedImmediate(overlapped,
|
||||
X_ERROR_NO_SUCH_USER);
|
||||
|
||||
@@ -36,8 +36,9 @@ X_HRESULT_result_t XamUserGetXUID_entry(dword_t user_index, dword_t type_mask,
|
||||
uint32_t result = X_E_NO_SUCH_USER;
|
||||
uint64_t xuid = 0;
|
||||
if (user_index < 4) {
|
||||
if (kernel_state()->IsUserSignedIn(user_index)) {
|
||||
const auto& user_profile = kernel_state()->user_profile(user_index);
|
||||
if (kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
const auto& user_profile =
|
||||
kernel_state()->xam_state()->GetUserProfile(user_index);
|
||||
auto type = user_profile->type() & type_mask;
|
||||
if (type & (2 | 4)) {
|
||||
// maybe online profile?
|
||||
@@ -62,8 +63,9 @@ dword_result_t XamUserGetSigninState_entry(dword_t user_index) {
|
||||
xe::threading::MaybeYield();
|
||||
uint32_t signin_state = 0;
|
||||
if (user_index < 4) {
|
||||
if (kernel_state()->IsUserSignedIn(user_index)) {
|
||||
const auto& user_profile = kernel_state()->user_profile(user_index);
|
||||
if (kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
const auto& user_profile =
|
||||
kernel_state()->xam_state()->GetUserProfile(user_index);
|
||||
signin_state = user_profile->signin_state();
|
||||
}
|
||||
}
|
||||
@@ -93,10 +95,11 @@ X_HRESULT_result_t XamUserGetSigninInfo_entry(
|
||||
return X_E_NO_SUCH_USER;
|
||||
}
|
||||
|
||||
kernel_state()->UpdateUsedUserProfiles();
|
||||
kernel_state()->xam_state()->UpdateUsedUserProfiles();
|
||||
|
||||
if (kernel_state()->IsUserSignedIn(user_index)) {
|
||||
const auto& user_profile = kernel_state()->user_profile(user_index);
|
||||
if (kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
const auto& user_profile =
|
||||
kernel_state()->xam_state()->GetUserProfile(user_index);
|
||||
info->xuid = user_profile->xuid();
|
||||
info->signin_state = user_profile->signin_state();
|
||||
xe::string_util::copy_truncating(info->name, user_profile->name(),
|
||||
@@ -114,8 +117,9 @@ dword_result_t XamUserGetName_entry(dword_t user_index, lpstring_t buffer,
|
||||
return X_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (kernel_state()->IsUserSignedIn(user_index)) {
|
||||
const auto& user_profile = kernel_state()->user_profile(user_index);
|
||||
if (kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
const auto& user_profile =
|
||||
kernel_state()->xam_state()->GetUserProfile(user_index);
|
||||
const auto& user_name = user_profile->name();
|
||||
xe::string_util::copy_truncating(
|
||||
buffer, user_name, std::min(buffer_len.value(), uint32_t(16)));
|
||||
@@ -138,11 +142,12 @@ dword_result_t XamUserGetGamerTag_entry(dword_t user_index,
|
||||
return X_E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (!kernel_state()->IsUserSignedIn(user_index)) {
|
||||
if (!kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
return X_E_INVALIDARG;
|
||||
}
|
||||
|
||||
const auto& user_profile = kernel_state()->user_profile(user_index);
|
||||
const auto& user_profile =
|
||||
kernel_state()->xam_state()->GetUserProfile(user_index);
|
||||
auto user_name = xe::to_utf16(user_profile->name());
|
||||
xe::string_util::copy_and_swap_truncating(
|
||||
buffer, user_name, std::min(buffer_len.value(), uint32_t(16)));
|
||||
@@ -173,8 +178,9 @@ uint32_t XamUserReadProfileSettingsEx(uint32_t title_id, uint32_t user_index,
|
||||
// TODO(gibbed): we assert here, but in case a title passes xuid_count > 1
|
||||
// until it's implemented for release builds...
|
||||
xuid_count = 1;
|
||||
if (kernel_state()->IsUserSignedIn(user_index)) {
|
||||
const auto& user_profile = kernel_state()->user_profile(user_index);
|
||||
if (kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
const auto& user_profile =
|
||||
kernel_state()->xam_state()->GetUserProfile(user_index);
|
||||
assert_true(static_cast<uint64_t>(xuids[0]) == user_profile->xuid());
|
||||
}
|
||||
}
|
||||
@@ -227,7 +233,7 @@ uint32_t XamUserReadProfileSettingsEx(uint32_t title_id, uint32_t user_index,
|
||||
|
||||
// Title ID = 0 means us.
|
||||
// 0xfffe07d1 = profile?
|
||||
if (!kernel_state()->IsUserSignedIn(user_index) && !xuids) {
|
||||
if (!kernel_state()->xam_state()->IsUserSignedIn(user_index) && !xuids) {
|
||||
if (overlapped) {
|
||||
kernel_state()->CompleteOverlappedImmediate(
|
||||
kernel_state()->memory()->HostToGuestVirtual(overlapped),
|
||||
@@ -237,11 +243,11 @@ uint32_t XamUserReadProfileSettingsEx(uint32_t title_id, uint32_t user_index,
|
||||
return X_ERROR_NO_SUCH_USER;
|
||||
}
|
||||
|
||||
auto user_profile = kernel_state()->user_profile(user_index);
|
||||
auto user_profile = kernel_state()->xam_state()->GetUserProfile(user_index);
|
||||
|
||||
if (xuids) {
|
||||
uint64_t user_xuid = static_cast<uint64_t>(xuids[0]);
|
||||
if (!kernel_state()->IsUserSignedIn(user_xuid)) {
|
||||
if (!kernel_state()->xam_state()->IsUserSignedIn(user_xuid)) {
|
||||
if (overlapped) {
|
||||
kernel_state()->CompleteOverlappedImmediate(
|
||||
kernel_state()->memory()->HostToGuestVirtual(overlapped),
|
||||
@@ -250,7 +256,7 @@ uint32_t XamUserReadProfileSettingsEx(uint32_t title_id, uint32_t user_index,
|
||||
}
|
||||
return X_ERROR_NO_SUCH_USER;
|
||||
}
|
||||
user_profile = kernel_state()->user_profile(user_xuid);
|
||||
user_profile = kernel_state()->xam_state()->GetUserProfile(user_xuid);
|
||||
}
|
||||
|
||||
// First call asks for size (fill buffer_size_ptr).
|
||||
@@ -361,7 +367,8 @@ dword_result_t XamUserWriteProfileSettings_entry(
|
||||
return X_ERROR_SUCCESS;
|
||||
}
|
||||
// Update and save settings.
|
||||
const auto& user_profile = kernel_state()->user_profile(user_index);
|
||||
const auto& user_profile =
|
||||
kernel_state()->xam_state()->GetUserProfile(user_index);
|
||||
|
||||
for (uint32_t n = 0; n < setting_count; ++n) {
|
||||
const X_USER_PROFILE_SETTING& setting = settings[n];
|
||||
@@ -429,7 +436,7 @@ dword_result_t XamUserCheckPrivilege_entry(dword_t user_index, dword_t mask,
|
||||
return X_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (!kernel_state()->IsUserSignedIn(user_index)) {
|
||||
if (!kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
return X_ERROR_NO_SUCH_USER;
|
||||
}
|
||||
}
|
||||
@@ -442,7 +449,7 @@ DECLARE_XAM_EXPORT1(XamUserCheckPrivilege, kUserProfiles, kStub);
|
||||
|
||||
dword_result_t XamUserContentRestrictionGetFlags_entry(dword_t user_index,
|
||||
lpdword_t out_flags) {
|
||||
if (!kernel_state()->IsUserSignedIn(user_index)) {
|
||||
if (!kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
return X_ERROR_NO_SUCH_USER;
|
||||
}
|
||||
|
||||
@@ -456,7 +463,7 @@ dword_result_t XamUserContentRestrictionGetRating_entry(dword_t user_index,
|
||||
dword_t unk1,
|
||||
lpdword_t out_unk2,
|
||||
lpdword_t out_unk3) {
|
||||
if (!kernel_state()->IsUserSignedIn(user_index)) {
|
||||
if (!kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
return X_ERROR_NO_SUCH_USER;
|
||||
}
|
||||
|
||||
@@ -491,7 +498,7 @@ dword_result_t XamUserGetMembershipTier_entry(dword_t user_index) {
|
||||
return X_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (!kernel_state()->IsUserSignedIn(user_index)) {
|
||||
if (!kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
return X_ERROR_NO_SUCH_USER;
|
||||
}
|
||||
return 6 /* 6 appears to be Gold */;
|
||||
@@ -507,8 +514,9 @@ dword_result_t XamUserAreUsersFriends_entry(dword_t user_index, dword_t unk1,
|
||||
if (user_index >= 4) {
|
||||
result = X_ERROR_INVALID_PARAMETER;
|
||||
} else {
|
||||
if (kernel_state()->IsUserSignedIn(user_index)) {
|
||||
const auto& user_profile = kernel_state()->user_profile(user_index);
|
||||
if (kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
const auto& user_profile =
|
||||
kernel_state()->xam_state()->GetUserProfile(user_index);
|
||||
if (user_profile->signin_state() == 0) {
|
||||
result = X_ERROR_NOT_LOGGED_ON;
|
||||
} else {
|
||||
@@ -545,7 +553,7 @@ DECLARE_XAM_EXPORT1(XamUserAreUsersFriends, kUserProfiles, kStub);
|
||||
dword_result_t XamShowSigninUI_entry(dword_t users_needed, dword_t unk_mask) {
|
||||
// XN_SYS_UI (on)
|
||||
kernel_state()->BroadcastNotification(kXNotificationIDSystemUI, 1);
|
||||
kernel_state()->UpdateUsedUserProfiles();
|
||||
kernel_state()->xam_state()->UpdateUsedUserProfiles();
|
||||
// Mask values vary. Probably matching user types? Local/remote?
|
||||
// Games seem to sit and loop until we trigger this notification:
|
||||
|
||||
@@ -554,7 +562,7 @@ dword_result_t XamShowSigninUI_entry(dword_t users_needed, dword_t unk_mask) {
|
||||
uint32_t active_users = 0;
|
||||
|
||||
for (uint32_t i = 0; i < 4; i++) {
|
||||
if (kernel_state()->IsUserSignedIn(i)) {
|
||||
if (kernel_state()->xam_state()->IsUserSignedIn(i)) {
|
||||
user_mask |= (1 << i);
|
||||
active_users++;
|
||||
if (active_users >= users_needed) break;
|
||||
@@ -773,4 +781,4 @@ DECLARE_XAM_EXPORT1(XamUserCreateStatsEnumerator, kUserProfiles, kSketchy);
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
DECLARE_XAM_EMPTY_REGISTER_EXPORTS(User);
|
||||
DECLARE_XAM_EMPTY_REGISTER_EXPORTS(User);
|
||||
Reference in New Issue
Block a user