summaryrefslogtreecommitdiff
path: root/examples/workflows/objectivec/objectivec.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 /examples/workflows/objectivec/objectivec.cpp
parent519c9db22367f2659d1a54599fab47e6313be06e (diff)
Format All Files
Diffstat (limited to 'examples/workflows/objectivec/objectivec.cpp')
-rw-r--r--examples/workflows/objectivec/objectivec.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/examples/workflows/objectivec/objectivec.cpp b/examples/workflows/objectivec/objectivec.cpp
index b3272f94..b5ce26c1 100644
--- a/examples/workflows/objectivec/objectivec.cpp
+++ b/examples/workflows/objectivec/objectivec.cpp
@@ -17,7 +17,7 @@ using namespace BinaryNinja;
using namespace std;
#if defined(_MSC_VER)
-#define snprintf _snprintf
+ #define snprintf _snprintf
#endif
@@ -46,7 +46,7 @@ extern "C"
return;
BinaryReader reader(data);
- reader.SetEndianness(data->GetDefaultEndianness()); // TODO fix GetDefaultEndianness for non-elf formats
+ reader.SetEndianness(data->GetDefaultEndianness()); // TODO fix GetDefaultEndianness for non-elf formats
reader.Seek(constSection->GetStart());
reader.Read32();
@@ -62,13 +62,13 @@ extern "C"
reader.Read64();
uint32_t methodListFlags = reader.Read32();
uint32_t methodListCount = reader.Read32();
- for (uint32_t i = 0; i < methodListCount; i++) // section end/symbol validation
+ for (uint32_t i = 0; i < methodListCount; i++) // section end/symbol validation
{
uint64_t selector = reader.Read64();
uint64_t typePtr = reader.Read64();
uint64_t impPtr = reader.Read64();
- //string methodName = reader.ReadCString(selector);
- string typeEncoding = "";//reader.ReadCString(typePtr);
+ // string methodName = reader.ReadCString(selector);
+ string typeEncoding = ""; // reader.ReadCString(typePtr);
g_classData[data->GetObject()].insert_or_assign(selector, std::forward_as_tuple(typeEncoding, impPtr));
}
@@ -118,11 +118,13 @@ extern "C"
if (msgSendAddr == (uint64_t)destExpr.GetValue().value)
{
auto params = instr.GetParameterExprs<LLIL_CALL_SSA>();
- if ((params.size() >= 2) && (params[0].operation == LLIL_REG_SSA) && (params[1].operation == LLIL_REG_SSA))
+ if ((params.size() >= 2) && (params[0].operation == LLIL_REG_SSA)
+ && (params[1].operation == LLIL_REG_SSA))
{
auto selfSSAReg = params[0].GetSourceSSARegister<LLIL_REG_SSA>();
auto selSSAReg = params[1].GetSourceSSARegister<LLIL_REG_SSA>();
- if (auto itr = classData.find(ssa->GetSSARegisterValue(selSSAReg).value); itr != classData.end())
+ if (auto itr = classData.find(ssa->GetSSARegisterValue(selSSAReg).value);
+ itr != classData.end())
{
size_t llilIndex = ssa->GetNonSSAInstructionIndex(instrIndex);
LowLevelILInstruction llilInstr = llilFunc->GetInstruction(llilIndex);
@@ -130,12 +132,13 @@ extern "C"
const auto& [typeEncoding, impPtr] = itr->second;
destExpr.Replace(llilFunc->ConstPointer(destExpr.size, impPtr, destExpr));
llilInstr.Replace(llilFunc->Call(destExpr.exprIndex, llilInstr));
- analysisContext->Inform("directRefs", "insert", impPtr, i->GetArchitecture(), instr.address);
+ analysisContext->Inform(
+ "directRefs", "insert", impPtr, i->GetArchitecture(), instr.address);
updated = true;
}
// else
- // LogError("ObjectiveC Workflow: missing classData for __objc_methname entry: 0x%" PRIx64 " at: 0x%" PRIx64,
- // ssa->GetSSARegisterValue(selSSAReg).value, instr.address);
+ // LogError("ObjectiveC Workflow: missing classData for __objc_methname entry: 0x%" PRIx64 "
+ // at: 0x%" PRIx64, ssa->GetSSARegisterValue(selSSAReg).value, instr.address);
}
// else
// LogError("Unhandled _objc_msgSend: 0x%" PRIx64, instr.address);
@@ -157,7 +160,7 @@ extern "C"
objectiveCWorkflow->RegisterActivity(new Activity("extension.objectiveC", &ObjectiveCAnalysis));
objectiveCWorkflow->Insert("core.function.translateTailCalls", "extension.objectiveC");
Workflow::RegisterWorkflow(objectiveCWorkflow,
- R"#({
+ R"#({
"title" : "Objective C Meta-Analysis (Example)",
"description" : "This analysis stands in as an example to demonstrate Binary Ninja's extensible analysis APIs. ***Note** this feature is under active development and subject to change without notice.",
"capabilities" : []