-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dhrake fails to create vtable entries #7
Comments
Hi, when running Is the data at address Can you please provide full Ghidra screenshots of the If you search for the function in Data Type Manager, does it show up twice? e.g. Are you running the latest version of Dhrake from this repo? Lastly, do you happen to know the Delphi compiler version used for this executable? Dhrake works fine with Ghidra 10.3 (tested on my side) so no worries there. |
Indeed, I reviewed the change, but I believe it is not the full appropriate fix. Calling This is what I recommend instead (it's existing code I haven't contributed yet) as it retrieves the function's existing pointer Data Type: if (vtbl != null) {
this.log(String.format(" Adding function definition %s::%s at %s to %s", className, name, entryPoint, vtbl.getName()));
try {
vtbl.add(this.getCurrentProgram().getDataTypeManager().getPointer(this.addFnType(function, catDefault)), 4, name, "");
} catch (IllegalArgumentException e) {
this.log("[ERROR] Cannot add function %s to %s", name, vtbl.getName());
}
} The We can extend the code to include the creation of the Pointer DT in the event it is missing (re: PR #8) if the retrieval fails. That said, I am waiting for @msm-cert to follow-up to fully understand the issue at hand. I've seen this problem before, and I suspect it's just bad disassembly by Ghidra getting in the way. |
Hi! Thanks for your prompt response. Let's start:
Yes.
If I understand your question correctly, it's a function (of type FUN_004ab448):
TFont::FUN_004ab448
Not sure it'll be helpful, since I've already ran my modified script on the binary so it may not be representative. I've created a fresh ghidra project to make this screen:
Once, yes:
Yes, I've copied the files from the master branch to my ghidra_scripts directory.
Possibly. Looking for strings in the compiled binary I see I've also used the build of IDR provided with this repository, if that helps.
I believe I'm a strong reverse engineer, but my knowledge of Ghidra API is severely lacking :) - so thanks for your suggestions. It's entirely possible my fix is suboptimal, I just did the simplest thing that solved the problem in my case.
I confirm that works too. I can run this on a random VMT_ symbol in my project and it works:
In comparison, when I run the original version from this repository (just
(the additional log line is added by me: |
Perfect, thank you for the details! The issue is that there was no actual function defined at address Please go to address |
I wasn't questioning whether it was a function or not but rather if Ghidra had successfully defined it as such. I'm used to seeing the large "FUNCTION" comment in Ghidra hence why I asked for screenshots. :) I'm mainly trying to figure out is why a pointer DT was not created for this function in the first place. I'm also wondering why I wrote the code above a few months ago to solve this particular issue, lol. All that said, your PR is still warranted as it fixes this issue. You are welcome to use the code I wrote above in your submission to avoid duplicates. Of course, @huettenhain has the final say in this matter. 😁
I'm ready to check it out (for science!) if you are willing to share! |
Yeah, sorry for cropping my original screenshot a bit too much.
I'll check your code and integrate it into my PR. I'm a bit short on time today, so it'll probably wait until Monday (or I'll commit it over the weekend).
Can I have your email address (or another contact method)? I don't see it on your profile. You can also email me at [email protected]. |
Just noting that I am all 👍 on this conversation. By this point, @sarog probably knows the code better than I do 😬. |
Hi!
Thanks for your great project. I've noticed that DhrakeInit works flawlessly, but I can't parse vtables.
I get the following error:
I've tried to add this data type to a structure and noticed that it's automatically changed to function pointer by Ghidra - maybe it's something done by the UI but not by the scripting API.
My Ghidra version is quite ancient (10.3) so it's entirely possible it's working in the newest version, I should update it someday. Anyway I've decided to create this issue (and a followup PR) to help others in a similar situation
The text was updated successfully, but these errors were encountered: