[Kernel] Copy title image/name from SPA->GPD, fix XDBF free data...

Velocity should now load Xenia-created GPDs fine :D

To try it just make a new profile package in Velocity, inject GPDs from Xenia, and inject random Account file from a 360 profile.
Then close created package, use Tools -> Profile Tools -> Profile Editor to open the package you just created, and if all goes well the profile should load up fine.
This commit is contained in:
emoose 2018-11-16 07:05:54 +00:00
parent e510972691
commit faeddbd34d
No known key found for this signature in database
GPG Key ID: 3735C67912F5FF97
2 changed files with 31 additions and 2 deletions

View File

@ -57,7 +57,7 @@ bool XdbfFile::Write(uint8_t* data, size_t* data_size) {
*data_size += sizeof(X_XDBF_HEADER);
*data_size += entries.size() * sizeof(X_XDBF_ENTRY);
*data_size += free_entries.size() * sizeof(X_XDBF_FILELOC);
*data_size += 1 * sizeof(X_XDBF_FILELOC);
size_t entries_size = 0;
for (auto ent : entries) {
@ -71,7 +71,7 @@ bool XdbfFile::Write(uint8_t* data, size_t* data_size) {
}
header.entry_count = header.entry_used = (uint32_t)entries.size();
header.free_count = header.free_used = (uint32_t)free_entries.size();
header.free_count = header.free_used = 1;
auto* ptr = data;
memcpy(ptr, &header, sizeof(X_XDBF_HEADER));
@ -93,6 +93,15 @@ bool XdbfFile::Write(uint8_t* data, size_t* data_size) {
ptr += sizeof(X_XDBF_ENTRY);
}
free_entries.clear();
X_XDBF_FILELOC free_ent;
free_ent.offset = (uint32_t)*data_size - sizeof(X_XDBF_HEADER) -
(sizeof(X_XDBF_ENTRY) * header.entry_count) -
(sizeof(X_XDBF_FILELOC) * header.free_count);
free_ent.size = 0 - free_ent.offset;
free_entries.push_back(free_ent);
for (auto ent : free_entries) {
memcpy(free_ptr, &ent, sizeof(X_XDBF_FILELOC));
free_ptr++;

View File

@ -162,6 +162,26 @@ util::GpdFile* UserProfile::SetTitleSpaData(const util::SpaFile& spa_data) {
}
}
// try adding title image & name
auto* title_image =
spa_data.GetEntry(static_cast<uint16_t>(util::XdbfSpaSection::kImage),
static_cast<uint64_t>(util::XdbfSpaID::Title));
if (title_image) {
title_gpd.UpdateEntry(*title_image);
}
auto title_name = xe::to_wstring(spa_data.GetTitleName());
if (title_name.length()) {
util::XdbfEntry title_name_ent;
title_name_ent.info.section =
static_cast<uint16_t>(util::XdbfGpdSection::kString);
title_name_ent.info.id = static_cast<uint64_t>(util::XdbfSpaID::Title);
title_name_ent.data.resize((title_name.length() + 1) * 2);
xe::copy_and_swap((wchar_t*)title_name_ent.data.data(),
title_name.c_str(), title_name.length());
title_gpd.UpdateEntry(title_name_ent);
}
title_gpds_[spa_title] = title_gpd;
// Update dash GPD with title and write updated GPDs