[XAM] Added overlap to XamUserWriteProfileSettings

This fixes saving in Earthworm Jim

Additionally fixed issue with not setting xuid to -1 when not provided
This commit is contained in:
Gliniak 2025-03-13 22:54:02 +01:00
parent c4867250e4
commit 23d1f7a308

View file

@ -319,6 +319,7 @@ uint32_t XamUserReadProfileSettingsEx(uint32_t title_id, uint32_t user_index,
if (xuids) { if (xuids) {
out_setting->xuid = user_profile->xuid(); out_setting->xuid = user_profile->xuid();
} else { } else {
out_setting->xuid = -1;
out_setting->user_index = user_index; out_setting->user_index = user_index;
} }
} }
@ -355,42 +356,46 @@ DECLARE_XAM_EXPORT1(XamUserReadProfileSettingsEx, kUserProfiles, kImplemented);
dword_result_t XamUserWriteProfileSettings_entry( dword_result_t XamUserWriteProfileSettings_entry(
dword_t title_id, dword_t user_index, dword_t setting_count, dword_t title_id, dword_t user_index, dword_t setting_count,
pointer_t<X_USER_PROFILE_SETTING> settings, pointer_t<X_USER_PROFILE_SETTING> settings, lpvoid_t overlapped) {
pointer_t<XAM_OVERLAPPED> overlapped) {
if (!setting_count || !settings) { if (!setting_count || !settings) {
return X_ERROR_INVALID_PARAMETER; return X_ERROR_INVALID_PARAMETER;
} }
// Update and save settings.
const auto& user_profile =
kernel_state()->xam_state()->GetUserProfile(user_index);
// Skip writing data about users with id != 0 they're not supported auto run = [=](uint32_t& extended_error, uint32_t& length) {
if (!user_profile) { // Update and save settings.
if (overlapped) { const auto& user_profile =
kernel_state()->CompleteOverlappedImmediate( kernel_state()->xam_state()->GetUserProfile(user_index);
kernel_state()->memory()->HostToGuestVirtual(overlapped),
X_ERROR_NO_SUCH_USER);
return X_ERROR_IO_PENDING;
}
return X_ERROR_SUCCESS;
}
for (uint32_t n = 0; n < setting_count; ++n) { // Skip writing data about users with id != 0 they're not supported
const UserSetting setting = UserSetting(&settings[n]); if (!user_profile) {
extended_error = X_HRESULT_FROM_WIN32(X_ERROR_NO_SUCH_USER);
if (!setting.is_valid_type()) { length = 0;
continue; return X_ERROR_NO_SUCH_USER;
} }
kernel_state()->xam_state()->user_tracker()->UpsertSetting( for (uint32_t n = 0; n < setting_count; ++n) {
user_profile->xuid(), title_id, &setting); const UserSetting setting = UserSetting(&settings[n]);
if (!setting.is_valid_type()) {
continue;
}
kernel_state()->xam_state()->user_tracker()->UpsertSetting(
user_profile->xuid(), title_id, &setting);
}
extended_error = X_HRESULT_FROM_WIN32(X_STATUS_SUCCESS);
length = 0;
return X_STATUS_SUCCESS;
};
if (!overlapped) {
uint32_t extended_error, length;
return run(extended_error, length);
} }
if (overlapped) { kernel_state()->CompleteOverlappedDeferredEx(run, overlapped);
kernel_state()->CompleteOverlappedImmediate(overlapped, X_ERROR_SUCCESS); return X_ERROR_IO_PENDING;
return X_ERROR_IO_PENDING;
}
return X_ERROR_SUCCESS;
} }
DECLARE_XAM_EXPORT1(XamUserWriteProfileSettings, kUserProfiles, kImplemented); DECLARE_XAM_EXPORT1(XamUserWriteProfileSettings, kUserProfiles, kImplemented);