From 248b661d14cb6ec24ebf2432cedb4f2eb777558d Mon Sep 17 00:00:00 2001 From: gibbed Date: Mon, 26 Nov 2018 19:53:03 -0600 Subject: [PATCH] [Kernel] Maybe fix XamEnumerate, again? Some titles, when using XamEnumerate synchronously, expect X_ERROR_NO_MORE_FILES as the return value. Some titles, when using XamEnumerate asynchronously, expect X_ERROR_FUNCTION_FAILED as the overlapped result. --- src/xenia/kernel/xam/xam_info.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xenia/kernel/xam/xam_info.cc b/src/xenia/kernel/xam/xam_info.cc index aa089927e..af1c5c3ee 100644 --- a/src/xenia/kernel/xam/xam_info.cc +++ b/src/xenia/kernel/xam/xam_info.cc @@ -373,7 +373,7 @@ dword_result_t XamEnumerate(dword_t handle, dword_t flags, lpvoid_t buffer, if (actual_buffer_length < e->item_size()) { result = X_ERROR_INSUFFICIENT_BUFFER; } else if (e->current_item() >= e->item_count()) { - result = X_ERROR_FUNCTION_FAILED; + result = X_ERROR_NO_MORE_FILES; } else { auto item_buffer = buffer.as(); auto max_items = actual_buffer_length / e->item_size(); @@ -387,8 +387,6 @@ dword_result_t XamEnumerate(dword_t handle, dword_t flags, lpvoid_t buffer, result = X_ERROR_SUCCESS; } - // Return X_ERROR_NO_MORE_FILES in HRESULT form. - X_HRESULT extended_result = result != 0 ? X_HRESULT_FROM_WIN32(result) : 0; if (items_returned) { assert_true(!overlapped); *items_returned = result == X_ERROR_SUCCESS ? item_count : 0; @@ -396,7 +394,9 @@ dword_result_t XamEnumerate(dword_t handle, dword_t flags, lpvoid_t buffer, } else if (overlapped) { assert_true(!items_returned); kernel_state()->CompleteOverlappedImmediateEx( - overlapped, result, extended_result, + overlapped, + result == X_ERROR_SUCCESS ? X_ERROR_SUCCESS : X_ERROR_FUNCTION_FAILED, + X_RESULT_FROM_WIN32(result), result == X_ERROR_SUCCESS ? item_count : 0); return X_ERROR_IO_PENDING; } else {