MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / visitILInstructionForToken

Function visitILInstructionForToken

ui/util.h:34–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32
33template <typename T>
34std::optional<T> visitILInstructionForToken(View* view, const HighlightTokenState& token,
35 const std::function<std::optional<T>(BinaryNinja::LowLevelILInstruction&)>& llil,
36 const std::function<std::optional<T>(BinaryNinja::MediumLevelILInstruction&)>& mlil,
37 const std::function<std::optional<T>(BinaryNinja::HighLevelILInstruction&)>& hlil)
38{
39 if (token.token.exprIndex == BN_INVALID_EXPR)
40 return {};
41
42 BNFunctionGraphType type = view->getILViewType().type;
43 switch (type)
44 {
45 case InvalidILViewType:
46 case NormalFunctionGraph:
47 break;
48 case LiftedILFunctionGraph:
49 case MappedMediumLevelILFunctionGraph:
50 case MappedMediumLevelILSSAFormFunctionGraph:
51 // omitted because I don't know how to get to _exactly_ the right mapped mlil
52 // function from the View frame -- if we go through the Function object we may
53 // not get the same IL function object the token corresponds to due to an update
54 break;
55 case LowLevelILFunctionGraph:
56 case LowLevelILSSAFormFunctionGraph:
57 {
58 LowLevelILFunctionRef llilFunc = view->getCurrentLowLevelILFunction();
59 if (llilFunc && type == LowLevelILSSAFormFunctionGraph)
60 llilFunc = llilFunc->GetSSAForm();
61 if (llilFunc)
62 {
63 BinaryNinja::LowLevelILInstruction instr = llilFunc->GetExpr(token.token.exprIndex);
64 return llil(instr);
65 }
66
67 break;
68 }
69 case MediumLevelILFunctionGraph:
70 case MediumLevelILSSAFormFunctionGraph:
71 {
72 MediumLevelILFunctionRef mlilFunc = view->getCurrentMediumLevelILFunction();
73 if (mlilFunc && type == MediumLevelILSSAFormFunctionGraph)
74 mlilFunc = mlilFunc->GetSSAForm();
75 if (mlilFunc)
76 {
77 BinaryNinja::MediumLevelILInstruction instr = mlilFunc->GetExpr(token.token.exprIndex);
78 return mlil(instr);
79 }
80 break;
81 }
82 case HighLevelILFunctionGraph:
83 case HighLevelILSSAFormFunctionGraph:
84 case HighLevelLanguageRepresentationFunctionGraph:
85 {
86 HighLevelILFunctionRef hlilFunc = view->getCurrentHighLevelILFunction();
87 if (hlilFunc && type == HighLevelILSSAFormFunctionGraph)
88 hlilFunc = hlilFunc->GetSSAForm();
89 if (hlilFunc)
90 {
91 BinaryNinja::HighLevelILInstruction instr = hlilFunc->GetExpr(token.token.exprIndex);

Callers

nothing calls this directly

Calls 2

GetSSAFormMethod · 0.45
GetExprMethod · 0.45

Tested by

no test coverage detected