forked from jonpalmisc/ObjectiveNinja
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathGlobalState.h
79 lines (63 loc) · 1.81 KB
/
GlobalState.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Copyright (c) 2022-2023 Jon Palmisciano. All rights reserved.
*
* Use of this source code is governed by the BSD 3-Clause license; the full
* terms of the license can be found in the LICENSE.txt file.
*/
#pragma once
#include <condition_variable>
#include "BinaryNinja.h"
#include "MessageHandler.h"
/**
* Namespace to hold metadata flag key constants.
*/
namespace Flag {
constexpr auto DidRunWorkflow = "objectiveNinja.didRunWorkflow";
constexpr auto DidRunStructureAnalysis = "objectiveNinja.didRunStructureAnalysis";
}
struct AnalysisInfo {
std::uint64_t imageBase;
bool hasObjcStubs = false;
std::pair<uint64_t, uint64_t> objcStubsStartEnd;
std::unordered_map<uint64_t, std::vector<uint64_t>> selRefToImp;
std::unordered_map<uint64_t, std::vector<uint64_t>> selToImp;
};
typedef std::shared_ptr<AnalysisInfo> SharedAnalysisInfo;
/**
* Global state/storage interface.
*/
class GlobalState {
/**
* Get the ID for a view.
*/
static BinaryViewID id(BinaryViewRef);
public:
/**
* Get the analysis info for a view.
*/
static SharedAnalysisInfo analysisInfo(BinaryViewRef);
/**
* Get ObjC Message Handler for a view
*/
static MessageHandler* messageHandler(BinaryViewRef);
/**
* Check if analysis info exists for a view.
*/
static bool hasAnalysisInfo(BinaryViewRef);
/**
* Add a view to the list of ignored views.
*/
static void addIgnoredView(BinaryViewRef);
/**
* Check if a view is ignored.
*/
static bool viewIsIgnored(BinaryViewRef);
/**
* Check if the a metadata flag is present for a view.
*/
static bool hasFlag(BinaryViewRef, const std::string&);
/**
* Set a metadata flag for a view.
*/
static void setFlag(BinaryViewRef, const std::string&);
};