Ghidra is a software reverse engineering (SRE) framework
GP-4708 updated createStructure to fix logic error.
ghidra00702aba11104bf
diff --git a/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RecoveredClass.java b/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RecoveredClass.javaindex c9ddafe0b6..2e02d61544 100644--- a/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RecoveredClass.java+++ b/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RecoveredClass.java@@ -498,16 +498,6 @@ public class RecoveredClass {String fieldName = newComponent.getFieldName();String comment = newComponent.getComment();- // if it is any empty placeholder structure - replace with- // undefined1 dt- if (newComponentDataType instanceof Structure &&- newComponentDataType.isNotYetDefined()) {-- computedClassStructure.replaceAtOffset(offset, new Undefined1DataType(), 1,- fieldName, comment);- continue;- }-// if new component is an existing class data type pointer then replace current item// with a void pointer of same size if there is roomif (newComponentDataType instanceof Pointer &&@@ -529,9 +519,19 @@ public class RecoveredClass {// if the new component is a non-empty structure, check to see if the current// structure has undefined or equivalent components and replace with new struct if soif (newComponentDataType instanceof Structure) {++ // if new component is any empty placeholder structure AND if the existing component+ // is undefined then replace with undefined1 dt+ if (newComponentDataType.isNotYetDefined()) {+ if (Undefined.isUndefined(currentComponentDataType)) {+ computedClassStructure.replaceAtOffset(offset, new Undefined1DataType(), 1,+ fieldName, comment);+ }+ continue;+ }if (EditStructureUtils.hasReplaceableComponentsAtOffset(computedClassStructure,- offset, (Structure) newComponentDataType, monitor)) {-+ offset, (Structure)newComponentDataType, monitor)) {+boolean successfulClear =EditStructureUtils.clearLengthAtOffset(computedClassStructure, offset,length, monitor);