-
Notifications
You must be signed in to change notification settings - Fork 227
/
Copy pathactivity.cpp
57 lines (44 loc) · 1.63 KB
/
activity.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "binaryninjaapi.h"
#include <string>
using namespace BinaryNinja;
using namespace std;
Activity::Activity(const string& configuration, const std::function<void(Ref<AnalysisContext> analysisContext)>& action,
const std::function<bool(Ref<Activity>, Ref<AnalysisContext>)>& eligibility) : m_action(action), m_eligibility(eligibility)
{
// LogError("API-Side Activity Constructed!");
if (eligibility)
m_object = BNCreateActivityWithEligibility(configuration.c_str(), this, RunAction, CheckEligibility);
else
m_object = BNCreateActivity(configuration.c_str(), this, RunAction);
}
Activity::Activity(BNActivity* activity)
{
// LogError("API-Side Activity Constructed!");
m_object = BNNewActivityReference(activity);
}
Activity::~Activity()
{
// LogError("API-Side Activity Destructed!");
}
void Activity::RunAction(void* ctxt, BNAnalysisContext* analysisContext)
{
// LogError("API-Side Activity RunAction!");
auto boundActivity = static_cast<Activity*>(ctxt);
Ref<AnalysisContext> ac = new AnalysisContext(BNNewAnalysisContextReference(analysisContext));
boundActivity->m_action(ac);
}
bool Activity::CheckEligibility(void* ctxt, BNActivity* activity, BNAnalysisContext* analysisContext)
{
auto boundActivity = static_cast<Activity*>(ctxt);
Ref<Activity> act = new Activity(BNNewActivityReference(activity));
Ref<AnalysisContext> ac = new AnalysisContext(BNNewAnalysisContextReference(analysisContext));
return boundActivity->m_eligibility(act, ac);
}
string Activity::GetName() const
{
// LogError("API-Side Activity GetName!");
char* name = BNActivityGetName(m_object);
string result = name;
BNFreeString(name);
return result;
}