Ghidra is a software reverse engineering (SRE) framework
GT-3261_emteere code review, changed checkCanceled()
emteere97dc1338fc46
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/SymbolTableCommand.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/SymbolTableCommand.javaindex 80d5a8ddbc..4ffceafaf0 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/SymbolTableCommand.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/SymbolTableCommand.java@@ -23,7 +23,6 @@ import java.util.stream.Collectors;import ghidra.app.util.bin.format.FactoryBundledWithBinaryReader;import ghidra.app.util.bin.format.macho.MachConstants;import ghidra.app.util.bin.format.macho.MachHeader;-import ghidra.app.util.bin.format.macho.dyld.DyldCacheAccelerateInfo;import ghidra.app.util.importer.MessageLog;import ghidra.program.flatapi.FlatProgramAPI;import ghidra.program.model.address.Address;@@ -75,7 +74,7 @@ public class SymbolTableCommand extends LoadCommand {long index = reader.getPointerIndex();reader.setPointerIndex(header.getStartIndexInProvider() + symoff);-+List<NList> nlistList = new ArrayList<>(nsyms);long startIndex = header.getStartIndexInProvider();boolean is32bit = header.is32bit();@@ -85,16 +84,16 @@ public class SymbolTableCommand extends LoadCommand {nlistList.add(NList.createNList(reader, is32bit));}// sort the entries by the index in the string table, so don't jump around reading- List<NList> sortedList = nlistList.stream()- .sorted((o1,o2)-> o1.getStringTableIndex() - o2.getStringTableIndex())- .collect(Collectors.toList());+ List<NList> sortedList = nlistList.stream().sorted(+ (o1, o2) -> o1.getStringTableIndex() - o2.getStringTableIndex()).collect(+ Collectors.toList());// initialize the NList strings from string tablelong stringTableOffset = stroff;- sortedList.forEach(entry -> {- entry.initString(reader, stringTableOffset);- symbols.add(entry);- } );+ for (NList nList : sortedList) {+ nList.initString(reader, stringTableOffset);+ symbols.add(nList);+ }reader.setPointerIndex(index);}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheLocalSymbolsInfo.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheLocalSymbolsInfo.javaindex 356cc2b666..c2bf823f48 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheLocalSymbolsInfo.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheLocalSymbolsInfo.java@@ -19,7 +19,6 @@ import java.io.IOException;import java.util.ArrayList;import java.util.List;import java.util.stream.Collectors;-import java.util.stream.Stream;import generic.continues.RethrowContinuesFactory;import ghidra.app.util.bin.BinaryReader;@@ -30,10 +29,7 @@ import ghidra.app.util.bin.format.macho.MachConstants;import ghidra.app.util.bin.format.macho.commands.NList;import ghidra.app.util.importer.MessageLog;import ghidra.program.model.address.Address;-import ghidra.program.model.data.CategoryPath;-import ghidra.program.model.data.DataType;-import ghidra.program.model.data.DataUtilities;-import ghidra.program.model.data.StructureDataType;+import ghidra.program.model.data.*;import ghidra.program.model.listing.Data;import ghidra.program.model.listing.Program;import ghidra.program.model.util.CodeUnitInsertionException;@@ -124,7 +120,7 @@ public class DyldCacheLocalSymbolsInfo implements StructConverter {public List<NList> getNList() {return nlistList;}-+/*** Gets the {@link List} of {@link DyldCacheLocalSymbolsEntry}s.*@@ -149,12 +145,11 @@ public class DyldCacheLocalSymbolsInfo implements StructConverter {return struct;}- private void parseNList(MessageLog log, TaskMonitor monitor)- throws CancelledException {+ private void parseNList(MessageLog log, TaskMonitor monitor) throws CancelledException {FactoryBundledWithBinaryReader nListReader = new FactoryBundledWithBinaryReader(RethrowContinuesFactory.INSTANCE, reader.getByteProvider(), reader.isLittleEndian());monitor.setMessage("Parsing DYLD nlist symbol table...");- monitor.initialize(nlistCount*2);+ monitor.initialize(nlistCount * 2);nListReader.setPointerIndex(startIndex + nlistOffset);try {@@ -164,18 +159,17 @@ public class DyldCacheLocalSymbolsInfo implements StructConverter {monitor.incrementProgress(1);}// sort the entries by the index in the string table, so don't jump around reading- List<NList> sortedList = nlistList.stream()- .sorted((o1,o2)-> o1.getStringTableIndex() - o2.getStringTableIndex())- .collect(Collectors.toList());+ List<NList> sortedList = nlistList.stream().sorted(+ (o1, o2) -> o1.getStringTableIndex() - o2.getStringTableIndex()).collect(+ Collectors.toList());// initialize the NList strings from string tablelong stringTableOffset = startIndex + stringsOffset;- sortedList.forEach(entry -> {- if (!monitor.isCancelled()) {- entry.initString(nListReader, stringTableOffset);- monitor.incrementProgress(1);- }- } );+ for (NList nList : sortedList) {+ monitor.checkCanceled();+ monitor.incrementProgress(1);+ nList.initString(nListReader, stringTableOffset);+ }}catch (IOException e) {log.appendMsg(DyldCacheAccelerateInfo.class.getSimpleName(), "Failed to parse nlist.");@@ -206,8 +200,8 @@ public class DyldCacheLocalSymbolsInfo implements StructConverter {try {Address addr = localSymbolsInfoAddr.add(nlistOffset);for (NList nlist : nlistList) {- Data d = DataUtilities.createData(program, addr, nlist.toDataType(), -1,- false, DataUtilities.ClearDataMode.CHECK_FOR_SPACE);+ Data d = DataUtilities.createData(program, addr, nlist.toDataType(), -1, false,+ DataUtilities.ClearDataMode.CHECK_FOR_SPACE);addr = addr.add(d.getLength());monitor.checkCanceled();monitor.incrementProgress(1);