[XAM] Cleanup parsing gamer tile key

This commit is contained in:
Adrian
2025-12-17 16:11:56 +00:00
committed by Radosław Gliński
parent a89513864c
commit 925c59790f
3 changed files with 29 additions and 14 deletions

View File

@@ -124,7 +124,7 @@ inline constexpr bool IsGamerPictureCustom(const uint32_t title_id) {
}
inline constexpr bool IsGamerPictureFromDash(const uint32_t title_id) {
return title_id == 0xFFFE07D1;
return title_id == kDashboardID;
}
inline constexpr bool IsGamerPictureKeySet(const uint32_t title_id) {
@@ -134,8 +134,8 @@ inline constexpr bool IsGamerPictureKeySet(const uint32_t title_id) {
static_assert(IsGamerPictureAvatar(0xFFFE0854)); // Avatar Gamer Picture
static_assert(IsGamerPictureCustom(0xFFFE0700)); // Custom Gamer Picture
static_assert(
IsGamerPictureFromDash(0xFFFE07D1)); // Default or OS Gamer Picture?
static_assert(!IsGamerPictureKeySet(0)); // No Gamer Picture Key
IsGamerPictureFromDash(kDashboardID)); // Default or OS Gamer Picture?
static_assert(!IsGamerPictureKeySet(0)); // No Gamer Picture Key
} // namespace kernel
} // namespace xe

View File

@@ -445,6 +445,25 @@ enum ACCELERATOR_CONTROL_OPTIONS : uint8_t {
ACCELERATOR_CONTROL_BUTTON
};
struct GamerPictureKey {
char title_id[8];
char big_tile_id[8];
char small_tile_id[8];
uint32_t GetTitleId() const {
return string_util::from_string<uint32_t>(title_id, true);
}
uint32_t GetBigTileId() const {
return string_util::from_string<uint32_t>(big_tile_id, true);
}
uint32_t GetSmallTileId() const {
return string_util::from_string<uint32_t>(small_tile_id, true);
}
};
static_assert_size(GamerPictureKey, 0x18);
class UserSetting : public UserData {
public:
UserSetting(const UserSetting& setting);

View File

@@ -758,8 +758,7 @@ dword_result_t XamParseGamerTileKey_entry(pointer_t<X_USER_DATA> key_ptr,
kernel_memory()->TranslateVirtual<const char16_t*>(
key_ptr->data.unicode.ptr)));
// Default key size is 24 bytes, but we need to include null terminator
if (tile_key.empty() || tile_key.size() != 24) {
if (tile_key.empty() || tile_key.size() != sizeof(GamerPictureKey)) {
return X_ERROR_INVALID_PARAMETER;
}
@@ -770,23 +769,20 @@ dword_result_t XamParseGamerTileKey_entry(pointer_t<X_USER_DATA> key_ptr,
if (!is_valid_hex_string) {
return X_ERROR_INVALID_PARAMETER;
}
// Simple parser for key. Key (lower case) contains: title_id (8 chars),
// big_tile_id (8 chars), small_tile_id (8 chars)
std::string title_id = tile_key.substr(0, 8);
std::string big_tile_id = tile_key.substr(8, 8);
std::string small_tile_id = tile_key.substr(16, 8);
const GamerPictureKey* gamer_picture_key =
reinterpret_cast<const GamerPictureKey*>(tile_key.data());
if (title_id_ptr) {
*title_id_ptr = string_util::from_string<uint32_t>(title_id, true);
*title_id_ptr = gamer_picture_key->GetTitleId();
}
if (big_tile_id_ptr) {
*big_tile_id_ptr = string_util::from_string<uint32_t>(big_tile_id, true);
*big_tile_id_ptr = gamer_picture_key->GetBigTileId();
}
if (small_tile_id_ptr) {
*small_tile_id_ptr =
string_util::from_string<uint32_t>(small_tile_id, true);
*small_tile_id_ptr = gamer_picture_key->GetSmallTileId();
}
bool is_from_dash = false;