[Kernel] - adjusting XAMEnumerate buffer size to fix Angry Birds and Resonance of Fate - thanks Gliniak

This commit is contained in:
Cancerous 2019-12-05 09:33:30 -05:00 committed by illusion98
parent 1fb027daa7
commit 027f691770
1 changed files with 16 additions and 11 deletions

View File

@ -361,17 +361,22 @@ dword_result_t XamEnumerate(dword_t handle, dword_t flags, lpvoid_t buffer,
} }
} }
size_t actual_buffer_length = (uint32_t)buffer_length; // size_t actual_buffer_length = (uint32_t)buffer_length;
if (buffer_length == e->items_per_enumerate()) { // if (buffer_length == e->items_per_enumerate()) {
actual_buffer_length = e->item_size() * e->items_per_enumerate(); // // Known culprits:
// Known culprits: // // Final Fight: Double Impact (saves)
// Final Fight: Double Impact (saves) // XELOGW(
XELOGW( // "Broken usage of XamEnumerate! buffer length=%.X vs actual length=%.X "
"Broken usage of XamEnumerate! buffer length=%.X vs actual length=%.X " // "(item size=%.X, items per enumerate=%u)",
"(item size=%.X, items per enumerate=%u)", // (uint32_t)buffer_length, actual_buffer_length, e->item_size(),
(uint32_t)buffer_length, actual_buffer_length, e->item_size(), // e->items_per_enumerate());
e->items_per_enumerate()); // actual_buffer_length = e->item_size() * e->items_per_enumerate();
} // }
// leaving old method commented for now until more widely tested
// Don't trust buffer_length. It might be invalid (Based on "Resonance of fate")
// also fixes "Angry Birds" - Thanks Gliniak
size_t actual_buffer_length = e->item_count() * e->item_size();
buffer.Zero(actual_buffer_length); buffer.Zero(actual_buffer_length);