Git Product home page Git Product logo

Comments (10)

astrelsky avatar astrelsky commented on August 23, 2024

Currently it's very tedious to create the structs representing the vtable in Ghidra. It would be convenient if this extension could create those structs and function pointer types based off of the signatures of the destinations.

It does. You can get to it quickly by right-clicking on the type in the "ClassTypeInfo Tree" and selecting "Edit Data Type". From there just right click on the _vptr component and choose "Edit Component".

The creation should occur when the corresponding c++ class analyzer is run.

from ghidra-cpp-class-analyzer.

jrmuizel avatar jrmuizel commented on August 23, 2024

Hmmm... I seem to not have those things. I have "Edit" but the structure that I get is empty. Is there an example binary that is known to work well with this extension that I can compare with?

from ghidra-cpp-class-analyzer.

astrelsky avatar astrelsky commented on August 23, 2024

Hmmm... I seem to not have those things. I have "Edit" but the structure that I get is empty. Is there an example binary that is known to work well with this extension that I can compare with?

It is "Edit". I was going off memory.

If the Structure is empty then the cause would be one of 3 things:

  • No vtable
  • Vtable wasn't found
  • Some other bug

If you are certain that there is a vtable for the class in question then this would definitely require further investigation.

A class which has a located vtable should have a "Goto vtable" option available on right clicking on it in the tree.

from ghidra-cpp-class-analyzer.

astrelsky avatar astrelsky commented on August 23, 2024

As a sanity check you can always run it on libstdc++.so and then check the iostream classes.

from ghidra-cpp-class-analyzer.

jrmuizel avatar jrmuizel commented on August 23, 2024

Ok, I think I have the analyzers running properly on this test case:

struct Bar {
        virtual int a(int x) = 0;
        virtual int b(double x, double y) = 0;
        virtual int get() = 0;
};

struct Foo : public Bar {
        int a(int ax) override {
                x = ax;
                return x;
        }
        int b(double ax, double ay) override {
                x = ax;
                y = ay;
                return y;
        }
        virtual int get() {
                return y;
        }
        int x;
        int y;
};

int main() {
        Bar* b = new Foo;
        b->a(4);
        b->b(6, 7);
        return b->get();
}

Foo and Bar both show up in the ClassTypeInfo Tree and both have "Goto Vtable". However the vtable* _vptr member of Bar is empty. I'd like it to be automatically/or semi-automatically filled in with 3 function pointers that have types matching the signatures of a, b and get respectively.

from ghidra-cpp-class-analyzer.

astrelsky avatar astrelsky commented on August 23, 2024

This seems like a regression. I will investigate with the provided example tomorrow. The vtable structs shouldn't be empty and should have the function signatures.

from ghidra-cpp-class-analyzer.

jrmuizel avatar jrmuizel commented on August 23, 2024

FWIW, I built it with gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)

from ghidra-cpp-class-analyzer.

astrelsky avatar astrelsky commented on August 23, 2024

I was able to reproduce this. I should have it fixed within a couple days.

from ghidra-cpp-class-analyzer.

astrelsky avatar astrelsky commented on August 23, 2024

b6f24a7 should have fixed the issue

from ghidra-cpp-class-analyzer.

jrmuizel avatar jrmuizel commented on August 23, 2024

Yep. It works for me now. Thanks!

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.