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:
parent
3b792edc90
commit
6eebb100f8
|
@ -63,7 +63,7 @@ Export* ExportResolver::GetExportByOrdinal(const char* module_name,
|
||||||
for (const auto& table : tables_) {
|
for (const auto& table : tables_) {
|
||||||
if (std::strncmp(module_name, table.module_name(),
|
if (std::strncmp(module_name, table.module_name(),
|
||||||
std::strlen(table.module_name())) == 0) {
|
std::strlen(table.module_name())) == 0) {
|
||||||
if (ordinal > table.exports_by_ordinal().size()) {
|
if (ordinal >= table.exports_by_ordinal().size()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return table.exports_by_ordinal().at(ordinal);
|
return table.exports_by_ordinal().at(ordinal);
|
||||||
|
|
|
@ -125,7 +125,7 @@ uint32_t XexModule::GetProcAddress(uint16_t ordinal) const {
|
||||||
xex_security_info()->export_table);
|
xex_security_info()->export_table);
|
||||||
|
|
||||||
ordinal -= export_table->base;
|
ordinal -= export_table->base;
|
||||||
if (ordinal > export_table->count) {
|
if (ordinal >= export_table->count) {
|
||||||
XELOGE("GetProcAddress(%.3X): ordinal out of bounds", ordinal);
|
XELOGE("GetProcAddress(%.3X): ordinal out of bounds", ordinal);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,12 +106,12 @@ uint32_t KernelModule::GetProcAddressByOrdinal(uint16_t ordinal) {
|
||||||
} else {
|
} else {
|
||||||
if (export_entry->function_data.trampoline ||
|
if (export_entry->function_data.trampoline ||
|
||||||
export_entry->function_data.shim) {
|
export_entry->function_data.shim) {
|
||||||
global_critical_region_.Acquire();
|
auto global_lock = global_critical_region_.Acquire();
|
||||||
|
|
||||||
// See if the function has been generated already.
|
// See if the function has been generated already.
|
||||||
if (guest_trampoline_map_.find(ordinal) != guest_trampoline_map_.end()) {
|
auto item = guest_trampoline_map_.find(ordinal);
|
||||||
auto entry = guest_trampoline_map_.find(ordinal);
|
if (item != guest_trampoline_map_.end()) {
|
||||||
return entry->second;
|
return item->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu::GuestFunction::ExternHandler handler = nullptr;
|
cpu::GuestFunction::ExternHandler handler = nullptr;
|
||||||
|
@ -130,7 +130,7 @@ uint32_t KernelModule::GetProcAddressByOrdinal(uint16_t ordinal) {
|
||||||
export_entry->name, guest_addr);
|
export_entry->name, guest_addr);
|
||||||
|
|
||||||
// Register the function in our map.
|
// Register the function in our map.
|
||||||
guest_trampoline_map_[ordinal] = guest_addr;
|
guest_trampoline_map_.emplace(ordinal, guest_addr);
|
||||||
return guest_addr;
|
return guest_addr;
|
||||||
} else {
|
} else {
|
||||||
// Not implemented.
|
// Not implemented.
|
||||||
|
|
Loading…
Reference in New Issue