[XAM] Fix xeXamUserReadProfileSettingsEx.
[XAM] Fix xeXamUserReadProfileSettingsEx. - Properly calculate initial buffer_offset. - Don't set buffer_size_ptr when its initial value is non-zero.
This commit is contained in:
parent
a8c3682b6f
commit
f631b02bcf
|
@ -163,15 +163,16 @@ uint32_t xeXamUserReadProfileSettingsEx(uint32_t title_id, uint32_t user_index,
|
||||||
return X_ERROR_INVALID_PARAMETER;
|
return X_ERROR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t needed_size = 0;
|
uint32_t needed_header_size = 0;
|
||||||
|
uint32_t needed_extra_size = 0;
|
||||||
for (uint32_t i = 0; i < setting_count; ++i) {
|
for (uint32_t i = 0; i < setting_count; ++i) {
|
||||||
needed_size += sizeof(X_USER_READ_PROFILE_SETTING);
|
needed_header_size += sizeof(X_USER_READ_PROFILE_SETTING);
|
||||||
UserProfile::Setting::Key setting_key;
|
UserProfile::Setting::Key setting_key;
|
||||||
setting_key.value = static_cast<uint32_t>(setting_ids[i]);
|
setting_key.value = static_cast<uint32_t>(setting_ids[i]);
|
||||||
switch (static_cast<UserProfile::Setting::Type>(setting_key.type)) {
|
switch (static_cast<UserProfile::Setting::Type>(setting_key.type)) {
|
||||||
case UserProfile::Setting::Type::WSTRING:
|
case UserProfile::Setting::Type::WSTRING:
|
||||||
case UserProfile::Setting::Type::BINARY: {
|
case UserProfile::Setting::Type::BINARY: {
|
||||||
needed_size += setting_key.size;
|
needed_extra_size += setting_key.size;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
@ -179,15 +180,16 @@ uint32_t xeXamUserReadProfileSettingsEx(uint32_t title_id, uint32_t user_index,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// needed_size *= !xuids_ptr ? 1 : xuid_count;
|
if (xuids_ptr) {
|
||||||
needed_size += sizeof(X_USER_READ_PROFILE_SETTINGS);
|
// needed_header_size *= xuid_count;
|
||||||
|
// needed_extra_size *= !xuid_count;
|
||||||
|
}
|
||||||
|
needed_header_size += sizeof(X_USER_READ_PROFILE_SETTINGS);
|
||||||
|
|
||||||
|
uint32_t needed_size = needed_header_size + needed_extra_size;
|
||||||
if (!buffer_ptr || buffer_size < needed_size) {
|
if (!buffer_ptr || buffer_size < needed_size) {
|
||||||
*buffer_size_ptr = needed_size;
|
if (!buffer_size) {
|
||||||
if (overlapped_ptr) {
|
*buffer_size_ptr = needed_size;
|
||||||
kernel_state()->CompleteOverlappedImmediate(overlapped_ptr,
|
|
||||||
X_ERROR_INSUFFICIENT_BUFFER);
|
|
||||||
return X_ERROR_IO_PENDING;
|
|
||||||
}
|
}
|
||||||
return X_ERROR_INSUFFICIENT_BUFFER;
|
return X_ERROR_INSUFFICIENT_BUFFER;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +243,7 @@ uint32_t xeXamUserReadProfileSettingsEx(uint32_t title_id, uint32_t user_index,
|
||||||
auto out_setting =
|
auto out_setting =
|
||||||
reinterpret_cast<X_USER_READ_PROFILE_SETTING*>(&out_header[1]);
|
reinterpret_cast<X_USER_READ_PROFILE_SETTING*>(&out_header[1]);
|
||||||
|
|
||||||
size_t buffer_offset = sizeof(X_USER_READ_PROFILE_SETTINGS);
|
size_t buffer_offset = needed_header_size;
|
||||||
for (uint32_t n = 0; n < setting_count; ++n) {
|
for (uint32_t n = 0; n < setting_count; ++n) {
|
||||||
uint32_t setting_id = setting_ids[n];
|
uint32_t setting_id = setting_ids[n];
|
||||||
auto setting = user_profile->GetSetting(setting_id);
|
auto setting = user_profile->GetSetting(setting_id);
|
||||||
|
|
Loading…
Reference in New Issue