汇编中的 C++ 类是什么样的

逆向工程 部件 C++
2021-07-03 07:06:46

我计划对以面向对象方式编写的应用程序进行一些逆向工程。现在我有点好奇 C++ 类在汇编中会是什么样子。我已经找到了有关函数及其调用约定的基础知识。但是类可能要复杂得多,对吗?

所以假设我们有这个类:

class Rectangle {
    int width, height;
  public:
    void set_values (int,int);
    int area() {return width*height;}
};

void Rectangle::set_values (int x, int y) {
  width = x;
  height = y;
}

和这个对象:

Rectangle rect;
rect.set_values (3,4);

组装时会/可能会是什么样子?

1个回答

https://reverseengineering.stackexchange.com/a/5957/1562 中所述,它依赖编译器(不同的编译器将生成不同的机器代码和数据结构)。

但是,您可能需要参考Reversing C++,因为它很好地展示了大多数编译器如何编译 C++ 类。