mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
GP-5682 - VxWorksSymTab script headless fix
This commit is contained in:
parent
bcb2d2934e
commit
667e439550
1 changed files with 5 additions and 28 deletions
|
@ -47,7 +47,6 @@ import ghidra.app.cmd.disassemble.DisassembleCommand;
|
||||||
import ghidra.app.cmd.label.DemanglerCmd;
|
import ghidra.app.cmd.label.DemanglerCmd;
|
||||||
import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
|
import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
|
||||||
import ghidra.app.script.GhidraScript;
|
import ghidra.app.script.GhidraScript;
|
||||||
import ghidra.app.services.DataTypeManagerService;
|
|
||||||
import ghidra.app.util.demangler.DemangledException;
|
import ghidra.app.util.demangler.DemangledException;
|
||||||
import ghidra.app.util.demangler.MangledContext;
|
import ghidra.app.util.demangler.MangledContext;
|
||||||
import ghidra.app.util.demangler.gnu.GnuDemangler;
|
import ghidra.app.util.demangler.gnu.GnuDemangler;
|
||||||
|
@ -64,28 +63,6 @@ public class VxWorksSymTab_Finder extends GhidraScript {
|
||||||
|
|
||||||
boolean debug = false;
|
boolean debug = false;
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
// getDataTypeManagerByName
|
|
||||||
//
|
|
||||||
// Retrieves data type manager by name.
|
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
// Success: DataTypeManager
|
|
||||||
// Failure: null
|
|
||||||
//------------------------------------------------------------------------
|
|
||||||
private DataTypeManager getDataTypeManagerByName(String name) {
|
|
||||||
|
|
||||||
DataTypeManagerService service = state.getTool().getService(DataTypeManagerService.class);
|
|
||||||
|
|
||||||
// Loop through all managers in the data type manager service
|
|
||||||
for (DataTypeManager manager : service.getDataTypeManagers()) {
|
|
||||||
if (manager.getName().equals(name)) {
|
|
||||||
return manager;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
// VxSymbol
|
// VxSymbol
|
||||||
//
|
//
|
||||||
|
@ -159,7 +136,7 @@ public class VxWorksSymTab_Finder extends GhidraScript {
|
||||||
private VxSymbol getVxSymbolClass(int type) {
|
private VxSymbol getVxSymbolClass(int type) {
|
||||||
|
|
||||||
// Pre-define base data types used to define symbol table entry data type
|
// Pre-define base data types used to define symbol table entry data type
|
||||||
DataTypeManager builtin = getDataTypeManagerByName("BuiltInTypes");
|
BuiltInDataTypeManager builtin = BuiltInDataTypeManager.getDataTypeManager();
|
||||||
DataType charType = builtin.getDataType("/char");
|
DataType charType = builtin.getDataType("/char");
|
||||||
DataType charPtrType = PointerDataType.getPointer(charType, 4);
|
DataType charPtrType = PointerDataType.getPointer(charType, 4);
|
||||||
DataType byteType = builtin.getDataType("/byte");
|
DataType byteType = builtin.getDataType("/byte");
|
||||||
|
@ -415,12 +392,12 @@ public class VxWorksSymTab_Finder extends GhidraScript {
|
||||||
// Test is weak.
|
// Test is weak.
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
private boolean isSymTblEntry(Address entry, VxSymbol vxSymbol) throws Exception {
|
private boolean isSymTblEntry(Address entry, VxSymbol vxSymbol) throws Exception {
|
||||||
|
|
||||||
// Make sure there's data for the symbol
|
// Make sure there's data for the symbol
|
||||||
if ( !isAddress(entry.getOffset() + vxSymbol.length() - 1) ) {
|
if (!isAddress(entry.getOffset() + vxSymbol.length() - 1)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// First dword must be null or a valid ptr (typically into the sym table)
|
// First dword must be null or a valid ptr (typically into the sym table)
|
||||||
long value = getInt(entry) & 0xffffffffL;
|
long value = getInt(entry) & 0xffffffffL;
|
||||||
if ((value != 0) && !isAddress(value)) {
|
if ((value != 0) && !isAddress(value)) {
|
||||||
|
@ -837,7 +814,7 @@ public class VxWorksSymTab_Finder extends GhidraScript {
|
||||||
|
|
||||||
case 4: // Local .text
|
case 4: // Local .text
|
||||||
case 5: // Global .text
|
case 5: // Global .text
|
||||||
|
|
||||||
doLocalDisassemble(symLoc);
|
doLocalDisassemble(symLoc);
|
||||||
createFunction(symLoc, symName);
|
createFunction(symLoc, symName);
|
||||||
if (getFunctionAt(symLoc) != null) {
|
if (getFunctionAt(symLoc) != null) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue