[XAM/User] Added descriptions and labels for achievements
Disclaimer: On old dash it causes memleak (slight), newer dashboards allocates them only once which is solution for that. Ps. If anyone have easy solution please implement it. Cheers
This commit is contained in:
parent
4d753faf19
commit
d30e415bc0
|
@ -605,19 +605,6 @@ dword_result_t XamUserCreateAchievementEnumerator(dword_t title_id,
|
|||
return X_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static uint32_t placeholder = 0;
|
||||
|
||||
if (!placeholder) {
|
||||
const wchar_t* placeholder_val = L"<placeholder>";
|
||||
|
||||
placeholder = kernel_memory()->SystemHeapAlloc(
|
||||
((uint32_t)wcslen(placeholder_val) + 1) * 2);
|
||||
auto* place_addr = kernel_memory()->TranslateVirtual<wchar_t*>(placeholder);
|
||||
|
||||
memset(place_addr, 0, (wcslen(placeholder_val) + 1) * 2);
|
||||
xe::copy_and_swap(place_addr, placeholder_val, wcslen(placeholder_val));
|
||||
}
|
||||
|
||||
std::vector<xdbf::Achievement> achievements;
|
||||
game_gpd->GetAchievements(&achievements);
|
||||
|
||||
|
@ -633,9 +620,14 @@ dword_result_t XamUserCreateAchievementEnumerator(dword_t title_id,
|
|||
// very bad...
|
||||
|
||||
// maybe we could alloc these in guest when the title GPD is first loaded?
|
||||
details->label_ptr = placeholder;
|
||||
details->description_ptr = placeholder;
|
||||
details->unachieved_ptr = placeholder;
|
||||
// Only the 1888 dashboard reallocates them every time
|
||||
// Newer dashes allocates this only once
|
||||
details->label_ptr =
|
||||
kernel_memory()->AllocSpaceForWStringInSystemHeap(ach.label);
|
||||
details->description_ptr =
|
||||
kernel_memory()->AllocSpaceForWStringInSystemHeap(ach.description);
|
||||
details->unachieved_ptr =
|
||||
kernel_memory()->AllocSpaceForWStringInSystemHeap(ach.unachieved_desc);
|
||||
}
|
||||
|
||||
XELOGD("XamUserCreateAchievementEnumerator: added %d items to enumerator",
|
||||
|
|
|
@ -1736,4 +1736,14 @@ uint32_t PhysicalHeap::GetPhysicalAddress(uint32_t address) const {
|
|||
return address;
|
||||
}
|
||||
|
||||
uint32_t Memory::AllocSpaceForWStringInSystemHeap(std::wstring phrase) {
|
||||
uint32_t address = SystemHeapAlloc((uint32_t)phrase.size());
|
||||
|
||||
auto* place_addr = TranslateVirtual<wchar_t*>(address);
|
||||
|
||||
memset(place_addr, 0, (uint32_t)phrase.size());
|
||||
xe::copy_and_swap(place_addr, phrase.c_str(), (uint32_t)phrase.size());
|
||||
return address;
|
||||
}
|
||||
|
||||
} // namespace xe
|
||||
|
|
|
@ -429,6 +429,9 @@ class Memory {
|
|||
// Gets the physical base heap.
|
||||
VirtualHeap* GetPhysicalHeap();
|
||||
|
||||
// Allocate space for wstring in memory and returns its address
|
||||
uint32_t AllocSpaceForWStringInSystemHeap(std::wstring phrase);
|
||||
|
||||
// Dumps a map of all allocated memory to the log.
|
||||
void DumpMap();
|
||||
|
||||
|
|
Loading…
Reference in New Issue