From 4620fa93d80c1cd866e20ce824e02fda2aaa6829 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Wed, 8 Jan 2025 22:11:10 +0100 Subject: [PATCH] [XAM] Added XamProfileOpen support and xam_profile.cc dedicated file for XamProfile exports - Modified implementation of MountProfile to allow custom mount paths --- src/xenia/kernel/xam/profile_manager.cc | 7 +++-- src/xenia/kernel/xam/profile_manager.h | 2 +- .../kernel/xam/xam_module_export_groups.inc | 1 + src/xenia/kernel/xam/xam_profile.cc | 31 +++++++++++++++++++ 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 src/xenia/kernel/xam/xam_profile.cc diff --git a/src/xenia/kernel/xam/profile_manager.cc b/src/xenia/kernel/xam/profile_manager.cc index c5cf26272..0774aab0c 100644 --- a/src/xenia/kernel/xam/profile_manager.cc +++ b/src/xenia/kernel/xam/profile_manager.cc @@ -253,9 +253,12 @@ void ProfileManager::ModifyGamertag(const uint64_t xuid, std::string gamertag) { DismountProfile(xuid); } -bool ProfileManager::MountProfile(const uint64_t xuid) { +bool ProfileManager::MountProfile(const uint64_t xuid, std::string mount_path) { std::filesystem::path profile_path = GetProfilePath(xuid); - std::string mount_path = fmt::format("{:016X}", xuid) + ':'; + if (mount_path.empty()) { + mount_path = fmt::format("{:016X}", xuid); + } + mount_path += ':'; auto device = std::make_unique(mount_path, profile_path, false); diff --git a/src/xenia/kernel/xam/profile_manager.h b/src/xenia/kernel/xam/profile_manager.h index 8be96b596..7e085c257 100644 --- a/src/xenia/kernel/xam/profile_manager.h +++ b/src/xenia/kernel/xam/profile_manager.h @@ -86,7 +86,7 @@ class ProfileManager { void ModifyGamertag(const uint64_t xuid, std::string gamertag); - bool MountProfile(const uint64_t xuid); + bool MountProfile(const uint64_t xuid, std::string mount_path = ""); bool DismountProfile(const uint64_t xuid); void Login(const uint64_t xuid, const uint8_t user_index = XUserIndexAny, diff --git a/src/xenia/kernel/xam/xam_module_export_groups.inc b/src/xenia/kernel/xam/xam_module_export_groups.inc index 1795f7259..7708691d6 100644 --- a/src/xenia/kernel/xam/xam_module_export_groups.inc +++ b/src/xenia/kernel/xam/xam_module_export_groups.inc @@ -24,6 +24,7 @@ XE_MODULE_EXPORT_GROUP(xam, Net) XE_MODULE_EXPORT_GROUP(xam, Notify) XE_MODULE_EXPORT_GROUP(xam, NUI) XE_MODULE_EXPORT_GROUP(xam, Party) +XE_MODULE_EXPORT_GROUP(xam, Profile) XE_MODULE_EXPORT_GROUP(xam, Task) XE_MODULE_EXPORT_GROUP(xam, UI) XE_MODULE_EXPORT_GROUP(xam, User) diff --git a/src/xenia/kernel/xam/xam_profile.cc b/src/xenia/kernel/xam/xam_profile.cc new file mode 100644 index 000000000..7940b2e80 --- /dev/null +++ b/src/xenia/kernel/xam/xam_profile.cc @@ -0,0 +1,31 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2025 Xenia Canary. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include "xenia/kernel/kernel_state.h" +#include "xenia/kernel/util/shim_utils.h" +#include "xenia/kernel/xam/xam_private.h" + +namespace xe { +namespace kernel { +namespace xam { + +dword_result_t XamProfileOpen_entry(qword_t xuid, lpstring_t mount_path) { + const bool result = + kernel_state()->xam_state()->profile_manager()->MountProfile( + xuid, mount_path.value()); + + return result ? X_ERROR_SUCCESS : X_ERROR_INVALID_PARAMETER; +} +DECLARE_XAM_EXPORT1(XamProfileOpen, kNone, kImplemented); + +} // namespace xam +} // namespace kernel +} // namespace xe + +DECLARE_XAM_EMPTY_REGISTER_EXPORTS(Profile); \ No newline at end of file