[XAM] Small XamUserCreateTitlesPlayedEnumerator tweaks + other fixups

This commit is contained in:
emoose 2019-12-25 20:26:04 +00:00 committed by illusion
parent a78335de1c
commit 4c88725f33
2 changed files with 18 additions and 4 deletions

View File

@ -348,7 +348,8 @@ DECLARE_XAM_EXPORT1(XamFree, kMemory, kImplemented);
dword_result_t XamEnumerate(dword_t handle, dword_t flags, lpvoid_t buffer, dword_result_t XamEnumerate(dword_t handle, dword_t flags, lpvoid_t buffer,
dword_t buffer_length, lpdword_t items_returned, dword_t buffer_length, lpdword_t items_returned,
pointer_t<XAM_OVERLAPPED> overlapped) { pointer_t<XAM_OVERLAPPED> overlapped) {
assert_true(flags == 0); assert_true(flags == 0 ||
flags == 2); // 2 seems to use more direct XAM code?
auto e = kernel_state()->object_table()->LookupObject<XEnumerator>(handle); auto e = kernel_state()->object_table()->LookupObject<XEnumerator>(handle);
if (!e) { if (!e) {

View File

@ -462,6 +462,8 @@ dword_result_t XamUserWriteProfileSettings(
gpd->UpdateSetting(setting); gpd->UpdateSetting(setting);
} }
user_profile->UpdateAllGpds();
if (overlapped_ptr) { if (overlapped_ptr) {
kernel_state()->CompleteOverlappedImmediate(overlapped_ptr, kernel_state()->CompleteOverlappedImmediate(overlapped_ptr,
X_ERROR_SUCCESS); X_ERROR_SUCCESS);
@ -718,18 +720,26 @@ DECLARE_XAM_EXPORT1(XamSessionRefObjByHandle, kUserProfiles, kStub);
dword_result_t XamUserCreateTitlesPlayedEnumerator( dword_result_t XamUserCreateTitlesPlayedEnumerator(
dword_t user_index, dword_t xuid, dword_t flags, dword_t offset, dword_t user_index, dword_t xuid, dword_t flags, dword_t offset,
dword_t games_count, lpdword_t buffer_size_ptr, lpdword_t handle_ptr) { dword_t games_count, lpdword_t buffer_size_ptr, lpdword_t handle_ptr) {
std::vector<xdbf::TitlePlayed> titles;
kernel_state()->user_profile()->GetDashboardGpd()->GetTitles(&titles);
// + 128 bytes for the 64-char titlename // + 128 bytes for the 64-char titlename
const uint32_t kEntrySize = sizeof(xdbf::X_XDBF_GPD_TITLEPLAYED) + 128; const uint32_t kEntrySize = sizeof(xdbf::X_XDBF_GPD_TITLEPLAYED) + 128;
if (buffer_size_ptr) {
*buffer_size_ptr = kEntrySize * games_count;
}
std::vector<xdbf::TitlePlayed> titles;
kernel_state()->user_profile()->GetDashboardGpd()->GetTitles(&titles);
auto e = new XStaticEnumerator(kernel_state(), games_count, kEntrySize); auto e = new XStaticEnumerator(kernel_state(), games_count, kEntrySize);
e->Initialize(); e->Initialize();
*handle_ptr = e->handle(); *handle_ptr = e->handle();
for (auto title : titles) { for (auto title : titles) {
if (e->item_count() >= games_count) {
break;
}
// For some reason dashboard gpd stores info about itself // For some reason dashboard gpd stores info about itself
if (title.title_id == kDashboardID) continue; if (title.title_id == kDashboardID) continue;
@ -741,6 +751,9 @@ dword_result_t XamUserCreateTitlesPlayedEnumerator(
title.WriteGPD(details); title.WriteGPD(details);
} }
XELOGD("XamUserCreateTitlesPlayedEnumerator: added %d items to enumerator",
e->item_count());
return X_ERROR_SUCCESS; return X_ERROR_SUCCESS;
} }
DECLARE_XAM_EXPORT1(XamUserCreateTitlesPlayedEnumerator, kUserProfiles, DECLARE_XAM_EXPORT1(XamUserCreateTitlesPlayedEnumerator, kUserProfiles,