[XAM] Cleanup parsing gamer tile key
This commit is contained in:
@@ -124,7 +124,7 @@ inline constexpr bool IsGamerPictureCustom(const uint32_t title_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr bool IsGamerPictureFromDash(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) {
|
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(IsGamerPictureAvatar(0xFFFE0854)); // Avatar Gamer Picture
|
||||||
static_assert(IsGamerPictureCustom(0xFFFE0700)); // Custom Gamer Picture
|
static_assert(IsGamerPictureCustom(0xFFFE0700)); // Custom Gamer Picture
|
||||||
static_assert(
|
static_assert(
|
||||||
IsGamerPictureFromDash(0xFFFE07D1)); // Default or OS Gamer Picture?
|
IsGamerPictureFromDash(kDashboardID)); // Default or OS Gamer Picture?
|
||||||
static_assert(!IsGamerPictureKeySet(0)); // No Gamer Picture Key
|
static_assert(!IsGamerPictureKeySet(0)); // No Gamer Picture Key
|
||||||
|
|
||||||
} // namespace kernel
|
} // namespace kernel
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|||||||
@@ -445,6 +445,25 @@ enum ACCELERATOR_CONTROL_OPTIONS : uint8_t {
|
|||||||
ACCELERATOR_CONTROL_BUTTON
|
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 {
|
class UserSetting : public UserData {
|
||||||
public:
|
public:
|
||||||
UserSetting(const UserSetting& setting);
|
UserSetting(const UserSetting& setting);
|
||||||
|
|||||||
@@ -758,8 +758,7 @@ dword_result_t XamParseGamerTileKey_entry(pointer_t<X_USER_DATA> key_ptr,
|
|||||||
kernel_memory()->TranslateVirtual<const char16_t*>(
|
kernel_memory()->TranslateVirtual<const char16_t*>(
|
||||||
key_ptr->data.unicode.ptr)));
|
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() != sizeof(GamerPictureKey)) {
|
||||||
if (tile_key.empty() || tile_key.size() != 24) {
|
|
||||||
return X_ERROR_INVALID_PARAMETER;
|
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) {
|
if (!is_valid_hex_string) {
|
||||||
return X_ERROR_INVALID_PARAMETER;
|
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)
|
const GamerPictureKey* gamer_picture_key =
|
||||||
std::string title_id = tile_key.substr(0, 8);
|
reinterpret_cast<const GamerPictureKey*>(tile_key.data());
|
||||||
std::string big_tile_id = tile_key.substr(8, 8);
|
|
||||||
std::string small_tile_id = tile_key.substr(16, 8);
|
|
||||||
|
|
||||||
if (title_id_ptr) {
|
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) {
|
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) {
|
if (small_tile_id_ptr) {
|
||||||
*small_tile_id_ptr =
|
*small_tile_id_ptr = gamer_picture_key->GetSmallTileId();
|
||||||
string_util::from_string<uint32_t>(small_tile_id, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_from_dash = false;
|
bool is_from_dash = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user