summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Snyder <ryan@vector35.com>2023-08-31 08:25:12 -0400
committerRyan Snyder <ryan@vector35.com>2024-02-07 19:36:57 -0500
commit533b108f96f9073fd4e075ccd330c07713a49d99 (patch)
tree1a45a269fe0c590483975349c32c8d9fe08bc2c5
parenta5129e2073b5bf6254d758f56d7ee3677a6fb599 (diff)
add exprIndex field to BNInstructionTextToken
-rw-r--r--architecture.cpp11
-rw-r--r--binaryninjaapi.h1
-rw-r--r--binaryninjacore.h1
-rw-r--r--python/architecture.py5
-rw-r--r--rust/src/disassembly.rs7
5 files changed, 20 insertions, 5 deletions
diff --git a/architecture.cpp b/architecture.cpp
index 7a4822e4..7c9cc9b5 100644
--- a/architecture.cpp
+++ b/architecture.cpp
@@ -51,7 +51,7 @@ void InstructionInfo::AddBranch(BNBranchType type, uint64_t target, Architecture
InstructionTextToken::InstructionTextToken() :
type(TextToken), value(0), width(WidthIsByteCount), size(0), operand(BN_INVALID_OPERAND),
- context(NoTokenContext), confidence(BN_FULL_CONFIDENCE), address(0)
+ context(NoTokenContext), confidence(BN_FULL_CONFIDENCE), address(0), exprIndex(BN_INVALID_EXPR)
{
if (width == WidthIsByteCount)
{
@@ -64,7 +64,7 @@ InstructionTextToken::InstructionTextToken(BNInstructionTextTokenType t, const s
size_t o, uint8_t c, const vector<string>& n, uint64_t w) :
type(t),
text(txt), value(val), width(w), size(s), operand(o), context(NoTokenContext), confidence(c), address(0),
- typeNames(n)
+ typeNames(n), exprIndex(BN_INVALID_EXPR)
{
if (width == WidthIsByteCount)
{
@@ -76,7 +76,8 @@ InstructionTextToken::InstructionTextToken(BNInstructionTextTokenType t, const s
InstructionTextToken::InstructionTextToken(BNInstructionTextTokenType t, BNInstructionTextTokenContext ctxt,
const string& txt, uint64_t a, uint64_t val, size_t s, size_t o, uint8_t c, const vector<string>& n, uint64_t w) :
type(t),
- text(txt), value(val), width(w), size(s), operand(o), context(ctxt), confidence(c), address(a), typeNames(n)
+ text(txt), value(val), width(w), size(s), operand(o), context(ctxt), confidence(c), address(a), typeNames(n),
+ exprIndex(BN_INVALID_EXPR)
{
if (width == WidthIsByteCount)
{
@@ -87,7 +88,8 @@ InstructionTextToken::InstructionTextToken(BNInstructionTextTokenType t, BNInstr
InstructionTextToken::InstructionTextToken(const BNInstructionTextToken& token) :
type(token.type), text(token.text), value(token.value), width(token.width), size(token.size),
- operand(token.operand), context(token.context), confidence(token.confidence), address(token.address)
+ operand(token.operand), context(token.context), confidence(token.confidence), address(token.address),
+ exprIndex(BN_INVALID_EXPR)
{
typeNames.reserve(token.namesCount);
for (size_t j = 0; j < token.namesCount; j++)
@@ -120,6 +122,7 @@ static void ConvertInstructionTextToken(const InstructionTextToken& token, BNIns
for (size_t i = 0; i < token.typeNames.size(); i++)
result->typeNames[i] = BNAllocString(token.typeNames[i].c_str());
result->namesCount = token.typeNames.size();
+ result->exprIndex = token.exprIndex;
}
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index b0794456..bf3cc5ad 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -2256,6 +2256,7 @@ namespace BinaryNinja {
uint8_t confidence;
uint64_t address;
std::vector<std::string> typeNames;
+ size_t exprIndex;
InstructionTextToken();
InstructionTextToken(uint8_t confidence, BNInstructionTextTokenType t, const std::string& txt);
diff --git a/binaryninjacore.h b/binaryninjacore.h
index aac5f5a3..a3210c52 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -1666,6 +1666,7 @@ extern "C"
uint64_t address;
char** typeNames;
size_t namesCount;
+ size_t exprIndex;
} BNInstructionTextToken;
typedef struct BNInstructionTextLine
diff --git a/python/architecture.py b/python/architecture.py
index 9fb32e0d..677192e4 100644
--- a/python/architecture.py
+++ b/python/architecture.py
@@ -2798,6 +2798,7 @@ class InstructionTextToken:
confidence: int = core.max_confidence
typeNames: List[str] = field(default_factory=list)
width: int = 0
+ il_expr_index: int = 0xffffffffffffffff
def __post_init__(self):
if self.width == 0:
@@ -2819,6 +2820,7 @@ class InstructionTextToken:
context = tokens[j].context
confidence = tokens[j].confidence
address = tokens[j].address
+ il_expr_index = tokens[j].exprIndex
typeNames = []
for i in range(tokens[j].namesCount):
if not isinstance(tokens[j].typeNames[i], str):
@@ -2827,7 +2829,7 @@ class InstructionTextToken:
typeNames.append(tokens[j].typeNames[i])
result.append(
InstructionTextToken(
- token_type, text, value, size, operand, context, address, confidence, typeNames, width
+ token_type, text, value, size, operand, context, address, confidence, typeNames, width, il_expr_index
)
)
return result
@@ -2848,6 +2850,7 @@ class InstructionTextToken:
result[j].address = tokens[j].address
result[j].namesCount = len(tokens[j].typeNames)
result[j].typeNames = (ctypes.c_char_p * len(tokens[j].typeNames))()
+ result[j].exprIndex = tokens[j].il_expr_index
for i in range(len(tokens[j].typeNames)):
result[j].typeNames[i] = tokens[j].typeNames[i].encode("utf-8")
return result
diff --git a/rust/src/disassembly.rs b/rust/src/disassembly.rs
index 161eebc3..1c8bcd0d 100644
--- a/rust/src/disassembly.rs
+++ b/rust/src/disassembly.rs
@@ -157,6 +157,7 @@ impl InstructionTextToken {
address,
typeNames: ptr::null_mut(),
namesCount: 0,
+ exprIndex: BN_INVALID_EXPR
})
}
@@ -206,6 +207,10 @@ impl InstructionTextToken {
pub fn address(&self) -> u64 {
self.0.address
}
+
+ pub fn expr_index(&self) -> usize {
+ self.0.exprIndex
+ }
}
impl Default for InstructionTextToken {
@@ -222,6 +227,7 @@ impl Default for InstructionTextToken {
address: 0,
typeNames: ptr::null_mut(),
namesCount: 0,
+ exprIndex: BN_INVALID_EXPR
})
}
}
@@ -240,6 +246,7 @@ impl Clone for InstructionTextToken {
confidence: 0xff,
typeNames: ptr::null_mut(),
namesCount: 0,
+ exprIndex: self.0.exprIndex
})
}
}