Replies: 25 comments 148 replies
-
Thanks for opening the discussion. I don't know the answers to all your questions. I assume you mean the data relocation issue when referencing into the EXTERNAL block? There was a change made to help with this issue in 10.0 although it isn't a complete fix yet. Thanks for the heads up about the other issues with the RTTI analyzer. I'll add those issues to the list. Both issues you mentioned are known big issues that many would like to see solved. If you can point us to sample programs that have the above issues you mentioned, we can use them to triage and test when we get to those issues. Thanks. |
Beta Was this translation helpful? Give feedback.
-
I just ran the recover classes script on my inheritance tests built with visual studio. I noticed that it has put the InheritanceTests.zip Also there is an undocumented, at least I never found it documented, bit in the |
Beta Was this translation helpful? Give feedback.
-
fysa there are multiple IP and license headers in the |
Beta Was this translation helpful? Give feedback.
-
Regarding #3266 and so that this is readily findable in the future, it is possible for both the "in charge" and "not in charge" virtual destructor slots to be null. When this occurs it is usually and abstract base and in my experience it most commonly occurs in construction vtables. I think this also happens if you explicitly declare a non virtual destructor on a class that has virtual functions but don't quote me on it. |
Beta Was this translation helpful? Give feedback.
-
Will any of this be applicable to Borland C++ (v 4.0, 4.02, 4.5, etc.) / Microsoft (mfc 1.0, 1.1, 1.51, etc) of the mid-1990's??? |
Beta Was this translation helpful? Give feedback.
-
I have a question about additive VFTables. Up to now, a separate structure, including VFTable, is created for each class. In the inherited classes, in turn, the underlying class is always referenced, in that the data type of the underlying structure is directly included in the current one. But now I have a problem with additive VFTables. Imagine the following example:
The following data types are created (simplified example):
During compilation the following VFTables are created. On some levels further virtual methods are added in it.
Because now in Ghidra with the help of the RTTI script only per level a VFTable is generated, and this is used in the next higher class likewise, there are naturally problems with the resolution of additive virtual methods. In the code these are not found accordingly, because naturally the enclosing classical with the additional additive methods only those of the internal know. Example: I address the question here directly to @ghidra007 and @astrelsky. How do you deal with something like this? Unfortunately, I can't help myself any other way than either to install the large VFTables with all virtual methods in the lower classes, or not to include the VFTables below as a direct reference in the structure. Is there a solution for this? |
Beta Was this translation helpful? Give feedback.
-
@ghidra007 what are you looking for in regards to tests? |
Beta Was this translation helpful? Give feedback.
-
They were pushed into our dev master yesterday. A lot of things have been as we are almost ready to freeze 10.1. I believe once the overnight test breakages get resolved master will get pushed out. The person who normally does this is out so I'm not sure when it will happen. I'll comment here once I know for sure. |
Beta Was this translation helpful? Give feedback.
-
This check here is a bit faulty considering that "default" is equivalent to "gcc" for a large majority of language definitions. |
Beta Was this translation helpful? Give feedback.
-
@ghidra007 There are some RTTI structures, which also have a name for classes, and there are even references to VFTables in them. But this is not recognized by the whole system. Could you please check what is wrong with this, or if it is not possible to create at least class structures from the existing RTTI data and use the existing VFTable information? If it is a bug from your point of view, I can always open an issue about it. Just wanted to clarify in advance if you already had to deal with such examples, or could make an extension to the routines, so that such truncated RTTI data can also be handled. Thanks for your support in advance. |
Beta Was this translation helpful? Give feedback.
-
I'll try to take a look and see what is going on. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Since the new version and the adjustments, I have encountered a llegalArgumentException in a few cases at the following location. The error always occurred when the proportions did not match, i.e. in this case there was not enough space in the structure. And here, too, the script has already blown up in my face. Here it is not checked whether it is a valid symbol name. There are template classes that have characters in their names that cause the programme to abort at this point. I think you should therefore check all names beforehand and clean them up if necessary so that the script runs over them without errors. Unfortunately, I can't provide you with examples directly, I'm sorry. |
Beta Was this translation helpful? Give feedback.
-
@ghidra007 it appears that |
Beta Was this translation helpful? Give feedback.
-
Do you remember where in the code it was trying to use a negative number of bases? |
Beta Was this translation helpful? Give feedback.
-
For the negative base issue, I can add a check to make sure the tables are not made in executable memory. |
Beta Was this translation helpful? Give feedback.
-
Can you replace this code in the processGccRTTI() method (line 231 of ghidra/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RTTIGccClassRecoverer.java)
with this code:
and tell me if that fixes the first issue? Thanks! |
Beta Was this translation helpful? Give feedback.
-
@ghidra007 Thereby I noticed the following points, which I find in part still in need of improvement: If the structures are split and integrated into others, then it comes to unsightly name duplications with the term "vftablePtr". This leads to multiple occurrences of the term "vftablePtr" in a structure, which makes it impossible to recognize the structure in the decompilation and to edit the structure, because the error message "Name "vftablePtr" already exists" always appears. It would be enough for me if the names here would be based on the class names, similar to the data structures, e.g. W_vftablePtr, W_data, if the class is named W. This is how it could look like as an example: Here is another example, this time for class D, which is much simpler in structure. This is how it looks so far (note again the name duplications): And this is how it would actually be optimal: I hope that I have not made any blunders now. My goal is only to improve the overall result. I would be satisfied if the VFTables had a reference, the VBTables would be more or less indifferent to me. |
Beta Was this translation helpful? Give feedback.
-
I have a follow-up question about VFTables. In this discussion it was written somewhere above that there would be a trick to use the function "Goto Definition" also for virtual functions, i.e. to get to the calling function relatively effortlessly. Can someone explain me how this works? Unfortunately I don't find anything about this on the UI, not even in the decompiler window. Would be super handy if I could somehow get to the actual function faster, and without much detours. |
Beta Was this translation helpful? Give feedback.
-
@ghidra007 constructors do not have a return value. Having the rtti analysis script set one causes an erroneous |
Beta Was this translation helpful? Give feedback.
-
@ghidra007 Not sure if this is the right place/right person to ask but here goes Ran this script on a bigger program, running into 2 separate issues. First problem is, the script seems to hang. It was stuck on this for a couple of hours: I'm not sure where it's getting this definition from. It doesn't exist in the tree. When I go to that address, ghidra doesn't seem to know what it is. Also, ghidra doesn't let me cancel this task. I have to close ghidra via the project window or kill it with taskmanager in order to cancel it. I fetched the latest versions of all the files that you've seemingly been working on, and ran it as a custom script. Found that disabling these 2 lines of code would fix this hang by skipping the fixup & analysis (should already be done, I have tons of RTTI_Complete_Object_Locator's in the symol tree)
Here: I hoped this would not break anything further down the line, It might have, or it might be a completely separate issue, but I'm running into a crash after about an hour. Here's a text version of that stacktrace:
Seems to be caused by this: |
Beta Was this translation helpful? Give feedback.
-
To fix the stack trace replace RecoverClass.class line 524 with:
Thanks for helping to find this issue. |
Beta Was this translation helpful? Give feedback.
-
I'm moving this here. It was convenient at the time to put it in the commit so you knew exactly what I was referring to but it doesn't play very nice with the mobile app. Anyway it's definitely not related to #761. I see a handful of problems that I do not recall seeing before. For one the relocation table is empty which is rather annoying because I use it when the special typeinfo are external. I do not recall if this is normal for a PE or not though. Also the symbols at the address for the vtables are |
Beta Was this translation helpful? Give feedback.
-
I have now played around a bit with pharos. The tool also does some of what you try in your scripts, only it goes a bit beyond that. I have recognized another quite important functionality. At the beginning of the analyses you specify the memory reservation method and the memory release method. Here are the descriptions from the manual:
It is quoted 1:1, you can find the original document here. This allows the program to find the presumed locations where a constructor or destructure is called. I found this quite interesting, plus it uses these locations to detect the sizes of the class structures. This works surprisingly well. Wouldn't this be something for your scripts, @ghidra007? I noticed in some examples that the class size detection sometimes works better, sometimes worse, in pharos the detection here was usually much better and more accurate. I think this could be improved mainly by providing the above methods the quality even better. |
Beta Was this translation helpful? Give feedback.
-
@ghidra007 Has the topic fallen asleep, is it still being actively worked on, or is it completely dead? I think it's kind of a pity, there was so much energy put into this topic, and now you don't hear anything about it anymore. Is it somehow possible to get a short status report here, how things stand, and whether it is still worthwhile to stay tuned, or is this wasted lifetime? |
Beta Was this translation helpful? Give feedback.
-
It seems that if a program contains multiple classes with the same name in an anonymous namespace, the script will fail with the error |
Beta Was this translation helpful? Give feedback.
-
@ghidra007 I figured I'd finally open the discussion. There is a lot that can be discussed here. I'm not the best at creating things of this sort so I'm just gonna wing it with not much thought put into it.
Some gotchas during analysis:
The data relocations I believe have been taken care of.
Windows control flow guard is something I never figured out how to deal with. It gets in the way because it appears that the compiler will insert pointers to the call checking functions (I forget the name) into the vftable.
64 bit PowerPC's function descriptors are a part of the abi. All you really need to know about this wrt rtti is that all function pointers really point to a structure whose first member is the actual function pointer. A that is needed here is an additional "dereference". It seems to apply to 64-32addr as well which I recently learned.
Android vftables don't seem to "follow the rules" wrt virtual destructor placement. It is not safe to assume that the first two entries are destructors. Iirc they are still present in the table but don't quote me on that.
Has any thought been put into proper handling of virtual inheritance in both the java end software modeling and in the decompiler?
Have #1431 and #1210 been seen as a bigger problems yet?
Beta Was this translation helpful? Give feedback.
All reactions