Merge remote-tracking branch 'origin/Ghidra_9.2'

This commit is contained in:
ghidra1 2020-11-03 16:52:37 -05:00
commit 27fb507b18
80 changed files with 6710 additions and 1773 deletions

View file

@ -124,6 +124,9 @@ public interface DataType {
* Sets the name of the dataType
* @param name the new name for this dataType.
* @throws InvalidNameException if the given name does not form a valid name.
* @throws DuplicateNameException if name change on stored {@link DataType}
* is a duplicate of another datatype within the same category (only applies to
* DB stored {@link DataType}).
*/
public void setName(String name) throws InvalidNameException, DuplicateNameException;
@ -132,7 +135,9 @@ public interface DataType {
* @param path the new category path.
* @param name the new name
* @throws InvalidNameException if the name is invalid
* @throws DuplicateNameException if a dataType already exists with that name and
* @throws DuplicateNameException if name change on stored {@link DataType}
* is a duplicate of another datatype within the same category (only applies to
* DB stored {@link DataType}).
*/
public void setNameAndCategory(CategoryPath path, String name)
throws InvalidNameException, DuplicateNameException;

View file

@ -37,7 +37,7 @@ public final class DataUtilities {
* @return true if name is valid, else false
*/
public static boolean isValidDataTypeName(String name) {
if (name == null) {
if (name == null || name.length() == 0) {
return false;
}

View file

@ -34,11 +34,13 @@ public abstract class FactoryStructureDataType extends BuiltIn implements Factor
super(null, name, dtm);
}
@Override
public abstract DataType clone(DataTypeManager dtm);
/**
* @see ghidra.program.model.data.DataType#getLength()
*/
@Override
public int getLength() {
return -1;
}
@ -46,6 +48,7 @@ public abstract class FactoryStructureDataType extends BuiltIn implements Factor
/**
* @see ghidra.program.model.data.DataType#getValue(ghidra.program.model.mem.MemBuffer, ghidra.docking.settings.Settings, int)
*/
@Override
public Object getValue(MemBuffer buf, Settings settings, int length) {
return null;
}
@ -53,6 +56,7 @@ public abstract class FactoryStructureDataType extends BuiltIn implements Factor
/**
* @see ghidra.program.model.data.DataType#getRepresentation(ghidra.program.model.mem.MemBuffer, ghidra.docking.settings.Settings, int)
*/
@Override
public String getRepresentation(MemBuffer buf, Settings settings, int length) {
return null;
}
@ -60,10 +64,12 @@ public abstract class FactoryStructureDataType extends BuiltIn implements Factor
/**
* @see ghidra.program.model.data.DataType#getDescription()
*/
@Override
public String getDescription() {
return "Dynamic Data Type should not be instantiated directly";
}
@Override
public DataType getDataType(MemBuffer buf) {
Structure struct = new StructureDataType(getName(), 0);
if (buf != null) {
@ -80,7 +86,7 @@ public abstract class FactoryStructureDataType extends BuiltIn implements Factor
* @param buf
* @return Returns a new structure with the correct category.
*/
private Structure setCategoryPath(Structure struct, MemBuffer buf) {
protected Structure setCategoryPath(Structure struct, MemBuffer buf) {
CategoryPath path = CategoryPath.ROOT;
try {
path =
@ -94,8 +100,9 @@ public abstract class FactoryStructureDataType extends BuiltIn implements Factor
}
private void setCategory(DataType dt, CategoryPath path) {
if (dt == null)
if (dt == null) {
return;
}
try {
dt.setCategoryPath(path);
@ -105,15 +112,15 @@ public abstract class FactoryStructureDataType extends BuiltIn implements Factor
if (dt instanceof Structure) {
Structure struct = (Structure) dt;
DataTypeComponent[] comps = struct.getDefinedComponents();
for (int i = 0; i < comps.length; i++) {
setCategory(comps[i].getDataType(), path);
for (DataTypeComponent comp : comps) {
setCategory(comp.getDataType(), path);
}
}
else if (dt instanceof Union) {
Union union = (Union) dt;
DataTypeComponent[] comps = union.getComponents();
for (int i = 0; i < comps.length; i++) {
setCategory(comps[i].getDataType(), path);
for (DataTypeComponent comp : comps) {
setCategory(comp.getDataType(), path);
}
}
else if (dt instanceof TypeDef) {