summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--architecture.cpp11
-rw-r--r--basicblock.cpp2
-rw-r--r--binaryninjaapi.h9
-rw-r--r--binaryninjacore.h20
-rw-r--r--binaryview.cpp4
-rw-r--r--function.cpp14
-rw-r--r--functiongraphblock.cpp2
-rw-r--r--python/__init__.py42
8 files changed, 92 insertions, 12 deletions
diff --git a/architecture.cpp b/architecture.cpp
index d068ff36..a10ef29c 100644
--- a/architecture.cpp
+++ b/architecture.cpp
@@ -51,8 +51,8 @@ InstructionTextToken::InstructionTextToken(): type(TextToken), value(0)
}
-InstructionTextToken::InstructionTextToken(BNInstructionTextTokenType t, const std::string& txt, uint64_t val) :
- type(t), text(txt), value(val)
+InstructionTextToken::InstructionTextToken(BNInstructionTextTokenType t, const std::string& txt, uint64_t val,
+ size_t s, size_t o) : type(t), text(txt), value(val), size(s), operand(o)
{
}
@@ -144,6 +144,8 @@ bool Architecture::GetInstructionTextCallback(void* ctxt, const uint8_t* data, u
(*result)[i].type = tokens[i].type;
(*result)[i].text = BNAllocString(tokens[i].text.c_str());
(*result)[i].value = tokens[i].value;
+ (*result)[i].size = tokens[i].size;
+ (*result)[i].operand = tokens[i].operand;
}
return true;
}
@@ -931,7 +933,10 @@ bool CoreArchitecture::GetInstructionText(const uint8_t* data, uint64_t addr, si
return false;
for (size_t i = 0; i < count; i++)
- result.push_back(InstructionTextToken(tokens[i].type, tokens[i].text, tokens[i].value));
+ {
+ result.push_back(InstructionTextToken(tokens[i].type, tokens[i].text, tokens[i].value,
+ tokens[i].size, tokens[i].operand));
+ }
BNFreeInstructionText(tokens, count);
return true;
diff --git a/basicblock.cpp b/basicblock.cpp
index 67ee1983..377c5704 100644
--- a/basicblock.cpp
+++ b/basicblock.cpp
@@ -162,6 +162,8 @@ vector<DisassemblyTextLine> BasicBlock::GetDisassemblyText(DisassemblySettings*
token.type = lines[i].tokens[j].type;
token.text = lines[i].tokens[j].text;
token.value = lines[i].tokens[j].value;
+ token.size = lines[i].tokens[j].size;
+ token.operand = lines[i].tokens[j].operand;
line.tokens.push_back(token);
}
result.push_back(line);
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 81bf571a..d5d12dce 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -629,9 +629,11 @@ namespace BinaryNinja
BNInstructionTextTokenType type;
std::string text;
uint64_t value;
+ size_t size, operand;
InstructionTextToken();
- InstructionTextToken(BNInstructionTextTokenType type, const std::string& text, uint64_t value = 0);
+ InstructionTextToken(BNInstructionTextTokenType type, const std::string& text, uint64_t value = 0,
+ size_t size = 0, size_t operand = BN_INVALID_OPERAND);
};
struct DisassemblyTextLine
@@ -1646,6 +1648,11 @@ namespace BinaryNinja
std::vector<IndirectBranchInfo> GetIndirectBranchesAt(Architecture* arch, uint64_t addr);
std::vector<std::vector<InstructionTextToken>> GetBlockAnnotations(Architecture* arch, uint64_t addr);
+
+ BNIntegerDisplayType GetIntegerConstantDisplayType(Architecture* arch, uint64_t instrAddr, uint64_t value,
+ size_t operand);
+ void SetIntegerConstantDisplayType(Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand,
+ BNIntegerDisplayType type);
};
struct FunctionGraphEdge
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 22dbab50..1ca43677 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -173,6 +173,7 @@ extern "C"
HexDumpTextToken = 20,
OpcodeToken = 21,
StringToken = 22,
+ CharacterConstantToken = 23,
// The following are output by the analysis system automatically, these should
// not be used directly by the architecture plugins
@@ -489,6 +490,19 @@ extern "C"
Utf32String = 2
};
+ enum BNIntegerDisplayType
+ {
+ DefaultIntegerDisplayType,
+ BinaryDisplayType,
+ SignedOctalDisplayType,
+ UnsignedOctalDisplayType,
+ SignedDecimalDisplayType,
+ UnsignedDecimalDisplayType,
+ SignedHexadecimalDisplayType,
+ UnsignedHexadecimalDisplayType,
+ CharacterConstantDisplayType
+ };
+
struct BNLowLevelILInstruction
{
BNLowLevelILOperation operation;
@@ -674,6 +688,7 @@ extern "C"
BNInstructionTextTokenType type;
char* text;
uint64_t value;
+ size_t size, operand;
};
struct BNInstructionTextLine
@@ -1423,6 +1438,11 @@ extern "C"
uint64_t addr, size_t* count);
BINARYNINJACOREAPI void BNFreeInstructionTextLines(BNInstructionTextLine* lines, size_t count);
+ BINARYNINJACOREAPI BNIntegerDisplayType BNGetIntegerConstantDisplayType(BNFunction* func, BNArchitecture* arch,
+ uint64_t instrAddr, uint64_t value, size_t operand);
+ BINARYNINJACOREAPI void BNSetIntegerConstantDisplayType(BNFunction* func, BNArchitecture* arch,
+ uint64_t instrAddr, uint64_t value, size_t operand, BNIntegerDisplayType type);
+
BINARYNINJACOREAPI BNAnalysisCompletionEvent* BNAddAnalysisCompletionEvent(BNBinaryView* view, void* ctxt,
void (*callback)(void* ctxt));
BINARYNINJACOREAPI BNAnalysisCompletionEvent* BNNewAnalysisCompletionEventReference(BNAnalysisCompletionEvent* event);
diff --git a/binaryview.cpp b/binaryview.cpp
index d97051c7..192b9b37 100644
--- a/binaryview.cpp
+++ b/binaryview.cpp
@@ -1289,6 +1289,8 @@ vector<LinearDisassemblyLine> BinaryView::GetPreviousLinearDisassemblyLines(Line
token.type = lines[i].contents.tokens[j].type;
token.text = lines[i].contents.tokens[j].text;
token.value = lines[i].contents.tokens[j].value;
+ token.size = lines[i].contents.tokens[j].size;
+ token.operand = lines[i].contents.tokens[j].operand;
line.contents.tokens.push_back(token);
}
result.push_back(line);
@@ -1330,6 +1332,8 @@ vector<LinearDisassemblyLine> BinaryView::GetNextLinearDisassemblyLines(LinearDi
token.type = lines[i].contents.tokens[j].type;
token.text = lines[i].contents.tokens[j].text;
token.value = lines[i].contents.tokens[j].value;
+ token.size = lines[i].contents.tokens[j].size;
+ token.operand = lines[i].contents.tokens[j].operand;
line.contents.tokens.push_back(token);
}
result.push_back(line);
diff --git a/function.cpp b/function.cpp
index 55f5cffb..7c188e72 100644
--- a/function.cpp
+++ b/function.cpp
@@ -539,3 +539,17 @@ vector<vector<InstructionTextToken>> Function::GetBlockAnnotations(Architecture*
BNFreeInstructionTextLines(lines, count);
return result;
}
+
+
+BNIntegerDisplayType Function::GetIntegerConstantDisplayType(Architecture* arch, uint64_t instrAddr, uint64_t value,
+ size_t operand)
+{
+ return BNGetIntegerConstantDisplayType(m_object, arch->GetObject(), instrAddr, value, operand);
+}
+
+
+void Function::SetIntegerConstantDisplayType(Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand,
+ BNIntegerDisplayType type)
+{
+ BNSetIntegerConstantDisplayType(m_object, arch->GetObject(), instrAddr, value, operand, type);
+}
diff --git a/functiongraphblock.cpp b/functiongraphblock.cpp
index 8d327cd0..af330497 100644
--- a/functiongraphblock.cpp
+++ b/functiongraphblock.cpp
@@ -88,6 +88,8 @@ vector<DisassemblyTextLine> FunctionGraphBlock::GetLines() const
token.type = lines[i].tokens[j].type;
token.text = lines[i].tokens[j].text;
token.value = lines[i].tokens[j].value;
+ token.size = lines[i].tokens[j].size;
+ token.operand = lines[i].tokens[j].operand;
line.tokens.push_back(token);
}
result.push_back(line);
diff --git a/python/__init__.py b/python/__init__.py
index ba3f1ba9..100d01d8 100644
--- a/python/__init__.py
+++ b/python/__init__.py
@@ -1706,7 +1706,9 @@ class BinaryView(object):
token_type = core.BNInstructionTextTokenType_names[lines[i].contents.tokens[j].type]
text = lines[i].contents.tokens[j].text
value = lines[i].contents.tokens[j].value
- tokens.append(InstructionTextToken(token_type, text, value))
+ size = lines[i].contents.tokens[j].size
+ operand = lines[i].contents.tokens[j].operand
+ tokens.append(InstructionTextToken(token_type, text, value, size, operand))
contents = DisassemblyTextLine(addr, tokens)
result.append(LinearDisassemblyLine(lines[i].type, func, block, lines[i].lineOffset, contents))
@@ -2829,7 +2831,9 @@ class Function(object):
token_type = core.BNInstructionTextTokenType_names[lines[i].tokens[j].type]
text = lines[i].tokens[j].text
value = lines[i].tokens[j].value
- tokens.append(InstructionTextToken(token_type, text, value))
+ size = lines[i].tokens[j].size
+ operand = lines[i].tokens[j].operand
+ tokens.append(InstructionTextToken(token_type, text, value, size, operand))
result.append(tokens)
core.BNFreeInstructionTextLines(lines, count.value)
return result
@@ -2840,6 +2844,14 @@ class Function(object):
def set_user_type(self, value):
core.BNSetFunctionUserType(self.handle, value.handle)
+ def get_int_display_type(self, arch, instr_addr, value, operand):
+ return core.BNGetIntegerConstantDisplayType(self.handle, arch.handle, instr_addr, value, operand)
+
+ def set_int_display_type(self, arch, instr_addr, value, operand, display_type):
+ if isinstance(display_type, str):
+ display_type = core.BNIntegerDisplayType_by_name[display_type]
+ core.BNSetIntegerConstantDisplayType(self.handle, arch.handle, instr_addr, value, operand, display_type)
+
class BasicBlockEdge:
def __init__(self, branch_type, target, arch):
self.type = core.BNBranchType_names[branch_type]
@@ -2972,7 +2984,9 @@ class BasicBlock(object):
token_type = core.BNInstructionTextTokenType_names[lines[i].tokens[j].type]
text = lines[i].tokens[j].text
value = lines[i].tokens[j].value
- tokens.append(InstructionTextToken(token_type, text, value))
+ size = lines[i].tokens[j].size
+ operand = lines[i].tokens[j].operand
+ tokens.append(InstructionTextToken(token_type, text, value, size, operand))
result.append(DisassemblyTextLine(addr, tokens))
core.BNFreeDisassemblyTextLines(lines, count.value)
return result
@@ -3070,7 +3084,9 @@ class FunctionGraphBlock(object):
token_type = core.BNInstructionTextTokenType_names[lines[i].tokens[j].type]
text = lines[i].tokens[j].text
value = lines[i].tokens[j].value
- tokens.append(InstructionTextToken(token_type, text, value))
+ size = lines[i].tokens[j].size
+ operand = lines[i].tokens[j].operand
+ tokens.append(InstructionTextToken(token_type, text, value, size, operand))
result.append(DisassemblyTextLine(addr, tokens))
core.BNFreeDisassemblyTextLines(lines, count.value)
return result
@@ -3118,7 +3134,9 @@ class FunctionGraphBlock(object):
token_type = core.BNInstructionTextTokenType_names[lines[i].tokens[j].type]
text = lines[i].tokens[j].text
value = lines[i].tokens[j].value
- tokens.append(InstructionTextToken(token_type, text, value))
+ size = lines[i].tokens[j].size
+ operand = lines[i].tokens[j].operand
+ tokens.append(InstructionTextToken(token_type, text, value, size, operand))
yield DisassemblyTextLine(addr, tokens)
finally:
core.BNFreeDisassemblyTextLines(lines, count.value)
@@ -3347,10 +3365,12 @@ class InstructionInfo:
return "<instr: %d bytes%s, %s>" % (self.length, branch_delay, repr(self.branches))
class InstructionTextToken:
- def __init__(self, token_type, text, value = 0):
+ def __init__(self, token_type, text, value = 0, size = 0, operand = 0xffffffff):
self.type = token_type
self.text = text
self.value = value
+ self.size = size
+ self.operand = operand
def __str__(self):
return self.text
@@ -3749,6 +3769,8 @@ class Architecture(object):
token_buf[i].type = tokens[i].type
token_buf[i].text = tokens[i].text
token_buf[i].value = tokens[i].value
+ token_buf[i].size = tokens[i].size
+ token_buf[i].operand = tokens[i].operand
result[0] = token_buf
ptr = ctypes.cast(token_buf, ctypes.c_void_p)
self._pending_token_lists[ptr.value] = (ptr.value, token_buf)
@@ -4187,7 +4209,9 @@ class Architecture(object):
token_type = core.BNInstructionTextTokenType_names[tokens[i].type]
text = tokens[i].text
value = tokens[i].value
- result.append(InstructionTextToken(token_type, text, value))
+ size = tokens[i].size
+ operand = tokens[i].operand
+ result.append(InstructionTextToken(token_type, text, value, size, operand))
core.BNFreeInstructionText(tokens, count.value)
return result, length.value
@@ -4551,7 +4575,9 @@ class LowLevelILInstruction(object):
token_type = core.BNInstructionTextTokenType_names[tokens[i].type]
text = tokens[i].text
value = tokens[i].value
- result.append(InstructionTextToken(token_type, text, value))
+ size = tokens[i].size
+ operand = tokens[i].operand
+ result.append(InstructionTextToken(token_type, text, value, size, operand))
core.BNFreeInstructionText(tokens, count.value)
return result