ApplyTypes: FamiliarAI routines typed __fastcall(Entity_Familiar *familiar) like NpcAI (ECX reads all fit)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cbb2f465ec
commit
5dbb3e398d
1 file changed
+10
-7
+10
-7
@@ -118,18 +118,21 @@ public class ApplyTypes extends GhidraScript {
|
||||
f.setCallingConvention("__thiscall");
|
||||
fitted++;
|
||||
}
|
||||
// NpcAI routines are __fastcall(npc in ECX)
|
||||
DataType npcPtr = new PointerDataType(dtm.getDataType(new CategoryPath("/"), "Entity_NPC"));
|
||||
Namespace ai = st.getNamespace("NpcAI", global);
|
||||
// per-type AI routines take the entity in ECX: NpcAI (dispatcher) and FamiliarAI (Entity_Familiar::Update cases,
|
||||
// their ECX reads all land in Entity_Familiar fields); FamiliarAI ones with stack arguments are left alone
|
||||
int ain = 0;
|
||||
if (ai != null) for (Symbol sym : st.getSymbols(ai)) {
|
||||
for (String[] ai : new String[][] {{"NpcAI", "Entity_NPC", "npc"}, {"FamiliarAI", "Entity_Familiar", "familiar"}}) {
|
||||
DataType npcPtr = new PointerDataType(dtm.getDataType(new CategoryPath("/"), ai[1]));
|
||||
Namespace aiNs = st.getNamespace(ai[0], global);
|
||||
if (aiNs != null) for (Symbol sym : st.getSymbols(aiNs)) {
|
||||
Function f = getFunctionAt(sym.getAddress());
|
||||
if (f == null) continue;
|
||||
if (f == null || (ai[0].equals("FamiliarAI") && f.getStackPurgeSize() != 0)) continue;
|
||||
f.setCallingConvention("__fastcall");
|
||||
f.replaceParameters(Function.FunctionUpdateType.DYNAMIC_STORAGE_FORMAL_PARAMS, true, SourceType.USER_DEFINED,
|
||||
new ParameterImpl("npc", npcPtr, currentProgram));
|
||||
new ParameterImpl(ai[2], npcPtr, currentProgram));
|
||||
ain++;
|
||||
}
|
||||
println("ApplyTypes: " + classes.size() + " structs, " + typed + " thiscall methods, " + fitted + " fitted by ECX use, " + ain + " NpcAI params");
|
||||
}
|
||||
println("ApplyTypes: " + classes.size() + " structs, " + typed + " thiscall methods, " + fitted + " fitted by ECX use, " + ain + " NpcAI/FamiliarAI params");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user