19
19
import java .util .ArrayList ;
20
20
import java .util .List ;
21
21
import java .util .stream .Collectors ;
22
- import java .util .stream .Stream ;
23
22
24
23
import generic .continues .RethrowContinuesFactory ;
25
24
import ghidra .app .util .bin .BinaryReader ;
30
29
import ghidra .app .util .bin .format .macho .commands .NList ;
31
30
import ghidra .app .util .importer .MessageLog ;
32
31
import ghidra .program .model .address .Address ;
33
- import ghidra .program .model .data .CategoryPath ;
34
- import ghidra .program .model .data .DataType ;
35
- import ghidra .program .model .data .DataUtilities ;
36
- import ghidra .program .model .data .StructureDataType ;
32
+ import ghidra .program .model .data .*;
37
33
import ghidra .program .model .listing .Data ;
38
34
import ghidra .program .model .listing .Program ;
39
35
import ghidra .program .model .util .CodeUnitInsertionException ;
@@ -124,7 +120,7 @@ public void markup(Program program, Address localSymbolsInfoAddr, TaskMonitor mo
124
120
public List <NList > getNList () {
125
121
return nlistList ;
126
122
}
127
-
123
+
128
124
/**
129
125
* Gets the {@link List} of {@link DyldCacheLocalSymbolsEntry}s.
130
126
*
@@ -149,12 +145,11 @@ public DataType toDataType() throws DuplicateNameException, IOException {
149
145
return struct ;
150
146
}
151
147
152
- private void parseNList (MessageLog log , TaskMonitor monitor )
153
- throws CancelledException {
148
+ private void parseNList (MessageLog log , TaskMonitor monitor ) throws CancelledException {
154
149
FactoryBundledWithBinaryReader nListReader = new FactoryBundledWithBinaryReader (
155
150
RethrowContinuesFactory .INSTANCE , reader .getByteProvider (), reader .isLittleEndian ());
156
151
monitor .setMessage ("Parsing DYLD nlist symbol table..." );
157
- monitor .initialize (nlistCount * 2 );
152
+ monitor .initialize (nlistCount * 2 );
158
153
nListReader .setPointerIndex (startIndex + nlistOffset );
159
154
try {
160
155
@@ -164,18 +159,17 @@ private void parseNList(MessageLog log, TaskMonitor monitor)
164
159
monitor .incrementProgress (1 );
165
160
}
166
161
// sort the entries by the index in the string table, so don't jump around reading
167
- List <NList > sortedList = nlistList .stream ()
168
- . sorted (( o1 ,o2 )-> o1 .getStringTableIndex () - o2 .getStringTableIndex ())
169
- . collect ( Collectors .toList ());
162
+ List <NList > sortedList = nlistList .stream (). sorted (
163
+ ( o1 , o2 ) -> o1 .getStringTableIndex () - o2 .getStringTableIndex ()). collect (
164
+ Collectors .toList ());
170
165
171
166
// initialize the NList strings from string table
172
167
long stringTableOffset = startIndex + stringsOffset ;
173
- sortedList .forEach (entry -> {
174
- if (!monitor .isCancelled ()) {
175
- entry .initString (nListReader , stringTableOffset );
176
- monitor .incrementProgress (1 );
177
- }
178
- } );
168
+ for (NList nList : sortedList ) {
169
+ monitor .checkCanceled ();
170
+ monitor .incrementProgress (1 );
171
+ nList .initString (nListReader , stringTableOffset );
172
+ }
179
173
}
180
174
catch (IOException e ) {
181
175
log .appendMsg (DyldCacheAccelerateInfo .class .getSimpleName (), "Failed to parse nlist." );
@@ -206,8 +200,8 @@ private void markupNList(Program program, Address localSymbolsInfoAddr, TaskMoni
206
200
try {
207
201
Address addr = localSymbolsInfoAddr .add (nlistOffset );
208
202
for (NList nlist : nlistList ) {
209
- Data d = DataUtilities .createData (program , addr , nlist .toDataType (), -1 ,
210
- false , DataUtilities .ClearDataMode .CHECK_FOR_SPACE );
203
+ Data d = DataUtilities .createData (program , addr , nlist .toDataType (), -1 , false ,
204
+ DataUtilities .ClearDataMode .CHECK_FOR_SPACE );
211
205
addr = addr .add (d .getLength ());
212
206
monitor .checkCanceled ();
213
207
monitor .incrementProgress (1 );
0 commit comments