Replies: 10 comments 13 replies
-
@Wall-AF It is possible that the script is incorrectly applying the _thiscall prototype in the case where you are seeing it on the stack. Can you check to see what was there on freshly analyzed binary and verify that you are seeing the same behavior? Is this the same binary as in the ticket where you made changes to the program before the script ran? |
Beta Was this translation helpful? Give feedback.
-
@Wall-AF I think you might have put the same image twice. I am not noticing differences between them. Both show using ECX as the this. |
Beta Was this translation helpful? Give feedback.
-
@Wall-AF right but both have the this as ECX. So can be the standard thiscall. |
Beta Was this translation helpful? Give feedback.
-
@Wall-AF You can look here: ghidra_\Ghidra\Processors\x86\data\languages and you will see various .cspec files. Depending on your specific use case you should be able to identify which one using the name, for example, there is a x86-64-win.cspec for 64-bit Windows. |
Beta Was this translation helpful? Give feedback.
-
@ghidra007 Aha, it's Microsoft! Some member functions are forced to use |
Beta Was this translation helpful? Give feedback.
-
@Wall-AF For the first thing I'll take a look to see how feasible it would be to figure out this use case. It's possible the script is making bad assumptions here and changing the function signature. Have you looked at the function signature for the stdcall function before the script is run? Does the script change it or does something already assume it is thiscall before the script runs? For the second, if I am understanding what you are asking for, if it wasn't c++ you could use the C parser to parse header files for the specific versions you are interested in and import the resulting function definitions into a new archive in the data type manager. You could then disable the analyzer that is taking function definition information from the existing parsed header files when you run initial analysis. Then you could run the apply function definitions action in the data type manager which will update the function signatures for functions with matching names as those definitions. This would get the function defintions from that specific version instead of the versions we include. |
Beta Was this translation helpful? Give feedback.
-
@Wall-AF All of that is beyond the scope of the RTTI script. |
Beta Was this translation helpful? Give feedback.
-
It seems that lots of these vtable entries use a macro |
Beta Was this translation helpful? Give feedback.
-
@Wall-AF It looks like the script is making them all thiscalls when processing them. I will add an update to not do this but it will probably not make the next version. To see if this helps you, you can Edit (via file system not the script manager since you can't edit Ghidra built in scripts and save back to the same file) the RecoverClassHelper.java file that is in the <ghidra_install>/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery folder. Go to line 4774 which should be makeFunctionThiscall(vfunction); and just put // in front of it to comment it out. Then save it and refresh the scripts in the script manager in Ghidra. Then run the script and see if you get better results for your vftable entries. |
Beta Was this translation helpful? Give feedback.
-
@Wall-AF I don't think the best solution would be to change to not make them thiscalls because not doing so makes it worse the other way for those that are supposed to be thiscalls. Since you found a solution for your issue I will go ahead and close this ticket. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a 32-bit Windows PE DLL that has classes (recoverable by running
RecoverClassesFromRTTIScript
) where some calls place thethis
on the stack whilst others use a register (ECX
). Is there some way to modify the__thiscall
prototype to enable that pattern?Adding an alternate prototype wouldn't help initially as the
RecoverClassesFromRTTIScript
will only use__thiscall
!Beta Was this translation helpful? Give feedback.
All reactions