I am planning to do some reverse engineering on an application that was written in a object oriented way. And now I'm kind of curious what a C++ class would look like in assembly. I already found out the basics about functions and their calling conventions. But classes are probably way more complex, right?

So let's say we have this class:

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

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

and this object:

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

What would/could it look like in assembly?

  • even for simple C code, the assembly output depends on compiler and compiler options. To see how the output is in various compilers, use GCC Godbolt compiler explorer
    – phuclv
    Oct 8, 2015 at 16:55

1 Answer 1


As discussed in https://reverseengineering.stackexchange.com/a/5957/1562, it's compiler-dependent (different compilers will generate different machine code and data structures).

However, you may want to refer to Reversing C++, as it does a pretty good job showing how most compilers compile C++ classes.

  • 2
    The reversing C++ paper is invaluable.
    – user15338
    Nov 3, 2017 at 13:20
  • In the microsoft x64 convention where RCX, RDX, R8, R9 are used are arguments, is RCX still used by c++ for the this pointer ?
    – Herz3h
    Jul 13, 2021 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.