Adjusted user profile settings so that we can know about settings, but have their data unset.
This commit is contained in:
parent
8965fda402
commit
afda577484
|
@ -47,8 +47,9 @@ class UserProfile {
|
|||
uint32_t setting_id;
|
||||
Type type;
|
||||
size_t size;
|
||||
Setting(uint32_t setting_id, Type type, size_t size)
|
||||
: setting_id(setting_id), type(type), size(size) {}
|
||||
bool is_set;
|
||||
Setting(uint32_t setting_id, Type type, size_t size, bool is_set)
|
||||
: setting_id(setting_id), type(type), size(size), is_set(is_set) {}
|
||||
virtual size_t extra_size() const { return 0; }
|
||||
virtual size_t Append(uint8_t* user_data, uint8_t* buffer,
|
||||
uint32_t buffer_ptr, size_t buffer_offset) {
|
||||
|
@ -65,7 +66,7 @@ class UserProfile {
|
|||
};
|
||||
struct Int32Setting : public Setting {
|
||||
Int32Setting(uint32_t setting_id, int32_t value)
|
||||
: Setting(setting_id, Type::INT32, 4), value(value) {}
|
||||
: Setting(setting_id, Type::INT32, 4, true), value(value) {}
|
||||
int32_t value;
|
||||
size_t Append(uint8_t* user_data, uint8_t* buffer, uint32_t buffer_ptr,
|
||||
size_t buffer_offset) override {
|
||||
|
@ -77,7 +78,7 @@ class UserProfile {
|
|||
};
|
||||
struct Int64Setting : public Setting {
|
||||
Int64Setting(uint32_t setting_id, int64_t value)
|
||||
: Setting(setting_id, Type::INT64, 8), value(value) {}
|
||||
: Setting(setting_id, Type::INT64, 8, true), value(value) {}
|
||||
int64_t value;
|
||||
size_t Append(uint8_t* user_data, uint8_t* buffer, uint32_t buffer_ptr,
|
||||
size_t buffer_offset) override {
|
||||
|
@ -89,7 +90,7 @@ class UserProfile {
|
|||
};
|
||||
struct DoubleSetting : public Setting {
|
||||
DoubleSetting(uint32_t setting_id, double value)
|
||||
: Setting(setting_id, Type::DOUBLE, 8), value(value) {}
|
||||
: Setting(setting_id, Type::DOUBLE, 8, true), value(value) {}
|
||||
double value;
|
||||
size_t Append(uint8_t* user_data, uint8_t* buffer, uint32_t buffer_ptr,
|
||||
size_t buffer_offset) override {
|
||||
|
@ -101,7 +102,7 @@ class UserProfile {
|
|||
};
|
||||
struct UnicodeSetting : public Setting {
|
||||
UnicodeSetting(uint32_t setting_id, const std::wstring& value)
|
||||
: Setting(setting_id, Type::WSTRING, 8), value(value) {}
|
||||
: Setting(setting_id, Type::WSTRING, 8, true), value(value) {}
|
||||
std::wstring value;
|
||||
size_t extra_size() const override {
|
||||
return value.empty() ? 0 : 2 * (static_cast<int32_t>(value.size()) + 1);
|
||||
|
@ -128,7 +129,7 @@ class UserProfile {
|
|||
};
|
||||
struct FloatSetting : public Setting {
|
||||
FloatSetting(uint32_t setting_id, float value)
|
||||
: Setting(setting_id, Type::FLOAT, 4), value(value) {}
|
||||
: Setting(setting_id, Type::FLOAT, 4, true), value(value) {}
|
||||
float value;
|
||||
size_t Append(uint8_t* user_data, uint8_t* buffer, uint32_t buffer_ptr,
|
||||
size_t buffer_offset) override {
|
||||
|
@ -139,8 +140,10 @@ class UserProfile {
|
|||
}
|
||||
};
|
||||
struct BinarySetting : public Setting {
|
||||
BinarySetting(uint32_t setting_id)
|
||||
: Setting(setting_id, Type::BINARY, 8, false), value() {}
|
||||
BinarySetting(uint32_t setting_id, const std::vector<uint8_t>& value)
|
||||
: Setting(setting_id, Type::BINARY, 8), value(value) {}
|
||||
: Setting(setting_id, Type::BINARY, 8, true), value(value) {}
|
||||
std::vector<uint8_t> value;
|
||||
size_t extra_size() const override {
|
||||
return static_cast<int32_t>(value.size());
|
||||
|
@ -167,7 +170,7 @@ class UserProfile {
|
|||
};
|
||||
struct DateTimeSetting : public Setting {
|
||||
DateTimeSetting(uint32_t setting_id, int64_t value)
|
||||
: Setting(setting_id, Type::DATETIME, 8), value(value) {}
|
||||
: Setting(setting_id, Type::DATETIME, 8, true), value(value) {}
|
||||
int64_t value;
|
||||
size_t Append(uint8_t* user_data, uint8_t* buffer, uint32_t buffer_ptr,
|
||||
size_t buffer_offset) override {
|
||||
|
|
|
@ -181,8 +181,10 @@ SHIM_CALL XamUserReadProfileSettings_shim(PPCContext* ppc_context,
|
|||
uint32_t setting_id = setting_ids[n];
|
||||
auto setting = user_profile->GetSetting(setting_id);
|
||||
if (setting) {
|
||||
if (setting->is_set) {
|
||||
auto extra_size = static_cast<uint32_t>(setting->extra_size());
|
||||
size_needed += extra_size;
|
||||
}
|
||||
} else {
|
||||
any_missing = true;
|
||||
XELOGE("XamUserReadProfileSettings requested unimplemented setting %.8X",
|
||||
|
@ -228,11 +230,12 @@ SHIM_CALL XamUserReadProfileSettings_shim(PPCContext* ppc_context,
|
|||
auto setting = user_profile->GetSetting(setting_id);
|
||||
|
||||
std::memset(out_setting, 0, sizeof(X_USER_READ_PROFILE_SETTING));
|
||||
out_setting->from = !setting ? 0 : setting->is_title_specific() ? 2 : 1;
|
||||
out_setting->from =
|
||||
!setting || !setting->is_set ? 0 : setting->is_title_specific() ? 2 : 1;
|
||||
out_setting->user_index = user_index;
|
||||
out_setting->setting_id = setting_id;
|
||||
|
||||
if (setting) {
|
||||
if (setting && setting->is_set) {
|
||||
buffer_offset =
|
||||
setting->Append(&out_setting->setting_data[0],
|
||||
SHIM_MEM_ADDR(buffer_ptr), buffer_ptr, buffer_offset);
|
||||
|
|
Loading…
Reference in New Issue