From 02aba11104bf9a54c75e80ce678bb0690024ee12 Mon Sep 17 00:00:00 2001 From: ghidra007 Date: Mon, 24 Jun 2024 22:57:15 +0000 Subject: [PATCH] GP-4708 updated createStructure to fix logic error. --- .../classrecovery/RecoveredClass.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RecoveredClass.java b/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RecoveredClass.java index 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 room if (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 so if (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);