-
Notifications
You must be signed in to change notification settings - Fork 210
/
activity.cpp
44 lines (33 loc) · 1.01 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
#include "binaryninjaapi.h"
#include <string>
using namespace BinaryNinja;
using namespace std;
Activity::Activity(const string& configuration, const std::function<void(Ref<AnalysisContext> analysisContext)>& action) : m_action(action)
{
// LogError("API-Side Activity Constructed!");
m_object = BNCreateActivity(configuration.c_str(), this, Run);
}
Activity::Activity(BNActivity* activity)
{
// LogError("API-Side Activity Constructed!");
m_object = BNNewActivityReference(activity);
}
Activity::~Activity()
{
// LogError("API-Side Activity Destructed!");
}
void Activity::Run(void* ctxt, BNAnalysisContext* analysisContext)
{
// LogError("API-Side Activity Run!");
Activity* activity = (Activity*)ctxt;
Ref<AnalysisContext> ac = new AnalysisContext(BNNewAnalysisContextReference(analysisContext));
activity->m_action(ac);
}
string Activity::GetName() const
{
// LogError("API-Side Activity GetName!");
char* name = BNActivityGetName(m_object);
string result = name;
BNFreeString(name);
return result;
}