Skip to content

Commit

Permalink
Merge branch 'NationalSecurityAgency:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
just-an-engineer authored Jul 19, 2024
2 parents 19106c3 + a46009f commit a8ac78e
Show file tree
Hide file tree
Showing 77 changed files with 4,067 additions and 3,094 deletions.
4 changes: 2 additions & 2 deletions DevGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ authors' names directly in the source code, so it is discouraged.
Download non-Maven Central dependencies. This creates a `dependencies` directory in the repository
root.
```
gradle -I gradle/support/fetchDependencies.gradle init
gradle -I gradle/support/fetchDependencies.gradle
```

Download Maven Central dependencies and setup the repository for development. By default, these
Expand Down Expand Up @@ -97,7 +97,7 @@ Sometimes you may want to move the Ghidra repository to an offline network and d
These are the recommended steps to ensure that you not only move the source repository, but all
downloaded dependencies as well:

1. `gradle -I gradle/support/fetchDependencies.gradle init`
1. `gradle -I gradle/support/fetchDependencies.gradle`
2. `gradle -g dependencies/gradle prepdev`
3. Move ghidra directory to different system
4. `gradle -g dependencies/gradle buildGhidra` (on offline system)
Expand Down
1 change: 1 addition & 0 deletions Ghidra/Features/Base/data/ExtensionPoint.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ ChecksumAlgorithm
OverviewColorService
DWARFFunctionFixup
ElfInfoProducer
FSBFileHandler
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ icon.fsbrowser.file.extension.zip = images/oxygen/16x16/application-x-bzi
icon.fsbrowser.file.substring.release. = images/famfamfam_silk_icons_v013/bullet_purple.png

icon.fsbrowser.file.overlay.imported = EMPTY_ICON{images/checkmark_green.gif[size(8,8)][move(8,8)]} // lower right quadrant
icon.fsbrowser.file.overlay.filesystem = EMPTY_ICON{images/ledgreen.png[size(8,8)][move(0,8)]} // lower left quadrant
icon.fsbrowser.file.overlay.missing.password = EMPTY_ICON{images/lock.png[size(8,8)][move(8,0)]} // upper right quadrant
icon.fsbrowser.file.overlay.filesystem = EMPTY_ICON{images/ledgreen.png[size(8,8)][move(0,8)]} // lower left quadrant
icon.fsbrowser.file.overlay.link = EMPTY_ICON{icon.content.handler.link[move(0,8)]} // lower-left quadrant
icon.fsbrowser.file.overlay.missing.password = EMPTY_ICON{images/lock.png[size(8,8)][move(8,0)]} // upper right quadrant
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private boolean doDemangle(Demangler demangler, Program program, TaskMonitor mon
// tell a mangled from a non-mangled symbol.
// Msg.debug(this, "Unable to demangle name: " + mangled);
}
catch (Exception e) { e.printStackTrace();
catch (Exception e) {
// Demangler IndexOutOfBoundsException that we're not sure how to fix
setStatusMsg("Unable to demangle symbol: " + mangled + " at " + addr + ". Message: " +
e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra.app.util.demangler;

import org.apache.commons.lang3.StringUtils;

import ghidra.program.model.symbol.Namespace;

/**
* Represents a plain namespace node that is not a type or method
*/
public class DemangledNamespaceNode implements Demangled {

// The intention is for this to be as refined a part of a larger mangled string as possible,
// but it is up to the user to know if they can pass that more refined string or if they
// just have to pass a bigger piece.
protected String mangled;
private String originalDemangled;
private String demangledName;
private String name; // 'safe' name

protected Demangled namespace;

/**
* Constructor
* @param mangled as a refined a piece of the (larger) original mangled stream as the user
* can provide, though many times the larger piece is all that the user can provide
* @param originalDemangled the original demangled string to match mangled string with the
* same caveats
* @param name the name of the namespace node
*/
public DemangledNamespaceNode(String mangled, String originalDemangled, String name) {
this.mangled = mangled;
this.originalDemangled = originalDemangled;
setName(name);
}

@Override
public void setName(String name) {
if (StringUtils.isBlank(name)) {
throw new IllegalArgumentException("Name cannot be blank");
}
demangledName = name;
this.name = DemanglerUtil.stripSuperfluousSignatureSpaces(name).replace(' ', '_');
}

@Override
public String getName() {
return name;
}

@Override
public String getMangledString() {
return mangled;
}

@Override
public String getOriginalDemangled() {
return originalDemangled;
}

@Override
public String getDemangledName() {
return demangledName;
}

@Override
public void setNamespace(Demangled ns) {
namespace = ns;
}

@Override
public Demangled getNamespace() {
return namespace;
}

@Override
public String getNamespaceString() {
return getName(true);
}

@Override
public String getNamespaceName() {
return name;
}

@Override
public String getSignature() {
return getNamespaceName();
}

private String getName(boolean includeNamespace) {
StringBuilder builder = new StringBuilder();
if (includeNamespace && namespace != null) {
builder.append(namespace.getNamespaceString());
builder.append(Namespace.DELIMITER);
}
builder.append(demangledName);
return builder.toString();
}

@Override
public String toString() {
return getNamespaceString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public class DemangledType implements Demangled {
private boolean isConst;
private boolean isVolatile;

public DemangledType(String mangled, String originaDemangled, String name) {
public DemangledType(String mangled, String originalDemangled, String name) {
this.mangled = mangled;
this.originalDemangled = originaDemangled;
this.originalDemangled = originalDemangled;
setName(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import ghidra.formats.gfilesystem.FSRL;
import ghidra.framework.model.*;
import ghidra.framework.store.LockException;
import ghidra.plugin.importer.ProgramMappingService;
import ghidra.program.database.ProgramDB;
import ghidra.program.database.function.OverlappingFunctionException;
import ghidra.program.model.address.*;
Expand Down Expand Up @@ -367,8 +366,7 @@ public static void setProgramProperties(Program prog, ByteProvider provider,
if (fsrl.getMD5() == null) {
fsrl = fsrl.withMD5(md5);
}
prog.getOptions(Program.PROGRAM_INFO)
.setString(ProgramMappingService.PROGRAM_SOURCE_FSRL, fsrl.toString());
FSRL.writeToProgramInfo(prog, fsrl);
}
prog.setExecutableMD5(md5);
String sha256 = computeBinarySHA256(provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package ghidra.formats.gfilesystem;

import java.io.IOException;
import java.util.Comparator;
import java.util.List;

Expand Down Expand Up @@ -65,6 +66,11 @@ public GFile lookup(String path) {
return fsIndex.lookup(null, path, getFilenameComparator());
}

@Override
public GFile getRootDir() {
return fsIndex.getRootDir();
}

@Override
public List<GFile> getListing(GFile directory) {
return fsIndex.getListing(directory);
Expand All @@ -75,4 +81,9 @@ public int getFileCount() {
return fsIndex.getFileCount();
}

@Override
public GFile resolveSymlinks(GFile file) throws IOException {
return fsIndex.resolveSymlinks(file);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.net.MalformedURLException;
import java.util.*;

import ghidra.plugin.importer.ProgramMappingService;
import ghidra.program.model.listing.Program;
import ghidra.util.SystemUtilities;

Expand Down Expand Up @@ -64,6 +63,7 @@
*/
public class FSRL {
public static final String PARAM_MD5 = "MD5";
public static final String FSRL_OPTION_NAME = "FSRL";

/**
* Returns the {@link FSRL} stored in a {@link Program}'s properties, or null if not present
Expand All @@ -73,8 +73,7 @@ public class FSRL {
* @return {@link FSRL} from program's properties, or null if not present or invalid
*/
public static FSRL fromProgram(Program program) {
String fsrlStr = program.getOptions(Program.PROGRAM_INFO)
.getString(ProgramMappingService.PROGRAM_SOURCE_FSRL, null);
String fsrlStr = program.getOptions(Program.PROGRAM_INFO).getString(FSRL_OPTION_NAME, null);
if (fsrlStr != null) {
try {
return FSRL.fromString(fsrlStr);
Expand All @@ -86,6 +85,16 @@ public static FSRL fromProgram(Program program) {
return null;
}

/**
* Writes a FSRL value to a {@link Program}'s properties.
*
* @param program {@link Program}
* @param fsrl {@link FSRL} to write
*/
public static void writeToProgramInfo(Program program, FSRL fsrl) {
program.getOptions(Program.PROGRAM_INFO).setString(FSRL_OPTION_NAME, fsrl.toString());
}

/**
* Creates a {@link FSRL} from a raw string. The parent portions of the FSRL
* are not intern()'d so will not be shared with other FSRL instances.
Expand Down
Loading

0 comments on commit a8ac78e

Please sign in to comment.