summaryrefslogtreecommitdiff
path: root/mediumlevelil.cpp
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2022-01-27 22:43:28 -0500
committerKyleMiles <krm504@nyu.edu>2022-01-28 00:24:06 -0500
commit6812c973c9fa9b4ad642ab81856c05f87bd6fcc4 (patch)
treedace4156d03148bcaf02df138ab4e0d93e61bc6f /mediumlevelil.cpp
parent519c9db22367f2659d1a54599fab47e6313be06e (diff)
Format All Files
Diffstat (limited to 'mediumlevelil.cpp')
-rw-r--r--mediumlevelil.cpp107
1 files changed, 53 insertions, 54 deletions
diff --git a/mediumlevelil.cpp b/mediumlevelil.cpp
index 04fcb0c0..4d606c41 100644
--- a/mediumlevelil.cpp
+++ b/mediumlevelil.cpp
@@ -97,27 +97,27 @@ BNMediumLevelILLabel* MediumLevelILFunction::GetLabelForSourceInstruction(size_t
}
-ExprId MediumLevelILFunction::AddExpr(BNMediumLevelILOperation operation, size_t size,
- ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
+ExprId MediumLevelILFunction::AddExpr(
+ BNMediumLevelILOperation operation, size_t size, ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
{
return BNMediumLevelILAddExpr(m_object, operation, size, a, b, c, d, e);
}
ExprId MediumLevelILFunction::AddExprWithLocation(BNMediumLevelILOperation operation, uint64_t addr,
- uint32_t sourceOperand, size_t size, ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
+ uint32_t sourceOperand, size_t size, ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
{
return BNMediumLevelILAddExprWithLocation(m_object, operation, addr, sourceOperand, size, a, b, c, d, e);
}
ExprId MediumLevelILFunction::AddExprWithLocation(BNMediumLevelILOperation operation, const ILSourceLocation& loc,
- size_t size, ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
+ size_t size, ExprId a, ExprId b, ExprId c, ExprId d, ExprId e)
{
if (loc.valid)
{
- return BNMediumLevelILAddExprWithLocation(m_object, operation, loc.address, loc.sourceOperand,
- size, a, b, c, d, e);
+ return BNMediumLevelILAddExprWithLocation(
+ m_object, operation, loc.address, loc.sourceOperand, size, a, b, c, d, e);
}
return BNMediumLevelILAddExpr(m_object, operation, size, a, b, c, d, e);
}
@@ -137,8 +137,8 @@ ExprId MediumLevelILFunction::Goto(BNMediumLevelILLabel& label, const ILSourceLo
}
-ExprId MediumLevelILFunction::If(ExprId operand, BNMediumLevelILLabel& t, BNMediumLevelILLabel& f,
- const ILSourceLocation& loc)
+ExprId MediumLevelILFunction::If(
+ ExprId operand, BNMediumLevelILLabel& t, BNMediumLevelILLabel& f, const ILSourceLocation& loc)
{
if (loc.valid)
return BNMediumLevelILIfWithLocation(m_object, operand, &t, &f, loc.address, loc.sourceOperand);
@@ -310,7 +310,7 @@ void MediumLevelILFunction::Finalize()
void MediumLevelILFunction::GenerateSSAForm(bool analyzeConditionals, bool handleAliases,
- const set<Variable>& knownNotAliases, const set<Variable>& knownAliases)
+ const set<Variable>& knownNotAliases, const set<Variable>& knownAliases)
{
BNVariable* knownNotAlias = new BNVariable[knownNotAliases.size()];
BNVariable* knownAlias = new BNVariable[knownAliases.size()];
@@ -332,18 +332,19 @@ void MediumLevelILFunction::GenerateSSAForm(bool analyzeConditionals, bool handl
}
BNGenerateMediumLevelILSSAForm(m_object, analyzeConditionals, handleAliases, knownNotAlias, knownNotAliases.size(),
- knownAlias, knownAliases.size());
+ knownAlias, knownAliases.size());
delete[] knownNotAlias;
delete[] knownAlias;
}
-bool MediumLevelILFunction::GetExprText(Architecture* arch, ExprId expr, vector<InstructionTextToken>& tokens, DisassemblySettings* settings)
+bool MediumLevelILFunction::GetExprText(
+ Architecture* arch, ExprId expr, vector<InstructionTextToken>& tokens, DisassemblySettings* settings)
{
size_t count;
BNInstructionTextToken* list;
- if (!BNGetMediumLevelILExprText(m_object, arch->GetObject(), expr, &list, &count,
- settings ? settings->GetObject() : nullptr))
+ if (!BNGetMediumLevelILExprText(
+ m_object, arch->GetObject(), expr, &list, &count, settings ? settings->GetObject() : nullptr))
return false;
tokens = InstructionTextToken::ConvertAndFreeInstructionTextTokenList(list, count);
@@ -352,12 +353,12 @@ bool MediumLevelILFunction::GetExprText(Architecture* arch, ExprId expr, vector<
bool MediumLevelILFunction::GetInstructionText(Function* func, Architecture* arch, size_t instr,
- vector<InstructionTextToken>& tokens, DisassemblySettings* settings)
+ vector<InstructionTextToken>& tokens, DisassemblySettings* settings)
{
size_t count;
BNInstructionTextToken* list;
- if (!BNGetMediumLevelILInstructionText(m_object, func ? func->GetObject() : nullptr, arch->GetObject(), instr, &list, &count,
- settings ? settings->GetObject() : nullptr))
+ if (!BNGetMediumLevelILInstructionText(m_object, func ? func->GetObject() : nullptr, arch->GetObject(), instr,
+ &list, &count, settings ? settings->GetObject() : nullptr))
return false;
tokens = InstructionTextToken::ConvertAndFreeInstructionTextTokenList(list, count);
@@ -366,7 +367,7 @@ bool MediumLevelILFunction::GetInstructionText(Function* func, Architecture* arc
void MediumLevelILFunction::VisitInstructions(
- const function<void(BasicBlock* block, const MediumLevelILInstruction& instr)>& func)
+ const function<void(BasicBlock* block, const MediumLevelILInstruction& instr)>& func)
{
for (auto& i : GetBasicBlocks())
for (size_t j = i->GetStart(); j < i->GetEnd(); j++)
@@ -375,12 +376,10 @@ void MediumLevelILFunction::VisitInstructions(
void MediumLevelILFunction::VisitAllExprs(
- const function<bool(BasicBlock* block, const MediumLevelILInstruction& expr)>& func)
+ const function<bool(BasicBlock* block, const MediumLevelILInstruction& expr)>& func)
{
VisitInstructions([&](BasicBlock* block, const MediumLevelILInstruction& instr) {
- instr.VisitExprs([&](const MediumLevelILInstruction& expr) {
- return func(block, expr);
- });
+ instr.VisitExprs([&](const MediumLevelILInstruction& expr) { return func(block, expr); });
});
}
@@ -545,22 +544,21 @@ RegisterValue MediumLevelILFunction::GetExprValue(const MediumLevelILInstruction
}
-PossibleValueSet MediumLevelILFunction::GetPossibleSSAVarValues(const SSAVariable& var, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleSSAVarValues(
+ const SSAVariable& var, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetMediumLevelILPossibleSSAVarValues(m_object, &var.var, var.version, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetMediumLevelILPossibleSSAVarValues(m_object, &var.var, var.version, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
-PossibleValueSet MediumLevelILFunction::GetPossibleExprValues(size_t expr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleExprValues(size_t expr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
@@ -572,8 +570,8 @@ PossibleValueSet MediumLevelILFunction::GetPossibleExprValues(size_t expr,
}
-PossibleValueSet MediumLevelILFunction::GetPossibleExprValues(const MediumLevelILInstruction& expr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleExprValues(
+ const MediumLevelILInstruction& expr, const set<BNDataFlowQueryOption>& options)
{
return GetPossibleExprValues(expr.exprIndex, options);
}
@@ -623,29 +621,29 @@ RegisterValue MediumLevelILFunction::GetRegisterValueAfterInstruction(uint32_t r
}
-PossibleValueSet MediumLevelILFunction::GetPossibleRegisterValuesAtInstruction(uint32_t reg, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleRegisterValuesAtInstruction(
+ uint32_t reg, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetMediumLevelILPossibleRegisterValuesAtInstruction(m_object, reg, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetMediumLevelILPossibleRegisterValuesAtInstruction(m_object, reg, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
-PossibleValueSet MediumLevelILFunction::GetPossibleRegisterValuesAfterInstruction(uint32_t reg, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleRegisterValuesAfterInstruction(
+ uint32_t reg, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetMediumLevelILPossibleRegisterValuesAfterInstruction(m_object, reg, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetMediumLevelILPossibleRegisterValuesAfterInstruction(m_object, reg, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
@@ -665,29 +663,29 @@ RegisterValue MediumLevelILFunction::GetFlagValueAfterInstruction(uint32_t flag,
}
-PossibleValueSet MediumLevelILFunction::GetPossibleFlagValuesAtInstruction(uint32_t flag, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleFlagValuesAtInstruction(
+ uint32_t flag, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetMediumLevelILPossibleFlagValuesAtInstruction(m_object, flag, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetMediumLevelILPossibleFlagValuesAtInstruction(m_object, flag, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
-PossibleValueSet MediumLevelILFunction::GetPossibleFlagValuesAfterInstruction(uint32_t flag, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleFlagValuesAfterInstruction(
+ uint32_t flag, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetMediumLevelILPossibleFlagValuesAfterInstruction(m_object, flag, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetMediumLevelILPossibleFlagValuesAfterInstruction(m_object, flag, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
@@ -707,29 +705,29 @@ RegisterValue MediumLevelILFunction::GetStackContentsAfterInstruction(int32_t of
}
-PossibleValueSet MediumLevelILFunction::GetPossibleStackContentsAtInstruction(int32_t offset, size_t len, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleStackContentsAtInstruction(
+ int32_t offset, size_t len, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetMediumLevelILPossibleStackContentsAtInstruction(m_object, offset, len, instr,
- optionArray, options.size());
+ BNPossibleValueSet value =
+ BNGetMediumLevelILPossibleStackContentsAtInstruction(m_object, offset, len, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
-PossibleValueSet MediumLevelILFunction::GetPossibleStackContentsAfterInstruction(int32_t offset, size_t len, size_t instr,
- const set<BNDataFlowQueryOption>& options)
+PossibleValueSet MediumLevelILFunction::GetPossibleStackContentsAfterInstruction(
+ int32_t offset, size_t len, size_t instr, const set<BNDataFlowQueryOption>& options)
{
BNDataFlowQueryOption* optionArray = new BNDataFlowQueryOption[options.size()];
size_t idx = 0;
for (auto i : options)
optionArray[idx++] = i;
- BNPossibleValueSet value = BNGetMediumLevelILPossibleStackContentsAfterInstruction(m_object, offset, len, instr,
- optionArray, options.size());
+ BNPossibleValueSet value = BNGetMediumLevelILPossibleStackContentsAfterInstruction(
+ m_object, offset, len, instr, optionArray, options.size());
delete[] optionArray;
return PossibleValueSet::FromAPIObject(value);
}
@@ -741,7 +739,8 @@ BNILBranchDependence MediumLevelILFunction::GetBranchDependenceAtInstruction(siz
}
-unordered_map<size_t, BNILBranchDependence> MediumLevelILFunction::GetAllBranchDependenceAtInstruction(size_t instr) const
+unordered_map<size_t, BNILBranchDependence> MediumLevelILFunction::GetAllBranchDependenceAtInstruction(
+ size_t instr) const
{
size_t count;
BNILBranchInstructionAndDependence* deps = BNGetAllMediumLevelILBranchDependence(m_object, instr, &count);