ApplyTypes: classes with __thiscall methods keep a typed this even with no confirmed field
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a71fed58c9
commit
3f88849636
1 file changed
+8
-1
@@ -64,12 +64,19 @@ public class ApplyTypes extends GhidraScript {
|
||||
Namespace global = currentProgram.getGlobalNamespace();
|
||||
Set<String> classes = new TreeSet<>(fields.keySet());
|
||||
classes.addAll(base.keySet());
|
||||
// classes with ZHL __thiscall methods get a struct even with no confirmed field, so `this` is still typed
|
||||
Set<String> methodClasses = new HashSet<>();
|
||||
for (Function f : currentProgram.getListing().getFunctions(true)) {
|
||||
String cm = f.getComment();
|
||||
if (cm != null && cm.contains("__thiscall") && !f.getParentNamespace().isGlobal()) methodClasses.add(f.getParentNamespace().getName());
|
||||
}
|
||||
classes.addAll(methodClasses);
|
||||
int typed = 0;
|
||||
for (int pass = 0; pass < 3; pass++) // later passes embed structs (Entity._sprite is an ANM2) built by earlier ones
|
||||
for (String cls : classes) {
|
||||
StructureDataType s = new StructureDataType(cls, 4);
|
||||
addFields(s, cls, 0);
|
||||
if (s.getLength() < 0x20) continue; // skip trivial structs
|
||||
if (s.getLength() < 0x20 && !methodClasses.contains(cls)) continue; // skip trivial structs
|
||||
DataType dt = dtm.addDataType(s, DataTypeConflictHandler.REPLACE_HANDLER);
|
||||
Namespace ns = st.getNamespace(cls, global);
|
||||
if (ns == null) ns = st.createClass(global, cls, SourceType.USER_DEFINED);
|
||||
|
||||
Reference in new issue
Block a user