[XAM/User] Store profile inside content root instead of next to EXE
eg. Documents/Xenia/content/profile/
This commit is contained in:
parent
5476aad0fc
commit
af738683bc
|
@ -48,7 +48,7 @@ KernelState::KernelState(Emulator* emulator)
|
||||||
file_system_ = emulator->file_system();
|
file_system_ = emulator->file_system();
|
||||||
|
|
||||||
app_manager_ = std::make_unique<xam::AppManager>();
|
app_manager_ = std::make_unique<xam::AppManager>();
|
||||||
user_profile_ = std::make_unique<xam::UserProfile>();
|
user_profile_ = std::make_unique<xam::UserProfile>(this);
|
||||||
|
|
||||||
auto content_root = emulator_->content_root();
|
auto content_root = emulator_->content_root();
|
||||||
content_root = xe::to_absolute_path(content_root);
|
content_root = xe::to_absolute_path(content_root);
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "xenia/kernel/xam/user_profile.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "xenia/base/clock.h"
|
#include "xenia/base/clock.h"
|
||||||
|
@ -14,16 +16,13 @@
|
||||||
#include "xenia/base/filesystem.h"
|
#include "xenia/base/filesystem.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/mapped_memory.h"
|
#include "xenia/base/mapped_memory.h"
|
||||||
|
#include "xenia/emulator.h"
|
||||||
#include "xenia/kernel/kernel_state.h"
|
#include "xenia/kernel/kernel_state.h"
|
||||||
#include "xenia/kernel/util/crypto_utils.h"
|
#include "xenia/kernel/util/crypto_utils.h"
|
||||||
#include "xenia/kernel/util/shim_utils.h"
|
#include "xenia/kernel/util/shim_utils.h"
|
||||||
#include "xenia/kernel/xam/user_profile.h"
|
|
||||||
|
|
||||||
DECLARE_int32(license_mask);
|
DECLARE_int32(license_mask);
|
||||||
|
|
||||||
DEFINE_string(profile_directory, "Content\\Profile\\",
|
|
||||||
"The directory to store profile data inside", "Kernel");
|
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
namespace xam {
|
namespace xam {
|
||||||
|
@ -33,7 +32,8 @@ std::string X_XAMACCOUNTINFO::GetGamertagString() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring UserProfile::directory() const {
|
std::wstring UserProfile::directory() const {
|
||||||
return xe::to_wstring(cvars::profile_directory);
|
return xe::to_absolute_path(kernel_state_->emulator()->content_root() +
|
||||||
|
L"\\profile\\");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UserProfile::DecryptAccountFile(const uint8_t* data,
|
bool UserProfile::DecryptAccountFile(const uint8_t* data,
|
||||||
|
@ -106,7 +106,8 @@ void UserProfile::EncryptAccountFile(const X_XAMACCOUNTINFO* input,
|
||||||
enc_data_size);
|
enc_data_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
UserProfile::UserProfile() : dash_gpd_(kDashboardID) {
|
UserProfile::UserProfile(KernelState* kernel_state)
|
||||||
|
: kernel_state_(kernel_state), dash_gpd_(kDashboardID) {
|
||||||
account_.xuid_online = 0xE000BABEBABEBABE;
|
account_.xuid_online = 0xE000BABEBABEBABE;
|
||||||
wcscpy(account_.gamertag, L"XeniaUser");
|
wcscpy(account_.gamertag, L"XeniaUser");
|
||||||
|
|
||||||
|
@ -116,11 +117,9 @@ UserProfile::UserProfile() : dash_gpd_(kDashboardID) {
|
||||||
|
|
||||||
void UserProfile::LoadProfile() {
|
void UserProfile::LoadProfile() {
|
||||||
auto mmap_ =
|
auto mmap_ =
|
||||||
MappedMemory::Open(xe::to_wstring(cvars::profile_directory) + L"Account",
|
MappedMemory::Open(directory() + L"Account", MappedMemory::Mode::kRead);
|
||||||
MappedMemory::Mode::kRead);
|
|
||||||
if (mmap_) {
|
if (mmap_) {
|
||||||
XELOGI("Loading Account file from path %SAccount",
|
XELOGI("Loading Account file from path %SAccount", directory().c_str());
|
||||||
xe::to_wstring(cvars::profile_directory).c_str());
|
|
||||||
|
|
||||||
X_XAMACCOUNTINFO tmp_acct;
|
X_XAMACCOUNTINFO tmp_acct;
|
||||||
bool success = DecryptAccountFile(mmap_->data(), &tmp_acct);
|
bool success = DecryptAccountFile(mmap_->data(), &tmp_acct);
|
||||||
|
@ -138,11 +137,9 @@ void UserProfile::LoadProfile() {
|
||||||
mmap_->Close();
|
mmap_->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
XELOGI("Loading profile GPDs from path %S",
|
XELOGI("Loading profile GPDs from path %S", directory().c_str());
|
||||||
xe::to_wstring(cvars::profile_directory).c_str());
|
|
||||||
|
|
||||||
mmap_ = MappedMemory::Open(
|
mmap_ = MappedMemory::Open(directory() + L"FFFE07D1.gpd",
|
||||||
xe::to_wstring(cvars::profile_directory) + L"FFFE07D1.gpd",
|
|
||||||
MappedMemory::Mode::kRead);
|
MappedMemory::Mode::kRead);
|
||||||
if (mmap_) {
|
if (mmap_) {
|
||||||
dash_gpd_.Read(mmap_->data(), mmap_->size());
|
dash_gpd_.Read(mmap_->data(), mmap_->size());
|
||||||
|
@ -232,8 +229,7 @@ void UserProfile::LoadProfile() {
|
||||||
for (auto title : titles) {
|
for (auto title : titles) {
|
||||||
wchar_t fname[256];
|
wchar_t fname[256];
|
||||||
swprintf(fname, 256, L"%X.gpd", title.title_id);
|
swprintf(fname, 256, L"%X.gpd", title.title_id);
|
||||||
mmap_ = MappedMemory::Open(xe::to_wstring(cvars::profile_directory) + fname,
|
mmap_ = MappedMemory::Open(directory() + fname, MappedMemory::Mode::kRead);
|
||||||
MappedMemory::Mode::kRead);
|
|
||||||
if (!mmap_) {
|
if (!mmap_) {
|
||||||
XELOGE("Failed to open GPD for title %X (%s)!", title.title_id,
|
XELOGE("Failed to open GPD for title %X (%s)!", title.title_id,
|
||||||
xe::to_string(title.title_name).c_str());
|
xe::to_string(title.title_name).c_str());
|
||||||
|
@ -539,17 +535,16 @@ bool UserProfile::UpdateGpd(uint32_t title_id, xdbf::GpdFile& gpd_data) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filesystem::PathExists(xe::to_wstring(cvars::profile_directory))) {
|
if (!filesystem::PathExists(directory())) {
|
||||||
filesystem::CreateFolder(xe::to_wstring(cvars::profile_directory));
|
filesystem::CreateFolder(directory());
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t fname[256];
|
wchar_t fname[256];
|
||||||
swprintf(fname, 256, L"%X.gpd", title_id);
|
swprintf(fname, 256, L"%X.gpd", title_id);
|
||||||
|
|
||||||
filesystem::CreateFile(xe::to_wstring(cvars::profile_directory) + fname);
|
filesystem::CreateFile(directory() + fname);
|
||||||
auto mmap_ =
|
auto mmap_ = MappedMemory::Open(
|
||||||
MappedMemory::Open(xe::to_wstring(cvars::profile_directory) + fname,
|
directory() + fname, MappedMemory::Mode::kReadWrite, 0, gpd_length);
|
||||||
MappedMemory::Mode::kReadWrite, 0, gpd_length);
|
|
||||||
if (!mmap_) {
|
if (!mmap_) {
|
||||||
XELOGE("Failed to open %X.gpd for writing!", title_id);
|
XELOGE("Failed to open %X.gpd for writing!", title_id);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
#include "xenia/kernel/xam/xdbf/xdbf.h"
|
#include "xenia/kernel/xam/xdbf/xdbf.h"
|
||||||
#include "xenia/xbox.h"
|
#include "xenia/xbox.h"
|
||||||
|
|
||||||
|
namespace xe {
|
||||||
|
namespace kernel {
|
||||||
|
class KernelState;
|
||||||
|
} // namespace kernel
|
||||||
|
} // namespace xe
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
|
@ -166,7 +171,7 @@ class UserProfile {
|
||||||
static void EncryptAccountFile(const X_XAMACCOUNTINFO* input, uint8_t* output,
|
static void EncryptAccountFile(const X_XAMACCOUNTINFO* input, uint8_t* output,
|
||||||
bool devkit = false);
|
bool devkit = false);
|
||||||
|
|
||||||
UserProfile();
|
UserProfile(KernelState* kernel_state);
|
||||||
|
|
||||||
uint64_t xuid() const { return account_.xuid_online; }
|
uint64_t xuid() const { return account_.xuid_online; }
|
||||||
std::string name() const { return account_.GetGamertagString(); }
|
std::string name() const { return account_.GetGamertagString(); }
|
||||||
|
@ -188,6 +193,8 @@ class UserProfile {
|
||||||
|
|
||||||
bool AddSettingIfNotExist(xdbf::Setting& setting);
|
bool AddSettingIfNotExist(xdbf::Setting& setting);
|
||||||
|
|
||||||
|
KernelState* kernel_state_;
|
||||||
|
|
||||||
X_XAMACCOUNTINFO account_;
|
X_XAMACCOUNTINFO account_;
|
||||||
|
|
||||||
std::unordered_map<uint32_t, xdbf::GpdFile> title_gpds_;
|
std::unordered_map<uint32_t, xdbf::GpdFile> title_gpds_;
|
||||||
|
|
Loading…
Reference in New Issue