diff options
| author | Rusty Wagner <rusty.wagner@gmail.com> | 2025-06-24 17:55:48 -0400 |
|---|---|---|
| committer | Alexander Taylor <alex@vector35.com> | 2025-06-25 18:36:47 -0400 |
| commit | c41f264a1dba68c89b4a224a70e3a5783f7fa879 (patch) | |
| tree | 00bb6e91d86b708bff7265ed7179a6ef2793b7fb /view | |
| parent | b1a7666164a000c5255f90568ed9597b58ce276a (diff) | |
Remove implicit conversions from Confidence to underlying type, these can cause bugs and also issues with C++20
Diffstat (limited to 'view')
| -rw-r--r-- | view/elf/elfview.cpp | 9 | ||||
| -rw-r--r-- | view/elf/elfview.h | 2 | ||||
| -rw-r--r-- | view/kernelcache/api/python/generator.cpp | 32 | ||||
| -rw-r--r-- | view/macho/machoview.cpp | 2 | ||||
| -rw-r--r-- | view/md1rom/md1rom.cpp | 2 | ||||
| -rw-r--r-- | view/pe/peview.cpp | 2 | ||||
| -rw-r--r-- | view/sharedcache/api/python/generator.cpp | 32 |
7 files changed, 41 insertions, 40 deletions
diff --git a/view/elf/elfview.cpp b/view/elf/elfview.cpp index d8a0a112..b8dd1aaa 100644 --- a/view/elf/elfview.cpp +++ b/view/elf/elfview.cpp @@ -2396,7 +2396,8 @@ bool ElfView::Init() ); /* create type, associate it with RTL_Resolve */ - Ref<Type> ptr_type = Type::PointerType(m_arch, Type::VoidType())->WithConfidence(BN_FULL_CONFIDENCE); + Confidence<Ref<Type>> ptr_type = + Type::PointerType(m_arch, Type::VoidType())->WithConfidence(BN_FULL_CONFIDENCE); Ref<CallingConvention> cc = m_arch->GetCallingConventionByName("linux-rtlresolve"); @@ -2452,20 +2453,20 @@ bool ElfView::Init() void ElfView::DefineElfSymbol(BNSymbolType type, const string& incomingName, uint64_t addr, bool gotEntry, - BNSymbolBinding binding, size_t size, Ref<Type> typeObj) + BNSymbolBinding binding, size_t size, const Confidence<Ref<Type>>& typeObj) { // Ensure symbol is within the executable if (type != ExternalSymbol && !IsValidOffset(addr)) return; string name = incomingName; - Ref<Type> symbolTypeRef; + Confidence<Ref<Type>> symbolTypeRef; if ((type == ExternalSymbol) || (type == ImportAddressSymbol) || (type == ImportedDataSymbol)) { QualifiedName n(name); Ref<TypeLibrary> lib = nullptr; symbolTypeRef = ImportTypeLibraryObject(lib, n); - if (symbolTypeRef) + if (symbolTypeRef.GetValue()) { m_logger->LogDebug("elf: type Library '%s' found hit for '%s'", lib->GetName().c_str(), name.c_str()); if (type != ExternalSymbol || addr != 0) diff --git a/view/elf/elfview.h b/view/elf/elfview.h index 23a5021a..a43716b7 100644 --- a/view/elf/elfview.h +++ b/view/elf/elfview.h @@ -518,7 +518,7 @@ namespace BinaryNinja SymbolQueue* m_symbolQueue = nullptr; void DefineElfSymbol(BNSymbolType type, const std::string& name, uint64_t addr, bool gotEntry, - BNSymbolBinding binding, size_t size=0, Ref<Type> typeObj=nullptr); + BNSymbolBinding binding, size_t size = 0, const Confidence<Ref<Type>>& typeObj = nullptr); void ApplyTypesToParentStringTable(const Elf64SectionHeader& section, const bool offset = true); void ApplyTypesToStringTable(const Elf64SectionHeader& section, const int64_t imageBaseAdjustment, const bool offset = true); diff --git a/view/kernelcache/api/python/generator.cpp b/view/kernelcache/api/python/generator.cpp index 89a187fa..31d5432c 100644 --- a/view/kernelcache/api/python/generator.cpp +++ b/view/kernelcache/api/python/generator.cpp @@ -142,21 +142,21 @@ void OutputType(FILE* out, Type* type, bool isReturnType = false, bool isCallbac else if (type->GetChildType()->GetClass() == FunctionTypeClass) { fprintf(out, "ctypes.CFUNCTYPE("); - OutputType(out, type->GetChildType()->GetChildType(), true, true); + OutputType(out, type->GetChildType()->GetChildType().GetValue(), true, true); for (auto& i : type->GetChildType()->GetParameters()) { fprintf(out, ", "); - OutputType(out, i.type); + OutputType(out, i.type.GetValue()); } fprintf(out, ")"); break; } fprintf(out, "ctypes.POINTER("); - OutputType(out, type->GetChildType()); + OutputType(out, type->GetChildType().GetValue()); fprintf(out, ")"); break; case ArrayTypeClass: - OutputType(out, type->GetChildType()); + OutputType(out, type->GetChildType().GetValue()); fprintf(out, " * %" PRId64, type->GetElementCount()); break; default: @@ -213,21 +213,21 @@ void OutputSwizzledType(FILE* out, Type* type) else if (type->GetChildType()->GetClass() == FunctionTypeClass) { fprintf(out, "ctypes.CFUNCTYPE("); - OutputType(out, type->GetChildType()->GetChildType(), true, true); + OutputType(out, type->GetChildType()->GetChildType().GetValue(), true, true); for (auto& i : type->GetChildType()->GetParameters()) { fprintf(out, ", "); - OutputType(out, i.type); + OutputType(out, i.type.GetValue()); } fprintf(out, ")"); break; } fprintf(out, "ctypes.POINTER("); - OutputType(out, type->GetChildType()); + OutputType(out, type->GetChildType().GetValue()); fprintf(out, ")"); break; case ArrayTypeClass: - OutputType(out, type->GetChildType()); + OutputType(out, type->GetChildType().GetValue()); fprintf(out, " * %" PRId64, type->GetElementCount()); break; default: @@ -397,7 +397,7 @@ int main(int argc, char* argv[]) } else fprintf(out, "\t\t(\"%s\", ", j.name.c_str()); - OutputType(out, j.type); + OutputType(out, j.type.GetValue()); fprintf(out, "),\n"); } fprintf(out, "\t]\n"); @@ -467,7 +467,7 @@ int main(int argc, char* argv[]) fprintf(out, "# %s\n\n", funcName.c_str()); fprintf(out, "%s = core.%s\n", funcName.c_str(), name.c_str()); fprintf(out, "%s.restype = ", funcName.c_str()); - OutputType(out, i.second->GetChildType(), true, callbackConvention); + OutputType(out, i.second->GetChildType().GetValue(), true, callbackConvention); fprintf(out, "\n"); if (!i.second->HasVariableArguments()) { @@ -480,11 +480,11 @@ int main(int argc, char* argv[]) // BNDebuggerFreeString expects a pointer to a string allocated by the core, so do not use // a c_char_p here, as that would be allocated by the Python runtime. This can // be enforced by outputting like a return value. - OutputType(out, j.type, true); + OutputType(out, j.type.GetValue(), true); } else { - OutputType(out, j.type); + OutputType(out, j.type.GetValue()); } fprintf(out, ",\n"); } @@ -528,9 +528,9 @@ int main(int argc, char* argv[]) fprintf(out, "\n\t\t"); fprintf(out, "%s: ", argName.c_str()); if (swizzleArgs) - OutputSwizzledType(out, arg.type); + OutputSwizzledType(out, arg.type.GetValue()); else - OutputType(out, arg.type); + OutputType(out, arg.type.GetValue()); argN ++; } } @@ -539,13 +539,13 @@ int main(int argc, char* argv[]) { if (stringResult || pointerResult) fprintf(out, "Optional["); - OutputSwizzledType(out, i.second->GetChildType()); + OutputSwizzledType(out, i.second->GetChildType().GetValue()); if (stringResult || pointerResult) fprintf(out, "]"); } else { - OutputType(out, i.second->GetChildType()); + OutputType(out, i.second->GetChildType().GetValue()); } fprintf(out, ":\n"); diff --git a/view/macho/machoview.cpp b/view/macho/machoview.cpp index 26839c93..3d8b0186 100644 --- a/view/macho/machoview.cpp +++ b/view/macho/machoview.cpp @@ -2478,7 +2478,7 @@ Ref<Symbol> MachoView::DefineMachoSymbol( if (deferred) { - m_symbolQueue->Append(process, [this](Symbol* symbol, Type* type) { + m_symbolQueue->Append(process, [this](Symbol* symbol, const Confidence<Ref<Type>>& type) { DefineAutoSymbolAndVariableOrFunction(GetDefaultPlatform(), symbol, type); }); return nullptr; diff --git a/view/md1rom/md1rom.cpp b/view/md1rom/md1rom.cpp index 1d8da293..b302cfb0 100644 --- a/view/md1rom/md1rom.cpp +++ b/view/md1rom/md1rom.cpp @@ -230,7 +230,7 @@ void Md1romView::DefineMd1RomSymbol(BNSymbolType type, const string& name, uint6 if (m_symbolQueue) { - m_symbolQueue->Append(process, [this](Symbol* symbol, Type* type) { + m_symbolQueue->Append(process, [this](Symbol* symbol, const Confidence<Ref<Type>>& type) { DefineAutoSymbolAndVariableOrFunction(GetDefaultPlatform(), symbol, type); }); } diff --git a/view/pe/peview.cpp b/view/pe/peview.cpp index 6c852bca..e45edd05 100644 --- a/view/pe/peview.cpp +++ b/view/pe/peview.cpp @@ -3003,7 +3003,7 @@ void PEView::AddPESymbol(BNSymbolType type, const string& dll, const string& nam new Symbol(type, shortName, fullName, rawName, address, binding, ns, ordinal), typeRef); }, - [this](Symbol* symbol, Type* type) { + [this](Symbol* symbol, const Confidence<Ref<Type>>& type) { DefineAutoSymbolAndVariableOrFunction(GetDefaultPlatform(), symbol, type); }); } diff --git a/view/sharedcache/api/python/generator.cpp b/view/sharedcache/api/python/generator.cpp index 89a187fa..31d5432c 100644 --- a/view/sharedcache/api/python/generator.cpp +++ b/view/sharedcache/api/python/generator.cpp @@ -142,21 +142,21 @@ void OutputType(FILE* out, Type* type, bool isReturnType = false, bool isCallbac else if (type->GetChildType()->GetClass() == FunctionTypeClass) { fprintf(out, "ctypes.CFUNCTYPE("); - OutputType(out, type->GetChildType()->GetChildType(), true, true); + OutputType(out, type->GetChildType()->GetChildType().GetValue(), true, true); for (auto& i : type->GetChildType()->GetParameters()) { fprintf(out, ", "); - OutputType(out, i.type); + OutputType(out, i.type.GetValue()); } fprintf(out, ")"); break; } fprintf(out, "ctypes.POINTER("); - OutputType(out, type->GetChildType()); + OutputType(out, type->GetChildType().GetValue()); fprintf(out, ")"); break; case ArrayTypeClass: - OutputType(out, type->GetChildType()); + OutputType(out, type->GetChildType().GetValue()); fprintf(out, " * %" PRId64, type->GetElementCount()); break; default: @@ -213,21 +213,21 @@ void OutputSwizzledType(FILE* out, Type* type) else if (type->GetChildType()->GetClass() == FunctionTypeClass) { fprintf(out, "ctypes.CFUNCTYPE("); - OutputType(out, type->GetChildType()->GetChildType(), true, true); + OutputType(out, type->GetChildType()->GetChildType().GetValue(), true, true); for (auto& i : type->GetChildType()->GetParameters()) { fprintf(out, ", "); - OutputType(out, i.type); + OutputType(out, i.type.GetValue()); } fprintf(out, ")"); break; } fprintf(out, "ctypes.POINTER("); - OutputType(out, type->GetChildType()); + OutputType(out, type->GetChildType().GetValue()); fprintf(out, ")"); break; case ArrayTypeClass: - OutputType(out, type->GetChildType()); + OutputType(out, type->GetChildType().GetValue()); fprintf(out, " * %" PRId64, type->GetElementCount()); break; default: @@ -397,7 +397,7 @@ int main(int argc, char* argv[]) } else fprintf(out, "\t\t(\"%s\", ", j.name.c_str()); - OutputType(out, j.type); + OutputType(out, j.type.GetValue()); fprintf(out, "),\n"); } fprintf(out, "\t]\n"); @@ -467,7 +467,7 @@ int main(int argc, char* argv[]) fprintf(out, "# %s\n\n", funcName.c_str()); fprintf(out, "%s = core.%s\n", funcName.c_str(), name.c_str()); fprintf(out, "%s.restype = ", funcName.c_str()); - OutputType(out, i.second->GetChildType(), true, callbackConvention); + OutputType(out, i.second->GetChildType().GetValue(), true, callbackConvention); fprintf(out, "\n"); if (!i.second->HasVariableArguments()) { @@ -480,11 +480,11 @@ int main(int argc, char* argv[]) // BNDebuggerFreeString expects a pointer to a string allocated by the core, so do not use // a c_char_p here, as that would be allocated by the Python runtime. This can // be enforced by outputting like a return value. - OutputType(out, j.type, true); + OutputType(out, j.type.GetValue(), true); } else { - OutputType(out, j.type); + OutputType(out, j.type.GetValue()); } fprintf(out, ",\n"); } @@ -528,9 +528,9 @@ int main(int argc, char* argv[]) fprintf(out, "\n\t\t"); fprintf(out, "%s: ", argName.c_str()); if (swizzleArgs) - OutputSwizzledType(out, arg.type); + OutputSwizzledType(out, arg.type.GetValue()); else - OutputType(out, arg.type); + OutputType(out, arg.type.GetValue()); argN ++; } } @@ -539,13 +539,13 @@ int main(int argc, char* argv[]) { if (stringResult || pointerResult) fprintf(out, "Optional["); - OutputSwizzledType(out, i.second->GetChildType()); + OutputSwizzledType(out, i.second->GetChildType().GetValue()); if (stringResult || pointerResult) fprintf(out, "]"); } else { - OutputType(out, i.second->GetChildType()); + OutputType(out, i.second->GetChildType().GetValue()); } fprintf(out, ":\n"); |
