this_types: also place unnamed FUN_ functions in a class when their ECX offsets match one class's field starts unambiguously

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-25 16:30:21 -04:00
1 parent 0b7ee2703d
commit 1d43433e1b
2 files changed
+24 -1

No files matched your search

+7 -1
View File
@@ -111,8 +111,14 @@ public class ApplyTypes extends GhidraScript {
// methods whose ECX offsets fit their class (scripts/this_types.py) become __thiscall, typing `this`
int fitted = 0;
if (getScriptArgs().length > 1) for (String l : Files.readAllLines(Paths.get(getScriptArgs()[1]))) {
Function f = getFunctionAt(toAddr(l.split("\t")[0]));
String[] c = l.split("\t");
Function f = getFunctionAt(toAddr(c[0]));
if (f == null || "__thiscall".equals(f.getCallingConventionName())) continue;
if (f.getName().startsWith("FUN_")) { // unnamed, placed by its ECX offsets: move it into the class
Namespace cn = st.getNamespace(c[1], global);
if (cn == null) continue;
try { f.setParentNamespace(cn); } catch (Exception e) { continue; }
}
Namespace ns = f.getParentNamespace();
if (!(ns instanceof GhidraClass)) try { st.convertNamespaceToClass(ns); } catch (Exception e) { continue; }
f.setCallingConvention("__thiscall");