diff --git a/src/xenia/cpu/export_resolver.cc b/src/xenia/cpu/export_resolver.cc index 68028e7a2..9b500caee 100644 --- a/src/xenia/cpu/export_resolver.cc +++ b/src/xenia/cpu/export_resolver.cc @@ -63,7 +63,7 @@ Export* ExportResolver::GetExportByOrdinal(const char* module_name, for (const auto& table : tables_) { if (std::strncmp(module_name, table.module_name(), std::strlen(table.module_name())) == 0) { - if (ordinal > table.exports_by_ordinal().size()) { + if (ordinal >= table.exports_by_ordinal().size()) { return nullptr; } return table.exports_by_ordinal().at(ordinal); diff --git a/src/xenia/cpu/xex_module.cc b/src/xenia/cpu/xex_module.cc index 7208b55b9..06e075ab9 100644 --- a/src/xenia/cpu/xex_module.cc +++ b/src/xenia/cpu/xex_module.cc @@ -125,7 +125,7 @@ uint32_t XexModule::GetProcAddress(uint16_t ordinal) const { xex_security_info()->export_table); ordinal -= export_table->base; - if (ordinal > export_table->count) { + if (ordinal >= export_table->count) { XELOGE("GetProcAddress(%.3X): ordinal out of bounds", ordinal); return 0; } diff --git a/src/xenia/kernel/kernel_module.cc b/src/xenia/kernel/kernel_module.cc index 69c958a08..fa4ff9af7 100644 --- a/src/xenia/kernel/kernel_module.cc +++ b/src/xenia/kernel/kernel_module.cc @@ -106,12 +106,12 @@ uint32_t KernelModule::GetProcAddressByOrdinal(uint16_t ordinal) { } else { if (export_entry->function_data.trampoline || export_entry->function_data.shim) { - global_critical_region_.Acquire(); + auto global_lock = global_critical_region_.Acquire(); // See if the function has been generated already. - if (guest_trampoline_map_.find(ordinal) != guest_trampoline_map_.end()) { - auto entry = guest_trampoline_map_.find(ordinal); - return entry->second; + auto item = guest_trampoline_map_.find(ordinal); + if (item != guest_trampoline_map_.end()) { + return item->second; } cpu::GuestFunction::ExternHandler handler = nullptr; @@ -130,7 +130,7 @@ uint32_t KernelModule::GetProcAddressByOrdinal(uint16_t ordinal) { export_entry->name, guest_addr); // Register the function in our map. - guest_trampoline_map_[ordinal] = guest_addr; + guest_trampoline_map_.emplace(ordinal, guest_addr); return guest_addr; } else { // Not implemented.