Skip to content

Commit

Permalink
Upgrade for 10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed May 17, 2023
1 parent 364a043 commit 5a42d40
Show file tree
Hide file tree
Showing 12 changed files with 333 additions and 295 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/build_on_tag_push.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Ghidra Extension Publish

env:
ghidra-url: https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_10.2.1_build/ghidra_10.2.1_PUBLIC_20221110.zip
ghidra-zip-filename: ghidra_10.2.1_PUBLIC_20221110.zip
ghidra-directory: ghidra_10.2.1_PUBLIC
ghidra-url: https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_10.3_build/ghidra_10.3_PUBLIC_20230510.zip
ghidra-zip-filename: ghidra_10.3_PUBLIC_20230510.zip
ghidra-directory: ghidra_10.3_PUBLIC

on:
push:
Expand All @@ -16,6 +16,11 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'

- name: Get the version
id: get_version
Expand All @@ -33,14 +38,11 @@ jobs:
- name: Build
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y openjdk-17-jdk-headless
sudo update-java-alternatives -s java-1.17.0-openjdk-amd64
unzip -qq ${{ steps.download-ghidra.outputs.file-path }} -d /opt
rm -v ${{ env.ghidra-zip-filename }}
cd lightkeeper
java --version
gradle -Dorg.gradle.java.home=/usr/lib/jvm/java-1.17.0-openjdk-amd64 -PGHIDRA_INSTALL_DIR=/opt/${{ env.ghidra-directory }}
gradle -PGHIDRA_INSTALL_DIR=/opt/${{ env.ghidra-directory }}
mv -v dist/*.zip ${{ github.workspace }}/lightkeeper-${{ steps.get_version.outputs.VERSION }}.zip
- name: Create Release
Expand Down
531 changes: 283 additions & 248 deletions lightkeeper/.classpath

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lightkeeper/.project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>LightKeeper</name>
<name>lightkeeper</name>
<comment></comment>
<projects>
</projects>
Expand All @@ -18,7 +18,7 @@
<link>
<name>Ghidra</name>
<type>2</type>
<location>/opt/ghidra_10.2.1_PUBLIC</location>
<location>/opt/ghidra_10.3_PUBLIC</location>
</link>
</linkedResources>
</projectDescription>
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void colour(TaskMonitor monitor) throws CancelledException {
try {
colorService.clearAllBackgroundColors();
for (AddressRange range : instructionModel.getModelData()) {
monitor.checkCanceled();
monitor.checkCancelled();
var min = range.getMinAddress();
var max = range.getMaxAddress();
colorService.setBackgroundColor(min, max, Color.GREEN);
Expand Down Expand Up @@ -120,7 +120,7 @@ public void addException(Exception exc) {
}

public void importCoverage(TaskMonitor monitor, List<File> files) throws CancelledException {
monitor.checkCanceled();
monitor.checkCancelled();
try {
for (File file : files) {
monitor.setMessage(String.format("Importing: %s", file.getAbsolutePath()));
Expand All @@ -145,7 +145,7 @@ public void importCoverage(TaskMonitor monitor, List<File> files) throws Cancell
}

public void clearCoverage(TaskMonitor monitor) throws CancelledException {
monitor.checkCanceled();
monitor.checkCancelled();
monitor.setMessage("Clearing");
addMessage("Clearing");
monitor.setProgress(0);
Expand All @@ -156,7 +156,7 @@ public void clearCoverage(TaskMonitor monitor) throws CancelledException {

public void refreshCoverage(TaskMonitor monitor) throws CancelledException {
try {
monitor.checkCanceled();
monitor.checkCancelled();
monitor.setMessage("Refreshing");
addMessage("Refreshing");
monitor.setProgress(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.awt.Color;
import java.math.BigInteger;

import docking.widgets.fieldpanel.LayoutModel;
import docking.widgets.fieldpanel.listener.IndexMapper;
import docking.widgets.fieldpanel.listener.LayoutModelListener;
import ghidra.app.decompiler.ClangLine;
Expand Down Expand Up @@ -37,7 +38,7 @@ public void modelChanged(TaskMonitor monitor) throws CancelledException {
DecompilerActionContext context = (DecompilerActionContext) dprov.getActionContext(null);
if (context != null) {
DecompilerPanel dpanel = context.getDecompilerPanel();
var controller = dpanel.getLayoutModel();
LayoutModel controller = dpanel.getFieldPanel().getLayoutModel();
controller.addLayoutModelListener(new LayoutModelListener() {

@Override
Expand Down Expand Up @@ -65,13 +66,13 @@ public void updateCoverage(TaskMonitor monitor, DecompilerPanel dpanel) throws C

for (ClangLine line : dpanel.getLines()) {
for (ClangToken token : line.getAllTokens()) {
monitor.checkCanceled();
monitor.checkCancelled();
var address = DecompilerUtils.getClosestAddress(program, token);
if (address == null) {
continue;
}
for (AddressRange range : model.getModelData()) {
monitor.checkCanceled();
monitor.checkCancelled();
if (!range.contains(address)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

public class BinaryLineReader extends BinaryReader {

protected CountedByteProvider provider;
protected CountedByteProvider countedProvider;

public BinaryLineReader(CountedByteProvider provider) {
super(provider, true);
this.provider = provider;
this.countedProvider = provider;
}

public String readLine() throws IOException {
Expand All @@ -22,7 +22,7 @@ public String readLine() throws IOException {
}

if (!isPrintable(c)) {
throw new IOException(String.format("Invalid character at position: %d", provider.getPosition()));
throw new IOException(String.format("Invalid character at position: %d", countedProvider.getPosition()));
}

buffer.append(c);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public void addException(Exception exc) {
}

public BlockEntry read() throws CancelledException, IOException {
monitor.checkCanceled();
monitor.checkCancelled();
var start = reader.readNextUnsignedInt();
var size = reader.readNextUnsignedShort();
var module = reader.readNextUnsignedShort();

var block = new BlockEntry(start, size, module);
addMessage(String.format("Read Block: %s", block));
monitor.checkCanceled();
monitor.checkCancelled();
return block;
}
}
22 changes: 11 additions & 11 deletions lightkeeper/src/main/java/lightkeeper/io/file/DynamoRioFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,18 @@ public void addException(Exception exc) {
}

private void readHeader(TaskMonitor monitor) throws CancelledException, IOException {
monitor.checkCanceled();
monitor.checkCancelled();
monitor.setMessage("Reading header");
var headerLine = reader.readLine();
addMessage(headerLine);
if (!headerLine.equals(HEADER)) {
throw new IOException(String.format("Invalid header: '%s' expected '%s'", headerLine, HEADER));
}
monitor.checkCanceled();
monitor.checkCancelled();
}

private void readFlavour(TaskMonitor monitor) throws CancelledException, IOException {
monitor.checkCanceled();
monitor.checkCancelled();
monitor.setMessage("Reading flavour");
var flavourLine = reader.readLine();
addMessage(flavourLine);
Expand All @@ -95,11 +95,11 @@ private void readFlavour(TaskMonitor monitor) throws CancelledException, IOExcep
}
flavour = flavourMatcher.group("flavour");
addMessage(String.format("Detected flavour: %s", flavour));
monitor.checkCanceled();
monitor.checkCancelled();
}

private void readTable(TaskMonitor monitor) throws CancelledException, IOException {
monitor.checkCanceled();
monitor.checkCancelled();
monitor.setMessage("Reading table");
var tableLine = reader.readLine();
addMessage(tableLine);
Expand All @@ -120,22 +120,22 @@ private void readTable(TaskMonitor monitor) throws CancelledException, IOExcepti
var count = tableMatcher.group("count");
tableCount = Integer.parseInt(count);
addMessage(String.format("Detected table count: %d", tableCount));
monitor.checkCanceled();
monitor.checkCancelled();
}

private void readModules(TaskMonitor monitor) throws CancelledException, IOException {
var moduleReader = new ModuleReader(monitor, reader, tableVersion);
moduleReader.addListener(this);
for (var i = 0; i < tableCount; i++) {
monitor.checkCanceled();
monitor.checkCancelled();
monitor.setMessage(String.format("Reading module: %d", i));
var module = moduleReader.read();
modules.add(module);
}
}

private void readBbHeader(TaskMonitor monitor) throws CancelledException, IOException {
monitor.checkCanceled();
monitor.checkCancelled();
monitor.setMessage("Reading BB header");
var bbHeaderLine = reader.readLine();
addMessage(bbHeaderLine);
Expand All @@ -147,7 +147,7 @@ private void readBbHeader(TaskMonitor monitor) throws CancelledException, IOExce
var blockString = bbHeaderMatcher.group("blocks");
blockCount = Integer.parseInt(blockString);
addMessage(String.format("Detected: %d blocks", blockCount));
monitor.checkCanceled();
monitor.checkCancelled();
}

private void readBlocks(TaskMonitor monitor) throws CancelledException, IOException {
Expand All @@ -157,7 +157,7 @@ private void readBlocks(TaskMonitor monitor) throws CancelledException, IOExcept
var moduleLimits = getModuleLimits();

for (var i = 0; i < blockCount; i++) {
monitor.checkCanceled();
monitor.checkCancelled();
monitor.setMessage(String.format("Reading block: %d", i));
var block = blockReader.read();
long moduleLimit = moduleLimits.get(block.getModule());
Expand All @@ -167,7 +167,7 @@ private void readBlocks(TaskMonitor monitor) throws CancelledException, IOExcept
blocks.add(block);
}

monitor.checkCanceled();
monitor.checkCancelled();

if (provider.getLength() != provider.getPosition()) {
throw new IOException(String.format("File has: %d unexpected trailing bytes at position: %d",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ protected void addMessage(String message) {
}

private void readColumnHeader() throws CancelledException, IOException {
monitor.checkCanceled();
monitor.checkCancelled();
monitor.setMessage("Reading Column Header");
columnHeader = reader.readLine();
addMessage(columnHeader);
}

public ModuleEntry read() throws CancelledException, IOException {
monitor.checkCanceled();
monitor.checkCancelled();
var moduleLine = reader.readLine();
addMessage(moduleLine);

Expand Down Expand Up @@ -150,7 +150,7 @@ public ModuleEntry read() throws CancelledException, IOException {

var module = new ModuleEntry(id, containingId, start, end, entry, checksum, timeStamp, pathString);
addMessage(String.format("Read Module: %s", module));
monitor.checkCanceled();
monitor.checkCancelled();
return module;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ public void update(TaskMonitor monitor) throws CancelledException, IOException {

Set<Integer> ids = this.getSelectedModuleIds(selectedModules);

var baseAddress = api.getCurrentProgram().getAddressMap().getImageBase();
var baseAddress = api.getCurrentProgram().getImageBase();
for (BlockEntry block : file.getBlocks()) {
monitor.checkCanceled();
monitor.checkCancelled();
if (!ids.contains(block.getModule())) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void update(TaskMonitor monitor) throws CancelledException {
var listing = api.getCurrentProgram().getListing();

for (AddressRange range : modelRanges) {
monitor.checkCanceled();
monitor.checkCancelled();
var iterator = listing.getInstructions(range.getMinAddress(), true);
while (iterator.hasNext()) {
var instruction = iterator.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public void update(TaskMonitor monitor) throws CancelledException {
return;
}

monitor.checkCanceled();
monitor.checkCancelled();

processRanges(monitor);

monitor.setMessage("Processing complete");
addMessage("Processing complete");
monitor.checkCanceled();
monitor.checkCancelled();
notifyUpdate(monitor);
}

Expand All @@ -55,7 +55,7 @@ public void processRanges(TaskMonitor monitor) throws CancelledException {
Set<AddressRange> unassigned = new HashSet<>();
var api = plugin.getApi();
for (var i = 0; i < modelRanges.size(); i++) {
monitor.checkCanceled();
monitor.checkCancelled();
monitor.setMessage(String.format("Processing block %d / %d", i, modelRanges.size()));
var range = modelRanges.get(i);

Expand Down Expand Up @@ -85,7 +85,7 @@ public void processFunctions(TaskMonitor monitor, HashMap<Function, Set<AddressR
var i = 0;
while (functionIterator.hasNext()) {
i++;
monitor.checkCanceled();
monitor.checkCancelled();
var function = functionIterator.next();
monitor.setMessage(
String.format("Processing function (%s) %d / %d", function.getName(), i, functions.size()));
Expand Down Expand Up @@ -113,7 +113,7 @@ public CoverageFraction processCodeBlocks(TaskMonitor monitor, Function function
var codeBlocks = 0;
var hitCodeBlocks = 0;
while (codeBlockIterator.hasNext()) {
monitor.checkCanceled();
monitor.checkCancelled();
codeBlocks++;

monitor.setMessage(String.format("Processing function blocks (%s) %d", function.getName(), codeBlocks));
Expand All @@ -123,7 +123,7 @@ public CoverageFraction processCodeBlocks(TaskMonitor monitor, Function function

var rangeIterator = ranges.iterator();
while (rangeIterator.hasNext()) {
monitor.checkCanceled();
monitor.checkCancelled();

var range = rangeIterator.next();
if (range.getMinAddress().compareTo(cb.getMinAddress()) < 0) {
Expand All @@ -150,7 +150,7 @@ public CoverageFraction processInstructions(TaskMonitor monitor, Function functi
var instructions = 0;
var hitInstructions = 0;
while (instructionIterator.hasNext()) {
monitor.checkCanceled();
monitor.checkCancelled();
instructions++;
monitor.setMessage(
String.format("Processing function instructions (%s) %d", function.getName(), instructions));
Expand All @@ -159,7 +159,7 @@ public CoverageFraction processInstructions(TaskMonitor monitor, Function functi
var instruction = instructionIterator.next();
var rangeIterator = ranges.iterator();
while (rangeIterator.hasNext()) {
monitor.checkCanceled();
monitor.checkCancelled();
var range = rangeIterator.next();

if (instruction.getMinAddress().compareTo(range.getMinAddress()) < 0) {
Expand All @@ -182,7 +182,7 @@ public void processUnassigned(TaskMonitor monitor, Set<AddressRange> unassigned)
var i = 0;
while (iterator.hasNext()) {
i++;
monitor.checkCanceled();
monitor.checkCancelled();
monitor.setMessage(String.format("Processing unassigned block %d / %d", i, unassigned.size()));
addMessage(String.format("Processing unassigned block %d / %d", i, unassigned.size()));
var range = iterator.next();
Expand Down

0 comments on commit 5a42d40

Please sign in to comment.