Git Product home page Git Product logo

Comments (6)

astrelsky avatar astrelsky commented on August 23, 2024 1

Unfortunately this is a Ghidra problem. I'm actually logging every single time Ghidra returns the wrong class from the method it uses to get the type for a thiscall function. You can open an issue in the Ghidra repo and hope they finally do something about it.

I recommend leaving the demangler analyzer on. I'll see if I can hack up a script to help deal with this but it will end up being very slow because of how the datatype manager handles type replacement.

from ghidra-cpp-class-analyzer.

astrelsky avatar astrelsky commented on August 23, 2024 1

Thanks! A script would be helpful.

I'm happy to file a bug on Ghidra as well, but it's not clear to me what's going wrong and where. I assumed the demangler analyzer created its own types (in the Demanagler folder in the data type manager), and is using those with the parameters of functions that it similarly created.

Suppose you have two classes namespaceA::Object and namespaceB::Object. If there is no demangler folder, VariableUtilities.findOrCreateClassStruct will return /namespaceA/Object for both of them in their __thiscall functions because that is the first Object it will find.

from ghidra-cpp-class-analyzer.

astrelsky avatar astrelsky commented on August 23, 2024 1

Hmm. Would DataTypeManager::replaceDataType work properly as a means to deduplicate? Wondering if it is affected by this bug.

https://ghidra.re/ghidra_docs/api/ghidra/program/model/data/DataTypeManager.html#replaceDataType(ghidra.program.model.data.DataType,ghidra.program.model.data.DataType,boolean)

It would work in your case where the datatype being replaced is trash and is the empty placeholder created by the demangler. This is what I would use in a script to fix your situation. However there is currently nothing that can be done about the case with two different valid class structures.

from ghidra-cpp-class-analyzer.

kevinhartman avatar kevinhartman commented on August 23, 2024 1

Got something working (for the placeholder case). It only works if the replacement type has the same name, though this limitation is simply because it makes my workflow easier (I can use a simple dropdown when prompting for the replacement type).

Posting for others.
https://gist.github.com/kevinhartman/a4dce3beadfe08dc7fd3fca61fb40567

from ghidra-cpp-class-analyzer.

kevinhartman avatar kevinhartman commented on August 23, 2024

Thanks! A script would be helpful.

I'm happy to file a bug on Ghidra as well, but it's not clear to me what's going wrong and where. I assumed the demangler analyzer created its own types (in the Demanagler folder in the data type manager), and is using those with the parameters of functions that it similarly created.

from ghidra-cpp-class-analyzer.

kevinhartman avatar kevinhartman commented on August 23, 2024

Hmm. Would DataTypeManager::replaceDataType work properly as a means to deduplicate? Wondering if it is affected by this bug.

https://ghidra.re/ghidra_docs/api/ghidra/program/model/data/DataTypeManager.html#replaceDataType(ghidra.program.model.data.DataType,ghidra.program.model.data.DataType,boolean)

from ghidra-cpp-class-analyzer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.