Rewrite XamEnumerate to copy one item at a time (for now anyways)
This commit is contained in:
parent
ee1565b0e8
commit
df500e162e
|
@ -198,51 +198,44 @@ SHIM_CALL XamFree_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||||
SHIM_SET_RETURN_32(X_ERROR_SUCCESS);
|
SHIM_SET_RETURN_32(X_ERROR_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
SHIM_CALL XamEnumerate_shim(PPCContext* ppc_context,
|
// https://github.com/LestaD/SourceEngine2007/blob/master/se2007/engine/xboxsystem.cpp#L518
|
||||||
KernelState* kernel_state) {
|
dword_result_t XamEnumerate(dword_t handle, dword_t flags, lpvoid_t buffer,
|
||||||
uint32_t handle = SHIM_GET_ARG_32(0);
|
dword_t buffer_length, lpdword_t items_returned,
|
||||||
uint32_t zero = SHIM_GET_ARG_32(1);
|
pointer_t<XAM_OVERLAPPED> overlapped) {
|
||||||
uint32_t buffer_ptr = SHIM_GET_ARG_32(2);
|
assert_true(flags == 0);
|
||||||
uint32_t buffer_length = SHIM_GET_ARG_32(3);
|
|
||||||
uint32_t item_count_ptr = SHIM_GET_ARG_32(4);
|
|
||||||
uint32_t overlapped_ptr = SHIM_GET_ARG_32(5);
|
|
||||||
|
|
||||||
assert_true(zero == 0);
|
auto e = kernel_state()->object_table()->LookupObject<XEnumerator>(handle);
|
||||||
|
|
||||||
XELOGD("XamEnumerate(%.8X, %d, %.8X, %d, %.8X, %.8X)", handle, zero,
|
|
||||||
buffer_ptr, buffer_length, item_count_ptr, overlapped_ptr);
|
|
||||||
|
|
||||||
auto e = kernel_state->object_table()->LookupObject<XEnumerator>(handle);
|
|
||||||
if (!e) {
|
if (!e) {
|
||||||
if (overlapped_ptr) {
|
if (overlapped) {
|
||||||
kernel_state->CompleteOverlappedImmediateEx(
|
kernel_state()->CompleteOverlappedImmediateEx(
|
||||||
overlapped_ptr, X_ERROR_INVALID_HANDLE, X_ERROR_INVALID_HANDLE, 0);
|
overlapped, X_ERROR_INVALID_HANDLE, X_ERROR_INVALID_HANDLE, 0);
|
||||||
SHIM_SET_RETURN_32(X_ERROR_IO_PENDING);
|
return X_ERROR_IO_PENDING;
|
||||||
} else {
|
} else {
|
||||||
SHIM_SET_RETURN_32(X_ERROR_INVALID_HANDLE);
|
return X_ERROR_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto item_count = e->item_count();
|
buffer.Zero(buffer_length);
|
||||||
e->WriteItems(SHIM_MEM_ADDR(buffer_ptr));
|
X_RESULT result =
|
||||||
|
e->WriteItem(buffer) ? X_ERROR_SUCCESS : X_ERROR_NO_MORE_FILES;
|
||||||
|
if (items_returned) {
|
||||||
|
assert_true(!overlapped);
|
||||||
|
*items_returned = result == X_ERROR_SUCCESS ? 1 : 0;
|
||||||
|
|
||||||
X_RESULT result = item_count ? X_ERROR_SUCCESS : X_ERROR_NO_MORE_FILES;
|
return result;
|
||||||
if (item_count_ptr) {
|
} else if (overlapped) {
|
||||||
assert_zero(overlapped_ptr);
|
assert_true(!items_returned);
|
||||||
SHIM_SET_MEM_32(item_count_ptr, item_count);
|
kernel_state()->CompleteOverlappedImmediateEx(
|
||||||
} else if (overlapped_ptr) {
|
overlapped, result, result,
|
||||||
assert_zero(item_count_ptr);
|
result == X_ERROR_SUCCESS ? e->item_count() : 0);
|
||||||
kernel_state->CompleteOverlappedImmediateEx(overlapped_ptr, result, result,
|
|
||||||
item_count);
|
return X_ERROR_IO_PENDING;
|
||||||
result = X_ERROR_IO_PENDING;
|
|
||||||
} else {
|
} else {
|
||||||
assert_always();
|
assert_always();
|
||||||
result = X_ERROR_INVALID_PARAMETER;
|
return X_ERROR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
SHIM_SET_RETURN_32(result);
|
|
||||||
}
|
}
|
||||||
|
DECLARE_XAM_EXPORT(XamEnumerate, ExportTag::kImplemented);
|
||||||
|
|
||||||
} // namespace kernel
|
} // namespace kernel
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
@ -258,6 +251,4 @@ void xe::kernel::xam::RegisterInfoExports(
|
||||||
|
|
||||||
SHIM_SET_MAPPING("xam.xex", XamAlloc, state);
|
SHIM_SET_MAPPING("xam.xex", XamAlloc, state);
|
||||||
SHIM_SET_MAPPING("xam.xex", XamFree, state);
|
SHIM_SET_MAPPING("xam.xex", XamFree, state);
|
||||||
|
|
||||||
SHIM_SET_MAPPING("xam.xex", XamEnumerate, state);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue