Merge remote-tracking branch 'origin/GP-3208_ghidra1_RelaxDyanmicDataMemoryRestriction'

This commit is contained in:
Ryan Kurtz
2023-05-15 08:37:54 -04:00
3 changed files with 10 additions and 16 deletions

View File

@@ -384,6 +384,13 @@ public class DataPlugin extends Plugin implements DataService {
return true;
}
if (newSize <= 0) {
tool.setStatusInfo(
"Invalid data location. Unable to resolve data length at " + start + " for " +
dataType.getName());
return false;
}
Address end = null;
try {
end = start.addNoWrap(newSize - 1);
@@ -491,15 +498,6 @@ public class DataPlugin extends Plugin implements DataService {
return newSize;
}
if (dataType instanceof Dynamic || dataType instanceof FactoryDataType) {
MemoryBlock block = program.getMemory().getBlock(start);
if (block == null || !block.isInitialized()) {
tool.setStatusInfo(
dataType.getName() + " may only be applied on initialized memory");
return -1;
}
}
DataTypeInstance dataTypeInstance = DataTypeInstance.getDataTypeInstance(dataType,
new DumbMemBufferImpl(program.getMemory(), start), false);
if (dataTypeInstance == null) {

View File

@@ -1952,13 +1952,6 @@ public class CodeManager implements ErrorHandler, ManagerDB {
length = dataType.getLength();
}
else if (dataType instanceof Dynamic) {
if (length <= 0 || !((Dynamic) dataType).canSpecifyLength()) {
MemoryBlock block = program.getMemory().getBlock(addr);
if (block == null || !block.isInitialized()) {
throw new CodeUnitInsertionException(originalDataType.getName() +
" may only be applied on initialized memory (" + addr + ")");
}
}
Dynamic dynamicDataType = (Dynamic) dataType;
MemBuffer memBuffer = new MemoryBufferImpl(program.getMemory(), addr);
length = dynamicDataType.getLength(memBuffer, length);

View File

@@ -346,6 +346,9 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
block.getName() + " does not contain address " + start.toString(true));
}
// TODO: We should not really permit changing Data where Dynamic datatype resides
// since it could impact its computed length.
try {
Address endAddr = start.addNoWrap(length - 1);
if (!block.contains(start)) {