mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
GP-5321: Fixing PE debug coff symbol NPE
This commit is contained in:
parent
a6809a3529
commit
5452e14db4
2 changed files with 25 additions and 27 deletions
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -16,6 +16,8 @@
|
||||||
package ghidra.app.util.bin.format.pe.debug;
|
package ghidra.app.util.bin.format.pe.debug;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import ghidra.app.util.bin.BinaryReader;
|
import ghidra.app.util.bin.BinaryReader;
|
||||||
import ghidra.app.util.bin.format.pe.NTHeader;
|
import ghidra.app.util.bin.format.pe.NTHeader;
|
||||||
|
@ -24,37 +26,34 @@ import ghidra.app.util.bin.format.pe.NTHeader;
|
||||||
* A class to represent the COFF Symbol Table.
|
* A class to represent the COFF Symbol Table.
|
||||||
*/
|
*/
|
||||||
public class DebugCOFFSymbolTable {
|
public class DebugCOFFSymbolTable {
|
||||||
private int ptrToSymbolTable;
|
private int ptrToSymbolTable;
|
||||||
private int symbolCount;
|
private int symbolCount;
|
||||||
|
|
||||||
private DebugCOFFSymbol [] symbols;
|
private List<DebugCOFFSymbol> symbols = new ArrayList<>();
|
||||||
|
|
||||||
public DebugCOFFSymbolTable(BinaryReader reader, DebugCOFFSymbolsHeader coffHeader, int offset)
|
public DebugCOFFSymbolTable(BinaryReader reader, DebugCOFFSymbolsHeader coffHeader, int offset)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
this.ptrToSymbolTable = coffHeader.getFirstSymbolLVA() + offset;
|
this.ptrToSymbolTable = coffHeader.getFirstSymbolLVA() + offset;
|
||||||
this.symbolCount = coffHeader.getNumberOfSymbols();
|
this.symbolCount = coffHeader.getNumberOfSymbols();
|
||||||
|
|
||||||
//TODO:
|
//TODO: should symbol table info in NT Header agree with info in COFF Header?
|
||||||
//should symbol table info in NT Header agree with info in COFF Header?
|
|
||||||
|
|
||||||
if (symbolCount > 0 && symbolCount < NTHeader.MAX_SANE_COUNT) {
|
if (symbolCount < NTHeader.MAX_SANE_COUNT) {
|
||||||
symbols = new DebugCOFFSymbol[symbolCount];
|
for (int i = 0; i < symbolCount; ++i) {
|
||||||
for (int i = 0 ; i < symbolCount ; ++i) {
|
symbols.add(new DebugCOFFSymbol(reader,
|
||||||
symbols[i] = new DebugCOFFSymbol(reader,
|
ptrToSymbolTable + (i * DebugCOFFSymbol.IMAGE_SIZEOF_SYMBOL), this));
|
||||||
ptrToSymbolTable + (i * DebugCOFFSymbol.IMAGE_SIZEOF_SYMBOL), this);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int getStringTableIndex() {
|
int getStringTableIndex() {
|
||||||
return ptrToSymbolTable + (symbolCount * DebugCOFFSymbol.IMAGE_SIZEOF_SYMBOL);
|
return ptrToSymbolTable + (symbolCount * DebugCOFFSymbol.IMAGE_SIZEOF_SYMBOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the COFF symbols defined in this COFF symbol table.
|
* {@return the COFF symbols defined in this COFF symbol table}
|
||||||
* @return the COFF symbols defined in this COFF symbol table
|
|
||||||
*/
|
*/
|
||||||
public DebugCOFFSymbol [] getSymbols() {
|
public List<DebugCOFFSymbol> getSymbols() {
|
||||||
return symbols;
|
return symbols;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -345,9 +345,8 @@ abstract class AbstractPeDebugLoader extends AbstractOrdinalSupportLoader {
|
||||||
if (dcst == null) {
|
if (dcst == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DebugCOFFSymbol[] symbols = dcst.getSymbols();
|
|
||||||
int errorCount = 0;
|
int errorCount = 0;
|
||||||
for (DebugCOFFSymbol symbol : symbols) {
|
for (DebugCOFFSymbol symbol : dcst.getSymbols()) {
|
||||||
if (monitor.isCancelled()) {
|
if (monitor.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue