From 3e0db586c0bf8b26db96a6449660e89474941bba Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 22 Sep 2013 16:45:41 -0700 Subject: [PATCH] RtlNtStatusToDosError, for successes. --- .../kernel/modules/xboxkrnl/xboxkrnl_rtl.cc | 31 +++++++++++++++++++ .../kernel/modules/xboxkrnl/xboxkrnl_rtl.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_rtl.cc b/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_rtl.cc index b4511034b..6f1d80327 100644 --- a/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_rtl.cc +++ b/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_rtl.cc @@ -535,6 +535,35 @@ SHIM_CALL _vsnprintf_shim( } +uint32_t xeRtlNtStatusToDosError(X_STATUS status) { + if (!status || (status & 0x20000000)) { + // Success. + return status; + } else if ((status & 0xF0000000) == 0xD0000000) { + // High bit doesn't matter. + status &= ~0x10000000; + } + + // TODO(benvanik): implement lookup table. + XELOGE("RtlNtStatusToDosError lookup NOT IMPLEMENTED"); + + return 317; // ERROR_MR_MID_NOT_FOUND +} + + +SHIM_CALL RtlNtStatusToDosError_shim( + xe_ppc_state_t* ppc_state, KernelState* state) { + uint32_t status = SHIM_GET_ARG_32(0); + + XELOGD( + "RtlNtStatusToDosError(%.4X)", + status); + + uint32_t result = xeRtlNtStatusToDosError(status); + SHIM_SET_RETURN(result); +} + + uint32_t xeRtlImageXexHeaderField(uint32_t xex_header_base_ptr, uint32_t image_field) { KernelState* state = shared_kernel_state_; @@ -835,6 +864,8 @@ void xe::kernel::xboxkrnl::RegisterRtlExports( SHIM_SET_MAPPING("xboxkrnl.exe", _vsnprintf, state); + SHIM_SET_MAPPING("xboxkrnl.exe", RtlNtStatusToDosError, state); + SHIM_SET_MAPPING("xboxkrnl.exe", RtlImageXexHeaderField, state); SHIM_SET_MAPPING("xboxkrnl.exe", RtlInitializeCriticalSection, state); diff --git a/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_rtl.h b/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_rtl.h index 9a998514b..fc4f59222 100644 --- a/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_rtl.h +++ b/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_rtl.h @@ -36,6 +36,8 @@ void xeRtlFreeUnicodeString(uint32_t string_ptr); X_STATUS xeRtlUnicodeStringToAnsiString( uint32_t destination_ptr, uint32_t source_ptr, uint32_t alloc_dest); +uint32_t xeRtlNtStatusToDosError(X_STATUS status); + uint32_t xeRtlImageXexHeaderField(uint32_t xex_header_base_ptr, uint32_t image_field);