mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
Merge remote-tracking branch
'origin/GP-5174_dev747368_pdb_altfilenames--SQUASHED' (Closes #7200)
This commit is contained in:
commit
03eae7abbd
3 changed files with 38 additions and 7 deletions
|
@ -126,7 +126,10 @@
|
||||||
See <A href="#OneLevel_SymbolDirectory">level 1</A>/<A href="#TwoLevel_SymbolDirectory">level 2</A> or
|
See <A href="#OneLevel_SymbolDirectory">level 1</A>/<A href="#TwoLevel_SymbolDirectory">level 2</A> or
|
||||||
<A href="#Unorganized_SymbolDirectory">unorganized</A> directory descriptions.</LI>
|
<A href="#Unorganized_SymbolDirectory">unorganized</A> directory descriptions.</LI>
|
||||||
<LI><B>URL</B> - allows the user to enter a HTTP or HTTPS URL to a web-based symbol server.</LI>
|
<LI><B>URL</B> - allows the user to enter a HTTP or HTTPS URL to a web-based symbol server.</LI>
|
||||||
<LI><B>Program's Import Location</B> - automatically references the directory from which the program was imported.</LI>
|
<LI><B>Program's Import Location</B> - automatically references the directory from
|
||||||
|
which the program was imported. This option first searches for the 'official'
|
||||||
|
PDB filename embedded in the program's metadata. If not found, it searches
|
||||||
|
for other PDB files that match variations of the program's filename.</LI>
|
||||||
<LI><B>Import _NT_SYMBOL_PATH</B> - parses the current value of the <code>_NT_SYMBOL_PATH</code> system environment variable to extract
|
<LI><B>Import _NT_SYMBOL_PATH</B> - parses the current value of the <code>_NT_SYMBOL_PATH</code> system environment variable to extract
|
||||||
URLs and symbol directory locations to be added to the Ghidra configuration. If no environment value is present,
|
URLs and symbol directory locations to be added to the Ghidra configuration. If no environment value is present,
|
||||||
the user can paste their own value into the text field.</LI>
|
the user can paste their own value into the text field.</LI>
|
||||||
|
|
|
@ -34,6 +34,7 @@ import ghidra.app.plugin.PluginCategoryNames;
|
||||||
import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
|
import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
|
||||||
import ghidra.app.plugin.core.analysis.PdbAnalyzerCommon;
|
import ghidra.app.plugin.core.analysis.PdbAnalyzerCommon;
|
||||||
import ghidra.app.services.DataTypeManagerService;
|
import ghidra.app.services.DataTypeManagerService;
|
||||||
|
import ghidra.formats.gfilesystem.FSRL;
|
||||||
import ghidra.framework.plugintool.*;
|
import ghidra.framework.plugintool.*;
|
||||||
import ghidra.framework.plugintool.util.PluginStatus;
|
import ghidra.framework.plugintool.util.PluginStatus;
|
||||||
import ghidra.framework.preferences.Preferences;
|
import ghidra.framework.preferences.Preferences;
|
||||||
|
@ -282,9 +283,11 @@ public class PdbPlugin extends Plugin {
|
||||||
symbolServerInstanceCreatorContext.getSymbolServerInstanceCreatorRegistry()
|
symbolServerInstanceCreatorContext.getSymbolServerInstanceCreatorRegistry()
|
||||||
.newSymbolServer(Preferences.getProperty(SYMBOL_STORAGE_DIR_OPTION, "", true),
|
.newSymbolServer(Preferences.getProperty(SYMBOL_STORAGE_DIR_OPTION, "", true),
|
||||||
symbolServerInstanceCreatorContext);
|
symbolServerInstanceCreatorContext);
|
||||||
SymbolStore symbolStore =
|
FSRL programFSRL = symbolServerInstanceCreatorContext.getProgramFSRL();
|
||||||
(temporarySymbolServer instanceof SymbolStore) ? (SymbolStore) temporarySymbolServer
|
SymbolStore symbolStore = (temporarySymbolServer instanceof SymbolStore tmpSymbolStore)
|
||||||
: new SameDirSymbolStore(symbolServerInstanceCreatorContext.getRootDir());
|
? tmpSymbolStore
|
||||||
|
: new SameDirSymbolStore(symbolServerInstanceCreatorContext.getRootDir(),
|
||||||
|
programFSRL != null ? programFSRL.getName() : null);
|
||||||
List<SymbolServer> symbolServers =
|
List<SymbolServer> symbolServers =
|
||||||
symbolServerInstanceCreatorContext.getSymbolServerInstanceCreatorRegistry()
|
symbolServerInstanceCreatorContext.getSymbolServerInstanceCreatorRegistry()
|
||||||
.createSymbolServersFromPathList(getSymbolSearchPaths(),
|
.createSymbolServersFromPathList(getSymbolSearchPaths(),
|
||||||
|
|
|
@ -18,6 +18,8 @@ package pdb.symbolserver;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
import ghidra.formats.gfilesystem.FSRL;
|
import ghidra.formats.gfilesystem.FSRL;
|
||||||
import ghidra.util.task.TaskMonitor;
|
import ghidra.util.task.TaskMonitor;
|
||||||
import pdb.symbolserver.SymbolServer.StatusRequiresContext;
|
import pdb.symbolserver.SymbolServer.StatusRequiresContext;
|
||||||
|
@ -77,10 +79,12 @@ public class SameDirSymbolStore implements SymbolStore, StatusRequiresContext {
|
||||||
if (programFSRL != null && programFSRL.getNestingDepth() != 1) {
|
if (programFSRL != null && programFSRL.getNestingDepth() != 1) {
|
||||||
return new ContainerFileSymbolServer(programFSRL);
|
return new ContainerFileSymbolServer(programFSRL);
|
||||||
}
|
}
|
||||||
return new SameDirSymbolStore(context.getRootDir());
|
String programFilename = programFSRL != null ? programFSRL.getName() : null;
|
||||||
|
return new SameDirSymbolStore(context.getRootDir(), programFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final File rootDir;
|
private final File rootDir;
|
||||||
|
private final String programFilename;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance, based on the directory where the program was originally imported from.
|
* Create a new instance, based on the directory where the program was originally imported from.
|
||||||
|
@ -90,6 +94,12 @@ public class SameDirSymbolStore implements SymbolStore, StatusRequiresContext {
|
||||||
*/
|
*/
|
||||||
public SameDirSymbolStore(File rootDir) {
|
public SameDirSymbolStore(File rootDir) {
|
||||||
this.rootDir = rootDir;
|
this.rootDir = rootDir;
|
||||||
|
this.programFilename = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SameDirSymbolStore(File rootDir, String programFilename) {
|
||||||
|
this.rootDir = rootDir;
|
||||||
|
this.programFilename = programFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -147,6 +157,21 @@ public class SameDirSymbolStore implements SymbolStore, StatusRequiresContext {
|
||||||
|
|
||||||
if (isValid()) {
|
if (isValid()) {
|
||||||
LocalSymbolStore.searchLevel0(rootDir, this, fileInfo, findOptions, results, monitor);
|
LocalSymbolStore.searchLevel0(rootDir, this, fileInfo, findOptions, results, monitor);
|
||||||
|
if (results.isEmpty() && programFilename != null) {
|
||||||
|
// Search for renamed versions of the pdb file, using the current program's
|
||||||
|
// name. Note: if this shouldn't be automatic, add FindOption enum to control this
|
||||||
|
List<String> altPdbfilenames = List.of(programFilename + ".pdb",
|
||||||
|
FilenameUtils.getBaseName(programFilename) + ".pdb");
|
||||||
|
for (String altPdbfilename : altPdbfilenames) {
|
||||||
|
SymbolFileInfo altFileInfo = SymbolFileInfo.fromPdbIdentifiers(altPdbfilename,
|
||||||
|
fileInfo.getIdentifiers());
|
||||||
|
LocalSymbolStore.searchLevel0(rootDir, this, altFileInfo, findOptions, results,
|
||||||
|
monitor);
|
||||||
|
if (!results.isEmpty()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue