diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_ob.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_ob.cc index 8ecc5b3c0..e09096eb0 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_ob.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_ob.cc @@ -7,6 +7,7 @@ ****************************************************************************** */ +#include "xenia/base/assert.h" #include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/util/shim_utils.h" @@ -31,10 +32,15 @@ dword_result_t ObOpenObjectByName_entry(lpunknown_t obj_attributes_ptr, // r5 = 0 // r6 = out_ptr (handle?) - auto name = util::TranslateAnsiStringAddress( - kernel_memory(), - xe::load_and_swap(kernel_memory()->TranslateVirtual( - obj_attributes_ptr.guest_address() + 4))); + if (!obj_attributes_ptr) { + return X_STATUS_INVALID_PARAMETER; + } + + auto obj_attributes = kernel_memory()->TranslateVirtual( + obj_attributes_ptr); + assert_true(obj_attributes->name_ptr != 0); + auto name = util::TranslateAnsiStringAddress(kernel_memory(), + obj_attributes->name_ptr); X_HANDLE handle = X_INVALID_HANDLE_VALUE; X_STATUS result = diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_threading.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_threading.cc index 7e6c605e4..5b3c97fc0 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_threading.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_threading.cc @@ -74,10 +74,12 @@ object_ref LookupNamedObject(KernelState* kernel_state, if (!obj_attributes_ptr) { return nullptr; } - auto name = util::TranslateAnsiStringAddress( - kernel_state->memory(), - xe::load_and_swap( - kernel_state->memory()->TranslateVirtual(obj_attributes_ptr + 4))); + auto obj_attributes = + kernel_state->memory()->TranslateVirtual( + obj_attributes_ptr); + assert_true(obj_attributes->name_ptr != 0); + auto name = util::TranslateAnsiStringAddress(kernel_state->memory(), + obj_attributes->name_ptr); if (!name.empty()) { X_HANDLE handle = X_INVALID_HANDLE_VALUE; X_RESULT result =