Skip to content

Commit

Permalink
[XGI] XUserSetPropertyEx validate size
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianCassar committed Feb 7, 2025
1 parent e3968da commit ea8f555
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
35 changes: 34 additions & 1 deletion src/xenia/kernel/xam/apps/xgi_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,41 @@ X_HRESULT XgiApp::DispatchMessageSync(uint32_t message, uint32_t buffer_ptr,
const std::string desc = title_xdbf.GetStringTableEntry(
title_language, property_xdbf.string_id);

// 58410821 & 58410AC2 use input size smaller than expected
if (value_size != property_xdbf.data_size) {
XELOGD("Property 0x{:08X} Input Size: {} Expected Size {}!",
property_id, value_size, property_xdbf.data_size.get());
}

const AttributeKey attribute = static_cast<AttributeKey>(property_id);

const X_USER_DATA_TYPE property_type =
static_cast<X_USER_DATA_TYPE>(attribute.type);

uint32_t property_size = property_xdbf.data_size;

switch (property_type) {
case xe::X_USER_DATA_TYPE::CONTEXT:
case xe::X_USER_DATA_TYPE::INT32:
case xe::X_USER_DATA_TYPE::FLOAT:
property_size = sizeof(uint32_t);
break;
case xe::X_USER_DATA_TYPE::INT64:
case xe::X_USER_DATA_TYPE::DOUBLE:
case xe::X_USER_DATA_TYPE::DATETIME:
property_size = sizeof(uint64_t);
break;
case xe::X_USER_DATA_TYPE::WSTRING:
case xe::X_USER_DATA_TYPE::BINARY:
property_size = value_size;
break;
}

// 58410821
// Properties are ad-hoc therefore should be updated on backend, only
// update if value changed to reduce POST requests.
Property property =
Property(property_id, value_size,
Property(property_id, property_size,
memory_->TranslateVirtual<uint8_t*>(value_ptr));

auto user_profile =
Expand Down
2 changes: 1 addition & 1 deletion src/xenia/kernel/xam/user_profile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ UserProfile::UserProfile(uint64_t xuid, X_XAMACCOUNTINFO* account_info)
Property GAMER_SIGMA = Property(X_PROPERTY_GAMER_SIGMA, sizeof(uint64_t),
reinterpret_cast<uint8_t*>(&gamer_sigma));

AddProperty(&PUID); // Required
AddProperty(&PUID); // Required - 58410AC2 sets this manually
AddProperty(&GAMER_HOST_NAME); // Required
AddProperty(&GAMER_NAME);
AddProperty(&GAMER_ZONE);
Expand Down
3 changes: 3 additions & 0 deletions src/xenia/kernel/xsession.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ X_RESULT XSession::CreateHostSession(XSESSION_INFO* session_info,
XELOGI("Creating xbox live session");
session_id_ = GenerateSessionId(XNKID_ONLINE);

// 58410821 adds properties after session creation
// Properties are ad-hoc therefore should be updated on backend, only
// update if value changed to reduce POST requests.
XLiveAPI::XSessionCreate(session_id_, session_data);
XLiveAPI::SessionPropertiesAdd(session_id_, properties_);
}
Expand Down

0 comments on commit ea8f555

Please sign in to comment.