[Kernel] Fixup GetProcAddressByOrdinal
Now properly takes a global lock when populating guest_trampoline_map_ as opposed to taking and immediately releasing it Also removes a redundant find() from guest_trampoline_map_ so map is not searched twice if the function has already been generated.
This commit is contained in:
parent
5795d25afe
commit
9205a6b062
|
@ -107,12 +107,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;
|
||||||
|
@ -131,7 +131,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