Merge branch 'get-proc-address-by-ordinal' of https://github.com/CookiePLMonster/xenia into canary

[Kernel] Fixup GetProcAddressByOrdinal PR 1473
This commit is contained in:
Cancerous 2019-09-08 23:10:12 -04:00 committed by illusion98
parent a17f507f0f
commit db2d11897c
3 changed files with 7 additions and 7 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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.