Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-111_emteere_RTTI3_CreationFix minor doc changes

emteere107a8d09a0d6
diff --git a/Ghidra/Features/MicrosoftCodeAnalyzer/src/main/java/ghidra/app/cmd/data/AbstractCreateDataBackgroundCmd.java b/Ghidra/Features/MicrosoftCodeAnalyzer/src/main/java/ghidra/app/cmd/data/AbstractCreateDataBackgroundCmd.java
index 02b3147e43..51fcdd5ae2 100644
--- a/Ghidra/Features/MicrosoftCodeAnalyzer/src/main/java/ghidra/app/cmd/data/AbstractCreateDataBackgroundCmd.java
+++ b/Ghidra/Features/MicrosoftCodeAnalyzer/src/main/java/ghidra/app/cmd/data/AbstractCreateDataBackgroundCmd.java
@@ -167,7 +167,7 @@ public abstract class AbstractCreateDataBackgroundCmd<T extends AbstractCreateDa
return false;
}
- boolean didCreate = createData();
+ boolean dataWasCreated = createData();
boolean success = true;
@@ -182,9 +182,10 @@ public abstract class AbstractCreateDataBackgroundCmd<T extends AbstractCreateDa
success = false;
}
- // If following data when applying, create any data referred to by the data just created.
- if (didCreate && applyOptions.shouldFollowData() && !createAssociatedData()) {
- success = false;
+ // If data type didn't exist (was created) and following data when applying,
+ if (dataWasCreated && applyOptions.shouldFollowData()) {
+ // create any data referred to by the data just created
+ success = createAssociatedData();
}
setStatusMsg(getName() + " completed successfully!");
return success;
@@ -200,7 +201,7 @@ public abstract class AbstractCreateDataBackgroundCmd<T extends AbstractCreateDa
* Creates data at this command's address using the data type obtained from the model.
* <br>If you need to create data other than by using the data type returned from getDataType(),
* you should override this method.
- * @return true if had to create, false otherwise
+ * @return false if the data type was not created because it already exists, true otherwise
* @throws CodeUnitInsertionException if the data can't be created.
* @throws CancelledException if the user cancels this task.
*/
diff --git a/Ghidra/Features/MicrosoftCodeAnalyzer/src/main/java/ghidra/app/cmd/data/CreateTypeDescriptorBackgroundCmd.java b/Ghidra/Features/MicrosoftCodeAnalyzer/src/main/java/ghidra/app/cmd/data/CreateTypeDescriptorBackgroundCmd.java
index 55ad6b8b16..89eb5b74a1 100644
--- a/Ghidra/Features/MicrosoftCodeAnalyzer/src/main/java/ghidra/app/cmd/data/CreateTypeDescriptorBackgroundCmd.java
+++ b/Ghidra/Features/MicrosoftCodeAnalyzer/src/main/java/ghidra/app/cmd/data/CreateTypeDescriptorBackgroundCmd.java
@@ -21,7 +21,6 @@ import ghidra.program.model.address.Address;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.*;
import ghidra.program.model.util.CodeUnitInsertionException;
-import ghidra.util.Msg;
import ghidra.util.exception.CancelledException;
import ghidra.util.exception.InvalidInputException;
@@ -90,13 +89,15 @@ public class CreateTypeDescriptorBackgroundCmd
* as its last component ( char[0] name ). The string data associated with this flexible char array will
* be applied as a sized character array immediately following the structure whose size does not include
* the char array bytes.
- * @return true if the data type needed to be created
+ * @return false if the data type was not created because it already exists, true otherwise
* @throws CodeUnitInsertionException
* @throws CancelledException
*/
@Override
protected boolean createData() throws CodeUnitInsertionException, CancelledException {
- super.createData(); // create the TypeDesciptor structure
+ if (!super.createData()) { // create the TypeDesciptor structure
+ return false;
+ }
// Determine the size of the flexible char array storage and create properly sized array
DataType dataType = model.getDataType();
@@ -110,12 +111,7 @@ public class CreateTypeDescriptorBackgroundCmd
Data nameData = DataUtilities.createData(program, arrayAddr, charArray,
charArray.getLength(), false, getClearDataMode());
- if (nameData != null) {
- nameData.setComment(CodeUnit.EOL_COMMENT, "TypeDescriptor.name");
- }
- else {
- Msg.error(this, "Failed to create TypeDescriptor name at " + arrayAddr);
- }
+ nameData.setComment(CodeUnit.EOL_COMMENT, "TypeDescriptor.name");
return true;
}