From c7e33d35b4adef40e53619662c7a6cfc198efd4a Mon Sep 17 00:00:00 2001 From: Xusheng Date: Tue, 21 Sep 2021 19:17:35 +0800 Subject: Better support for change type in linear view --- basicblock.cpp | 1 + binaryninjaapi.h | 4 ++++ binaryninjacore.h | 1 + linearviewobject.cpp | 2 +- rust/src/disassembly.rs | 3 +++ ui/linearview.h | 3 +-- 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/basicblock.cpp b/basicblock.cpp index 1675afdf..6045f6ef 100644 --- a/basicblock.cpp +++ b/basicblock.cpp @@ -99,6 +99,7 @@ DisassemblyTextLine::DisassemblyTextLine() typeInfo.hasTypeInfo = false; typeInfo.fieldIndex = -1; typeInfo.parentType = nullptr; + typeInfo.offset = 0; } diff --git a/binaryninjaapi.h b/binaryninjaapi.h index bb104ef3..f3bea556 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -1364,6 +1364,10 @@ __attribute__ ((format (printf, 1, 2))) bool hasTypeInfo; BinaryNinja::Ref parentType; size_t fieldIndex; + uint64_t offset; + + DisassemblyTextLineTypeInfo(): hasTypeInfo(false), parentType(nullptr), fieldIndex(-1), offset(0) + {} }; struct DisassemblyTextLine diff --git a/binaryninjacore.h b/binaryninjacore.h index 2b24423f..11120259 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -1734,6 +1734,7 @@ extern "C" bool hasTypeInfo; BNType* parentType; size_t fieldIndex; + uint64_t offset; }; struct BNDisassemblyTextLine diff --git a/linearviewobject.cpp b/linearviewobject.cpp index afd6d0c8..7bd41064 100644 --- a/linearviewobject.cpp +++ b/linearviewobject.cpp @@ -39,7 +39,7 @@ LinearDisassemblyLine LinearDisassemblyLine::FromAPIObject(BNLinearDisassemblyLi result.contents.typeInfo.fieldIndex = line->contents.typeInfo.fieldIndex; result.contents.typeInfo.parentType = line->contents.typeInfo.parentType ? new Type(BNNewTypeReference(line->contents.typeInfo.parentType)) : nullptr; - + result.contents.typeInfo.offset = line->contents.typeInfo.offset; return result; } diff --git a/rust/src/disassembly.rs b/rust/src/disassembly.rs index 2eb96680..c4ca2b33 100644 --- a/rust/src/disassembly.rs +++ b/rust/src/disassembly.rs @@ -128,6 +128,7 @@ impl From> for DisassemblyTextLine { hasTypeInfo: false, parentType: ptr::null_mut(), fieldIndex: usize::MAX, + offset: 0 }, }) } @@ -167,6 +168,7 @@ impl From<&Vec<&str>> for DisassemblyTextLine { hasTypeInfo: false, parentType: ptr::null_mut(), fieldIndex: usize::MAX, + offset: 0 }, }) } @@ -195,6 +197,7 @@ impl Default for DisassemblyTextLine { hasTypeInfo: false, parentType: ptr::null_mut(), fieldIndex: usize::MAX, + offset: 0 }, }) } diff --git a/ui/linearview.h b/ui/linearview.h index f6191862..02f14b88 100644 --- a/ui/linearview.h +++ b/ui/linearview.h @@ -192,7 +192,6 @@ class BINARYNINJAUIAPI LinearView: public QAbstractScrollArea, public View, publ StructureRef defineInnerStruct(TypeRef type, uint64_t offset, uint64_t size, std::set& seen); StructureRef defineInnerArray(TypeRef type, uint64_t offset, uint64_t size, std::set& seen); StructureRef defineInnerName(TypeRef type, uint64_t offset, uint64_t size, std::set& seen); - StructureRef defineInnerUnknownType(QWidget* parent, TypeRef type, uint64_t offset, uint64_t size, std::set& seen); StructureRef defineInnerIntegerSize(TypeRef type, uint64_t offset, uint64_t size, std::set& seen); StructureRef defineInnerSign(TypeRef type, uint64_t offset, uint64_t size, std::set& seen); TypeRef getPointerTypeAndName(ArchitectureRef arch, uint64_t addr, std::string& name); @@ -266,7 +265,7 @@ private Q_SLOTS: void toggleFloatSize(); void makePtr(); void makeString(); - void changeType(); + void changeType(const UIActionContext& context); void undefineVariable(); void displayAs(const UIActionContext& context, BNIntegerDisplayType displayType) override; void createStructOrInferStructureType(); -- cgit v1.3.1