Skip to content

Commit

Permalink
Formatting + typo fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sarog committed Aug 4, 2023
1 parent 718d3de commit 95a1ae1
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions DhrakeInit.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//Uses metadata from an IDR generated IDC script to rename symbols
//and fix certain calls in Delphi programs
// Uses metadata from an IDR-generated IDC script to rename symbols
// and fix certain calls in Delphi programs
//@category Delphi
//@author Jesko Huettenhain

Expand Down Expand Up @@ -200,18 +200,18 @@ private boolean importSymbolsFromIDC() {
int progress = 0;
int linecount = 0;

monitor.setMessage("loading symbols from IDC");
monitor.setMessage("Loading symbols from IDC");

try {
idc = this.askFile("IDC File Path", "Load an IDC file");
} catch (CancelledException e) {
return false;
}
Pattern pattern = Pattern.compile("^\\s*MakeNameEx\\((?:0x)?([A-Fa-f0-9]+),\\s*\"([^\"]*)\",\\s*([xA-Fa-f0-9]+)\\);\\s*$");

Pattern pattern = Pattern.compile("^\\s*MakeNameEx\\((?:0x)?([A-Fa-f0-9]+),\\s*\"([^\"]*)\",\\s*([xA-Fa-f0-9]+)\\);\\s*$");

try (BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(idc)); Scanner sc = new Scanner(inputStream, StandardCharsets.UTF_8)) {
//count lines
// Count lines
while (sc.hasNextLine()) {
sc.nextLine();
linecount++;
Expand All @@ -224,7 +224,7 @@ private boolean importSymbolsFromIDC() {

try (BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(idc)); Scanner sc = new Scanner(inputStream, StandardCharsets.UTF_8)) {
monitor.setMessage("Processing IDC file");
logMsg(String.format("Processing IDC file %s", idc.toPath()));
this.logMsg("Processing IDC file %s", idc.toPath());

while (sc.hasNextLine()) {
if (monitor.isCancelled()) break;
Expand All @@ -233,11 +233,12 @@ private boolean importSymbolsFromIDC() {

monitor.setProgress(progress++);

if (!line.contains("MakeNameEx"))
continue;
if (!line.contains("MakeNameEx")) continue;

Matcher match = pattern.matcher(line);
if (!match.matches())
continue;

if (!match.matches()) continue;

Integer offset = Integer.parseUnsignedInt(match.group(1), 16);
Address entryPoint = this.toAddr(offset);
String functionName = match.group(2);
Expand All @@ -246,7 +247,7 @@ private boolean importSymbolsFromIDC() {
try {
this.renameSymbol(entryPoint, functionName);
} catch (InvalidInputException e) {
this.logMsg("renaming failed for: %s", functionName);
this.logMsg("Renaming failed for: %s", functionName);
}
}
}
Expand All @@ -258,7 +259,7 @@ private boolean importSymbolsFromIDC() {
}
private void repairStringCompareFunctions() {
try {
monitor.setMessage("reparing known function signatures");
monitor.setMessage("Repairing known function signatures");

VariableStorage zfReturn = new VariableStorage(
currentProgram, currentProgram.getRegister("ZF"));
Expand Down

0 comments on commit 95a1ae1

Please sign in to comment.