From 85d51eeefdca18ec9efe8c4b85d9e5b457ad9e11 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sun, 11 May 2025 21:40:35 -0400 Subject: Misc shared cache improvements - Removed last use of user object creation in objective-c - Fixed function type info being omitted from certain images loaded automatically - Add TODO about undo action in view init. This is not critical, just a non-actionable warning because of a design flaw I will restate this again for anyone in the future, until the undo action system is thread-safe avoid calling it from any thread other than the main thread, it is very easy to deadlock or cause other issues. That goes for basically all user analysis object creation. --- view/sharedcache/workflow/SharedCacheWorkflow.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'view/sharedcache/workflow/SharedCacheWorkflow.cpp') diff --git a/view/sharedcache/workflow/SharedCacheWorkflow.cpp b/view/sharedcache/workflow/SharedCacheWorkflow.cpp index cde8310c..3fce2e39 100644 --- a/view/sharedcache/workflow/SharedCacheWorkflow.cpp +++ b/view/sharedcache/workflow/SharedCacheWorkflow.cpp @@ -87,7 +87,7 @@ 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. + // TODO: The demangled type here is almost always wrong so we omit it for now. auto [demangledName, demangledType] = symbol->DemangledName(view); auto rawName = STUB_PREFIX + symbol->name; auto shortName = STUB_PREFIX + demangledName; @@ -97,13 +97,16 @@ void IdentifyStub(BinaryView& view, const SharedCacheController& controller, uin { // 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 selectedType = demangledType; + // TODO: The demangled type here is missing a param + // Ref selectedType = demangledType; + Ref selectedType = nullptr; if (const auto image = controller.GetImageContaining(symbolAddr)) if (auto typeLib = TypeLibraryFromName(view, image->name)) - selectedType = view.ImportTypeLibraryObject(typeLib, {symbol->name}); + if (Ref libraryType = view.ImportTypeLibraryObject(typeLib, {symbol->name}); libraryType) + selectedType = libraryType; - if (selectedType) - targetFunc->SetAutoType(selectedType); + if (selectedType != nullptr) + targetFunc->ApplyAutoDiscoveredType(selectedType); } // Define the new symbol! @@ -167,6 +170,8 @@ void AnalyzeStubFunction(Ref func, Ref mlil, Sh if (defInstr.operation != MLIL_SET_VAR_SSA) return; expr = defInstr.GetSourceExpr(); + if (expr.operation != MLIL_LOAD_SSA) + return; // Fallthrough to MLIL_LOAD_SSA. } case MLIL_LOAD_SSA: -- cgit v1.3.1