forked from gdbinit/MachOView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataController.h
207 lines (167 loc) · 7.43 KB
/
DataController.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/*
* DataController.h
* MachOView
*
* Created by psaghelyi on 15/06/2010.
*
*/
#define OFFSET_COLUMN 0
#define DATA_COLUMN 1 // use this with details
#define DESCRIPTION_COLUMN 2 // use this with details
#define VALUE_COLUMN 3
#define DATA_LO_COLUMN 1 // use this with no details
#define DATA_HI_COLUMN 2 // use this with no details
extern NSString * const MVUnderlineAttributeName;
extern NSString * const MVCellColorAttributeName;
extern NSString * const MVTextColorAttributeName;
extern NSString * const MVMetaDataAttributeName;
extern NSString * const MVLayoutUserInfoKey;
extern NSString * const MVNodeUserInfoKey;
extern NSString * const MVStatusUserInfoKey;
extern NSString * const MVDataTreeWillChangeNotification;
extern NSString * const MVDataTreeDidChangeNotification;
extern NSString * const MVDataTreeChangedNotification;
extern NSString * const MVDataTableChangedNotification;
extern NSString * const MVThreadStateChangedNotification;
extern NSString * const MVStatusTaskStarted;
extern NSString * const MVStatusTaskTerminated;
struct MVNodeSaver;
@protocol MVSerializing <NSObject>
- (void)loadFromFile:(FILE *)pFile;
- (void)saveToFile:(FILE *)pFile;
- (void)clear;
@end
//----------------------------------------------------------------------------
@interface MVColumns : NSObject
{
NSString * offsetStr;
NSString * dataStr;
NSString * descriptionStr;
NSString * valueStr;
}
@property (nonatomic) NSString * offsetStr;
@property (nonatomic) NSString * dataStr;
@property (nonatomic) NSString * descriptionStr;
@property (nonatomic) NSString * valueStr;
+(MVColumns *) columnsWithData:(NSString *)col0 :(NSString *)col1 :(NSString *)col2 :(NSString *)col3;
@end
//----------------------------------------------------------------------------
@interface MVRow : NSObject <MVSerializing>
{
MVColumns * columns;
NSDictionary * attributes;
uint64_t offset; // for sorting if necessary
off_t columnsOffset; // offset of columns
off_t attributesOffset; // offset of attribues
BOOL deleted;
BOOL dirty; // eg. attributes has changed
}
@property (nonatomic) NSDictionary * attributes;
@property (nonatomic) MVColumns * columns;
@property (nonatomic) uint64_t offset;
@property (nonatomic) BOOL deleted;
@property (nonatomic) BOOL dirty;
-(NSString *)columnAtIndex:(NSUInteger)index;
@end
@class MVArchiver;
//----------------------------------------------------------------------------
@interface MVTable : NSObject
{
NSMutableArray * rows; // array of MVRow * (host of all the rows)
NSMutableArray * displayRows; // array of MVRow * (rows filtered by search criteria)
MVArchiver * __weak archiver;
FILE * swapFile;
NSLock * tableLock;
}
@property (nonatomic) FILE * swapFile;
- (NSUInteger) rowCountToDisplay;
- (MVRow *) getRowToDisplay:(NSUInteger)rowIndex;
- (void) popRow;
- (void) appendRow:(id)col0 :(id)col1 :(id)col2 :(id)col3;
- (void) insertRowWithOffset:(uint64_t)offset :(id)col0 :(id)col1 :(id)col2 :(id)col3;
- (void) updateCellContentTo:(id)object atRow:(NSUInteger)rowIndex andCol:(NSUInteger)colIndex;
- (NSUInteger) rowCount;
- (void) setAttributes:(NSString *)firstArg, ... NS_REQUIRES_NIL_TERMINATION;
- (void) setAttributesForRowIndex:(NSUInteger)index :(NSString *)firstArg, ... NS_REQUIRES_NIL_TERMINATION;
- (void) setAttributesFromRowIndex:(NSUInteger)index :(NSString *)firstArg, ... NS_REQUIRES_NIL_TERMINATION;
@end
//----------------------------------------------------------------------------
@interface MVNode : NSObject <MVSerializing>
{
NSString * caption;
MVNode * __weak parent;
NSMutableArray * children;
NSRange dataRange;
MVTable * details;
NSMutableDictionary * userInfo;
off_t detailsOffset;
}
@property (nonatomic) NSString * caption;
@property (nonatomic,weak) MVNode * parent;
@property (nonatomic) NSRange dataRange;
@property (nonatomic) MVTable * details;
@property (nonatomic) NSMutableDictionary * userInfo;
@property (nonatomic) off_t detailsOffset;
- (NSUInteger) numberOfChildren;
- (MVNode *) childAtIndex:(NSUInteger)n;
- (MVNode *) insertChild:(NSString *)_caption location:(uint64_t)location length:(uint64_t)length;
- (MVNode *) insertChildWithDetails:(NSString *)_caption location:(uint64_t)location length:(uint64_t)length saver:(MVNodeSaver &)saver;
- (MVNode *) findNodeByUserInfo:(NSDictionary *)uinfo;
- (void) openDetails; // open swap file for reading details on demand
- (void) closeDetails; // close swap file
- (void) sortDetails;
- (void) filterDetails:(NSString *)filter;
- (void) loadFromFile:(FILE *)pFile;
- (void) saveToFile:(FILE *)pFile;
@end
//----------------------------------------------------------------------------
@interface MVDataController : NSObject
{
NSString * fileName; // path to the binary handled by this data controller
NSMutableData * fileData; // content of the binary
NSMutableData * realData; // patched content by relocs and bindings
NSMutableArray * layouts;
MVNode * rootNode;
MVNode * __weak selectedNode;
NSLock * treeLock; // semaphore for the node tree
}
@property (nonatomic) NSString * fileName;
@property (nonatomic) NSMutableData * fileData;
@property (nonatomic) NSMutableData * realData;
@property (nonatomic,readonly) NSArray * layouts;
@property (nonatomic,readonly) MVNode * rootNode;
@property (nonatomic,weak) MVNode * selectedNode;
@property (nonatomic,readonly) NSLock * treeLock;
-(NSString *) getMachine:(cpu_type_t)cputype;
-(NSString *) getARMCpu:(cpu_subtype_t)cpusubtype;
- (void) createLayouts:(MVNode *)parent location:(uint64_t)location length:(uint64_t)length;
- (void) updateTreeView: (MVNode *)node;
- (void) updateTableView;
- (void) updateStatus: (NSString *)status;
@end
//----------------------------------------------------------------------------
@interface MVArchiver : NSObject
{
NSString * swapPath;
NSMutableArray * objectsToSave; // conforms MVSerializing
NSThread * saverThread;
NSLock * saverLock;
}
@property (nonatomic,readonly) NSString * swapPath;
+(MVArchiver *) archiverWithPath:(NSString *)path;
-(void) addObjectToSave:(id)object;
-(void) suspend;
-(void) resume;
-(void) halt;
@end
//----------------------------------------------------------------------------
struct MVNodeSaver
{
MVNodeSaver();
~MVNodeSaver();
void setNode(MVNode * node) { m_node = node; }
private:
MVNodeSaver(MVNodeSaver const &);
MVNodeSaver & operator=(MVNodeSaver const &);
MVNode * __weak m_node;
};