This repository has been archived by the owner on Jun 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
MachOReader.h
214 lines (169 loc) · 4.85 KB
/
MachOReader.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
208
209
210
211
212
213
214
//
// MachOReader.h
// MachoViewer
//
// Created by Alexander Stavonin on 28.01.10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "macho_reader.h"
////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////// Data representation //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
@interface MachODyLib : NSObject
{
NSURL *pathName;
NSString *name;
NSNumber *timestamp;
NSNumber *current_version;
NSNumber *compatibility_version;
}
@property (readonly) NSURL *pathName;
@property (readonly) NSString *name;
@property (readonly) NSNumber *timestamp;
@property (readonly) NSNumber *current_version;
@property (readonly) NSNumber *compatibility_version;
-(id)initWithDylib:(macho_dylib_t*)data;
@end
@interface MachOSymbol : NSObject
{
NSString *name;
NSNumber *type;
uint8 sect;
uint16 desc;
}
@property (readonly) NSString *name;
@property (readonly) NSNumber *type;
@property (readonly) uint8 sect;
@property (readonly) uint16 desc;
-(id)initWithSymbol:(macho_symbol_t*)data;
@end
@interface MachOSection : NSObject
{
NSString *sectname;
NSString *segname;
uint addr;
uint size;
uint offset;
uint align;
uint reloff;
uint nreloc;
uint flags;
NSString *asString;
NSArray *sections; // fake!!!
}
@property (readonly) NSArray *sections;
@property (readonly) NSString *asString;
@property (readonly) NSString *sectname;
@property (readonly) NSString *segname;
@property (readonly) uint addr;
@property (readonly) uint size;
@property (readonly) uint offset;
@property (readonly) uint align;
@property (readonly) uint reloff;
@property (readonly) uint nreloc;
@property (readonly) uint flags;
-(id)initWithSection:(macho_section_t*)data;
-(id)initWithSection64:(macho_section_64_t*)data;
-(void)buildInfoString;
@end
@interface MachOSegment : NSObject
{
NSString *segname;
uint vmaddr;
uint vmsize;
uint fileoff;
uint filesize;
uint flags;
uint nsects;
NSMutableArray *sections;
NSString *asString;
}
@property (readonly) NSString *asString;
@property (readonly) NSString *segname;
@property (readonly) uint vmaddr;
@property (readonly) uint vmsize;
@property (readonly) uint fileoff;
@property (readonly) uint filesize;
@property (readonly) uint flags;
@property (readonly) uint nsects;
@property (readonly) NSMutableArray *sections;
-(id)initWithSegment:(macho_segment_t*)data;
-(id)initWithSegment64:(macho_segment_64_t*)data;
-(void)buildInfoString;
@end
@interface StringFormatter : NSObject
{
NSDictionary *boldFont;
NSDictionary *normalFont;
NSMutableAttributedString *resultString;
}
@property (readonly) NSMutableAttributedString *resultString;
-(void)addString:(NSString*)data withName:(NSString*)name;
-(void)addUInt:(uint)data withName:(NSString*)name;
@end
@interface MachOArch : NSObject
{
NSNumber *magic;
NSNumber *cputype;
NSNumber *cpusubtype;
NSNumber *offset;
NSNumber *filetype;
NSNumber *ncmds;
NSNumber *flags;
NSURL *dylinker;
NSNumber *nseg;
NSMutableArray *segments;
NSMutableArray *dylibs;
NSMutableArray *symbols;
}
@property (readonly) NSNumber *nseg;
@property (readonly) NSNumber *magic;
@property (readonly) NSNumber *cputype;
@property (readonly) NSNumber *cpusubtype;
@property (readonly) NSNumber *offset;
@property (readonly) NSNumber *filetype;
@property (readonly) NSNumber *ncmds;
@property (readonly) NSNumber *flags;
@property (readonly) NSURL *dylinker;
@property (readonly) NSMutableArray *segments;
@property (readonly) NSMutableArray *dylibs;
@property (readonly) NSMutableArray *symbols;
-(id)initWithArch:(macho_arch_t*)data;
@end
////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Reader /////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
@interface MachOReader : NSObject {
macho_info_t *machoInfo;
NSString *binaryName;
NSURL *binaryPath;
NSMutableArray *archs;
}
@property (readonly) NSString *binaryName;
@property (readonly) NSURL *binaryPath;
@property (retain) NSMutableArray *archs;
-(BOOL)openMachOFile:(NSString*)path;
-(void)closeMachOFile;
@end
////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Transformers /////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
@interface ArchListToNamesTransformer : NSObject
{}
@end
@interface ArchToNameTransformer : NSObject
{}
@end
@interface DecToHexTransformer : NSObject
{}
@end
@interface FileTypeTransformer : NSObject
{}
@end
@interface ArchFlagsTransformer : NSObject
{}
@end
@interface SymbFlagsTransformer : NSObject
{}
@end