summaryrefslogtreecommitdiff
path: root/view/sharedcache/workflow/SharedCacheWorkflow.cpp
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-04-08 14:16:05 -0400
committerMason Reed <mason@vector35.com>2025-04-08 14:16:16 -0400
commit0f26e9236d52e5e2f0a8e64114d954a516cbeb95 (patch)
tree3f011a89ae1f486eec1641a5c01a9dfc392086ba /view/sharedcache/workflow/SharedCacheWorkflow.cpp
parenta45466fc3227c615c72e77eb7368d7e83220b325 (diff)
[SharedCache] Apply demangled names and types more broadly
Fixes the case of stub functions being applied with mangled names.
Diffstat (limited to 'view/sharedcache/workflow/SharedCacheWorkflow.cpp')
-rw-r--r--view/sharedcache/workflow/SharedCacheWorkflow.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/view/sharedcache/workflow/SharedCacheWorkflow.cpp b/view/sharedcache/workflow/SharedCacheWorkflow.cpp
index 5980d141..c0c90f87 100644
--- a/view/sharedcache/workflow/SharedCacheWorkflow.cpp
+++ b/view/sharedcache/workflow/SharedCacheWorkflow.cpp
@@ -87,22 +87,28 @@ void IdentifyStub(BinaryView& view, const SharedCacheController& controller, uin
if (!symbol.has_value())
return;
+ // Demangle if possible, the type pulled will be used, however type library will take precedence.
+ auto [demangledName, demangledType] = symbol->DemangledName(view);
+ auto rawName = STUB_PREFIX + symbol->name;
+ auto shortName = STUB_PREFIX + demangledName;
+
// Try and retrieve a type for the stub function using type libraries.
if (const auto targetFunc = view.GetAnalysisFunction(view.GetDefaultPlatform(), stubFuncAddr))
{
// NOTE: The type library name is expected to be the image name currently.
// Try and pull the type from the associated type library (if there is one)
- Ref<Type> type = nullptr;
+ Ref<Type> selectedType = demangledType;
if (const auto image = controller.GetImageContaining(symbolAddr))
if (auto typeLib = TypeLibraryFromName(view, image->name))
- type = view.ImportTypeLibraryObject(typeLib, {symbol->name});
+ selectedType = view.ImportTypeLibraryObject(typeLib, {symbol->name});
- if (type)
- targetFunc->SetAutoType(type);
+ if (selectedType)
+ targetFunc->SetAutoType(selectedType);
}
// Define the new symbol!
- view.DefineAutoSymbol(new Symbol(symbol->type, STUB_PREFIX + symbol->name, stubFuncAddr));
+ auto bnSymbol = new Symbol(symbol->type, shortName, shortName, rawName, stubFuncAddr, nullptr);
+ view.DefineAutoSymbol(bnSymbol);
}
void AnalyzeStubFunction(Ref<Function> func, Ref<MediumLevelILFunction> mlil, SharedCacheController& controller, bool loadImage)