-
Notifications
You must be signed in to change notification settings - Fork 21
/
logic.h
94 lines (73 loc) · 2.38 KB
/
logic.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// logic.h -- May 9, 2009
// by geohot
// part of "The Embedded Disassembler"
// released under GPLv3,
#ifndef EDA_LOGIC_H_
#define EDA_LOGIC_H_
#include "data_memory.h"
namespace eda {
class MemoryManager {
};
// This is an abstract class to be extended by the different arches
// If I thought this through right, no other class needs to be
// This also kills the ARM/Thumb problem
// EDA plugins are extensions to this
class InstructionFactory {
public:
// Sets up the addresses of the registers
virtual void InitRegisters(Memory *m) { };
// Parses an instruction
// instruction should be null when passed in
// Returns the address after the end of this instruction
virtual Address* Process(Address* start) = 0;
virtual void StateToXML(std::ostringstream& out) { }
// This is the instruction that is currently running
virtual uint32_t GetProgramCounter() {
uint32_t ret;
program_counter_->get32(0, &ret);
return TranslateToProgramCounter(ret);
}
virtual uint32_t GetStackPointer() {
uint32_t ret;
stack_pointer_->get32(0, &ret);
return ret;
}
// This is extended for different archs to get the real program counter
virtual uint32_t TranslateToProgramCounter(uint32_t in) {
return in-program_counter_offset_;
}
virtual uint32_t TranslateFromProgramCounter(uint32_t in) {
return in+program_counter_offset_;
}
void FastAnalyse(Memory* m, Address* start);
void FastAnalyseRecurse(Memory* m, Address* location, Address* temp_program_counter, int* changelist_number);
Address* program_counter_;
Address* link_register_;
Address* stack_pointer_;
int program_counter_offset_;
vector<pair<std::string, Address*> > registers_;
private:
};
// This creates changelists
// Currently, theres two ways
class ChangelistFactory {
// out should be null when passed in to all
public:
ChangelistFactory();
// Used for loading from files or straight web data
Changelist* CreateFromInput(Address* owner, const string& data, Address* start);
// Used by the Core
Changelist* CreateFromStatelessChangelist(Address* owner, StatelessChangelist& in,
Memory* state);
inline int get_current_changelist_number() {
return current_changelist_number_;
}
private:
// This is incremented every time a changelist is created
// It starts out at zero
int current_changelist_number_;
};
class Core {
};
}
#endif