[XAM] Ensure items returned is set in enumerate.

[XAM] Ensure items returned is set in xeXamEnumerate.
This commit is contained in:
gibbed 2020-11-29 02:00:16 -06:00 committed by Rick Gibbed
parent c55918d944
commit 215f2a340b
1 changed files with 33 additions and 39 deletions

View File

@ -32,17 +32,13 @@ uint32_t xeXamEnumerate(uint32_t handle, uint32_t flags, void* buffer,
uint32_t overlapped_ptr) { uint32_t overlapped_ptr) {
assert_true(flags == 0); assert_true(flags == 0);
X_RESULT result;
uint32_t item_count = 0;
auto e = kernel_state()->object_table()->LookupObject<XEnumerator>(handle); auto e = kernel_state()->object_table()->LookupObject<XEnumerator>(handle);
if (!e) { if (!e) {
if (overlapped_ptr) { result = X_ERROR_INVALID_HANDLE;
kernel_state()->CompleteOverlappedImmediateEx(
overlapped_ptr, X_ERROR_INVALID_HANDLE, X_ERROR_INVALID_HANDLE, 0);
return X_ERROR_IO_PENDING;
} else { } else {
return X_ERROR_INVALID_HANDLE;
}
}
size_t actual_buffer_length = buffer_length; size_t actual_buffer_length = 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(); actual_buffer_length = e->item_size() * e->items_per_enumerate();
@ -58,9 +54,6 @@ uint32_t xeXamEnumerate(uint32_t handle, uint32_t flags, void* buffer,
std::memset(buffer, 0, actual_buffer_length); std::memset(buffer, 0, actual_buffer_length);
X_RESULT result;
uint32_t item_count = 0;
if (actual_buffer_length < e->item_size()) { if (actual_buffer_length < e->item_size()) {
result = X_ERROR_INSUFFICIENT_BUFFER; result = X_ERROR_INSUFFICIENT_BUFFER;
} else if (e->current_item() >= e->item_count()) { } else if (e->current_item() >= e->item_count()) {
@ -77,6 +70,7 @@ uint32_t xeXamEnumerate(uint32_t handle, uint32_t flags, void* buffer,
} }
result = X_ERROR_SUCCESS; result = X_ERROR_SUCCESS;
} }
}
if (items_returned) { if (items_returned) {
assert_true(!overlapped_ptr); assert_true(!overlapped_ptr);