summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXusheng <xusheng@vector35.com>2020-08-24 21:46:36 +0800
committerXusheng <xusheng@vector35.com>2020-09-15 09:29:54 +0800
commit75d05ea710f80a0ca2fdc53b638952a7a97e7ad8 (patch)
treef8fe2205178cd7942a1e6d45c79dda9d748b526f
parent33e31719d37deed58cfe709bf475b80fece8c34a (diff)
display as in linear view
-rw-r--r--architecture.cpp4
-rw-r--r--basicblock.cpp3
-rw-r--r--binaryninjaapi.h14
-rw-r--r--binaryninjacore.h14
-rw-r--r--linearviewcursor.cpp4
-rw-r--r--linearviewobject.cpp4
-rwxr-xr-xpython/examples/export_svg.py2
-rw-r--r--type.cpp8
-rw-r--r--ui/action.h2
-rw-r--r--ui/flowgraphwidget.h13
-rw-r--r--ui/linearview.h15
-rw-r--r--ui/tokenizedtextview.h13
-rw-r--r--ui/viewframe.h2
13 files changed, 53 insertions, 45 deletions
diff --git a/architecture.cpp b/architecture.cpp
index a3bd77fa..9415b966 100644
--- a/architecture.cpp
+++ b/architecture.cpp
@@ -2208,9 +2208,9 @@ void ArchitectureHook::Register(BNCustomArchitecture* callbacks)
string DisassemblyTextRenderer::GetDisplayStringForInteger(Ref<BinaryView> binaryView, BNIntegerDisplayType type,
- uint64_t value, size_t inputWidth)
+ uint64_t value, size_t inputWidth, bool isSigned)
{
- char* str = BNGetDisplayStringForInteger(binaryView->GetObject(), type, value, inputWidth);
+ char* str = BNGetDisplayStringForInteger(binaryView->GetObject(), type, value, inputWidth, isSigned);
string s(str);
BNFreeString(str);
return s;
diff --git a/basicblock.cpp b/basicblock.cpp
index b9936896..21d78db0 100644
--- a/basicblock.cpp
+++ b/basicblock.cpp
@@ -96,6 +96,9 @@ DisassemblyTextLine::DisassemblyTextLine()
highlight.g = 0;
highlight.b = 0;
highlight.alpha = 0;
+ typeInfo.hasTypeInfo = false;
+ typeInfo.fieldIndex = -1;
+ typeInfo.parentType = nullptr;
}
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 0348c52b..05924070 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -1198,6 +1198,13 @@ __attribute__ ((format (printf, 1, 2)))
class Tag;
+ struct DisassemblyTextLineTypeInfo
+ {
+ bool hasTypeInfo;
+ BinaryNinja::Ref<BinaryNinja::Type> parentType;
+ size_t fieldIndex;
+ };
+
struct DisassemblyTextLine
{
uint64_t addr;
@@ -1205,6 +1212,7 @@ __attribute__ ((format (printf, 1, 2)))
std::vector<InstructionTextToken> tokens;
BNHighlightColor highlight;
std::vector<Ref<Tag>> tags;
+ DisassemblyTextLineTypeInfo typeInfo;
DisassemblyTextLine();
};
@@ -2500,6 +2508,8 @@ __attribute__ ((format (printf, 1, 2)))
QualifiedName GetStructureName() const;
Ref<NamedTypeReference> GetRegisteredName() const;
+ BNIntegerDisplayType GetIntegerTypeDisplayType() const;
+
uint64_t GetElementCount() const;
uint64_t GetOffset() const;
@@ -2597,6 +2607,7 @@ __attribute__ ((format (printf, 1, 2)))
Confidence<bool> IsSigned() const;
Confidence<bool> IsConst() const;
Confidence<bool> IsVolatile() const;
+ void SetIntegerTypeDisplayType(BNIntegerDisplayType displayType);
Confidence<Ref<Type>> GetChildType() const;
Confidence<Ref<CallingConvention>> GetCallingConvention() const;
@@ -5289,7 +5300,8 @@ __attribute__ ((format (printf, 1, 2)))
bool hasAutoAnnotations,
const std::string& leadingSpaces=" ",
const std::string& indentSpaces="");
- static std::string GetDisplayStringForInteger(Ref<BinaryView> binaryView, BNIntegerDisplayType type, uint64_t value, size_t inputWidth);
+ static std::string GetDisplayStringForInteger(Ref<BinaryView> binaryView, BNIntegerDisplayType type,
+ uint64_t value, size_t inputWidth, bool isSigned = true);
};
struct LinearViewObjectIdentifier
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 7715bd9d..9cc2bb32 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -259,6 +259,7 @@ extern "C"
CommentToken = 29,
PossibleValueToken = 30,
PossibleValueTypeToken = 31,
+ ArrayIndexToken = 32,
// The following are output by the analysis system automatically, these should
// not be used directly by the architecture plugins
CodeSymbolToken = 64,
@@ -1546,6 +1547,13 @@ extern "C"
uint8_t mix, r, g, b, alpha;
};
+ struct BNDisassemblyTextLineTypeInfo
+ {
+ bool hasTypeInfo;
+ BNType* parentType;
+ size_t fieldIndex;
+ };
+
struct BNDisassemblyTextLine
{
uint64_t addr;
@@ -1555,6 +1563,7 @@ extern "C"
BNHighlightColor highlight;
BNTag** tags;
size_t tagCount;
+ BNDisassemblyTextLineTypeInfo typeInfo;
};
struct BNLinearDisassemblyLine
@@ -3027,7 +3036,8 @@ __attribute__ ((format (printf, 1, 2)))
BNDisassemblySettings* settings, size_t* count);
BINARYNINJACOREAPI void BNFreeDisassemblyTextLines(BNDisassemblyTextLine* lines, size_t count);
- BINARYNINJACOREAPI char* BNGetDisplayStringForInteger(BNBinaryView* binaryView, BNIntegerDisplayType type, uint64_t value, size_t inputWidth);
+ BINARYNINJACOREAPI char* BNGetDisplayStringForInteger(BNBinaryView* binaryView, BNIntegerDisplayType type,
+ uint64_t value, size_t inputWidth, bool isSigned);
BINARYNINJACOREAPI BNDisassemblyTextRenderer* BNCreateDisassemblyTextRenderer(BNFunction* func,
BNDisassemblySettings* settings);
BINARYNINJACOREAPI BNDisassemblyTextRenderer* BNCreateLowLevelILDisassemblyTextRenderer(BNLowLevelILFunction* func,
@@ -3996,6 +4006,8 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNTypeClass BNGetTypeClass(BNType* type);
BINARYNINJACOREAPI uint64_t BNGetTypeWidth(BNType* type);
BINARYNINJACOREAPI size_t BNGetTypeAlignment(BNType* type);
+ BINARYNINJACOREAPI BNIntegerDisplayType BNGetIntegerTypeDisplayType(BNType* type);
+ BINARYNINJACOREAPI void BNSetIntegerTypeDisplayType(BNTypeBuilder* type, BNIntegerDisplayType displayType);
BINARYNINJACOREAPI BNBoolWithConfidence BNIsTypeSigned(BNType* type);
BINARYNINJACOREAPI BNBoolWithConfidence BNIsTypeConst(BNType* type);
BINARYNINJACOREAPI BNBoolWithConfidence BNIsTypeVolatile(BNType* type);
diff --git a/linearviewcursor.cpp b/linearviewcursor.cpp
index 41356c47..7be2a96b 100644
--- a/linearviewcursor.cpp
+++ b/linearviewcursor.cpp
@@ -208,6 +208,10 @@ vector<LinearDisassemblyLine> LinearViewCursor::GetLines()
line.contents.highlight = lines[i].contents.highlight;
line.contents.tokens = InstructionTextToken::ConvertInstructionTextTokenList(lines[i].contents.tokens, lines[i].contents.count);
line.contents.tags = Tag::ConvertTagList(lines[i].contents.tags, lines[i].contents.tagCount);
+ line.contents.typeInfo.hasTypeInfo = lines[i].contents.typeInfo.hasTypeInfo;
+ line.contents.typeInfo.fieldIndex = lines[i].contents.typeInfo.fieldIndex;
+ line.contents.typeInfo.parentType = lines[i].contents.typeInfo.parentType ?
+ new Type(BNNewTypeReference(lines[i].contents.typeInfo.parentType)) : nullptr;
result.push_back(line);
}
diff --git a/linearviewobject.cpp b/linearviewobject.cpp
index 1a563b9e..3c608b5e 100644
--- a/linearviewobject.cpp
+++ b/linearviewobject.cpp
@@ -145,6 +145,10 @@ vector<LinearDisassemblyLine> LinearViewObject::GetLines(LinearViewObject* prev,
line.contents.highlight = lines[i].contents.highlight;
line.contents.tokens = InstructionTextToken::ConvertInstructionTextTokenList(lines[i].contents.tokens, lines[i].contents.count);
line.contents.tags = Tag::ConvertTagList(lines[i].contents.tags, lines[i].contents.tagCount);
+ line.contents.typeInfo.hasTypeInfo = lines[i].contents.typeInfo.hasTypeInfo;
+ line.contents.typeInfo.fieldIndex = lines[i].contents.typeInfo.fieldIndex;
+ line.contents.typeInfo.parentType = lines[i].contents.typeInfo.parentType ?
+ new Type(BNNewTypeReference(lines[i].contents.typeInfo.parentType)) : nullptr;
result.push_back(line);
}
diff --git a/python/examples/export_svg.py b/python/examples/export_svg.py
index ab0fe4af..c96873e1 100755
--- a/python/examples/export_svg.py
+++ b/python/examples/export_svg.py
@@ -192,7 +192,7 @@ def render_svg(function, offset, mode, form, showOpcodes, showAddresses, orignam
.AnnotationToken {
fill: rgb(218, 196, 209);
}
- .IndirectImportToken, .ImportToken {
+ .IndirectImportToken, .ImportToken, .ExternalSymbolToken {
fill: rgb(237, 189, 129);
}
.LocalVariableToken, .StackVariableToken {
diff --git a/type.cpp b/type.cpp
index 58d23767..05465a62 100644
--- a/type.cpp
+++ b/type.cpp
@@ -831,6 +831,10 @@ Ref<Type> Type::FunctionType(const Confidence<Ref<Type>>& returnValue,
return type;
}
+BNIntegerDisplayType Type::GetIntegerTypeDisplayType() const
+{
+ return BNGetIntegerTypeDisplayType(m_object);
+}
string Type::GenerateAutoTypeId(const string& source, const QualifiedName& name)
{
@@ -1052,6 +1056,10 @@ Confidence<bool> TypeBuilder::IsConst() const
return Confidence<bool>(result.value, result.confidence);
}
+void TypeBuilder::SetIntegerTypeDisplayType(BNIntegerDisplayType displayType)
+{
+ BNSetIntegerTypeDisplayType(m_object, displayType);
+}
Confidence<BNMemberScope> TypeBuilder::GetScope() const
{
diff --git a/ui/action.h b/ui/action.h
index a374731b..3414d8b0 100644
--- a/ui/action.h
+++ b/ui/action.h
@@ -19,6 +19,7 @@
class View;
class UIContext;
+struct LinearViewCursorPosition;
struct BINARYNINJAUIAPI HighlightTokenState
{
@@ -49,6 +50,7 @@ struct BINARYNINJAUIAPI UIActionContext
FunctionRef function;
LowLevelILFunctionRef lowLevelILFunction;
MediumLevelILFunctionRef mediumLevelILFunction;
+ LinearViewCursorPosition* cursorPosition;
UIActionContext();
UIActionContext(const BinaryNinja::PluginCommandContext& pluginContext);
diff --git a/ui/flowgraphwidget.h b/ui/flowgraphwidget.h
index a6e02076..532a506a 100644
--- a/ui/flowgraphwidget.h
+++ b/ui/flowgraphwidget.h
@@ -308,19 +308,6 @@ private Q_SLOTS:
void skipAndReturnZero();
void skipAndReturnValue();
- void displayAsDefault();
- void displayAsBinary();
- void displayAsSignedOctal();
- void displayAsUnsignedOctal();
- void displayAsSignedDecimal();
- void displayAsUnsignedDecimal();
- void displayAsSignedHexadecimal();
- void displayAsUnsignedHexadecimal();
- void displayAsCharacterConstant();
- void displayAsPointer();
- void displayAsFloat();
- void displayAsDouble();
-
void makePtr();
void makeString();
diff --git a/ui/linearview.h b/ui/linearview.h
index 00f02c76..7bdc464f 100644
--- a/ui/linearview.h
+++ b/ui/linearview.h
@@ -230,6 +230,7 @@ private Q_SLOTS:
void makeString();
void changeType();
void undefineVariable();
+ void displayAs(const UIActionContext& context, BNIntegerDisplayType displayType) override;
void createStructOrInferStructureType();
void createArray();
void createStruct();
@@ -237,19 +238,6 @@ private Q_SLOTS:
size_t getStringLength(uint64_t startAddr);
- void displayAsDefault();
- void displayAsBinary();
- void displayAsSignedOctal();
- void displayAsUnsignedOctal();
- void displayAsSignedDecimal();
- void displayAsUnsignedDecimal();
- void displayAsSignedHexadecimal();
- void displayAsUnsignedHexadecimal();
- void displayAsCharacterConstant();
- void displayAsPointer();
- void displayAsFloat();
- void displayAsDouble();
-
void setInstructionHighlight(BNHighlightColor color);
void setBlockHighlight(BNHighlightColor color);
@@ -273,6 +261,7 @@ public:
virtual BinaryViewRef getData() override { return m_data; }
void getCurrentOffsetByType(TypeRef resType, uint64_t baseAddr, uint64_t& begin, uint64_t& end, bool singleLine);
virtual uint64_t getCurrentOffset() override;
+ virtual UIActionContext actionContext() override;
virtual BNAddressRange getSelectionOffsets() override;
virtual BNAddressRange getSelectionForInfo() override;
virtual void setSelectionOffsets(BNAddressRange range) override;
diff --git a/ui/tokenizedtextview.h b/ui/tokenizedtextview.h
index 28d0399b..d937760a 100644
--- a/ui/tokenizedtextview.h
+++ b/ui/tokenizedtextview.h
@@ -92,19 +92,6 @@ class BINARYNINJAUIAPI TokenizedTextView: public QAbstractScrollArea, public Vie
void inferStructureType();
size_t getStringLength(uint64_t startAddr);
- void displayAsDefault();
- void displayAsBinary();
- void displayAsSignedOctal();
- void displayAsUnsignedOctal();
- void displayAsSignedDecimal();
- void displayAsUnsignedDecimal();
- void displayAsSignedHexadecimal();
- void displayAsUnsignedHexadecimal();
- void displayAsCharacterConstant();
- void displayAsPointer();
- void displayAsFloat();
- void displayAsDouble();
-
void setInstructionHighlight(BNHighlightColor color);
void setBlockHighlight(BNHighlightColor color);
diff --git a/ui/viewframe.h b/ui/viewframe.h
index 7d63b84a..4d367074 100644
--- a/ui/viewframe.h
+++ b/ui/viewframe.h
@@ -106,7 +106,7 @@ public:
virtual void writeData(const BinaryNinja::DataBuffer& data);
- virtual bool canDisplayAs(const UIActionContext& context);
+ virtual bool canDisplayAs(const UIActionContext& context, const BNIntegerDisplayType);
virtual void displayAs(const UIActionContext& context, BNIntegerDisplayType type);
virtual HistoryEntry* getHistoryEntry();