Merge pull request #8370 from sepalani/fix-hle-patch

HLE: Fix patching functions with the same name
This commit is contained in:
JMC47 2019-10-06 05:07:54 -04:00 committed by GitHub
commit b6545ea285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

@ -192,11 +192,13 @@ u32 GetFunctionIndex(u32 address)
u32 GetFirstFunctionIndex(u32 address) u32 GetFirstFunctionIndex(u32 address)
{ {
u32 index = GetFunctionIndex(address); const u32 index = GetFunctionIndex(address);
auto first = std::find_if( // Fixed hooks use a fixed address and don't patch the whole function
s_original_instructions.begin(), s_original_instructions.end(), if (index == 0 || OSPatches[index].flags == HookFlag::Fixed)
[=](const auto& entry) { return entry.second == index && entry.first < address; }); return index;
return first == std::end(s_original_instructions) ? index : 0;
const auto symbol = g_symbolDB.GetSymbolFromAddr(address);
return (symbol && symbol->address == address) ? index : 0;
} }
HookType GetFunctionTypeByIndex(u32 index) HookType GetFunctionTypeByIndex(u32 index)